fix(examples): pin the trusted root in the cross-operator demo, and stop it dying on cp1252 - #140
Merged
Conversation
…top it dying on cp1252 Two bugs, both of which made `demo.py` fail before it reached its own point. **The trust root was only half-threaded through.** #132 made `verify_chain` fail closed when no trusted root issuer is supplied, which is right: a self-consistent chain minted by an attacker passes every signature and attenuation check, so the pinned anchor is what makes the call authorization rather than structure checking. That change updated the two CLI invocations at the end of this demo to pass `--trusted-root-issuer`, and missed all three in-process call sites. The demo died at step 4 with `UntrustedDelegationRoot`, which reads like the example is wrong about delegation when the example was simply not passing the root. `effective_scope` and both `enforce_peer_call` sites now pass `trusted_root_issuers=[chain[0].issuer]`, with a comment saying why the anchor is load-bearing rather than ceremony. **The demo crashed on a default Windows console.** It prints the set-intersection sign when reporting scope n policy, and cp1252 cannot encode it, so a run on stock Windows died with a UnicodeEncodeError partway through the checks. stdout and stderr are reconfigured to UTF-8 rather than downgrading the notation, since the intersection is the clearest way to write what that step does. 12/12 checks now pass on a default Windows console, including the sealed task, the binary-swap rejection, and the offline provenance-DAG verification. The regenerated chain.json and dag.json are deliberately not included: the demo mints fresh keys each run, so committing them is pure churn. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P1p7BCjLPmLCw4VcBpcF8J
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.
The demo was broken on
mainTwo independent bugs, both of which stopped
examples/cross-operator-delegation/demo.pybefore it reached the thing it exists to demonstrate.1. The trusted root was only half-threaded through
#132 made
verify_chainfail closed when no trusted root issuer is supplied. That is the right call: a self-consistent chain minted by an attacker passes every signature, continuity and attenuation check, so the pinned anchor is what makes this authorization rather than structure-checking.That change updated the two CLI invocations at the end of this demo to pass
--trusted-root-issuer, and missed all three in-process call sites. Result onmaintoday:Which reads like the example is wrong about delegation, when the example was simply not passing the root it already had in hand.
Fixed at
effective_scopeand bothenforce_peer_callsites, with a comment on why the anchor is load-bearing rather than ceremony.2. It crashed on a default Windows console
The demo prints the set-intersection sign when reporting
scope ∩ policy. A stock Windows console is cp1252, which cannot encode it, so the run died withUnicodeEncodeErrorat step 4 on any default Windows shell.stdout/stderrare now reconfigured to UTF-8 rather than downgrading the notation, since the intersection sign is the clearest way to write what that step does.Worth noting the other two demos (
rejection-with-proof,trace-dag) were checked and run clean on cp1252 already, so this is specific to this file.After
Verified on a default Windows console, no
PYTHONIOENCODINGneeded.Not included
The regenerated
chain.jsonanddag.json. The demo mints fresh keys on every run, so committing them is pure churn and would make every future example run show a spurious diff.Unrelated observation
ruff format --check examples/reportsexamples/trace-dag/demo.pywould be reformatted. Pre-existing and untouched here; flagging rather than folding an unrelated reformat into this PR.