closedhumanPR #217Trust
trust(parc): anchor behavioral_merkle_root into a capsule, closing the equivocation gap.
cc @Skyrider3 @dhve @Sharathvc23 — wiring PARC (#63, #66) to the capsule/anchor machinery (#197, #200) that docs/layers/trust.md already named as the next step.
Author
@StevenMih
github profile →- Status
- Closed without merging
- Opened on
- Aug 8
- Branch
- nanda-parc-root-anchor
Description
The pitch.
cc @Skyrider3 @dhve @Sharathvc23 — wiring PARC (#63, #66) to the capsule/anchor machinery (#197, #200) that docs/layers/trust.md already named as the next step.
**The gap**
ParcTrust.build_credential (#63) computes behavioral_merkle_root = merkle_root(receipts) and signs the whole credential through the identity layer (#66 layers selective disclosure on top). That signature proves an issuer signed some root for a subject — it does not stop the SAME issuer from regenerating its own receipt tree (drop a receipt, add a fabricated one) and re-exporting a different, still self-consistently-signed root for the identical nominal (issuer, subject, validFrom). Nothing outside the issuer's own signature catches that today.
docs/layers/trust.md already named the target shape, in its closing line under bonded_trust's pluggable-scarcity-anchor section: "an anchored PARC reputation standing... fits the same seam; both are planned." This PR builds the anchoring primitive that line points at — not the full NotaryBackedLedger integration (PARC standing as a bonded_trust scarcity source), which stays open. Just the sealed-root witness such an integration would sit on top of.
**What this does**
Seal at issuance. build_credential, with anchor=True, seals {behavioral_merkle_root, receipt_count} into a capsule right after signing (ParcTrust._anchor_root) — a second, independent witness of the root the issuer already committed to, not a replacement for that signature.
Check at verification. verify_presentation gains an anchor_capsule option: when supplied, it checks the presented (root, receipt_count) against the sealed capsule (capsule_emit.verify_input_digest) and surfaces a mismatch as the typed reason anchor_mismatch — same typed-reason contract every other gate in this file already uses.
Same optional posture as aae_permit_gate's anchor, exactly. Soft dependency: importlib.import_module("capsule_emit") inside a try/except ImportError; absent ⇒ one-time debug log + no-op, never a hard requirement. Namespaced action "parc.root_sealed" (mirrors permit.granted / permit.denied) so a sealed root never reads as an executed action. anchor=False is the default — this PR does not change build_credential's or verify_presentation's behavior for any existing caller.
Anchor URL
Deliberately unset in this PR — capsule_emit.emit() reads AAC_ANCHOR_URL from the environment on its own. Nothing here hard-pins an endpoint or an ACL instance.
Discrimination test — the equivocation case
TestAnchor::test_equivocation_after_anchor_rejected (packages/nest-plugins-reference/tests/test_parc.py): issuer builds and anchors a genuine credential (root₁), then reports one more corroborated receipt and re-exports for the SAME (subject, validFrom) — a different, self-consistent root₂, signed and internally valid on its own. The presentation over root₂ verifies clean under the CURRENT (pre-this-PR) checks:
python
unchecked = await trust.verify_presentation(pres2, identity=gate_ident)
assert (unchecked.ok, unchecked.reasons) == (True, ()) # passes — the gap
Supplying the ORIGINAL sealed capsule catches it:
python
checked = await trust.verify_presentation(
pres2, identity=gate_ident, anchor_capsule=original_capsule
)
assert checked.ok is False
assert "anchor_mismatch" in checked.reasons # passes — the close
Mutant check (condition-removed): temporarily deleted the anchor_capsule branch in verify_presentation (the 4 lines that call _anchor_reason and append its result to reasons) and re-ran this one test:
FAILED test_parc.py::TestAnchor::test_equivocation_after_anchor_rejected
AssertionError: assert True is False
+ where True = DisclosureResult(ok=True, reasons=(), detail='').ok
The test flips to incorrectly passing exactly as expected — it depends on the check, not on incidental setup. Restored the code, re-ran:
test_anchor_off_by_default_no_capsule PASSED
test_anchor_unavailable_degrades_to_noop PASSED
…Try it
Open PR on GitHubView diffCheckout locally
git fetch origin pull/217/head:pr-217
git checkout pr-217