Repository navigation
Realize add-dispatch-credential-contract (contract side): examples + validator + naming ratified - #171
Merged
Conversation
- Ratify the openXdox naming record (docs/openxdox-naming.md: draft -> ratified, Ratified by: add-dispatch-credential-contract) — task 1.2. - Add packaged example credential records (task 2.1): the openXdox dispatch + content requirements and bindings (distinct secret_ref, reference-delivered), plus three negatives — dispatch-reuses-content-secret, dispatch-grants-contents, baked-secret-in-binding. - Mechanize the two invariants in validate-credential-contracts.py (task 2.2): dispatch-scope-ceiling (a dispatch_only requirement may hold only trigger scopes, one workflow), shared-secret-identity (distinct bindings may not share a secret_ref — the serving tier holds no content-write key material), and baked-secret (secret_ref must be a reference, never a raw value). A self-test gates the examples; a pytest wrapper gates the self-test. Validator self-test: 2 positive + 3 negative confirmed. openspec --all --strict green. Tasks 1.1/1.2/2.1/2.2 ticked. Downstream (3.x): the org-owned dispatch App + token-minter + QA secret repoint remain. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Hi @brettheap! 👋
Your private repo does not have access to Sourcery.
Please upgrade to continue using Sourcery ✨
There was a problem hiding this comment.
Pull request overview
Implements the contract-side realization of add-dispatch-credential-contract by adding packaged credential-contract examples (positive + negative) and extending the credential-contracts validator with dispatch-credential semantic checks plus a self-test that gates the shipped examples.
Changes:
- Added openXdox dispatch/content example credential-contract records plus three negative fixtures.
- Extended
validate-credential-contracts.pywith semantic validations and an on-invocation self-test over packaged examples. - Added a pytest self-test wrapper that runs the validator and asserts the packaged examples are present.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/credential_contracts/test_dispatch_credential_contract.py | Adds pytest coverage that runs the validator and ensures packaged examples exist. |
| scripts/validate-credential-contracts.py | Adds dispatch-credential semantic checks and a packaged-examples self-test; reports semantic findings during repo scan. |
| openspec/changes/add-dispatch-credential-contract/tasks.md | Marks contract tasks 1.1/1.2/2.1/2.2 as completed. |
| examples/credential-contracts/openxdox-dispatch.requirements.example.yaml | Positive example of dispatch-only + content-write requirements. |
| examples/credential-contracts/openxdox-dispatch.binding-template.example.yaml | Positive example binding template with distinct dispatch/content bindings. |
| examples/credential-contracts/negative/dispatch-reuses-content-secret.yaml | Negative binding template fixture for shared-secret identity. |
| examples/credential-contracts/negative/dispatch-grants-contents.yaml | Negative requirements fixture for dispatch scope ceiling violation. |
| examples/credential-contracts/negative/baked-secret-in-binding.yaml | Negative binding template fixture for baked secret detection. |
| docs/openxdox-naming.md | Ratifies openXdox naming and records ratification provenance. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+69
to
+71
| if len(req.get("allowed_workflows") or []) > 1: | ||
| out.append(f"dispatch-one-workflow: requirement {rid!r} is dispatch_only but names " | ||
| f">1 allowed_workflow; a dispatch credential triggers exactly one") |
Comment on lines
+60
to
+71
| for req in doc.get("requirements") or []: | ||
| if req.get("access_mode") != "dispatch_only": | ||
| continue | ||
| rid = req.get("id", "<?>") | ||
| bad = [s for s in (req.get("minimum_scopes") or []) if s not in DISPATCH_SCOPES] | ||
| if bad: | ||
| out.append(f"dispatch-scope-ceiling: requirement {rid!r} is dispatch_only but " | ||
| f"requests non-trigger scope(s) {bad}; a dispatch credential carries no " | ||
| f"contents authority (allowed: {sorted(DISPATCH_SCOPES)})") | ||
| if len(req.get("allowed_workflows") or []) > 1: | ||
| out.append(f"dispatch-one-workflow: requirement {rid!r} is dispatch_only but names " | ||
| f">1 allowed_workflow; a dispatch credential triggers exactly one") |
Comment on lines
+73
to
+86
| seen: dict[str, str] = {} | ||
| for name, binding in (doc.get("credential_bindings") or {}).items(): | ||
| ref = binding.get("secret_ref") if isinstance(binding, dict) else None | ||
| if not isinstance(ref, str): | ||
| continue | ||
| if _looks_like_raw_secret(ref): | ||
| out.append(f"baked-secret: binding {name!r} secret_ref is a raw secret value, not a " | ||
| f"vault reference; credentials are delivered by reference, never baked") | ||
| if ref in seen: | ||
| out.append(f"shared-secret-identity: bindings {seen[ref]!r} and {name!r} share " | ||
| f"secret_ref {ref!r}; dispatch and content credentials must be distinct " | ||
| f"bindings so the serving tier holds no content-write key material") | ||
| else: | ||
| seen[ref] = name |
Comment on lines
+20
to
+21
| # the validator runs its self-test on every invocation; the positional arg | ||
| # is the (here empty) domain-repo scan target. |
Comment on lines
+97
to
+114
| positives = sorted(EXAMPLES_DIR.glob("*.example.yaml")) | ||
| for path in positives: | ||
| doc = yaml.safe_load(path.read_text()) | ||
| problems = [e.message for e in validator.iter_errors(doc)] + _semantic_findings(doc) | ||
| if problems: | ||
| print(f"ERROR self-test: positive {path.name} unexpectedly invalid: {problems}") | ||
| errs += 1 | ||
| neg_dir = EXAMPLES_DIR / "negative" | ||
| negatives = sorted(neg_dir.glob("*.yaml")) if neg_dir.is_dir() else [] | ||
| for path in negatives: | ||
| want = NEGATIVE_EXPECTATIONS.get(path.name) | ||
| findings = _semantic_findings(yaml.safe_load(path.read_text())) | ||
| if not want: | ||
| print(f"ERROR self-test: negative {path.name} has no registered expectation") | ||
| errs += 1 | ||
| elif not any(f.startswith(want) for f in findings): | ||
| print(f"ERROR self-test: negative {path.name} did not raise {want!r} (got {findings})") | ||
| errs += 1 |
| def test_selftest_passes_on_the_packaged_examples() -> None: | ||
| result = _run() | ||
| assert result.returncode == 0, result.stdout + result.stderr | ||
| assert "self-test: 2 positive + 3 negative example(s) confirmed" in result.stdout |
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.
Realizes the openxFactory contract side of
add-dispatch-credential-contract.docs/openxdox-naming.mddraft → ratified(Ratified by: add-dispatch-credential-contract).secret_ref, reference-delivered), plus three negatives.validate-credential-contracts.pygains three mechanized checks:dispatch-scope-ceiling,shared-secret-identity,baked-secret, with a self-test over the examples and a pytest wrapper.Self-test: 2 positive + 3 negative confirmed.
openspec --all --strictgreen; new test 2/2.Downstream (§3, needs the App + a minter-topology decision): create the org-owned openXdox Intent Dispatch App, the token-minter, repoint the QA secret, retire the personal PAT.
🤖 Generated with Claude Code