{"slug": "how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify", "title": "How Spec-First Kiro Built Anchora — A Two-Pillar Audit Trail You Can Verify Offline", "summary": "A developer built Anchora, a TypeScript evidence skeleton (@anchora/core) that powers two client-side audit applications, Seal and Witness, plus an offline verifier CLI and a stdio Kiro MCP server. The system seals 500 deterministic events with Ed25519 signatures and create-only anchors, detecting tampering such as an edited loan decision at seq 217 via a HASH_MISMATCH and firstDivergence report. The build was driven by Kiro steering files and hooks that enforce TypeScript strict mode, a static security scan, and 199 unit and property-based tests before any agent turn can end.", "body_md": "*Written as part of **Kiroween 2026** (Skeleton Crew category).*\n\nMost AI agent demos stop at a green dashboard. That works until an auditor asks two harder questions:\n\nIf the dashboard reads the same database table an administrator can edit, a green checkmark proves nothing. And if an outage drops a role grant from the audit stream, an immutable-looking hash chain only proves that an incomplete record wasn't altered later.\n\nFor **Kiroween 2026**, I built **Anchora** (`https://tradexy.github.io/reliquary/` | repo: `https://github.com/tradexy/reliquary`) in the **Skeleton Crew** category: one reusable TypeScript evidence skeleton (`@anchora/core`) powering two distinct client-side applications (**Seal** and **Witness**), an offline verifier CLI, and a stdio Kiro MCP server.\n\nBefore writing a single line of cryptography, I wrote four **steering files** (`.kiro/steering/`) locking down the non-negotiable promises:\n\n`simulated` badges) and publish `docs/limits.md`.` connect-src 'none'` CSP, system fonts, zero backend).\nFrom there, Kiro generated **15 EARS requirements**, a canonical preimage & verification design doc, and 16 scoped task groups. Every task ran behind **three automated Kiro hooks**:\n\n`security-on-write.json` (`PostToolUse` on `write`): blocks `eval`, `innerHTML`, web storage, external CDN/font URLs, secrets, and banned overclaims on every edit.`contract-on-core-change.json` (`PostFileSave` on `crypto`/` chain`/` capture`): immediately runs Vitest on core changes.` verify-on-stop.json` (`Stop`): refuses to end any agent turn unless TypeScript strict mode (`4` projects), the static security scan, and all `199` unit & `fast-check` property-based tests pass.\nBoth applications import `@anchora/core` without duplicating a single line of crypto:\n\n`500` deterministic events over one canonical serialiser (`anchora/1`), seals heads with `@noble/ed25519`, and writes create-only (` wx`) anchors. Edit `seq 217` (a £2,000,000 AI commercial loan decision flipped from `approved` to `declined`) and the SVG chain visualizer fractures at `HASH_MISMATCH`, showing `firstDivergence: 217`. Click `217→500` — every link looks consistent, and Seal still catches it at `seq 240` (`SEAL_INVALID` / `ANCHOR_MISSING`) because the external seal & anchor were already written.` 15` auditable actions as `fail-closed` (widening actions like `roles.grant` or `agents.guardrail.ceiling.raise` refuse with `audit-unavailable` when the audit store is down) or `queue` (tightening actions like `roles.revoke` or `agents.disable` complete and queue durably). A coverage build guard fails CI if any catalogued action lacks a test, and SOC 2, ISO 27001, and EU AI Act controls link directly back to supporting events in Seal.\nTo make Kiro verify its own work directly inside the repo, I added:\n\n`tools/mcp/server.ts`, registered in `.kiro/settings/mcp.json`) exposing `verify_bundle`, `inspect_seq`, `check_coverage`, and `check_compliance` with zero extra dependencies and zero network calls.`.kiro/agents/security-auditor.json` and `evidence-builder.json`, verified via `kiro-cli agent validate`).`.kiro/powers/anchora/POWER.md`) so developers can extend `@anchora/core` into a third domain app in three steps.`packages/core/data/kiro-audit.bundle.json`), recording Anchora's own build milestones in the exact same Ed25519-sealed format.\nRunning `kiro-cli chat --agent security-auditor` verified both `bundle.json` (500 events, PASS) and `kiro-audit.bundle.json` (24 events, PASS) plus `0` coverage gaps via MCP — and cleanly refused to claim results for a shell command blocked by non-interactive permissions.\n\nKiro's hook loop caught its own `fast-check` v3 API mistake immediately by executing the suite instead of guessing. Meanwhile, human review caught a subtle semantic bug: an in-place lawful erasure that re-hashes its row leaves a matching hash, so the verifier had to report declared lawful markers independently of the mismatch loop.\n\nBoth the demo and the offline CLI (`npm run verify:bundle -- packages/core/data/bundle.json`) are MIT-licensed and open to inspect — no login, no server, just arithmetic you can re-run yourself.", "url": "https://wpnews.pro/news/how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify", "canonical_source": "https://dev.to/sudo_grep_c26594a296e8d29/how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify-offline-9d3", "published_at": "2026-12-01 00:08:42+00:00", "updated_at": "2026-12-01 00:14:38.763928+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-safety"], "entities": ["Kiro", "Anchora", "Seal", "Witness", "@anchora/core", "@noble/ed25519", "fast-check", "Kiroween 2026"], "also_reported_by": [], "takeaway": "Sealing audit heads with Ed25519 and create-only anchors catches tampering that an in-place hash chain misses, since an edited record re-hashes consistently but fails SEAL_INVALID against the external anchor.", "recommendation": {"advice": "Anchor audit heads externally with Ed25519 signatures and create-only writes, and gate agent turns on strict type checks, security scans and the full test suite.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify", "markdown": "https://wpnews.pro/news/how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify.md", "text": "https://wpnews.pro/news/how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify.txt", "jsonld": "https://wpnews.pro/news/how-spec-first-kiro-built-anchora-a-two-pillar-audit-trail-you-can-verify.jsonld"}}