Skip to content

emrg: open-source task must never stash/reset host's uncommitted work — dirty tree runs read-only (rant 2026-08-20T11:58:27) - #881

Merged
argszero merged 1 commit into
masterfrom
feature/open-source-respect-dirty-tree
Aug 20, 2026
Merged

emrg: open-source task must never stash/reset host's uncommitted work — dirty tree runs read-only (rant 2026-08-20T11:58:27)#881
argszero merged 1 commit into
masterfrom
feature/open-source-respect-dirty-tree

Conversation

@argszero

Copy link
Copy Markdown
Owner

open-source task must never stash/reset the host's uncommitted work (rant 2026-08-20T11:58:27)

Bug (host data-loss report)

The open-source task type (emrg/server/open_source_prompt.md) ran on the host's live working directory (e.g. aitokenpool-opensource-task on the aitokenpool repo) and its §0.3 "Source sync" phase instructed agents to git stash the host's uncommitted local changes. This silently hid — and effectively lost — the host's live edits twice on 2026-08-20 11:15-11:20 (files reset to HEAD with no reflog trace). The host had to disable the task (~/.emrg/tasks.yml enabled: false) to protect their work.

Fix

  • §0.3 Source sync rewritten: a dirty working tree is now treated as NORMAL (the source dir is the host's working directory, not a dedicated clone):
    • Never run git stash / git checkout . / git restore . / git clean / git reset --hard or anything that hides/discards uncommitted changes
    • Never create branches / commit / push / open PRs while the tree is dirty
    • Dirty tree → the cycle runs read-only (scan / review / issue discussion / state-file update), records "dirty working tree — read-only cycle", and finishes without any git write
    • git pull --rebase only when the tree is clean; if dirty + behind → skip the pull
  • Error-handling table: git pull conflicts now use git rebase --abort (the tree was clean before the pull, so abort restores it) instead of stashing host work
  • Regression testtest_open_source_template_never_stashes_host_work asserts the rendered prompt contains the safety rules and no longer instructs git stash

Files

  • emrg/server/open_source_prompt.md — §0.3 + error-handling row
  • tests/test_scheduler.py — new regression test
  • Agent.md — test count 987 → 988 (doc-count guard)

Verification

  • uv run pytest tests/ -q987 passed, 1 skipped
  • import + CLI checks OK

… — dirty tree runs read-only (rant 2026-08-20T11:58:27)

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle (1/3)

Host data-loss fix (rant 2026-08-20T11:58:27): the open-source task's source-sync phase used to git stash the host's uncommitted work in the live working directory — silently losing edits (no reflog trace). Rewritten:

  • dirty working tree → read-only cycle (never stash/checkout ./restore ./reset --hard; no branch/commit/push/PR while dirty)
  • git pull --rebase gated on a clean tree; dirty + behind → skip
  • pull conflicts → git rebase --abort (tree was clean pre-pull) instead of stashing
  • regression test asserts the rendered prompt contains the safety rules

CI: test + test-windows PASS (32330596704). pytest 987 passed + 1 skipped locally.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle (2/3)

Fresh-cycle re-review of the full diff (head 25f4785, 3 files +58/−5):

  • open_source_prompt.md §0.3 rewritten: dirty working tree is now explicitly NORMAL (source dir = host's working dir, not a dedicated clone) → cycle runs read-only. Prohibitions cover stash/checkout ./restore ./clean/reset --hard; no branch/commit/push/PR while dirty. pull --rebase gated on clean tree; dirty+behind → skip.
  • Error-handling table: pull conflicts → git rebase --abort (tree was clean pre-pull, abort restores it) — never stashes host work.
  • Regression test test_open_source_template_never_stashes_host_work asserts the rendered prompt contains the safety rules and no longer instructs stash; Agent.md count synced (987→988) for the doc-count guard.

CI: test + test-windows PASS (32330596704). Local pytest 987 passed + 1 skipped.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle (3/3)

Fresh-cycle re-verification: head 25f4785 unchanged since 2/3; mergeState CLEAN; test + test-windows SUCCESS (32330596704). The safety fix is complete and correct — open-source task now treats the host's dirty working tree as normal and runs read-only instead of stashing/resetting host work. Merging.

@argszero
argszero merged commit 406973b into masterAug 20, 2026
2 checks passed
@argszero
argszero deleted the feature/open-source-respect-dirty-tree branch August 20, 2026 04:17
argszero added a commit that referenced this pull request Aug 20, 2026
#885)
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
Sign up for freeto 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

@argszero