Skip to content

feat(workspace): principal classes a plugin defines, for write scope - #3342

Merged
lex00 merged 2 commits into
mainfrom
ws-3080-principal-classes
Oct 3, 2026
Merged

lex00 merged 2 commits into
mainfrom
ws-3080-principal-classes

Conversation

@lex00

@lex00 lex00 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Write scope (#2548, ws-067) knew only the four core principal classes. A principal holding some other role was judged as human, so a domain role such as reviewer or operator couldn't be scoped. This adds the domain classes #2524 D5 assigns to plugins.

A pinned package names classes in a JSON file at a data-only ./workspace-principals subpath, next to ./workspace-kinds and under the same rules: the literal export key, a .json target inside the package, and chant never imports it. Each class has a name, a description and the role whose grant in the trust policy at base (.chant/trust.json roles) puts a principal in it. The schema is workspace-principals.schema.json (.../workspace/principals/v1/...). writeScope now takes any class name as a key (minReader 0.102.0). A principal's class is the first core role it holds (agent, runner, service), then the first domain class in pin order and file order, and otherwise human. The new principal-classes.ts holds the registry. Its classesOf() lists every class a principal's grants put it in, which is what #3163 needs to ask "is this forge identity or signer in the declared class" for gates and person-attributed records. #3163 itself is not implemented here.

Two safety rules follow ws-067's threat model. First, write scope reads a path-pinned plugin at the base revision along with the declaration and the trust policy, so a change can't remap a class by editing its own copy of the plugin. A package pin must be installed at the version the base pins. Second, a writeScope key that no pinned package supplies fails closed. chant workspace check reports it with WSP003, whose description now covers classes. The record writes refuse any writer judged human with the new reason code write-scope-class-unknown, because that writer may belong to the unknown class. check --changes reports such a commit as one finding with a null path. A writer in a core or known class is still judged by that class. WSP002 now also covers a principals file that doesn't validate. Two pins that supply the same class name or the same role leave every class involved out.

Contract changes for readers: changes.schema.json scope.restricted[], scope.commits[].class and scope.findings[].class go from an enum of the four core names to a class-name pattern, so a reader treats any other name as a domain class. write-scope-class-unknown is added to the code lists of changes, records new|amend|review|close and work evidence. The boundary roster and page are regenerated. kinds.ts now shares its pin resolution (pinnedPackageDir) and export-target rule with the class loader. Kind loading behaves as before.

The decision is recorded as ws-079 (options: the kinds file, declaration-local classes, ignoring unknown keys). The docs are updated on the workspace-kinds, workspace-declaration, read-contract, workspace-check and workspace-records pages.

Verified with core tsc and npx vitest run --project unit. New tests are in principal-classes.test.ts (data file, registry, clashes, base-tree reads, class order) and write-scope.test.ts, which covers a path-pinned plugin end to end: a record write judged by the domain class, the remap-in-working-tree case, check --changes with the class in its output validated against the schema, fail-closed record writes and commits, and the WSP002 and WSP003 findings. I mutation-checked the base-revision read and the fail-closed guard, and each mutation fails its test. Also ran the boundary roster, reason codes, kinds, checks, changes and box-factory tests, the docs diataxis check and the prose lint.

Closes #3080

A pinned package can now name domain principal classes at a data-only
./workspace-principals subpath, beside ./workspace-kinds. Each class names
the role whose grant in the trust policy at base puts a principal in it.
writeScope takes any class name as a key. A principal's class is the first
of the core agent, runner and service roles it holds, then the domain
classes in pin order, else human; classesOf lists every class a principal
is in, for gates and records to build on (#3163).

Write scope reads a path-pinned plugin at the base revision, with the
declaration and the trust policy, so a change can't remap a class. A
writeScope key no pin supplies fails workspace check with WSP003 and refuses
a writer judged human with write-scope-class-unknown (fail closed). WSP002
also covers unreadable principals files. Recorded as ws-079.

Closes #3080
@lex00 lex00 added area:workspace chant workspace epic (#2525) level:3 workspace opt-in level 3 (#2525) labels Oct 3, 2026
…sses

# Conflicts:
#	docs/design/decisions/README.md
#	docs/src/content/docs/reference/boundary.mdx
@lex00
lex00 merged commit 2512b2a into main Oct 3, 2026
12 checks passed
@lex00
lex00 deleted the ws-3080-principal-classes branch October 3, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:workspace chant workspace epic (#2525) level:3 workspace opt-in level 3 (#2525)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

write scope: principal classes a plugin defines (#2524 D5 domain classes)

1 participant