Skip to content

feat(projects): chat projects routes, filing, session rows, the projects capability - #933

Merged
OAraLabs merged 26 commits into
mainfrom
feat/chat-projects-routes
Nov 15, 2026
Merged

OAraLabs merged 26 commits into
mainfrom
feat/chat-projects-routes

Conversation

@OAraLabs

Copy link
Copy Markdown
Owner

Chat projects PR 3 (design: #931, sections 3.1-3.3, 4-6). Stacked on #932 (the store); retargeted to main when it merges.

Routes (web/chat_projects_routes.py):

  • GET /api/chat-projects: the owner gets {"role": "owner", "rev", "projects": [full…]}; a chat-only device gets {"role": "chat_only", "projects": [{"id", "name", "sessions"}]}: only projects one of its own sessions is in, sessions counting its own, no folder, no rev.
  • GET /api/chat-projects/{id}: owner: full plus session_ids; chat-only: {"id", "name", "session_ids"} with its own sessions, 404 otherwise.
  • POST /api/chat-projects (owner): design 3.1's rules: import key, same-name convergence when no different folder is asked, 409 name_taken / folder_in_use, managed folder under projects.root, folder refusals (validator, home, root, agent home, nested either way, symlinked root), concurrent create returns the winner and removes its own empty folder.
  • PUT|DELETE /api/chat-projects/{id} (owner): rename (409 on a clash), delete (unfiles, clears the project's bindings, deletes no file).
  • PUT /api/sessions/{session_id}/project (owner): binds by default; keep_workspace label only; replace_workspace; 409 workspace_set; 409 device_session unless device_session: true (binding only); 400 machine_session; 404 unknown session or project; folder re-validated and must still resolve to the stored path.
  • Every owner handler re-checks is_operator; a test asserts no owner-only route matches a chat-only pattern.

Hooks: GET /api/sessions rows gain chat_project_id via one lookup after both branches; POST /api/sessions accepts chat_project_id (owner only, checked before minting); route_access lists the routes; ws_server._server_capabilities adds projects (one line); chat_project_changed goes to owner sockets only via the bridge's send_to_operators (ids and change kind only). Template documents projects.root; reference docs regenerated.

Decisions under the charter: the chat-only role is chat_only (a quoted "device" reads as a reader of whisper.device to the config-drift ratchet, and chat_only says what it means); POST /api/sessions validates the project and folder before minting, so a refusal creates nothing.

Tests: tests/test_chat_projects_routes.py (red first), on the real app with real device tokens and a real bridge; test_api_sessions_meta updated for the new field. Gate: ruff, mypy_gate clean; config, route, session, web and device suites pass (only the known worktree reference artifacts fail locally).

Review: two independent reviews (authorization).

🤖 Generated with Claude Code

OAraLabs and others added 10 commits November 13, 2026 23:20
…binding stays; root never followed or chmodded (review)

Writes run in a SAVEPOINT under a lock instead of the connection's
context manager, which committed or rolled back other work on the shared
connection; the tables are made with the conversation store's schema so
building the store commits nothing. Filing onto a folder the owner bound
by hand keeps that binding theirs. An existing projects root keeps its
mode and must be a plain directory owned by this user; the folder
returned is resolved. Forgetting a filed session raises rev; an import
key collision is its own error; names are NFC, stripped of control and
format characters, and casefolded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OAraLabs and others added 3 commits November 13, 2026 23:53
…ade, forgotten sessions not counted (reviews)

Folder checks compare file identity, never spelling: on a case-insensitive
disk a folder typed in another case no longer slips past home, the agent's
home (resolved, including the config and data dirs), the projects root,
another project's folder or a folder that contains home. The projects root
is checked (absolute, its existing parent valid, not under denied_paths)
before anything is made, and a null root means the default. A forgotten
session no longer counts in a project; instructions_rev hashes the whole
file off the event loop; a session bound before its first message cannot
be claimed after a restart; machine gateways and every error carry a kind;
a daemon without a store answers 404 (no projects).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed; store methods for existence and tool calls (review lows)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@OAraLabs

Copy link
Copy Markdown
Owner Author

Reviews: two independent reviews, two rounds each. Review 1 (authorization): the chat-only boundary held everywhere; 2 medium in the owner's folder checks (macOS case variants slipped past string comparisons for home, the agent's home, the root, nesting and folder reuse; the agent's-home rule was a literal prefix, missed config/data dirs and folders containing home), lows (null/relative root, a bound session claimable after restart, root inside a denied path, full() on the event loop, devices None); all fixed: identity-based checks, root validated before mkdir, has_session_rows. Review 2 (contract): 5 medium (forgotten sessions counted, root under denied_paths left folders, root: null became 'None', agent home unresolved, instructions_rev wrong over 1 MB), lows (vanished managed folder collision, rule order, machine gateway, missing kinds, 503 vs 404); all fixed. Re-checks: nothing medium or higher from either; lows taken (unfiled counts what clients see, root ancestors resolved, store methods instead of the private connection).

@OAraLabs
OAraLabs marked this pull request as ready for review November 14, 2026 05:02
OAraLabs and others added 7 commits November 14, 2026 00:18
Regenerated with rebaseline-from-exchanges on ubuntu-24.04. Adds the empty
chat_projects, chat_projects_rev and session_chat_projects tables to every
scenario; the other moved lines are the title row's known order race and a
key moving inside an object, both compared order-free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h its default

The store reads projects.root, so the template block and the inline
default belong here rather than in the routes PR. Same text as #933, so
the stack merges cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
OAraLabs added a commit that referenced this pull request Nov 15, 2026
* test(projects): pin the chat projects store and managed folders (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): label-only filing (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): the chat projects store and managed folders

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): bindings name the project that set them (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): a binding names the project that set it; only that project clears it

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): store review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): savepoint writes on the shared connection; a hand-set binding stays; root never followed or chmodded (review)

