Skip to content

autofix: isolate orchestrator spawns from live sync#15

Merged
jschatz1 merged 5 commits into
mainfrom
fix/autofix-spawn-sync-isolation
Jun 29, 2026
Merged

autofix: isolate orchestrator spawns from live sync#15
jschatz1 merged 5 commits into
mainfrom
fix/autofix-spawn-sync-isolation

Conversation

@jschatz1

Copy link
Copy Markdown
Member

Problem

kai autofix PRs were contaminated with unrelated changes from other issues — e.g. an issue-12 (banner) PR also reverting/adding issue-8's repl.go streaming code.

Root cause (traced via lifecycle instrumentation)

Not the snapshot, the agent, or absorb — it's live sync. kai spawn --sync none set the registry SyncMode to none, but materializeFirst's kai ws checkout (step 6) → runWsCheckoutstartAutoSync unconditionally started the autosync daemon. That subscribed the ephemeral spawn to the repo's shared sync channel and pulled in edits from other kai sessions mid-run.

Proof, from the spawn's own .kai/autosync.log:

[kai-sync] subscribed: channel=ch_c70374… workspace="spawn-1"
[kai-sync] applied 6095 op(s) to repl.go from kai-cli:<peer>   ← another session's fix
Live sync running for workspace spawn-1 on https://atlas.kaicontext.com

Fix

When --sync none, write the autosync-off marker into the spawn's .kai right after kai init (before ws checkout can start the daemon). startAutoSync already honors it (the kai live off opt-out). --sync none now genuinely means no sync.

Also adopts kai-engine v0.1.1 (delta-based absorb — applies only the agent's diff vs the spawn's pre-agent baseline; defense-in-depth).

Validation

kai autofix --issue 12 (kaicontext/kai-tui): 1-file banner-only diff (was 4 files incl. repl.go); deterministic ✓ / semantic judge match ✓ / code review approved ✓.

Note: kit is unaffected (no autosync feature).

jschatz1 added 5 commits June 29, 2026 09:32
`kai spawn --sync none` set the spawn registry's SyncMode to none but did
NOT stop the autosync daemon: materializeFirst's `kai ws checkout` (step 6)
calls runWsCheckout, which unconditionally runs startAutoSync. That subscribed
the ephemeral spawn workspace to the repo's SHARED live-sync channel and
pulled in edits from OTHER kai sessions (peers) mid-run.

Impact: an autofix run for one issue had a *different* issue's fix synced into
its spawn (e.g. issue-8's repl.go streaming change, 6095 sync ops, landing in
an issue-12 banner spawn), so the PR carried unrelated/contaminating changes.
Confirmed via the spawn's .kai/autosync.log:
  [kai-sync] applied 6095 op(s) to repl.go from kai-cli:<peer>

Fix: when --sync none, write the autosync-off marker into the spawn's .kai
right after `kai init`, before `ws checkout` can start the daemon.
startAutoSync already honors this marker (the `kai live off` opt-out).
--sync none now genuinely means no sync.

Also adopts kai-engine v0.1.1 (delta-based absorb: applies only the agent's
diff vs the spawn's pre-agent baseline, defense-in-depth against any
spawn-vs-main drift / wholesale-delete).

Validated: `kai autofix --issue 12` now lands a single-file banner-only diff
(was 4 files incl. repl.go); all three gate signals green.
Fix #16: kai init should be idempotent
@jschatz1 jschatz1 merged commit c2e9079 into main Jun 29, 2026
10 checks passed
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