Skip to content

fix(subagents): self-healing workspace staging — orphan sweep + self-gitignore - #161

Merged
jkyberneees merged 1 commit into
mainfrom
fix/staging-sweep
Aug 30, 2026
Merged

fix(subagents): self-healing workspace staging — orphan sweep + self-gitignore#161
jkyberneees merged 1 commit into
mainfrom
fix/staging-sweep

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Fixes a staging-hygiene gap in the M3 artifact channel (#160, v1.33.0).

Problem

The workspace staging root (.odek-artifacts/) had three hygiene gaps the ~/.odek janitor cannot see (it only knows the odek home):

  1. Crash/kill before relocation orphaned staging subtrees with content, indefinitely — the janitor sweeps ~/.odek/artifacts/, not user workspaces.
  2. The empty staging parent persisted after every artifact-bearing task.
  3. Staged deliverables were visible to the user's git — accidental commits of sub-agent output.

Fix — every artifact-bearing child run self-heals its workspace

  • Startup sweep: sibling staging subtrees older than 24 h (aligned with the janitor backstop) are removed at run start. The current task dir is never touched; fresh siblings may belong to in-flight parallel tasks in the same workspace.
  • Self-gitignore: the staging root carries .gitignore (* / !.gitignore), so staged content is invisible to git even when a run dies mid-write.
  • Tidy root: after relocation the root is re-created containing only the gitignore.

Normal-path behavior is unchanged (relocation already removed the task dir); this covers the abnormal paths it couldn't.

Verification

  • RED first: cmd/odek/subagent_staging_sweep_test.go — gitignore creation + idempotency, aged-vs-fresh sweep, current-task protection, missing-root no-op, post-relocation tidy.
  • Full cmd/odek suite: ok (darwin 72s · linux container 62s) · -race scoped: ok · golangci-lint: 0 issues

…gitignore

The workspace staging root (.odek-artifacts/) had three hygiene gaps the
~/.odek janitor cannot see (it only knows the odek home):

- crash/kill before relocation orphaned staging WITH content, forever
- the empty staging parent persisted after every artifact-bearing task
- staged deliverables were visible to the user's git (accidental
  commits of sub-agent output)

Every artifact-bearing child run now self-heals its workspace:

- startup sweep removes sibling staging subtrees older than 24h
  (aligned with the janitor backstop); the current task dir is never
  touched and fresh siblings may belong to in-flight parallel tasks
- ensureStagingRoot drops a self-gitignore (* / !.gitignore) so staged
  content is invisible to git even when a run dies mid-write
- after relocation the root is re-created tidy (gitignore only)

RED first: subagent_staging_sweep_test.go — gitignore creation +
idempotency, aged-vs-fresh sweep, missing-root no-op, post-relocation
tidy.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
odek 0a1a468 Commit Preview URL

Branch Preview URL
Aug 30 2026, 03:58 PM

@jkyberneees
jkyberneees merged commit b09e304 into main Aug 30, 2026
10 checks passed
@jkyberneees
jkyberneees deleted the fix/staging-sweep branch August 30, 2026 16:03
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