Writes run in a SAVEPOINT under a lock instead of the connection's
context manager, which committed or rolled back other work on the shared
connection; the tables are made with the conversation store's schema so
building the store commits nothing. Filing onto a folder the owner bound
by hand keeps that binding theirs. An existing projects root keeps its
mode and must be a plain directory owned by this user; the folder
returned is resolved. Forgetting a filed session raises rev; an import
key collision is its own error; names are NFC, stripped of control and
format characters, and casefolded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): project names are scrubbed; the uniqueness key is a hash

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(parity): rebaseline expected files for the chat-projects tables

Regenerated with rebaseline-from-exchanges on ubuntu-24.04. Adds the empty
chat_projects, chat_projects_rev and session_chat_projects tables to every
scenario; the other moved lines are the title row's known order race and a
key moving inside an object, both compared order-free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): document projects.root in the template and read it with its default

The store reads projects.root, so the template block and the inline
default belong here rather than in the routes PR. Same text as #933, so
the stack merges cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reference): regenerate after merging main

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@OAraLabs
OAraLabs changed the base branch from feat/chat-projects-store to main November 15, 2026 00:09
…utes

# Conflicts:
#	CHANGELOG.md
#	src/prometheus/memory/lcm_conversation_store.py
#	src/prometheus/projects/folders.py
#	src/prometheus/projects/store.py
@OAraLabs
OAraLabs enabled auto-merge (squash) November 15, 2026 00:10
…utes

# Conflicts:
#	CHANGELOG.md
#	docs/reference/routes.md
#	src/prometheus/web/route_access.py
#	src/prometheus/web/server.py
#	src/prometheus/web/ws_server.py
#	tests/test_route_access.py
@OAraLabs
OAraLabs merged commit 4412f8e into main Nov 15, 2026
14 checks passed
OAraLabs added a commit that referenced this pull request Nov 15, 2026
… and the daemon's folders (#934)

* test(projects): pin the chat projects store and managed folders (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): label-only filing (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): the chat projects store and managed folders

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): bindings name the project that set them (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): a binding names the project that set it; only that project clears it

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): store review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): savepoint writes on the shared connection; a hand-set binding stays; root never followed or chmodded (review)

Writes run in a SAVEPOINT under a lock instead of the connection's
context manager, which committed or rolled back other work on the shared
connection; the tables are made with the conversation store's schema so
building the store commits nothing. Filing onto a folder the owner bound
by hand keeps that binding theirs. An existing projects root keeps its
mode and must be a plain directory owned by this user; the folder
returned is resolved. Forgetting a filed session raises rev; an import
key collision is its own error; names are NFC, stripped of control and
format characters, and casefolded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): project names are scrubbed; the uniqueness key is a hash

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): pin the chat projects routes on the real app (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): chat projects routes, filing, session rows, the projects capability

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): the desktop's suggestion smoke cases, plus the daemon's folders (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): the suggestions route (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): suggestions from tool calls, with the desktop's rules and the daemon's folders

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): routes review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): folder checks by identity, root checked before it is made, forgotten sessions not counted (reviews)

Folder checks compare file identity, never spelling: on a case-insensitive
disk a folder typed in another case no longer slips past home, the agent's
home (resolved, including the config and data dirs), the projects root,
another project's folder or a folder that contains home. The projects root
is checked (absolute, its existing parent valid, not under denied_paths)
before anything is made, and a null root means the default. A forgotten
session no longer counts in a project; instructions_rev hashes the whole
file off the event loop; a session bound before its first message cannot
be claimed after a restart; machine gateways and every error carry a kind;
a daemon without a store answers 404 (no projects).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): suggestions review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): unfiled counts what clients see; root ancestors resolved; store methods for existence and tool calls (review lows)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): known folders match on path boundaries; suggestions cached by folders, not rev (review)

