HackathonNovember 22, 2026 • 14 min read • By DevBuildTool Team

TimeWraith: Building a Kiro Crew That Hunts Time Bugs (and the Credit Budget I Got Wrong)

How TimeWraith combines a Kiro Crew, scoped MCP tools, a 13-zone Docker clock sweep, and eight verification gates to catch reproducible date and time bugs—plus honest lessons on credit budgets and over-constraining agents.

Editorial blueprint illustration of a mechanical clock dial frozen between 11:55 and midnight, intersected by 13 time-zone meridian arcs, a highlighted DST fall-back wedge, and subtle lantern and bat linework.
Advertisement

This post is written as part of Kiroween 2026, the Kiro hackathon hosted on Devpost, and is my entry for the Bonus Blog Prize. TimeWraith is entered in the Costume Contest category, with Frankenstein and Resurrection as supporting angles.

Most bugs are reproducible. Time bugs are not. They depend on the process time zone, the IANA database, the host clock, the test runner’s fake timers, and the exact instant you happen to execute the code. A test suite can stay green in UTC while quietly breaking in America/Los_Angeles during a fall-back night or looping forever in Australia/Lord_Howe.

TimeWraith is an autonomous regression investigator built for that gap. You hand it a public GitHub repository and a ref. A crew of Kiro agents finds time-sensitive code, designs clock experiments, sweeps them inside isolated Docker containers, and reports only the bugs it can reproduce cleanly. A proposed patch is called “verified” only after it passes eight deterministic gates on a fresh checkout. You can watch the demo walkthrough on YouTube or jump straight into the architecture below.

The short version

  • The core rule: the agent proposes, plain code referees. Agents suggest suspects, adapters, verdicts, and patches; deterministic code re-runs the evidence and decides what counts.
  • What actually worked: four finished cases ship inside the container image—three reached fixed version verified (rrule, cron-parser, and node-cron), and a date-fns run ended honestly as inconclusive instead of pretending to be clean.
  • How Kiro fits in: Kiro Crew is the runtime (agents inside a locked-down container talking over scoped MCP tools), and Kiro specs, steering, hooks, and skills built the project.
  • Mistake #1 (budget): I spent roughly 1,800 of my 4,000 Kiroween credits on the frontend—including a full redesign—leaving roughly 2,200 for the backend and for testing an agentic app that spends credits every time it runs.
  • Mistake #2 (generality): I over-restricted the agents and built per-language harnesses for safety. That made the sandbox strong, but left TimeWraith as a focused JS/TS (Jest/Vitest) investigator with a partial Python path rather than a universal bug finder.

Why time is the worst input

Date and time logic fails in ways that look harmless in code review:

  • Ambiguous fall-back hours: when daylight saving time ends, the same local wall-clock time occurs twice. Calling a setter like setMilliseconds can re-resolve the ambiguous local hour to the earlier UTC offset.
  • Fractional DST shifts: Australia/Lord_Howe shifts by 30 minutes rather than a full hour. Stepping logic that assumes whole-hour transitions can stall or loop until it throws.
  • Time-traveling schedules: a next() calculation near a transition can return an instant before now, sending a scheduler backward or into an infinite loop.
  • Zone-leaking instants: an instant that should be independent of where a server runs can silently shift with the process TZ environment variable.

Catching these requires controlling the clock, the process zone, and the calendar simultaneously across clean runs.

Backend design: isolation boundaries first

Because TimeWraith clones and runs code from arbitrary public repositories, the backend is built around four distinct trust boundaries rather than trusting prompt instructions to keep agents in line.

TimeWraith backend architecture showing the four isolated containers: the FastAPI backend, the locked-down Kiro Crew container communicating over a token-gated MCP proxy, throwaway no-network Docker sandboxes, and a separate GitHub container for credentials.

  1. TimeWraith Backend (timewraith, FastAPI + SQLite on 127.0.0.1:8787): owns the case workspaces, the SQLite database, the pipeline orchestrator (pipeline.py), the token-gated tool server (/api/v1/internal/fix-tools/*), and the append-only DecisionRecord audit log.
  2. Kiro Crew Container (timewraith-crew, ghcr.io/kirodotdev/kirocrew:stable): runs kiro-cli with --cap-drop ALL, no-new-privileges, a 2 GB memory cap, a 256-process limit, and no repository or workspace mounted.
  3. Throwaway Docker Sandboxes (sandbox.py): every sweep, probe, and test executes in a fresh container with all capabilities dropped, a read-only root filesystem, no Docker socket, and no network. Network access is enabled only during dependency installation—and before npm/pnpm/yarn runs, the backend moves TimeWraith’s own __tw__/ and .tw/ folders out of the workspace so repository install scripts never see generated files.
  4. GitHub Container (timewraith-git): isolates gh credentials in its own volume. The backend passes only a validated patch and branch name after explicit user approval; Kiro agents never see the GitHub token.

The MCP seam and untrusted data

When an agent needs tools—for adapter repair, violation verification, install repair, or bug fixing—it connects through backend/agents/tw_mcp_proxy.py, a small standard-library stdio MCP server running inside the Crew container. The proxy holds no repository access and no business logic; it forwards every call over HTTP with a short-lived X-TW-Session token bound to that single attempt.

Every tool session enforces hard walls:

  • Path guards: reads see only git-tracked files plus the generated regression test and adapter; path traversal is rejected.
  • Protected files: edits refuse tests, test configs, package.json, lockfiles, CI workflows, and TimeWraith’s generated folders while preserving original line endings (CRLF/LF).
  • Session budgets: each tool session enforces a wall-clock deadline and call budget (currently 100 tool calls for fix, design, and verification sessions, and 400 calls / 300 commands per round for install repair). Once exhausted, every tool except the final submission tool refuses.
  • Untrusted repository framing: every repository snippet sent in a prompt is wrapped in <data-<random-hex>>...</data-<random-hex>> after stripping any matching tag from the source, preventing repository content from closing the data block and hijacking agent instructions.

The investigation flow: agent proposes, code referees

One rule shaped every module in backend/src/timewraith/: the agent proposes, code decides. Every agent decision is recorded as a DecisionRecord—storing the claim, the citations that resolved against real files, how many invented citations were dropped, the checks that ran, and the deterministic rule that accepted or rejected it (GET /api/v1/investigations/{id}/decisions).

End-to-end TimeWraith investigation pipeline across six stages—Repository, Discovery, Design, Execution, Verification, and Fix & 8 Gates—distinguishing Kiro agent proposals from deterministic code referees, plus the Wraith Director coverage-ledger feedback loop.

Here is how a case moves through the six stages:

  1. Repository (Code): ingest.py and analyze.py clone the pinned commit with hardened Git flags (hooks, submodules, LFS, and symlinks disabled) and build a capability report detailing the language, package manager, test runner, lockfile, and fake-timer usage.
  2. Discovery (Bat Scout → Code): a static scanner flags clock reads, date math, and time-zone code. Bat Scout keeps up to 15 candidates worth testing (and can inspect source files for additional leads), citing concrete signals and lines. Code drops any citation it cannot resolve.
  3. Design (Pumpkin Mechanic → Code): Pumpkin writes a lightweight adapter per candidate—defining how to call the target API, which output fields (date, instant, flag, next, expiry_trace, clock_jumps, etc.) to return, and which invariants apply. After dependency installation, code runs a baseline check at ordinary mid-day instants in UTC and America/New_York. Adapters that fail baseline enter Pumpkin’s tool-backed repair workshop (designsession.py, 8 minutes) rather than polluting the sweep.
  4. Execution (Code, No-Network Docker): sweep.py sweeps roughly 2,600 clock points per experiment across 13 IANA zones—covering 2024–2026 DST transitions (±1 ms to ±1 h), month ends, leap day, and anchors, including tricky zones like Australia/Lord_Howe (30-minute DST), Asia/Kathmandu (+05:45), Pacific/Kiritimati (UTC+14), and Pacific/Pago_Pago (UTC-11). Fixed code oracles decide pass/fail—never the LLM.
  5. Verification (Code → Raven Archivist → Code): selected violations must repeat 3/3 in clean containers before an agent ever sees them. Code first searches the repository’s own tests and docs (intent.py) for passages mentioning the target code and transition type. Raven Archivist then opens a read-only probe session (verifysession.py, 10 minutes) to run live probes, execute repo tests, search public issues, and submit a verdict (defect, intended_behavior, allowed_exception, or adapter_error).
    • A defect counts only if code re-runs Raven’s reproduction and public-API user check (failing 3/3 at the failing instant, passing at a control instant) and generates a regression test that fails with an assertion on the original commit.
    • intended_behavior counts only if a cited repository test passes on the original commit or the cited doc line actually exists—and is listed separately rather than reported as a bug.
  6. Follow-up Planning (Wraith Director): after the first sweep and verification, code builds a coverage ledger summarizing what was tested, which rules broke, and which clock situations remain uncovered. Wraith Director proposes up to 3 new experiment intents per round (up to 2 rounds) while time and agent budgets allow.

Fixed invariant oracles

Because pass/fail judgment lives in sweep.py rather than a prompt, regression tests are generated directly from the violated rule:

Invariant Output field Rule checked by code
well_formed (always) Returns without throwing; no NaN or Invalid Date
deterministic (always) Same instant and zone return identical output
local_date_matches date Local YYYY-MM-DD matches the process time zone
instant_zone_independent instant Same instant regardless of process TZ (dropped if adapter passes ctx.tz)
flag_monotonic flag Changes at most once as time moves forward
next_after_now next Next run is strictly after now, never moves backward
expiry_deadline expiry_trace Valid 1 ms before deadline, expired 1 ms after
elapsed_clock_jump clock_jumps Relative timer preserves elapsed delay across a ±1 h wall-clock jump

The eight fix gates

When a bug is reproduced, Doctor Stitch gets up to three attempts (fixsession.py, 12 minutes per attempt) using TimeWraith’s scoped tools: list_files, read_file, search, replace, replace_lines, show_diff, run_regression_test, check_all_zones, run_tests, and submit.

Submitting does not make a fix verified. The backend extracts git diff, resets the workspace, applies the diff with git apply onto a fresh clean copy of the pinned commit, and runs eight gates in order from cheapest to most expensive. The first failure stops the attempt and feeds the failing gate detail and previous diff into the next attempt.

Diagram of TimeWraith’s eight sequential fix gates on a fresh clean commit—test_first, diff_limits, fixed, mutation_check, no_regressions, no_new_anomalies, static_checks, and blind independent_review by Raven Archivist—leading to a verified fix or retry feedback loop.

  1. test_first: the original violation repeated 3/3 and the generated regression test failed on the unmodified code.
  2. diff_limits: at most 3 files and 60 changed lines (git apply --numstat), with zero protected files touched.
  3. fixed: the regression test passes 3/3 and the full 13-zone sweep shows the invariant now holds everywhere.
  4. mutation_check: reverting only the source edit makes the regression test fail again (proving the test actually exercises the patch).
  5. no_regressions: the repository’s full test suite has no new failures.
  6. no_new_anomalies: none of the case’s other experiments show a violation they did not show before.
  7. static_checks: the repository’s tsc and ESLint checks do not newly fail.
  8. independent_review: Raven Archivist reviews the diff and regression test blind, without ever seeing Doctor Stitch’s explanation or reasoning.

Only when all eight pass does a fix become verified. From there, accepting the fix creates a local branch and downloadable .patch file. Before anything can be pushed to a fork, contribute.py checks the target repository’s CONTRIBUTING rules, PR template, commitlint config, and upstream tip—moving the test into the repository’s own test directory and refusing to open a duplicate PR silently.

What TimeWraith found, honestly

The shipped Docker image includes four completed cases—three that reached fixed version verified and one that stopped honestly as inconclusive. TimeWraith found each behaviour independently and then matched it against public issue/PR evidence; I am not claiming these bugs were unknown to maintainers or that any fix has been merged upstream.

Repository Bug reproduced by TimeWraith Where it triggers Upstream status
jkbrzt/rrule Default dtstart resolves one hour early during the repeated DST hour because setMilliseconds re-resolves the ambiguous local time to the earlier offset (src/parseoptions.ts:43) America/Los_Angeles, 2026-11-01T09:00Z PR #679 open (not merged)
harrisiirak/cron-parser addHour stalls at the Lord Howe 30-minute DST fall-back, causing an hourly expression to repeat the same instant or hit LOOP_LIMIT (src/CronDate.ts:145) Australia/Lord_Howe, 2024-04-06T14:00Z PR #483 closed as duplicate of another author’s PR #453
kelektiv/node-cron getNextDateFrom returns an instant before start inside a repeated DST hour when the system clock is prior to the transition (src/time.ts:330, :363) America/Los_Angeles, 2027-04-03T15:00Z No upstream PR
date-fns/date-fns No bug claimed; three candidates required Temporal, which the Node 22 environment lacked Marked inconclusive with reasons Not applicable

The cron-parser PR taught me something important. The maintainer closed PR #483 for fair reasons: it duplicated an open PR (#453) and placed the regression test out of tree rather than in the repository’s test layout. TimeWraith had learned how to reproduce and fix a bug before it had learned contribution etiquette. That feedback directly led to contribute.py—checking upstream rules, commit conventions, and test placement before anything is pushed—and to adding a Temporal polyfill path outside the repo for environments like date-fns.

How Kiro built and runs TimeWraith

Kiro plays two distinct roles in this project: Kiro Crew is the product’s agent runtime, and Kiro’s specs, steering, hooks, and skills drove the build workflow.

  • Specs (.kiro/specs/): separate requirements.md, design.md, and tasks.md trees for the frontend (timewraith/) and engine (backend/). Auditing tasks.md against the code after two interrupted sessions caught an unbuilt Version Timeline component and led to a property test that uncovered a DOM ID leak in Case Cards (fixed with useId).
  • Steering (.kiro/steering/): three focused files that stop you from re-explaining constraints every session:
    • product.md (always on): enshrines “agent proposes, code referees,” frozen scope, and a blunt credit rule—test with fakes in backend/tests, not live cases.
    • backend.md (backend/**/*.py): module map and an exact checklist for adding a new invariant without drifting schemas or frontend labels.
    • windows-shell.md (always on): shell habits for Windows (PowerShell quoting traps, preserving CRLF, avoiding root docker exec).
  • Hooks (.kiro/hooks/): backend-ruff-on-save runs ruff check and ruff format --check on every saved backend Python file. Additional documented hooks cover style-guard checks, ESLint/TypeScript verification, Reduce Motion coverage, and a debug hook used to capture Kiro’s actual STDIN hook JSON schema (scripts/hooks/read-event.mjs).
  • Skills (.kiro/skills/): four reusable workspace skills—generate-mascot-asset, add-motion-effect, run-landing-qa, and write-kiro-usage-readme (a skill specifically designed to audit documentation against real repo files so submission claims stay honest).
  • MCP: tw_mcp_proxy.py is the security seam itself. Because agent profiles strip built-in shell, file, and web tools, safety is enforced by the proxy and backend rather than hoped for in prompts.

Where the credit budget went

Kiroween 2026 grants participants 4,000 free Kiro credits. I started with the ambitious goal of finding time bugs in any project in any language. That plan did not survive contact with an agentic credit budget: every live investigation spends credits across discovery, design, verification, and fix attempts—in the seeded runs, a single investigation took 18 to 30 agent calls even when it found nothing.

The frontend detour (~1,800 credits)

Roughly 1,800 of my 4,000 credits went into the frontend, including a complete redesign after the first attempt missed the mark.

Part of the problem was trying to ask coding models to act like image generators. The models I had available in Kiro at the time could write React, CSS, and SVG, not generate raster illustration parts—leaving early prototypes with placeholder vector figures and stiff whole-figure tweens.

What finally unlocked the Violet Midnight interface was flipping the workflow:

  1. Design the motion choreography first (what moves, when it settles, and its Reduce Motion fallback).
  2. Sketch rough parts and generate separate raster assets (body, wings, lantern arm, clock hands) via a dedicated image pipeline (tools/art/ + the generate-mascot-asset skill).
  3. Wire those parts back into React with strict style-guard rules (pnpm --dir frontend guard:style) that ban glass blur, blurred shadows, neon gradients, and stray color literals outside tokens.css.

That produced the midnight clock intro (ticking 11:55 to 12:00 with a 245-bat perspective swarm), the cursor-reactive Lantern Wraith, and the Crew awakening eye—all with Reduce Motion equivalents. Looking back, though, spending nearly half the grant on the costume before finishing the engine was backwards: the frontend is what judges see first, but the backend decides whether the tool is real.

The backend trade-off: safety before generality (~2,200 credits)

With roughly 2,200 credits left for the backend and live testing, I leaned hard into safety. Locking down the Docker sandbox and Crew container was the right decision. Where I over-corrected was restricting the agent tool surface too early and writing bespoke per-language harnesses instead of a smaller set of general primitives refereed by code.

As a result, JavaScript/TypeScript projects using Jest or Vitest at the root package work end to end, Python has a partial worker path, and other ecosystems are unsupported. Safety belonged in the sandbox and output referees, not in making the agent’s toolkit overly narrow.

What works, what does not, and what I would change

Works today:

  • End-to-end JS/TS investigations with Jest or Vitest at the repository root.
  • Deterministic 13-zone sweeps across 2024–2026 DST boundaries, month ends, and leap day.
  • Independent 3/3 clean-container verification, generated regression tests, eight fix gates, and an optional GitHub PR workflow.
  • Honest terminal states: no bugs, intended behaviour, inconclusive, agents stopped, and no safe fix are all distinct outcomes.

Current limits:

  • Focused time-bug investigator, not a general-purpose bug finder.
  • Partial Python support; other languages are not supported yet.
  • Does not control browser or remote server clocks, and sweeps a fixed clock schedule without adaptive shrinking.
  • Intent search uses plain-text matching over repo tests and docs.

What I would do differently next time:

  1. Budget credits by phase: cap the UI early and reserve most of the budget for the core loop and live agent runs.
  2. Build the thinnest end-to-end loop before the costume: one repo, one adapter, one clock point, one verdict first.
  3. Use the right tool for raster art: design motion first, generate modular parts outside the coding model, then integrate.
  4. Write steering and hooks before code: they are the cheapest way to enforce architecture rules and prevent credit burn.
  5. Keep safety in the sandbox and referees, not rigid tool scripts: keep containers strict while letting agents adapt to unfamiliar project layouts.
  6. Test contribution etiquette on a fork first: test placement, commit style, and duplicate-PR detection are part of the product.

Try it locally

If you have Docker Desktop 4.29+ or Docker Engine 26+, you can run TimeWraith with one command—no cloning required:

docker run -d --name timewraith --restart unless-stopped -p 127.0.0.1:8787:8787 \
  --label com.docker.compose.project=timewraith \
  --label com.docker.compose.service=app \
  -v timewraith-data:/data \
  -v /var/run/docker.sock:/var/run/docker.sock \
  ghcr.io/tumblerwarren/timewraith-kiroween:latest

Open http://localhost:8787 to inspect all four shipped cases (rrule, cron-parser, node-cron, and date-fns) without signing in or spending credits. To launch a live hunt, sign in with your Kiro account once from the Crew page.

TimeWraith is intentionally narrow and stubborn. The hard part of building an agentic developer tool is not getting a model to produce an impressive patch once—it is building the referees that decide what counts, and teaching the system to say “inconclusive” when the evidence is not there.

Sponsored Content