[Hackathon] distributed-systems-architect: private_commerce — four-layer cross-plugin composition with joint validators#57
Open
Abi5678 wants to merge 2 commits into
Conversation
…on with joint validators Composes gossip_registry + streaming_payments + hybrid_x25519 + agent_receipts into one scenario and instruments the emergent, cross-layer invariants no single-layer validator can see: - commerce_discovery_precedes_bid: registry x privacy ordering - commerce_bid_opacity: privacy x transport confidentiality - commerce_undelivered_penalized: payments x trust (adversary punished) - commerce_delivery_rewarded: payments x trust (honesty rewarded) The adversary is a wash-trading shill seller that drains a payment stream without delivering and covers itself with mutually co-signed fake receipts. Adversarial discrimination, one YAML line each: privacy: noop fails the opacity check; trust: score_average fails the penalty check (the wash-trade inflates its average score, while agent_receipts severs the isolated shill pair to zero). Deterministic under any fixed seed; 25 new tests including Hypothesis property tests for parser robustness and drop-redundancy dedup.
There was a problem hiding this comment.
Pull request overview
This PR adds a new Tier-1 “private_commerce” scenario that composes four previously-merged layer plugins (gossip registry, streaming payments, hybrid X25519 privacy, and receipt-based trust) and introduces joint validators that check cross-layer invariants over the resulting trace.
Changes:
- Added
private_commercescenario YAML and a built-in scenario factory that wires per-agent plugin overrides (gossip registries, hybrid privacy keypairs, streaming payments ledgers). - Added four “private_commerce” joint validators to
nest_core.validatorsand registered them underVALIDATORS["private_commerce"]. - Added comprehensive unit/property/integration tests for the scenario + exact adversarial discriminations, and updated validator registry tests to include the new scenario type.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scenarios/private_commerce.yaml | New scenario wiring for the four-layer composition, failures (drop + partition heal), and trace output. |
| packages/nest-plugins-reference/tests/test_private_commerce.py | Unit/property/integration coverage for the new joint validators and end-to-end scenario runs. |
| packages/nest-core/tests/test_validators.py | Updates expected validator registry keys to include private_commerce. |
| packages/nest-core/nest_core/validators.py | Implements and registers four new cross-layer “private_commerce” validators. |
| packages/nest-core/nest_core/scenarios.py | Registers the new built-in scenario loader branch for private_commerce. |
| packages/nest-core/nest_core/scenarios_builtin/private_commerce.py | Implements the 12-agent scenario and per-agent plugin override wiring. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+335
to
+339
| payments = ctx.plugins.get("payments") | ||
| if payments is not None and hasattr(payments, "open_stream"): | ||
| await payments.open_stream( | ||
| to=seller, rate_per_tick=self._stream_rate, max_total=self._stream_max, ref=ref | ||
| ) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.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.
[Hackathon] distributed-systems-architect: private_commerce — four-layer cross-plugin composition with joint validators
Problem picked
None of the ten listed problems — this PR targets the gap they leave behind. Every merged hackathon plugin (gossip registry #24, streaming payments #21, hybrid_x25519 privacy #28, agent_receipts trust #26) was designed, tested, and validated in isolation. Nobody has asked what happens when they run together, and no validator in the repo can even express a cross-layer invariant. This PR is a scenario + validator submission per the charter ("a layer plugin or a scenario or a validator"): a
private_commercescenario that composes four merged plugins into one workflow, plus four joint validators that test emergent properties spanning layer boundaries.What it does
Scenario (12 agents): 5 buyers discover sellers through per-agent gossip registries (partition-honest — buyers 0-1 are partitioned away for the first 3000 ticks and must wait for the heal), open per-tick streaming payments, and send bids wrapped in hybrid X25519 + ChaCha20-Poly1305 envelopes. 4 honest sellers decrypt, deliver, and issue Ed25519 cross-signed purchase receipts; they also settle among themselves in a directed receipt cycle, forming the strongly-connected honest anchor that collusion severance needs. The adversary —
shill_seller-0— looks legitimate on the registry, decrypts the bid, drains the stream, never delivers, and covers itself by wash-trading mutually co-signed fake receipts withshill-0. An auditor ingests receipts and negatives into the configured trust plugin and emits final scores.Joint validators (registered as
VALIDATORS["private_commerce"]):commerce_discovery_precedes_bidcommerce_bid_opacitybid:wire message (send / receive / dropped)commerce_undelivered_penalizedcommerce_delivery_rewardedAdversarial discrimination (one YAML line each)
The charter asks for validators the reference plugin cannot satisfy. Here each cross-layer check is pinned to the specific plugin that makes it pass:
privacy: hybrid_x25519 → noop: bid envelopes become plaintext;commerce_bid_opacityFAILS (the other three still pass — the failure is surgically attributable).trust: agent_receipts → score_average: the shill's wash-traded receipts raise its running average to 0.75;commerce_undelivered_penalizedFAILS. Underagent_receiptsthe isolated mutual co-signing pair is severed by the SCC analysis and the shill collapses to 0.0 — the composition passes.Both discriminations are integration tests (
test_noop_privacy_fails_exactly_the_opacity_validator,test_score_average_trust_fails_exactly_the_penalty_validator) that assert the exact verdict vector, not just "something failed."Design decisions & tradeoffs
bidmeta:): opacity is unfalsifiable unless the validator knows the plaintext. Buyers broadcast abidmeta:marker declaring what they encrypted; the validator then proves that string never rides the wire in abid:message. In production this sidecar would not exist; in a test rig, making the invariant checkable is the point.discovered:,stream:*,fulfilled:,score:) are broadcasts — recorded in the trace at send time, so a dropped delivery can never make the trace lie about what an agent did. Functional messages (bid, ack, receipt) get 3× send redundancy with receiver-side dedup by ref/receipt-id; self-scheduled ticks get 5× redundancy (drop-chain death probability ≈ 0.05⁵). This is the same pattern the gossip scenario ([Hackathon] bori7-onchain-registry-author: gossip registry plugin with partition-honest eventual consistency #24) uses, extended to point-to-point traffic."the adversary never fired"), rather than passing vacuously.1 − exp(−5/10) ≈ 0.39underagent_receipts; a severed shill scores exactly 0.0; the reference neutral prior is 0.5. 0.3 separates every honest outcome from the severed adversary with margin on both sides, and sits below the 0.5 prior soscore_average's wash-trade inflation (0.75) is caught._agent_pluginsoverride channel (same as [Hackathon] bori7-onchain-registry-author: gossip registry plugin with partition-honest eventual consistency #24): per-agent gossip views, per-buyer streaming ledgers, per-agent X25519 keypairs cross-registered at build time. No runner changes needed.Test rigor
25 tests in
packages/nest-plugins-reference/tests/test_private_commerce.py:How to verify
Full CI (
uv sync && uv run ruff check . && uv run ruff format --check . && uv run pyright && uv run pytest -v) is green locally: 761 passed, 0 ruff, 0 pyright.Persona
distributed-systems-architect: the submission's whole thesis is that correctness of parts does not compose for free. The code reflects it — redundancy budgets computed from the drop rate, partition-aware pairing deadlines, an SCC-severance-aware threshold derivation, and validators that treat the trace as the only source of truth (markers recorded at send time so drops can't hide behavior). The novelty is not any one algorithm; it is the instrumented composition and the two one-line adversarial swaps that attribute each cross-layer failure to the exact layer that caused it.