Known-folder paths match only where a path segment ends and begins, so
/srv/app no longer matches /srv/application or /data/srv/app, and the
pattern is built once per tally. Suggestions read only assistant rows
that hold a tool call, and the cache key moves with the projects' ids,
names and folders, so filing a session no longer recomputes every other
one. Case ties pick the spelling the desktop picks; a checkout folder maps
to its project; folders compare without case on macOS; an owner lookup
that fails skips the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): a --flag=path still finds a project folder (review low)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(parity): rebaseline expected files for the chat-projects tables

Regenerated with rebaseline-from-exchanges on ubuntu-24.04. Adds the empty
chat_projects, chat_projects_rev and session_chat_projects tables to every
scenario; the other moved lines are the title row's known order race and a
key moving inside an object, both compared order-free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): document projects.root in the template and read it with its default

The store reads projects.root, so the template block and the inline
default belong here rather than in the routes PR. Same text as #933, so
the stack merges cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reference): regenerate after merging main

* docs(reference): regenerate after merging main

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
OAraLabs added a commit that referenced this pull request Nov 15, 2026
…ference note (#935)

* test(projects): pin the chat projects store and managed folders (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): label-only filing (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): the chat projects store and managed folders

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): bindings name the project that set them (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): a binding names the project that set it; only that project clears it

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): store review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): savepoint writes on the shared connection; a hand-set binding stays; root never followed or chmodded (review)

Writes run in a SAVEPOINT under a lock instead of the connection's
context manager, which committed or rolled back other work on the shared
connection; the tables are made with the conversation store's schema so
building the store commits nothing. Filing onto a folder the owner bound
by hand keeps that binding theirs. An existing projects root keeps its
mode and must be a plain directory owned by this user; the folder
returned is resolved. Forgetting a filed session raises rev; an import
key collision is its own error; names are NFC, stripped of control and
format characters, and casefolded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): project names are scrubbed; the uniqueness key is a hash

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): pin the chat projects routes on the real app (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): chat projects routes, filing, session rows, the projects capability

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): the desktop's suggestion smoke cases, plus the daemon's folders (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): the suggestions route (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): suggestions from tool calls, with the desktop's rules and the daemon's folders

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): routes review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): folder checks by identity, root checked before it is made, forgotten sessions not counted (reviews)

Folder checks compare file identity, never spelling: on a case-insensitive
disk a folder typed in another case no longer slips past home, the agent's
home (resolved, including the config and data dirs), the projects root,
another project's folder or a folder that contains home. The projects root
is checked (absolute, its existing parent valid, not under denied_paths)
before anything is made, and a null root means the default. A forgotten
session no longer counts in a project; instructions_rev hashes the whole
file off the event loop; a session bound before its first message cannot
be claimed after a restart; machine gateways and every error carry a kind;
a daemon without a store answers 404 (no projects).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): suggestions review cases (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): unfiled counts what clients see; root ancestors resolved; store methods for existence and tool calls (review lows)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): known folders match on path boundaries; suggestions cached by folders, not rev (review)

Known-folder paths match only where a path segment ends and begins, so
/srv/app no longer matches /srv/application or /data/srv/app, and the
pattern is built once per tally. Suggestions read only assistant rows
that hold a tool call, and the cache key moves with the projects' ids,
names and folders, so filing a session no longer recomputes every other
one. Case ties pick the spelling the desktop picks; a checkout folder maps
to its project; folders compare without case on macOS; an owner lookup
that fails skips the row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): a --flag=path still finds a project folder (review low)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(projects): instructions and reference files (red)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* feat(projects): instructions and reference files, and the prompt's reference note

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): one save wins, reads capped, effective matches the loader, safe names and downloads (reviews)

Saves and uploads run under a per-folder lock on one directory handle, so
two saves with the same base_rev cannot both win and an upload without
replace never overwrites (an exclusive link). Reads are capped (1 MB for
instructions, 20 MB for a reference file) and a hard-linked file is not
served. effective follows the loader's own config: truncated, omitted and
shadowed_by, and max_chars is the configured per-file cap. Saving keeps
the file's mode; a lone surrogate is a 400; a missing folder is
folder_missing; I/O errors are io_error, never a bare 500. Names a person
would not type (trailing dot or space, odd spaces, non-NFC, over 255
bytes) are refused, and the 200 cap counts files only. Markup downloads
as octet-stream under a sandbox CSP. Instruction and file changes move
rev; the /api 413 carries kind too_large; the prompt note is its own
heading with readable names. The API guide documents the routes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): effective reads at most the cap; a stalled upload times out (review lows)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): file names are normalised to NFC; a missed rev never fails a save (review)

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(parity): rebaseline expected files for the chat-projects tables

Regenerated with rebaseline-from-exchanges on ubuntu-24.04. Adds the empty
chat_projects, chat_projects_rev and session_chat_projects tables to every
scenario; the other moved lines are the title row's known order race and a
key moving inside an object, both compared order-free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(projects): document projects.root in the template and read it with its default

The store reads projects.root, so the template block and the inline
default belong here rather than in the routes PR. Same text as #933, so
the stack merges cleanly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reference): regenerate after merging main

* docs(reference): regenerate after merging main

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(reference): regenerate after merging main

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant