Repository navigation
feat(workspace): principal classes a plugin defines, for write scope - #3342
Merged
Merged
Conversation
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
…sses # Conflicts: # docs/design/decisions/README.md # docs/src/content/docs/reference/boundary.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-principalssubpath, next to./workspace-kindsand under the same rules: the literal export key, a.jsontarget 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.jsonroles) puts a principal in it. The schema isworkspace-principals.schema.json(.../workspace/principals/v1/...).writeScopenow takes any class name as a key (minReader0.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 newprincipal-classes.tsholds the registry. ItsclassesOf()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
writeScopekey that no pinned package supplies fails closed.chant workspace checkreports it with WSP003, whose description now covers classes. The record writes refuse any writer judged human with the new reason codewrite-scope-class-unknown, because that writer may belong to the unknown class.check --changesreports 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.jsonscope.restricted[],scope.commits[].classandscope.findings[].classgo 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-unknownis added to the code lists ofchanges,records new|amend|review|closeandwork evidence. The boundary roster and page are regenerated.kinds.tsnow 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 inprincipal-classes.test.ts(data file, registry, clashes, base-tree reads, class order) andwrite-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 --changeswith 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