Your code says what should exist. Your system says what does. Touchstone finds the gap and proves every fix.
Category: Skeleton Crew · Kiroween 2026
- Repo: https://github.com/NithinBR-AI/touchstone (MIT)
- The Crypt (Schema Drift): https://touchstone-schema-drift.onrender.com
- The Séance (Contract Observer): https://touchstone-contract-observer.onrender.com
- The Poltergeist (cache drift): https://touchstone-poltergeist.onrender.com
- Demo target API: https://touchstone-demo-target-repo.vercel.app/health (code: https://github.com/NithinBR-AI/touchstone-demo-target-repo)
The three apps run on Render's free tier and sleep when idle, so the first load can take up to a minute. The demo API runs on Vercel and has no long cold start.
Try it in two minutes (no login)
- Open The Crypt and click ↺ Reset Demo, then Hunt Ghosts. Four ghosts appear.
- Click ⚡ Exorcise on Missing Specter and confirm. The SQL runs on Neon, Touchstone re-reads the schema, and the card turns ✝ LAID TO REST.
- Open The Séance, click Hunt Ghosts, then ⚡ Exorcise on a Shadow Field. After 20–60 seconds a popup links to a real pull request on the demo target repo.
- Open The Poltergeist, click Hunt Ghosts, and Exorcise both ghosts.
Reset Demo puts every app back to its starting drift, so the next person sees the same ghosts. A demo video is linked on this page.
Inspiration
Every team I have worked on had the same quiet bug: the repo describes one system and production runs another. A migration ran on staging but not prod. Someone added a field to the API response and never touched openapi.yaml. A cache key that the config promises is never warmed, and a debug key nobody declared sits in Redis holding session data.
Each of these gaps has its own tool, or more often no tool, and each tool has its own idea of what "fixed" means. I wanted one engine that does the same thing for all of them: read what the code declares, read what the live system has, name the gaps, propose one fix per gap, refuse anything unsafe, and after applying a fix, re-read the system to prove it worked.
The ghosts are the gaps: tables, fields and keys that exist in one state but not the other.
Who it's for. Backend and platform teams, and whoever is on call when the gap shows up in production. The cost is concrete: a missing index turns a fast query into a slow page; an undocumented response field becomes something a client depends on and then breaks when it changes; a debug key left in a shared cache holds data nobody meant to keep. Today these surface as incidents. Touchstone surfaces them as cards, with a proposed fix and proof the fix worked.
Built for Skeleton Crew
The Skeleton Crew brief asks for one lean skeleton and two or more distinct apps built from it. That is the whole architecture of Touchstone.
The skeleton is core/. Six files, 1,301 lines, with no knowledge of any domain. It defines the 10-step compare → classify → resolve → validate → apply → verify workflow, the data models, a seven-state lifecycle, persistence, and a fix cache. A domain plugs in by implementing seven protocols: InputSource, SourceAdapter, Comparator, Resolver, Validator, Executor, Verifier (plus two optional capabilities, BatchExecutor and RollbackSupport).
The brief asks for two apps. Touchstone ships three, each in its own folder. The third, The Poltergeist, is the extra one: a different domain (cache drift), built on the same core/ after the first two were working.
| App | Folder | Domain code | Declared state | Live state |
|---|---|---|---|---|
| The Crypt (Schema Drift) | apps/schema-drift/ |
adapters/postgres/ |
SQLAlchemy models.py on GitHub |
Neon Postgres |
| The Séance (Contract Observer) | apps/contract-observer/ |
adapters/openapi/ |
openapi.yaml on GitHub |
The deployed API on Vercel |
| The Poltergeist | apps/poltergeist/ |
adapters/redis/ |
cache_config.yaml |
Upstash Redis via the demo API |
All three share one UI template (apps/shared/ui/, vanilla JS and Tailwind CDN, no build step). Each app supplies a config.json with its domain, accent colour and title, and registers a renderer for its evidence cards.
How I proved the skeleton is actually generic, not just claimed to be:
tests/test_skeleton.pyparsescore/with Python's AST and fails the build ifcore/gains a file, imports fromadapters/,agents/orapps/, importssqlglot, or branches on.domain == "<string>".tests/test_fourth_domain.pybuilds a fourth, in-memory "config" domain inside the test file and runs the full lifecycle through the unchanged orchestrator.- The third app, The Poltergeist, goes beyond the brief's two. It was added after the first two, and the commit that added it changed no file in
core/: a new domain needed only its adapter (adapters/redis/) and its app folder.
One honest note: I planned to freeze core/ after the first app. During the second app I extended it once (apply_batch and a human_authorized flag) because the Contract Observer needed to open one pull request per file instead of one per field. I dropped the freeze rule rather than pretend it held. The AST tests are what keep the skeleton domain-free.
What it does
Each app shows its ghosts as cards. Every card has a state:
| State | Label | Meaning |
|---|---|---|
| PENDING | 👻 HAUNTING | A safe fix is proposed and validated. Ready to apply. |
| REVIEW_REQUIRED | 🕯 SÉANCE NEEDED | Ambiguous. A human must decide. |
| BLOCKED | ⛓ BOUND | Destructive or outside the safe operation matrix. |
| RESOLVED | ✝ LAID TO REST | Applied and re-verified against the live system. For API drift: the fix is an open pull request, confirmed by a re-scan after merge. |
| STILL_PRESENT | 😱 STILL HAUNTING | Applied, but re-verification found the gap still there. |
| EXECUTION_FAILED | 💀 RITUAL FAILED | The apply step errored. |
| SUPERSEDED | 🌫 FADED | Reserved; not used yet. |
The Crypt compares SQLAlchemy models with a live Neon Postgres database. In the demo it finds a missing index ix_orders_user_id and a widening type change on users.email (varchar(50) → varchar(255)), both HAUNTING, plus a narrowing type change on users.age and an extra index ix_users_email, both SÉANCE NEEDED. Click ⚡ Exorcise and confirm: the SQL runs, Touchstone re-reads the catalog, and the card turns LAID TO REST with the exact state it re-read as evidence.
The Séance compares openapi.yaml with what the live API actually returns. It finds two fields the API returns but the spec does not declare (account_status, sku) and one field the spec declares but the API never returns (loyalty_tier). Click Exorcise: an LLM writes the patch, a second LLM checks it, and Touchstone opens one pull request per file on the demo target repo (spec fixes on openapi.yaml, code fixes on main.py). Re-running is idempotent. If the patch fails the model check twice, a draft PR still opens for a human to review, but the card shows 💀 RITUAL FAILED: it never counts as a success. Nothing changes until a human merges a PR.
The Poltergeist compares a declared cache config with live Redis. It finds a declared key that is not warmed (products:list) and an undeclared key that should not exist (debug:session_dump). Exorcise warms the first and deletes the second, then re-reads Redis to confirm. It uses no LLM and needs no secrets.
Every app has ↺ Reset Demo, which restores its starting drift (re-seeding Neon, closing Touchstone's open PRs, or restoring the cache keys) so the next judge sees the same ghosts.
It isn't tied to the demo. The touchstone compare CLI scans any Postgres against any SQLAlchemy models.py with two environment variables, and it's read-only. I tried it with a models file containing three changes the demo doesn't cover (a new column, a widened column, a new table): all three were found with the state the operation matrix assigns. The models file and the real output are in the repo under examples/scan-your-own/.
How it differs from existing tools
Each of these gaps already has tools, and they are good at their own job:
- Schema diff and migration tools (for example Atlas or Liquibase's diff) compare a declared schema with a database and generate the migration.
- Contract testers (for example Schemathesis or Dredd) check a running API against its OpenAPI spec.
- Infrastructure drift detection (for example
terraform plan) compares declared infrastructure with what is deployed.
Each one covers one domain. As far as I know, none covers cache drift at all. Touchstone's bet is different in four ways:
- One engine for every domain. The same
core/runs databases, APIs and caches. A new domain is an adapter, not a new tool. That is the Skeleton Crew idea, and a fourth domain is already tested. - The fix is proposed, then bounded. An LLM proposes one fix per gap, but only fixes inside a parsed-AST operation matrix can run, and destructive ones are refused structurally.
- A human authorizes each gap separately, not a whole migration at once.
- "Fixed" means re-verified. For the database and the cache, Touchstone re-reads the live system after a fix and stores what it read as evidence; a ghost is laid to rest only if it is really gone. API fixes are pull requests, so they are confirmed by a re-scan after the merge.
It also combines a few things in ways I haven't seen together:
- Context7 at runtime, not just in the editor. The app's own resolver grounds its SQL proposals in current PostgreSQL docs from Context7, and falls back to
confidence: LOWwithout them. - Two models with separate jobs. For API drift, DeepSeek v3.2 writes the patch and Qwen3-235B checks it before any pull request opens.
- A Kiro agent that is deliberately stricter than the app. The Validator Reviewer keeps rejecting DROP and narrowing changes even when a human has authorized them, so the second opinion never loosens.
How I built it
The pipeline
- Read intended state from the repo (fetched over HTTPS from GitHub raw URLs listed in
repos.json; adding a repo is one JSON entry). - Read actual state from the live system.
- Compare deterministically into typed
Differencerecords with a stable signature. - Classify each difference against a policy table: auto-fixable, review-required, or blocked.
- Resolve: one LLM call proposes one fix per difference.
- Validate the proposal independently of the LLM.
- Human authorizes by clicking Exorcise and confirming.
- Execute.
- Verify by re-reading the live system and recording what was read. For API drift, the evidence records the open pull request instead.
- Persist the report and cache the validated fix, keyed by
Difference.signature, so the same ghost next time costs no LLM call.
LLM proposes, validator decides, human authorizes
The LLM never gets the final say. For the database, adapters/postgres/validator.py parses the proposed SQL with sqlglot and checks the AST against an operation matrix:
- Only
CREATE INDEX(plain B-tree, namedix_<table>_<cols>, columns in declared order) andALTER COLUMN TYPEfor an exhaustive widening list (smallint→integer, integer→bigint, real→double precision, varchar(n)→varchar(m>n), varchar→text) are auto-fixable. - The SQL must target exactly the table, column or index of the difference it claims to fix.
- The (old, new) type pair is taken from the comparator's evidence, not from the LLM's rationale.
- Multi-statement SQL,
SET,USING, expression and partial indexes are rejected. Unknown forms fail closed.
Exorcising a SÉANCE NEEDED or BOUND ghost sends human_authorized=True. That lets a human approve a narrowing change after review, but the validator still runs and SET, DELETE and TRUNCATE are always refused.
For the API, the validator decides which file and which fields may change, bound to the ghost: a Shadow Field may only patch openapi.yaml, a Vanished Field only main.py. The orchestrator runs that check for every ghost in a batch. The patch itself is written at Exorcise time and checked by a second model, and a human merges every PR.
Models
| Where | Model | Job |
|---|---|---|
| The Crypt | Qwen3-235B (qwen.qwen3-235b-a22b-2507) via Amazon Bedrock |
Propose SQL fixes |
| The Séance | DeepSeek v3.2 (deepseek.v3.2) via Amazon Bedrock |
Write spec and code patches |
| The Séance | Qwen3-235B | Check the patch before the PR opens |
| The Poltergeist | none | Fixes are derived directly from the difference |
Context7 at runtime
Before The Crypt's resolver proposes SQL, it fetches PostgreSQL documentation from Context7 and puts it in the prompt. If no docs come back, the rationale is marked confidence: LOW. In practice the users.age rationale cites PostgreSQL's implicit cast rules. Context7 also returns examples with USING and multi-column statements that the validator would reject, so the prompt tells the model to use the docs for syntax only. Context7 improves the proposal; the validator still decides.
Outbound HTTP and secrets
All outbound requests go through one SSRF guard (adapters/ssrf.py): private, loopback, link-local, CGNAT, multicast, reserved and IPv4-mapped IPv6 addresses are refused, redirects are not followed, and proxy environment variables are ignored. Evidence is redacted before it is stored, logged or shown to the LLM, using token matching so client_secret and privateKey are caught but monkey and author are not. Errors are stored as a code and a generated summary, never as raw exception text.
Stack
Python 3.12, FastAPI, psycopg 3, sqlglot (pinned), httpx, Hypothesis, Amazon Bedrock, Context7. One Dockerfile per app, three Render web services from one render.yaml. The demo API runs as a Vercel serverless function. Neon Postgres and Upstash Redis for the live systems.
How I used Kiro
I used Kiro IDE for the whole build. I did not use Kiro CLI, Web or Crew.
Spec-driven development
One spec in .kiro/specs/ covers the whole project: 43 requirements, a design document with the full 7-state × 8-event transition table (56 cells) and a mermaid state diagram, and 94 tasks (92 done; the 2 still open are the reserved SUPERSEDED state and keeping the apps live until judging ends). The requirements are grouped per adapter, so each app was built against its own block of requirements while sharing one design. When development changed the plan, such as dropping the freeze or replacing docker-compose with per-app Dockerfiles, I updated the spec to match instead of leaving it stale.
Compared with vibe coding: the spec gave every session the same starting point. Instead of re-explaining the operation matrix or the state machine in chat, I pointed Kiro at a requirement and a task, and the result could be checked against written acceptance criteria. coding was faster for UI tweaks, but for the validator and the state machine the spec stopped Kiro from inventing behaviour the design didn't allow.
Steering
Three steering docs in .kiro/steering/:
product.md: 13 non-negotiable principles and a list of what Touchstone refuses to do.tech.md: the stack, a forbidden list, the SQL operation matrix, the SSRF ranges and the redaction rules.kiro-features.md: how each Kiro feature is meant to be used.
The steering that made the biggest difference was writing the refusals first. "Destructive operations are structurally rejected, not by keyword", "no automatic database rollback" and "review-only resolutions have no proposed change" stopped Kiro from producing the easy wrong version of the validator many times. The closing line of product.md, "Does this require changing core/? If yes, the answer is no. Write an adapter.", kept new features out of the skeleton.
Agent hooks
Three hooks in .kiro/hooks/, all verified firing in Kiro IDE:
- new-adapter (on creating
adapters/**/comparator.py): scaffolds the app folder, config, test stub, README and renderer stub. It never touchescore/and never writes the adapter itself. - comparator-test (when the Kiro agent saves a comparator): runs that domain's comparator tests through a Python helper and logs the result to
.kiro/hook-runs.log(committed in the repo as evidence), e.g.tests/test_comparator_pg.py exit=0 10 passed. - demo-case-cache (on saving
fixtures/cases.json): checks, read-only, that every demo case yields a stable cache key.
Getting them to fire took work. The first trigger names I used (FileSave, FileCreate) never fired; the right ones are PostFileSave and PostFileCreate. On Windows the path matcher needs adapters[\\/].+[\\/]comparator\.py$. Command hooks receive {session_id, hook_event_name, cwd, file_path} as JSON on stdin, which is why the helper is a Python script and not a shell one-liner.
Custom agent: Validator Reviewer
.kiro/agents/validator-reviewer.md is an independent reviewer for proposed SQL, built and used in Kiro IDE. Input:
{ "difference_kind": "...", "difference_target": "...", "proposed_sql": "...", "old_type": null, "new_type": null }
It returns an approve/reject verdict with reasons. It is advisory only and runs in Kiro chat during development; no app calls it at runtime. When it disagrees with the deterministic validator, the disagreement shows up in chat and the validator still decides. I used it as a second opinion while building the validator, for example confirming that DROP TABLE users for a TABLE_EXTRA is rejected even when a human has authorized the apply.
MCP: Context7
Context7 (pinned at @upstash/[email protected], not @latest) was configured in Kiro during development for library docs on sqlglot, psycopg, FastAPI and httpx. The same service is used at runtime by The Crypt, as described above.
Property-based testing
tests/test_properties.py uses Hypothesis on the type normalizer, the SQL validator (positive and mutated SQL, executed against real Postgres), the state machine (all 56 cells, plus random event sequences that must never move BLOCKED or REVIEW_REQUIRED back to PENDING) and redaction.
It found two real bugs that the existing unit tests (13 for the SSRF guard alone) had missed:
- The SSRF guard let blocked ranges through. Hypothesis found
100.64.0.0(CGNAT, also as::ffff:100.64.0.0), then224.0.0.0(multicast), then192.0.0.9. The guard now checks the exact range list fromtech.mdplus a non-global check. - The CREATE INDEX validator was too loose. It compared columns after sorting, so
(b, a)passed for a difference on(a, b), and it accepted unnamed,USING hashandDESCindexes. All four are now rejected.
Kiro powers
None. Context7 was used as a plain MCP server, not as a power.
Challenges I ran into
- Hooks that silently did nothing. Wrong trigger names, a matcher that only worked with forward slashes, and hooks that load at session start and fire only on agent edits. Each looked like "the hook is broken" until I logged every run to a file.
- A sleeping service that never woke. The demo API first ran on Render's free tier next to the three apps. After 15 idle minutes it slept, and The Séance read it as three false "lost endpoint" ghosts while The Poltergeist got errors. A 120-second warmup didn't help. I added a wake check that reports why it failed, and it showed the cause: requests from the other Render apps got an immediate HTTP 502 (in 76 ms) and never woke the service, while a request from outside Render woke it in about 30 seconds. Render's docs say free services can't receive private-network traffic, which fits. I moved the demo API to Vercel as a serverless function; its code needed no changes because all state already lived in Neon and Upstash. I also fixed the bug the outage exposed: a path that times out, fails or answers 5xx is now recorded as not observed instead of a lost endpoint, and if nothing answers, Hunt Ghosts says the target API is unreachable.
- Keeping the skeleton honest. It is easy to let one
if domain == "database"slip into the orchestrator. The AST tests made that a build failure instead of a code-review argument. - Formatter conflicts on Windows. isort and black kept reformatting each other's output, and isort skipped five files on a Windows charmap error without failing. Fixed with
profile = "black"andPYTHONUTF8=1. - A CLI that looked fine but didn't run. Trying Touchstone on a new models file showed that the
touchstonecommand couldn't start (cli.pywasn't packaged) and thatcomparecrashed after a refactor changed the comparator's return type. No test covered the CLI. Both are fixed, andtests/test_cli.pynow covers it. - An external code review found a bypass. Batch apply, the path The Séance uses, never called the validator. It now runs the same checks as single apply, with regression tests. The same review showed The Séance marking a ghost resolved when it had only opened a PR; the evidence now says so plainly.
- Docs drifting from code. The steering docs still said
core/was about 600 lines and frozen after week 2; it is 1,301 lines and the freeze was dropped. I corrected the README, the steering docs and the architecture diagram instead of repeating the old claims.
Accomplishments I'm proud of
- Three working apps on one skeleton where the brief asks for two, all deployed, with a fourth domain proven in a test.
- Every database and cache fix is verified by re-reading the live system, and the report stores what was read, not a boolean. API fixes go through a pull request that a human merges.
- The safety boundary is a parsed-AST operation matrix, not a keyword blocklist, and property-based tests found and closed real holes in it.
- The Séance opens real pull requests on a real repo, one per file, and re-running does not duplicate them.
- 688 tests pass offline (12 skip without credentials) across 30 test files; with a freshly seeded Neon database, 699 pass and 1 skips.
Limitations
- No automatic database rollback. The report keeps the original state and the executed SQL for manual recovery.
- One user per app. Each app holds one orchestrator in memory.
- Postgres
publicschema only. - The Séance observes one response per endpoint, so it finds drift but cannot prove a contract correct. Its Exorcise runs live and is not cached.
models.pyis imported to read the declared schema, so the target repo must be trusted.- Context7 grounding is used for the database app only.
- The CLI scans databases only; API and cache scans run through the web apps.
- The three apps run on Render's free tier, so a cold load can take up to a minute.
- SUPERSEDED is reserved and not yet produced.
What I learned
About building safe tools around an LLM
- A deterministic validator next to an LLM is far easier to trust than a better prompt. The LLM can be wrong; the validator decides what runs.
- Property-based tests are best at the edges I didn't think to write down. The SSRF and index bugs were both in cases I assumed were covered.
- A skeleton stays generic only if something enforces it. Tests that read the source are cheap and catch what reviews miss.
About building with Kiro
- Steering works best as a list of refusals. Descriptions of what to build got me reasonable code. Rules like "destructive operations are structurally rejected, not by keyword" and "does this require changing core/? If yes, write an adapter" got me the right code, and kept giving it across many sessions without my repeating them.
- Steering is also where the exact numbers belong. Putting the SSRF CIDR list, the widening pairs and the redaction tokens in
tech.mdmeant the code, the unit tests and the property tests were all generated against the same source. That is how Hypothesis could catch the SSRF guard disagreeing with the documented ranges. - A spec is only useful if it stays true. Grouping requirements per adapter let each app be built against its own block. When the plan changed (the freeze, docker-compose), updating the spec and marking tasks superseded or deferred kept the task list an honest record of progress instead of a wish list.
- Hooks remove a step I would otherwise skip. Once
comparator-testfired on every comparator save, I got test results without asking for them. The lesson was to verify hooks before trusting them: log every run to a file, because a hook with a wrong trigger name fails silently. - Scaffolding hooks should stop at plumbing.
new-adaptercreates the app folder, config, test stub and renderer stub, and deliberately writes no adapter logic. That keeps the part that needs thought in my hands and the repetitive part out of them. - A custom agent is most useful with a narrow contract. The Validator Reviewer takes five fields and returns a verdict. Running it in its own context, without the resolver's reasoning, made it a real second opinion. Making it advisory meant I could use it freely without it ever becoming a second safety boundary to keep in sync.
- MCP improves quality, not safety. Context7 gave both Kiro and the runtime resolver current PostgreSQL docs, and the proposals got better. The same docs also contain
USINGclauses and multi-statement examples the validator rejects, which confirmed that grounding and enforcement have to be separate. Pinning the MCP package version instead of using@latestkept the development setup reproducible.
What's next for Touchstone
Stage 2: wider drift coverage. Nullability, default and constraint drift; the SUPERSEDED state; Context7 docs for API patches; MySQL and SQLite adapters.
Stage 3: CI and automation. A GitHub Action that runs Touchstone on every pull request, scheduled scans, and a replayable Contract Observer that works from recorded responses.
Stage 4: production use. Multi-user sessions, authenticated apply, a safer way to read declared models without executing them, and a persistent fix cache.
Originality and third-party code
Everything in both repos was written during the Submission Period (first commit 2 November 2026). No starter template or pre-existing project code was used. The project depends only on the open-source libraries in pyproject.toml and on these services, used under their own terms: Amazon Bedrock, Context7, Neon, Upstash, GitHub, Render and Vercel.
Built with
python · fastapi · postgresql · neon · redis · upstash · sqlglot · psycopg · httpx · hypothesis · amazon-bedrock · qwen · deepseek · context7 · mcp · kiro · render · vercel · docker · tailwind
Built With
- amazon-bedrock
- context7
- deepseek
- docker
- fastapi
- httpx
- hypothesis
- kiro
- mcp
- neon
- postgresql
- psycopg
- python
- qwen
- redis
- render
- sqlglot
- tailwind
- upstash
- vercel
