Repository navigation
fix(workcontext): owner scope follow-ups from review r109 of #845 - #846
Merged
Merged
Conversation
resource_owner_id is bounded in bytes (max_bytes 512, not 512 runes) and its pattern refuses Unicode separators, control, format (zero-width) and private-use characters, not only ASCII whitespace. protovalidate enforces the schema at mint and decode; tests cover a 2048-byte owner, a vertical tab, a non-breaking space, a zero-width space and control characters. The conformance kit gains owner vectors: owner-delegated (a hop narrowing within the owner, accepted), and owner-dropped-by-hop / owner-changed-by-hop (genuinely signed hops refused with "widens authority"), so a second implementation that ignores the owner fails the kit. A verify-side test feeds Verify the rewritten chains directly. An owner in an operation's authority is refused with its origin (declaration, installation binding, composition's selection) and the reason, "owner-scoped parent". workcontext.InheritResourceOwner is how a runtime mints an operation child under an owner-scoped parent: it keeps what the parent covers as written, inherits the one covering owner, and refuses no owner, several owners, or a replaced owner. The fail-closed claim in docs/work-context.md and ScopeContained is narrowed to checks built on ScopeContained, and the doc lists the readers known to inspect scopes field by field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-ups to #845 (merged at 8af4b78) from security review r109: the three minor findings, plus the wording fix for the major one.
Changes
F2: owner validation matches what the schema states.
resource_owner_idnow usesmax_bytes = 512. The oldmax_lencounted runes, so a 2048-byte owner passed. The pattern is now^[^\s\p{Z}\p{C}*]*$, which also refuses\v, NBSP, U+3000, U+2028, zero-width characters, BOM, C0/C1 controls, DEL and private-use characters. Go enforces the schema through protovalidate at mint and at decode.TestResourceOwnerSchemacovers 21 refusals (including a 2048-byte owner, a vertical tab, NBSP, ZWSP and controls) and 4 acceptances. Control: restoring the old generated descriptor fails 12 of those subtests.F3: conformance vectors for the owner rule.
workcontext.Fixturesgains three fixtures:owner-delegated(accepted): a hop narrowing within the owner.owner-dropped-by-hop(rejected): a genuinely signed hop that drops the owner.owner-changed-by-hop(rejected): a genuinely signed hop that changes the owner.Both rejections require
ErrInvalidwith "widens authority". The authority builds its shared Python/TSclaims.jsonfrom this kit, and consumers runconformance.Runagainst it. So an owner-blind second implementation now fails.TestVerifyRefusesAHopThatDropsOrChangesTheOwneris the verify-side Go test. Decode's structural list names the two refusals. Control: removing the ownerifinScopeContainedfails both fixtures, the verify test, and every conformance kit test.F4: the refusal names the real reason, and a runtime can mint under an owner-scoped parent.
validateSelectedScope, which used to ignore the owner. Each refusal reads "owner-scoped parent: a resource owner is inherited from the capability the operation is invoked under …" and no longer says "never declared".workcontext.InheritResourceOwner(requested, parent):ErrInvalidand a named reason when no owner covers it, when several do ("mint one child per owner"), or when the scope already names another owner.Child, while the inherited one mints and verifies.docs/work-context.md(new section "Scopes and the resource owner") anddocs/runnable.md.F1 wording.
docs/work-context.mdand theScopeContainedcomment now limit "fails closed" to checks built onScopeContained/ScopesAttenuate. They state that a reader inspectingWorkScopeV1fields itself must refuse (or grant nothing from) an owner-selected scope until it compares owners. The doc lists the known readers:hop.goflattenScope/scope_containedcodefly_hop._flattenReuse
InheritResourceOwneris built entirely onScopeContained. It adds no second containment rule.fixtureResignso both fixture builders share it.Classification
Fix, at the place that owns each behaviour: the schema, core's conformance kit, and core's runnable validation. No hack.
Evidence
make buf-lint: clean.make buf-breaking: "no breaking change against origin/main".go build ./...ok.go vet ./workcontext/... ./runnable/...ok.go test -race -count=1passes on: workcontext, workcontext/conformance, runnable, composition, moduleupdate, policy, policy/testharness, solutionhost../internal/ciguard/...passed under-racebefore the merge with main.codefly generate proto --localand with--template buf.gen.python.yaml. Thebuf.lockbump the companion's dep update made was reverted.Not verified
buf.validatedescriptor clash and version mismatches. Core's Python package is bindings only.Left for owners
codefly-dev/authority: the
owner_awareissuance gate, and making the hop flatten and the Python/TS twins owner-aware. All of this must land before the authority mints any owner-selected scope. When the authority bumps core and regeneratesclaims.json, it picks up the new fixtures.🤖 Generated with Claude Code