fsanyoto commited on
Commit
6f43354
·
verified ·
1 Parent(s): 8873406

Prune files not in the deploy set (stale build context)

Browse files
Files changed (1) hide show
  1. api/routes_notes.py +0 -109
api/routes_notes.py DELETED
@@ -1,109 +0,0 @@
1
- """routes_notes.py — shared-note READ STATE (wave 47, instruction 19, ticket W47-T16).
2
-
3
- ⛔⛔ **THIS FILE WAS MOUNTED BEFORE IT HAD A SINGLE ROUTE, ON PURPOSE, AND THAT IS THE WHOLE POINT
4
- OF IT EXISTING AT PLAN TIME.** `main.py`'s own mount block records the scar: three routers in wave
5
- 23, four features in wave 29, and the `include_router` line lost again in waves 31 and 32 — five
6
- consecutive waves in which a complete, gated, type-clean router shipped 404 for every caller. In a
7
- worktree-parallel wave the cause is structural rather than careless: `main.py` can live in exactly
8
- ONE lane's fence, so a new router built in any OTHER lane has nowhere to be mounted from. Mounting
9
- an empty router in the planning manifest removes the failure mode instead of warning about it.
10
-
11
- WHAT LIVES HERE, and what deliberately does not:
12
-
13
- W47-T16 adds the per-user READ STATE behind the Notes button's unread badge — a read version per
14
- (subject, user), plus the door that stamps it when a note is opened. `platform/core/
15
- user_tables.py::put_shared_note` already stores `revisions[]` and bumps `version` on every save,
16
- so a note has a version to compare against; it stored no read state at all, which is why the
17
- badge needed a new marker rather than a new read of an old one.
18
-
19
- ⛔ The EXISTING shared-note doors stay where they are. `routes_grid.py::get_shared_note` and
20
- `::update_shared_note` belong to lane G this wave (that file also carries the date-recurrence
21
- persist path), and W47-T16 must not reach into them. This module is ADDITIVE for exactly that
22
- reason: the unread count is a separate question from the note's body, and asking it separately is
23
- also cheaper to poll.
24
-
25
- ⭐ **THE PERMISSION WALL IS BORROWED, NOT REBUILT.** `_shared_note_subject` resolves a scope and an
26
- optional view id into a note subject *only after the ordinary workspace wall has admitted the
27
- caller*, and it 404s a view the caller cannot see. Importing it is a deliberate choice over copying
28
- it: a second wall around the same data is how two answers to "may this person see this note" start
29
- to disagree, and the unread count must never be the looser of the two. It is a read-only dependency
30
- on lane G's file — this module never writes there.
31
- ⚠ If that helper is ever renamed, THIS import is the thing that breaks, loudly, at boot. That is the
32
- intended failure mode: a mounted router that cannot resolve its subject should refuse to start
33
- rather than quietly answer with a wall of its own.
34
-
35
- ⚠ An empty router is a real router: `verify_api.py::section_mounts` walks `main.app.routes` and
36
- reads `main.py`'s `import routes_*` lines against `git ls-files`, so this file has been tracked from
37
- the manifest commit onward. Adding these routes does not change the mount line.
38
- """
39
-
40
- from fastapi import APIRouter, Body, Depends
41
-
42
- from deps import Session, err, require_session
43
-
44
- router = APIRouter(prefix="/api/v1")
45
-
46
-
47
- def _subjects_for(session, scope, view_id):
48
- """The note subjects the Notes button covers: the DATABASE, plus the open View if there is one.
49
-
50
- ⭐ That pair is the button's whole world, and the count has to match it. The drawer offers
51
- exactly two tabs, Database note and View note, so a badge that counted anything else would be
52
- promising notes the button cannot reach.
53
- """
54
- from routes_grid import _shared_note_subject
55
-
56
- kind, subject_id, _view = _shared_note_subject(session, scope, "")
57
- subjects = [(kind, subject_id)]
58
- if view_id:
59
- v_kind, v_id, _v = _shared_note_subject(session, scope, view_id)
60
- subjects.append((v_kind, v_id))
61
- return subjects
62
-
63
-
64
- @router.get("/notes/unread")
65
- def notes_unread(scope: str = "customer", viewId: str = "",
66
- session: Session = Depends(require_session)):
67
- """How many of this Database's notes THIS viewer has not opened at their current version.
68
-
69
- Answers the subjects too, each with the version that would clear it, so the client never has to
70
- invent a number: it stamps back exactly what it was told it had read.
71
- """
72
- from core import user_tables
73
-
74
- unread = user_tables.unread_note_subjects(
75
- _subjects_for(session, scope, viewId), session.uname, st=session.runtime)
76
- return {"unread": len(unread), "subjects": unread}
77
-
78
-
79
- @router.post("/notes/read")
80
- def notes_mark_read(scope: str = "customer", viewId: str = "",
81
- body: dict = Body(default=None),
82
- session: Session = Depends(require_session)):
83
- """Stamp that this viewer has opened one subject's note at a given version.
84
-
85
- ⛔ THE SUBJECT IS RESOLVED THROUGH THE SAME WALL AS THE NOTE ITSELF, never taken from the body.
86
- A caller who could name an arbitrary `subjectId` could stamp a read mark against a database they
87
- cannot open — harmless on its own, but it would make the store's per-user branch a place an
88
- outsider can write, and that is the property the whole design rests on.
89
- ⛔ AND IT WRITES ONLY THIS SESSION'S OWN BRANCH: `session.uname`, never a name from the body.
90
- """
91
- from core import user_tables
92
-
93
- payload = body or {}
94
- kind = str(payload.get("subjectKind") or "database")
95
- if kind not in {"database", "view"}:
96
- raise err(400, "bad_subject_kind", "a note belongs to a Database or a View")
97
- wanted_view = viewId if kind == "view" else ""
98
- if kind == "view" and not wanted_view:
99
- raise err(400, "view_required", "a View note needs the View it belongs to")
100
-
101
- from routes_grid import _shared_note_subject
102
-
103
- resolved_kind, subject_id, _view = _shared_note_subject(session, scope, wanted_view)
104
- mark = user_tables.mark_note_read(
105
- resolved_kind, subject_id, session.uname, payload.get("version"), st=session.runtime)
106
- if mark is None:
107
- raise err(400, "note_read_refused", "that note could not be marked as read")
108
- return {"subjectKind": resolved_kind, "subjectId": str(subject_id),
109
- "version": mark.get("version", 0)}