Add isolated scratch sessions (no-project general-agent chats) #241

Merged
weichen merged 6 commits from feature/scratch-session-general-agent into main 2026-10-22 05:14:44 +00:00
Owner

Why: Accounts without project.create need an isolated general-agent chat ("无项目对话"). Each scratch session is a private shell project (settings host.kind=scratch) holding exactly one conversation, and it must never reach project-only capabilities.

What:

  • POST /api/scratch-sessions: inherent capability for every enabled account (no role-matrix action, not configurable); creates the scratch project + one cross-private conversation atomically.
  • Project lists omit scratch projects; POST /api/projects and settings writes cannot add/remove the marker; a second conversation under scratch is 409.
  • Owner work/read on scratch bypasses the RDM provider; non-owners and shared adapters get NotFound.
  • Scratch runs: no project context (X1), no knowledge retrieval, only conversation-scoped context entries, no user/project memory, no cross-session reads in either direction.
  • Knowledge add/search 400; rdm.* and formal project commands 403; uploads skip indexing; deleting the sole conversation removes the scratch project.
  • Conversation responses carry scratch: true for scratch conversations (omitempty otherwise).

Evidence: go test ./internal/store ./internal/server ./internal/runmgr ./internal/app pass locally (SELF); CI on this HEAD is authoritative.
Refs: Agent-System-Dev docs/superpowers/specs/2026-10-22-scratch-session-general-agent-design.md (branch feature/scratch-session-general-agent)

Why: Accounts without project.create need an isolated general-agent chat ("无项目对话"). Each scratch session is a private shell project (settings host.kind=scratch) holding exactly one conversation, and it must never reach project-only capabilities. What: - POST /api/scratch-sessions: inherent capability for every enabled account (no role-matrix action, not configurable); creates the scratch project + one cross-private conversation atomically. - Project lists omit scratch projects; POST /api/projects and settings writes cannot add/remove the marker; a second conversation under scratch is 409. - Owner work/read on scratch bypasses the RDM provider; non-owners and shared adapters get NotFound. - Scratch runs: no project context (X1), no knowledge retrieval, only conversation-scoped context entries, no user/project memory, no cross-session reads in either direction. - Knowledge add/search 400; rdm.* and formal project commands 403; uploads skip indexing; deleting the sole conversation removes the scratch project. - Conversation responses carry scratch: true for scratch conversations (omitempty otherwise). Evidence: go test ./internal/store ./internal/server ./internal/runmgr ./internal/app pass locally (SELF); CI on this HEAD is authoritative. Refs: Agent-System-Dev docs/superpowers/specs/2026-10-22-scratch-session-general-agent-design.md (branch feature/scratch-session-general-agent)
weichen added 3 commits 2026-10-22 03:05:37 +00:00
Why: Accounts without project.create need an isolated general-agent chat; each
scratch session is a private shell project (settings host.kind=scratch) with
exactly one cross-private conversation.
Evidence: agent-exec run 9b3d31a3 (pi, success); go test ./internal/store ./internal/server -run Scratch pass.
Impact: New POST /api/scratch-sessions (no project.create needed); project lists
omit scratch; second conversation under scratch 409; client writes cannot add or
remove the scratch marker; POST /api/projects rejects the marker.
Refs: Agent-System-Dev docs/superpowers/specs/2026-10-22-scratch-session-general-agent-design.md

Co-authored-by: Cursor <cursoragent@cursor.com>
Why: A scratch session is a private general-agent chat; it must work for its
owner without the RDM provider and must not share documents or context with any
other conversation.
Evidence: agent-exec run fb04c4a9 (pi, success); go test ./internal/store ./internal/server ./internal/runmgr ./internal/app pass.
Impact: Owner work/read on scratch bypasses the domain provider; non-owners and
shared adapters get NotFound. Scratch runs skip project context, knowledge
retrieval, owner/project context entries, user/project memory, and cross-session
reads (both directions). Knowledge add/search 400, rdm.* and formal project
commands 403, settings writes 400, uploads skip indexing, and deleting the sole
conversation removes the scratch project.
Refs: Agent-System-Dev docs/superpowers/specs/2026-10-22-scratch-session-general-agent-design.md

Co-authored-by: Cursor <cursoragent@cursor.com>
Mark scratch conversations in conversation responses
governance / governance (pull_request) Successful in 21s
ci / vet-and-test (pull_request) Successful in 1m27s
f3f70a7978
Why: The Frontend groups scratch sessions under a separate sidebar category and
needs an explicit marker instead of inferring it from the project list.
Evidence: agent-exec run 2d662c46 (pi, success); go test ./internal/store ./internal/server pass.
Impact: listTasks, listConversations, conversationDetail and POST /api/scratch-sessions
return scratch: true for scratch conversations; other conversations keep the same JSON (omitempty).
Refs: Agent-System-Dev docs/superpowers/specs/2026-10-22-scratch-session-general-agent-design.md

Co-authored-by: Cursor <cursoragent@cursor.com>
weichen added 2 commits 2026-10-22 04:02:13 +00:00
Why: Independent review found scratch runs still called the project
context resolver, and chat intent routing plus system.intent re-dispatch
could deliver rdm.* commands with a scratch host project.

Evidence: go test ./internal/runmgr ./internal/cmdbus ./internal/app
./internal/server ./internal/store pass locally (SELF); CI is authoritative.

Impact: ProjectContext returns nothing when project context is disabled;
Bus.Dispatch applies a host-project guard to every request carrying a host
project, rejecting rdm.* and formal project commands on scratch hosts;
scratch lookups that fail keep isolation gates closed.

Refs: Agent-System-Backend#241; agent-exec receipt u2c-run (pi, success)
Co-authored-by: Cursor <cursoragent@cursor.com>
Fail closed both ways when the scratch host lookup fails
governance / governance (pull_request) Successful in 16s
ci / vet-and-test (pull_request) Successful in 1m23s
b704ba9897
Why: Returning true from scratchProject on a lookup error closed the
isolation gates correctly, but the same helper also skipped RDM
observation and project context for a normal project during a
transient store failure.

Evidence: go test ./internal/runmgr ./internal/cmdbus ./internal/app
./internal/server ./internal/store pass locally (SELF); CI is authoritative.

Impact: confirmedScratchProject (lookup succeeded and marked scratch)
drives the relaxing gates; scratchProject (lookup error => true) keeps
driving the tightening ones.

Refs: Agent-System-Backend#241; agent-exec receipt u2d-run (pi, success)
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen added 1 commit 2026-10-22 04:06:54 +00:00
Merge origin/main into feature/scratch-session-general-agent
governance / governance (pull_request) Successful in 17s
ci / vet-and-test (pull_request) Successful in 1m24s
2424f8e3f7
Why: main advanced with agent-stack audit batch-1; resolve the Bus
struct conflict by keeping both hostProjectGuard and operationQuery.

Evidence: go test ./internal/cmdbus ./internal/app ./internal/runmgr
./internal/server ./internal/store pass locally (SELF).

Impact: scratch host guard retained alongside the new operation query
port; deps gitlinks match origin/main.

Refs: Agent-System-Backend#241
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen merged commit 029917e843 into main 2026-10-22 05:14:44 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Backend#241