Skip to content

Guard, agents and shared payload (David, Day 0) - #4

Merged
Chibey-max merged 101 commits into
Phantomcall:mainfrom
Chibey-max:d/day0-guard-agents
Nov 5, 2026
Merged

Chibey-max merged 101 commits into
Phantomcall:mainfrom
Chibey-max:d/day0-guard-agents

Conversation

@Chibey-max

Copy link
Copy Markdown
Collaborator

David's Day 0–5 work that doesn't depend on testnet: the shared payload and schemas, Guard (rules engine and signer), the agents service, the audit verifier, CI and docs. Nothing in it needs a key or a deployed contract. pnpm mock runs the whole flow locally.

Start with docs/decisions-pending.md. It lists where this departs from or adds to PRD v2. Items 1–2 change the rules hash Isaac needs for Vault init (H3).

What's in it

Task What
D-0.1 pnpm monorepo, strict TS, eslint, vitest, gitleaks pre-commit hook, .env.example
D-0.2 / H1 Borsh BasketPayloadV1, hash and ed25519 signing, plus the shared vector packages/shared/vectors/basket-v1.json. Cross-checked byte for byte against Rust borsh 1.x, sha2 and ed25519-dalek; the matching Rust struct is in vectors/README.md.
D-0.3 / H2 Zod contracts for the Guard and agents APIs and SSE events, docs/api.md, and pnpm mock (the real pipeline with an in-process Guard, mock Vault and fake wallet)
D-0.4 LLM via Groq (openai/gpt-oss-120b, strict structured output) instead of Anthropic. Team decision; supersedes PRD §13 and D-10. Live pnpm llm:check passed.
D-1.1 Rules R-01–R-10 and R-20–R-24: pure, integer-only, with the AT-02 boundary tests. rules_hash is in decisions-pending item 2.
D-1.2 Snapshot loader and pnpm snapshot:check
D-2.1 / D-2.2 Guard HTTP API: assess, sign-basket, fails closed on any Vault read failure (503); CLI pnpm guard assess, rules:hash, keygen
D-3.1–3.3 Deterministic and LLM parsers, Coordinator, orchestrator, SQLite event store, SSE with Last-Event-ID replay, approval watcher
D-4.2 GET /v1/audit/:id, pnpm verify:audit, and verifyEvidenceBundle() in @checkpoint/shared for the web audit page
D-5.1–5.3 Explanations with a post-check on numbers and IDs, AT-13 (injected listing changes nothing), AT-14 (Guard/RPC down → no signature), rate limit, secret redaction
D-7.1 / D-7.2 docs/architecture.md, a README section draft, and the CI workflow

For Isaac

  • H8, Guard public key v1: CAR74z4PpMpNAmCnmaRY3dPrjFUSMrswynTah4oSsBrY. The secret is on David's machine and in the password manager.
  • Vault view JSON: Guard and the agents parse get_policy, get_owner_state, get_balance, get_approval and get_basket with the shapes in packages/shared/src/vault-views.ts (table in docs/api.md). Please confirm or change them (decisions item 8). Guard fails closed on any other shape.
  • H9: packages/agents/src/settlement.ts is the slot for your Settlement module. Its interface is execute(payload_b64, signature_b64) → { tx_hash }.
  • AT-09: GUARD_DEV=1 does not let Guard sign rule-breaking baskets. over-cap.ts can sign directly with the shared payload helpers (decisions item 11).

For Patrick

  • @checkpoint/shared exports the same schemas, the SSE reducer (replayRequest / reduceRequest), decodePayload and basketHashHex for the local hash check, and verifyEvidenceBundle. All are browser-safe, so apps/web/src/lib/agents/{types,reducer}.ts and lib/payload.ts could import them instead of keeping copies.
  • Snapshot: the 7 rows in data/snapshot/fixtures/adversarial.json say capture_method: "manual". Decision #5 proposes "fixture", so the UI and README can label synthetic rows. Until they're relabelled, snapshot:check reports 7 errors and Guard won't load data/snapshot. The CI step is non-blocking for now. Your item keys match the ones Guard expects.
  • The REVIEW → acknowledge beat needs an acknowledge action on REVIEW rows in the offers table (decision Redesign the landing page, plus the desk, basket approval and Vault pages (P-0.2, P-1.2, P-2.1, P-2.2, P-3.1) #3).

Merge notes

Testing

  • pnpm test: 149 tests pass, covering the payload vector, rule boundaries, the Guard API, the pipeline end to end, SSE replay, acknowledgement re-plan, expiry, cancel, AT-13, AT-14, verify:audit and the Groq client with fallback.
  • pnpm typecheck passes for all workspaces, including apps/web. pnpm lint and Prettier are clean.
  • Ran Guard and the agents as separate processes from .env: a request went to final (PartiallyPaid, with vendor-06 failing as designed), and verify:audit printed PASS.
  • A live Groq check agreed with the deterministic parser, and all 16 verdict explanations passed the post-check.
  • Not tested: anything on testnet, because the Vault isn't deployed yet.

…ents

Resolve add/add conflicts: union of both .gitignore files, workspace includes
apps/*, packages/* and scripts, lockfile regenerated with pnpm 9.15.9.
@Chibey-max
Chibey-max merged commit 899717b into Phantomcall:main Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant