5. Autonomous AI Program Manager

5.5 Flight Deck, Shadow-KV Forking & Trajectory Time-Travel

chinwag ui --desktop && chinwag fork-run --step 42

Branch failed agent runs in 0ms with 0 replayed tokens via chinwag fork-run and Shadow-KV (250 Credits), pinpoint exact trajectory divergence with Weighted-LCS chinwag diff-run, and freeze failures into <50ms offline CI cassettes with chinwag tombstone --emit-test.

5.5 Flight Deck, Shadow-KV Forking & Trajectory Time-Travel

chinwag ui --desktop && chinwag fork-run --step 42

Outcome Summary & Δ Velocity Proof: Chinwag Flight Deck records every LLM call, tool invocation, simulated clock tick, UUID, and Shadow-KV prefix digest into a content-addressed flight tape anchored in your organization's 3-Repo Chinwag Cryptographic Time Machine (<org>/chinwag-bus.git, <org>/<project>.git, <org>/chinwag-config.git). Branch any run at Step N in 0 ms with $0 in replayed LLM tokens (chinwag fork-run · 250 Credits, half the 500 Credits of re-running 10 fresh steps), align and diff two trajectories with Weighted-LCS (chinwag diff-run), and turn every caught mistake into a <50 ms, $0 offline CI regression cassette (chinwag tombstone --emit-test & chinwag-ci test-regressions).


1. chinwag fork-run Paired With Shadow-KV (0 ms, 0 Replayed Tokens · 250 Credits)

When an agent takes a suboptimal turn at Step 11 of a 15-step task, re-running from scratch wastes minutes of wall-clock time, consumes 500 Credits (10 fresh steps × 50 Credits), and re-bills every prefix token. Each warm Shadow-KV fork (250 Credits · same model or cross-model) saves ~450,000 to 800,000 re-read tokens ($4.50 to $12.00 in frontier LLM API spend) and 4 minutes of wall-clock tool replay compared to a cold start.

chinwag fork-run <run-id> --at-step <N> --variant <agent> eliminates prefix re-execution completely:

# Replay Steps 0..10 from the flight tape in 0ms with $0 in replayed LLM tokens,
# pre-warm the Shadow-KV prefix cache at Step 10, and branch Step 11+ live (250 Credits):
chinwag fork-run run_01J9X8A2 --at-step 11 --variant Reflex-1 --json

How chinwag fork-run + Shadow-KV Works Under the Hood

  1. RFC 8785 JCS SHA-256 Tape Verification (0 ms, $0): Replays Steps 0..N-1 directly from <org>/chinwag-bus.git (refs/chinwag/runs/<run_id>/steps/<step_index>), verifying each step's RFC 8785 Canonical JSON SHA-256 request digest (request_jcs_sha256), deterministic clock (simulated_clock_ms), and virtual UUID (simulated_uuid) with zero live LLM or tool calls.
  2. Zero-Copy Encrypted Worktree Fork (repo.fork(...)): The Chinwag Encrypted Artifact Store spawns an instant zero-copy repository <org>/<project>--fork-<run_id>--step-<N>.git (and branches refs/chinwag/forks/<fork_run_id>/worktree from refs/chinwag/time-machine/<run_id>/step-<N>) pinned to the exact project_worktree_oid at Step N-1, issuing a 10-minute scoped art_v1_<TOKEN> write token so parallel variants never collide on HEAD.
  3. Warm Shadow-KV Prefix Handoff & 1-Click Ticket Teleportation (chinwag teleport ENG-402 --at-step 8): Restores the Shadow-KV KV-cache prefix pointer (refs/chinwag/shadow-kv/<prefix_hash> or refs/chinwag/tasks/ENG-402/shadow-kv) at Step N-1 and branches Step N+ live to Reflex-1, Builder, or a human engineer in <300 ms:
# 1-Click Ticket Teleportation: hand off Linear ticket ENG-402 at Step 8 (<300ms)
# with exact project_worktree_oid, warm Shadow-KV, and a 10-minute art_v1_ token:
chinwag teleport ENG-402 --at-step 8

2. Weighted-LCS Trajectory Diff (chinwag diff-run <runA> <runB>) in Chinwag Flight Deck

When comparing two agent runs, such as a parallel Triad race (Builder vs. Reflex-1) or a passing baseline run vs. a failing regression, naive line-by-line log diffs collapse as soon as one agent inserts an extra tool call.

chinwag diff-run <runA> <runB> aligns both trajectories using Weighted Longest Common Subsequence (LCS) with fixed forward-walk tie-breaking:

# Align two runs across the Chinwag Encrypted Artifact Store step chains and pinpoint the exact first divergence:
chinwag diff-run run_builder_108 run_reflex1_108 --json

Example Output

{
  "run_a_steps": 12,
  "run_b_steps": 11,
  "weighted_lcs_score": 31,
  "shared_shadow_kv_steps": 7,
  "first_divergence": "step 7 tool: changed at $.tool_args.isolation_mode, $.worktree_oid",
  "tokens_in_delta": -4820,
  "tokens_out_delta": -610,
  "cost_micro_usd_delta": -19400
}

What chinwag diff-run Compares at Every Step

  • LLM & Tool JSONPaths ($.path): Recursive RFC 8785 JCS structural diff across prompt messages, tool arguments, and structured outputs.
  • Code Worktree Trees (project_worktree_oid): Exact Git tree OIDs in <org>/<project>.git (refs/chinwag/time-machine/<run_id>/step-<k>).
  • Governance Policy Commits (config_commit_sha): Exact policy revision in <org>/chinwag-config.git.
  • Economics & Shadow-KV Reuse: Computes tokens_in_delta, tokens_out_delta, cost_micro_usd_delta, and shared_shadow_kv_steps.

3. chinwag tombstone --emit-test & chinwag-ci test-regressions (<50 ms, $0 Offline CI Gate)

Every time a human engineer or Chinwag Vision-3 / Chinwag Reflex-1 catches an agent mistake and records a negative-memory Tombstone, --emit-test turns that failure into a permanent, deterministic offline CI regression test:

# 1. Record a Tombstone and emit a deterministic regression cassette:
chinwag memory tombstone \
  --id "tombstone-jwt-alg-none-v1" \
  --file-scope "src/auth/**" \
  --reason "Agent accepted unverified alg:none JWT header during OIDC token verification" \
  --alternative "Always enforce ed25519_dalek::verify_strict or JWKS RS256 verification" \
  --from-run run_01J9X8A2 \
  --at-step 7 \
  --emit-test

# 2. Run all Tombstone regression cassettes locally or in CI (<50ms, $0 LLM spend, 0 network calls):
chinwag-ci test-regressions --dir .chinwag/regressions --json

How Offline Tombstone Cassettes Work

  1. Deterministic Cassette Snapshot (.chinwag/regressions/<tombstone-id>.json): Freezes the prefix steps 0..k (ctx.llm, ctx.tool, ctx.clock, ctx.uuid), project_worktree_oid, config_commit_sha, and assertions (JsonPathEquals, MaxToolCalls, ForbiddenPattern, MustMatchPrefixHash).
  2. Encrypted Time-Machine Sync (refs/chinwag/regressions/<tombstone_id>): Anchors the cassette in <org>/chinwag-bus.git so chinwag-ci runners in GitHub Actions and GitLab CI can inspect and execute all cassettes at the edge or in the runner in <50 ms with $0 LLM spend and 0 network calls.