Skip to content

feat(workspace): write scope per member and record kind, and agent sessions bound to one member - #3078

Merged
lex00 merged 2 commits into
mainfrom
ws-write-scope-2548
Oct 1, 2026
Merged

lex00 merged 2 commits into
mainfrom
ws-write-scope-2548

Conversation

@lex00

@lex00 lex00 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Closes #2548

Write scope per member and record kind for each principal class, and agent sessions bound to one member that reload from the repository alone (#2524 D5, D20).

What ships

  • The declaration gains writeScope (an entry per restricted class: human, agent, runner, service, with members and per-kind records verbs new, amend, review, close) and agents (sessions, each bound to one declared member, optionally listing principals). Validated in code: members exist, names unique, a principal listed by one session at most.
  • packages/core/src/workspace/write-scope.ts: a writer's class comes from role grants in the trust policy at base, read through one function (roleGrants/principalClass); an agent is always bound to its session's member; the workspace's own kinds are in every writer's reach.
  • Write paths: chant workspace records new|amend|review|close and the MCP record tools refuse a write outside scope with write-scope-member or write-scope-kind, and an undeclared session with agent-unknown. The session comes from CHANT_AGENT; by naming a listed principal binds too. The scope is read from the declaration at base, so a working-tree edit can't widen it.
  • Enforcement boundary: chant workspace check --changes <range> gains a scope block. Each commit is judged by its Chant-Agent trailer, its attested principal, or its author, against the declaration, kinds and trust policy at the range's base. A scope finding fails the check whatever the severity. An agent editing chant.workspace.json (in no member) is itself out of scope.
  • Session reload: chant workspace agent [<name>] [--json] (agent.schema.json) prints the session, its member, its scope with verbs per kind, and the spec block of records --current --json. Served over MCP as workspace-agent.
  • The three codes are in reason-codes.ts, the write schemas (records-new|amend|review|close, work-evidence), changes.schema.json and agent.schema.json, and the boundary roster.
  • Decisions: ws-067 (write scope and agent sessions: declared in the declaration, read at base, classes from role grants) and ws-068 (chant's lifecycle ledgers stay ledgers, not record kinds), both decided, decided_by lex00.
  • Chant repo (workspace: dogfood on the chant repo #2557): writeScope.agent lets agents propose and review decisions only, and an agent session decisions is bound to the docs member.
  • Reference workspace: sessions app and design, and an agent records rule over its decision, work, lesson and session kinds; README row added.
  • Docs: workspace-declaration (Write scope and agent sessions), workspace-check (Write scope), workspace-records, read contract (codes, scope, Agent sessions), MCP page and agent-integration guide, new cli/workspace-agent page.

Acceptance criteria

  • A write outside a principal's scope fails check at the enforcement boundary.
  • An agent session cannot write another member's files (refused on chant's write paths; a commit doing it fails check --changes).
  • Session reload needs only the repo.
  • A decision is recorded on whether chant's own ledgers become record kinds (ws-068).
  • Works on the chant repo (workspace: dogfood on the chant repo #2557).
  • Level 0 is unaffected: everything is opt-in under a declaration; level-0 goldens pass. No CHANGELOG entry (workspace-only).

Gates (local)

vitest over every touched module and its importers (70 files), test/level0-goldens, scripts/typecheck.ts (no regressions), scripts/check-lexicons.ts (no untracked tier-1 failures), lint-docs-sentences (no regressions; the new page's two frontmatter hits are baselined like every page's) and check-docs-diataxis.

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.

workspace: write scope per member and agent sessions (phase 3c)

1 participant