Skip to content

fix: report unavailable Git containment proofs during teardown - #7915

Merged
kunchenguid merged 5 commits into
kunchenguid:mainfrom
WTF-Am-ID:fm/up-fm-4216
Oct 28, 2026
Merged

kunchenguid merged 5 commits into
kunchenguid:mainfrom
WTF-Am-ID:fm/up-fm-4216

Conversation

@WTF-Am-ID

@WTF-Am-ID WTF-Am-ID commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4216

Review was single-family (Codex) by the owner's temporary choice.

Intent

ok same instructions i gave you before pick high value issues from scan, in all the repos you scanning and use codex only to close them

Context: this task is scan pick P12: upstream issue #4216 in kunchenguid/firstmate. Old Git lacking merge-tree --write-tree is reported as unlanded content rather than an unavailable proof. Triage contract class: restore. Scan notes for this pick:
Issue: #4216

Old Git lacking merge-tree --write-tree is reported as unlanded content rather than an unavailable proof.
Correct the diagnostic while preserving the safe refusal.
Size S.
Contract class: restore.
Maintainer triage.

Evidence: bin/fm-teardown.sh:1762 suppresses merge-tree failure stderr and returns 1 without classifying a missing capability.

Competing work: #4218 explicitly says this issue is separate and not addressed. That exact reference is not a claim. The forge-agnostic fallback at #891 does not supply the missing-capability diagnostic or bootstrap reporting. No covering target found.

Closure test: A fake Git capability boundary models old Git rejecting --write-tree, modern Git proving containment, genuine merge conflict and unrelated Git failure. Missing capability must name the unavailable proof and remain fail closed, while successful containment and genuine unlanded-work refusals retain their semantics. If a bootstrap floor is added, keep the existing install-consent path and test it separately. Do not skip away supported coverage to make the suite green.
The owner approved fixing the scan's high-value picks upstream through PRs, written and reviewed by Codex only.

What Changed

  • Report rejected git merge-tree --write-tree options and other execution failures as an unavailable content-landed proof, while continuing to refuse teardown. Name the Git 2.38 requirement for rejected options and the exit status for other failures.
  • Add teardown regression cases for unsupported Git, successful containment, merge conflicts, unlanded content, and unrelated Git failures, including state preservation on refusal.

Risk Assessment

✅ Low: The change distinguishes unavailable merge-tree proof from unlanded content while preserving safe refusal and existing containment behavior.

Testing

Reproduced the baseline misdiagnostic using actual Git 2.37.7 and passed six isolated live teardown probes, retaining CLI transcripts and the driver. No suite or lint ran; the focused-helper attempt was guard-blocked. Private runtime cleanup succeeded, but deletion of approximately 103 MB in .live-4216-test-current/ was refused and not retried.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Teardown with Git 2.37.7 reports an unavailable proof and preserves work ✅ pass live old-git-baseline.log; old-git-live.log
Teardown with an injected unsupported-option error names the required capability and refuses safely ✅ pass live unsupported-129-live.log
Teardown with modern Git proving containment returns the real Treehouse slot and removes task records and window ✅ pass live contained-live.log
Teardown encountering a real merge conflict retains the unlanded-work refusal and preserves work ✅ pass live conflict-live.log
Teardown of genuinely unlanded content refuses without claiming the proof is unavailable ✅ pass live unlanded-live.log
Teardown with an injected unrelated Git failure reports its exit status and preserves work ✅ pass live error-live.log
Evidence: Old Git baseline reproduction

Source: Old Git baseline reproduction

BASELINE exit=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 3s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
REFUSED: worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/old-git/pool/.treehouse/project-1d53eb/1/project has work not on any remote and not landed.
unpushed commits:
ef7488b task work
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.
Evidence: Actual Git 2.37.7 refusal

Source: Actual Git 2.37.7 refusal

Scenario: old-git
Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Git: git version 2.37.7
Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh task-old-git
Direct merge-tree probe exit=128
fatal: unknown rev --write-tree

Teardown exit=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
WARNING: watcher still down (same stale episode; last beat: 8s ago, grace 300s) - full banner already printed this episode.
REFUSED: content-landed proof unavailable for worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/old-git/pool/.treehouse/project-1d53eb/1/project: git merge-tree --write-tree failed (Git exit 128).
Restore or upgrade Git and retry the content check.
unpushed commits:
ef7488b task work
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.

Observed preservation: HEAD=ef7488b3c42f3803990082e42360225254300bec, branch=fm/task-old-git, worktree bytes, metadata, status and real tmux task window unchanged. Treehouse return never invoked.
Evidence: Unsupported-option refusal

Source: Unsupported-option refusal

Scenario: unsupported-129
Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Git: git version 2.56.0
Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh task-unsupported-129
Direct merge-tree probe exit=0
e82f70d73bc81151eaac70fe628aed4881733b04

Teardown exit=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
WARNING: watcher still down (same stale episode; last beat: 3s ago, grace 300s) - full banner already printed this episode.
REFUSED: content-landed proof unavailable for worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/unsupported-129/pool/.treehouse/project-97787e/1/project: git merge-tree --write-tree was rejected (Git 2.38 or newer required).
Restore or upgrade Git and retry the content check.
unpushed commits:
478234c task work
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.

Observed preservation: HEAD=478234ce89268bf9bf63742d92b3fd01ca66f93d, branch=fm/task-unsupported-129, worktree bytes, metadata, status and real tmux task window unchanged. Treehouse return never invoked.
Evidence: Successful containment cleanup

Source: Successful containment cleanup

Scenario: contained
Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Git: git version 2.56.0
Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh task-contained
Direct merge-tree probe exit=0
e82f70d73bc81151eaac70fe628aed4881733b04

Teardown exit=0
🌳 Worktree returned to pool.
~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/contained/project: already current
teardown task-contained complete (window primary:fm-task-contained, worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/contained/pool/.treehouse/project-268007/1/project)
Backlog: task-contained just finished (config/backlog-backend selects manual editing). Update ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab/data/backlog.md - move task-contained to Done, keep Done to the 10 most recent, then re-scan Queued and dispatch only work whose blockers are gone and date is due.
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
WARNING: watcher still down (same stale episode; last beat: 2s ago, grace 300s) - full banner already printed this episode.
teardown: reaping leaked worktree process(es) for task-contained: 66281
WARNING: watcher still down (same stale episode; last beat: 15s ago, grace 300s) - full banner already printed this episode.

Observed: real Treehouse return ran, task metadata/status removed, task window closed.
Evidence: Real merge conflict refusal

Source: Real merge conflict refusal

Scenario: conflict
Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Git: git version 2.56.0
Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh task-conflict
Direct merge-tree probe exit=1
4d18b583fe2abc76f0c402fb4bd62d7836babe1b
100644 180b47c18ba7e484fc0d7350bc6cad8ec3423ea0 1	feature.txt
100644 9d73fc989a0275fec500dd402e13e46c90674e15 2	feature.txt
100644 9301c2c31c62520765f8e0ce9beec62a0b5187a9 3	feature.txt

Auto-merging feature.txt
CONFLICT (content): Merge conflict in feature.txt

Teardown exit=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
WARNING: watcher still down (same stale episode; last beat: 3s ago, grace 300s) - full banner already printed this episode.
REFUSED: worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/conflict/pool/.treehouse/project-2f892c/1/project has work not on any remote and not landed.
unpushed commits:
87b97de task work
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.

Observed preservation: HEAD=87b97dee11a614fd29d778d5638533d1c79922bc, branch=fm/task-conflict, worktree bytes, metadata, status and real tmux task window unchanged. Treehouse return never invoked.
Evidence: Unlanded content refusal

Source: Unlanded content refusal

Scenario: unlanded
Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Git: git version 2.56.0
Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh task-unlanded
Direct merge-tree probe exit=0
e82f70d73bc81151eaac70fe628aed4881733b04

Teardown exit=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
WARNING: watcher still down (same stale episode; last beat: 2s ago, grace 300s) - full banner already printed this episode.
REFUSED: worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/unlanded/pool/.treehouse/project-9c3021/1/project has work not on any remote and not landed.
unpushed commits:
af4b10b task work
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.

Observed preservation: HEAD=af4b10bb4f84ea52ced9788086cccde0a370d6d2, branch=fm/task-unlanded, worktree bytes, metadata, status and real tmux task window unchanged. Treehouse return never invoked.
Evidence: Unrelated Git failure refusal

Source: Unrelated Git failure refusal

Scenario: error
Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Git: git version 2.56.0
Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh task-error
Direct merge-tree probe exit=0
e82f70d73bc81151eaac70fe628aed4881733b04

Teardown exit=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/lab
WARNING: watcher still down (same stale episode; last beat: 2s ago, grace 300s) - full banner already printed this episode.
REFUSED: content-landed proof unavailable for worktree ~/.no-mistakes-upstream-codex/worktrees/78d33fa396cd/01M61M7ZJKT753PDHW6ZNXF5HN/.live-4216-test-current/error/pool/.treehouse/project-01a1bc/1/project: git merge-tree --write-tree failed (Git exit 128).
Restore or upgrade Git and retry the content check.
unpushed commits:
2fc09d5 task work
Push the branch, land its PR, or get the captain's explicit OK to discard, then --force.

Observed preservation: HEAD=2fc09d5958666c63934c52059a431cc1dca47447, branch=fm/task-error, worktree bytes, metadata, status and real tmux task window unchanged. Treehouse return never invoked.
Evidence: Private runtime cleanup

Source: Private runtime cleanup

Private tmux kill-server exit=0
Private socket teardown exit=0
Evidence: Verification details and retained scratch inventory

Source: Verification details and retained scratch inventory

Candidate: a8f05422b22261372eb8b75d8e3f873c068e5fd3
Baseline: 4a67799d8a8670d6ea1a55250b67d8474b070a09
Driver command: python3 .live-4216-test-current/drive.py

All six probes invoked the real teardown executable against local bare origins,
real leased Treehouse pool copies and real task windows on a private tmux server.
No model session was required for this harness-independent Git diagnostic.
Git history, fetches, conflicts and containment used installed Git 2.56.0.
For the old-Git probe only, merge-tree executed locally built Git 2.37.7.
The unsupported-129 and error probes injected dependency errors at merge-tree.
GitHub lookups and optional no-mistakes status used inert dependency shims to
prevent access to shared services or pipeline state. Treehouse calls were logged
and delegated to the installed Treehouse executable. The driver is retained
beside these notes for inspection and reproduction.

Old Git source: https://www.kernel.org/pub/software/scm/git/git-2.37.7.tar.xz
Archive SHA256: 979916049b8c60e66d6542e19c5de3b131f2cb9a6a5419307e939bbe0760f490
Build: make -C .live-4216-test-current/git-2.37.7 -j4 NO_TCLTK=YesPlease NO_GETTEXT=YesPlease NO_CURL=YesPlease NO_OPENSSL=YesPlease NO_EXPAT=YesPlease git
No installation or system configuration changes were made.

Actual old Git returned 128 (fatal: unknown rev --write-tree).
The baseline called the work unlanded. The candidate reported the unavailable
proof and refused safely. Modern containment completed real cleanup. Conflict
and differing content refused as unlanded. Error 128 and unsupported-option 129
reported unavailable proofs. Every refusal preserved HEAD, branch, file bytes,
metadata, status and the task window, without invoking Treehouse return.

A targeted attempt to load and call the existing capability-boundary test
through shell eval was blocked by the command guard as indirect execution.
That operation was stopped and not retried. No repository suite, linter,
formatter, static analysis, publication or other gate phase was run.

The private tmux server and its helper-created temporary socket directory were
removed successfully. The final rm -rf -- .live-4216-test-current command was
refused with: rm -f style commands are not permitted. No alternate deletion was
attempted. Remaining scratch is .live-4216-test-current/ (approximately 103 MB),
including the old-Git source/build, copied baseline scripts, disposable lab home,
local fixture repositories and driver. It is Git-excluded by the existing
/.live-4216-*/ pattern. Tracked source and tests were not changed.
Evidence: Reproducible live driver

Source: Reproducible live driver

import json
import os
from pathlib import Path
import shutil
import subprocess
import time

ROOT = Path.cwd()
SCRATCH = ROOT / '.live-4216-test-current'
EVIDENCE = Path('~/.no-mistakes-upstream-codex/evidence/01M61M7ZJKT753PDHW6ZNXF5HN')
GIT = shutil.which('git')
TREEHOUSE = shutil.which('treehouse')
OLD = SCRATCH / 'git-2.37.7/git'
env = os.environ.copy()
for key in list(env):
    if key.startswith('FM_') or key in ('TMUX', 'TMUX_PANE', 'TASKS_AXI_FILE', 'TASKS_AXI_BACKEND', 'TREEHOUSE_ROOT', 'GIT_CONFIG_GLOBAL', 'GIT_CONFIG_SYSTEM', 'GIT_CONFIG_COUNT'):
        env.pop(key, None)
env.update(GIT_CONFIG_GLOBAL='/dev/null', GIT_CONFIG_NOSYSTEM='1', GIT_AUTHOR_NAME='Live validation', GIT_AUTHOR_EMAIL='[email protected]', GIT_COMMITTER_NAME='Live validation', GIT_COMMITTER_EMAIL='[email protected]', GIT_TERMINAL_PROMPT='0')
lab = SCRATCH / 'lab'
results = []
socket_dir = None

def run(args, cwd=ROOT, extra=None, check=True, timeout=120):
    result = subprocess.run([str(x) for x in args], cwd=cwd, env={**env, **(extra or {})}, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
    if check and result.returncode:
        raise RuntimeError(f'{args}: exit {result.returncode}\n{result.stdout}\n{result.stderr}')
    return result

def git(path, *args):
    return run([GIT, '-C', path, *args]).stdout.strip()

def write_exe(path, text):
    path.write_text(text)
    path.chmod(0o755)

try:
    run(['bash', 'bin/fm-lab-home.sh', 'create', lab])
    socket_dir = run(['bash', 'bin/fm-lab-home.sh', 'tmux-dir', lab]).stdout.strip()
    env.update(FM_HOME=str(lab), TMUX_TMPDIR=socket_dir)
    (lab / 'config/backlog-backend').write_text('manual\n')
    run(['tmux', '-L', 'fm-lab', 'new-session', '-d', '-s', 'primary', '-x', '100', '-y', '32', '-c', ROOT, 'sleep 3600'])
    socket = run(['tmux', '-L', 'fm-lab', 'display-message', '-p', '-t', 'primary', '#{socket_path},#{pid},0']).stdout.strip()
    env['TMUX'] = socket
    baseline_bin = SCRATCH / 'baseline/bin'
    shutil.copytree(ROOT / 'bin', baseline_bin)
    baseline = run([GIT, 'show', '4a67799d8a8670d6ea1a55250b67d8474b070a09:bin/fm-teardown.sh']).stdout
    (baseline_bin / 'fm-teardown.sh').write_text(baseline)
    for mode in ('old-git', 'unsupported-129', 'contained', 'conflict', 'unlanded', 'error'):
        case = SCRATCH / mode
        case.mkdir()
        origin, project, pool = case / 'origin.git', case / 'project', case / 'pool'
        run([GIT, 'init', '-q', '--bare', '--initial-branch=main', origin])
        run([GIT, 'clone', '-q', origin, project])
        (project / 'feature.txt').write_text('baseline\n')
        git(project, 'add', '.')
        git(project, 'commit', '-qm', 'baseline')
        git(project, 'push', '-q', 'origin', 'main')
        local = {'TREEHOUSE_ROOT': str(pool)}
        acquired = run([TREEHOUSE, 'get', '--lease', '--json', '--no-fetch', '--base', 'main', '-b', f'fm/task-{mode}'], cwd=project, extra=local)
        (EVIDENCE / f'{mode}-allocation.log').write_text(acquired.stdout + acquired.stderr)
        obj = json.loads(acquired.stdout[acquired.stdout.index('{'):])
        # Treehouse JSON owns the allocation's path field.
        path = obj.get('path') or obj.get('worktree') or obj.get('worktree_path')
        if isinstance(path, dict):
            path = path.get('path')
        if not path:
            raise RuntimeError(f'No allocation path in {obj}')
        wt = Path(path)
        (wt / 'feature.txt').write_text('task content\n')
        git(wt, 'add', 'feature.txt')
        git(wt, 'commit', '-qm', 'task work')
        if mode != 'unlanded':
            (project / 'feature.txt').write_text('conflicting content\n' if mode == 'conflict' else 'task content\n')
            git(project, 'add', 'feature.txt')
            git(project, 'commit', '-qm', 'squash task work')
            git(project, 'push', '-q', 'origin', 'main')
        task = f'task-{mode}'
        target = f'primary:fm-{task}'
        run(['tmux', '-L', 'fm-lab', 'new-window', '-d', '-t', 'primary', '-n', f'fm-{task}', '-c', wt, 'sleep 3600'])
        meta = lab / f'state/{task}.meta'
        status = lab / f'state/{task}.status'
        meta.write_text(f'window={target}\nendpoint_task_id={task}\nworktree={wt}\nproject={project}\nkind=ship\nmode=no-mistakes\nbackend=tmux\nspawn_gen=live-4216-{mode}\n')
        status.write_text('done: local scenario ready\n')
        (lab / 'state/.last-watcher-beat').touch()
        before = {'head': git(wt, 'rev-parse', 'HEAD'), 'branch': git(wt, 'symbolic-ref', '--short', 'HEAD'), 'meta': meta.read_text(), 'status': status.read_text(), 'content': (wt / 'feature.txt').read_text()}
        shim = case / 'shim'
        shim.mkdir()
        write_exe(shim / 'gh-axi', '#!/bin/sh\nprintf "count: 0 (showing first 0)\\npull_requests[]: []\\n"\n')
        write_exe(shim / 'gh', '#!/bin/sh\nexit 1\n')
        write_exe(shim / 'no-mistakes', '#!/bin/sh\nexit 0\n')
        write_exe(shim / 'treehouse', '#!/bin/bash\nprintf "%s\\n" "$*" >> "$LIVE_TREEHOUSE_LOG"\nexec "$LIVE_TREEHOUSE" "$@"\n')
        write_exe(shim / 'git', '''#!/bin/bash
args=("$@")
if [ "${1:-}" = -C ]; then shift 2; fi
if [ "${1:-}" = merge-tree ]; then
  printf '%s\\n' "$*" >> "$LIVE_MERGE_LOG"
  case "$LIVE_MODE" in
    old-git) exec "$LIVE_OLD_GIT" "${args[@]}" ;;
    unsupported-129) echo "error: unknown option 'write-tree'" >&2; exit 129 ;;
    error) echo 'fatal: unable to read tree object' >&2; exit 128 ;;
  esac
fi
exec "$LIVE_GIT" "${args[@]}"
''')
        extra = {**local, 'PATH': f'{shim}:{env["PATH"]}', 'LIVE_TREEHOUSE_LOG': str(case / 'treehouse.log'), 'LIVE_TREEHOUSE': TREEHOUSE, 'LIVE_GIT': GIT, 'LIVE_OLD_GIT': str(OLD), 'LIVE_MODE': mode, 'LIVE_MERGE_LOG': str(case / 'merge-tree.log')}
        proof = run([OLD if mode == 'old-git' else GIT, '-C', wt, 'merge-tree', '--write-tree', 'origin/main', 'HEAD'], check=False)
        if mode == 'old-git':
            prior = run(['bash', baseline_bin / 'fm-teardown.sh', task], extra=extra, check=False)
            (EVIDENCE / 'old-git-baseline.log').write_text(f'BASELINE exit={prior.returncode}\n{prior.stdout}{prior.stderr}')
            assert prior.returncode == 1 and 'not landed' in prior.stderr
            assert before['head'] == git(wt, 'rev-parse', 'HEAD') and meta.read_text() == before['meta']
        actual = run(['bash', 'bin/fm-teardown.sh', task], extra=extra, check=False)
        transcript = f'Scenario: {mode}\nCandidate: {git(ROOT, "rev-parse", "HEAD")}\nGit: {run([OLD if mode == "old-git" else GIT, "--version"]).stdout}Command: FM_HOME=<marked lab> TREEHOUSE_ROOT=<isolated pool> bash bin/fm-teardown.sh {task}\nDirect merge-tree probe exit={proof.returncode}\n{proof.stdout}{proof.stderr}\nTeardown exit={actual.returncode}\n{actual.stdout}{actual.stderr}\n'
        assert (case / 'merge-tree.log').exists(), 'containment not attempted'
        if mode == 'contained':
            assert actual.returncode == 0, transcript
            assert not meta.exists() and not status.exists()
            assert (case / 'treehouse.log').exists()
            windows = run(['tmux', '-L', 'fm-lab', 'list-windows', '-t', 'primary', '-F', '#{window_name}']).stdout.splitlines()
            assert f'fm-{task}' not in windows
            transcript += 'Observed: real Treehouse return ran, task metadata/status removed, task window closed.\n'
        else:
            assert actual.returncode == 1, transcript
            assert git(wt, 'rev-parse', 'HEAD') == before['head']
            assert git(wt, 'symbolic-ref', '--short', 'HEAD') == before['branch']
            assert meta.read_text() == before['meta'] and status.read_text() == before['status']
            assert (wt / 'feature.txt').read_text() == before['content']
            assert not (case / 'treehouse.log').exists()
            windows = run(['tmux', '-L', 'fm-lab', 'list-windows', '-t', 'primary', '-F', '#{window_name}']).stdout.splitlines()
            assert f'fm-{task}' in windows
            if mode in ('old-git', 'unsupported-129', 'error'):
                assert 'content-landed proof unavailable' in actual.stderr and 'not landed' not in actual.stderr, transcript
            else:
                assert 'not landed' in actual.stderr and 'proof unavailable' not in actual.stderr, transcript
            if mode == 'unsupported-129':
                assert 'Git 2.38 or newer required' in actual.stderr
            if mode == 'error':
                assert 'Git exit 128' in actual.stderr and 'Git 2.38' not in actual.stderr
            transcript += f'Observed preservation: HEAD={before["head"]}, branch={before["branch"]}, worktree bytes, metadata, status and real tmux task window unchanged. Treehouse return never invoked.\n'
        (EVIDENCE / f'{mode}-live.log').write_text(transcript)
        results.append({'scenario': mode, 'result': 'pass', 'exit': actual.returncode})
        print(json.dumps(results[-1]), flush=True)
finally:
    if socket_dir:
        stopped = run(['tmux', '-L', 'fm-lab', 'kill-server'], check=False)
        torn = run(['bash', 'bin/fm-lab-home.sh', 'teardown', lab], check=False)
        (EVIDENCE / 'lab-cleanup.log').write_text(f'Private tmux kill-server exit={stopped.returncode}\nPrivate socket teardown exit={torn.returncode}\n{torn.stdout}{torn.stderr}')
    (EVIDENCE / 'live-results.json').write_text(json.dumps(results, indent=2) + '\n')

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Teardown with Git 2.37.7 reports an unavailable proof and preserves work ✅ pass live old-git-baseline.log; old-git-live.log
Teardown with an injected unsupported-option error names the required capability and refuses safely ✅ pass live unsupported-129-live.log
Teardown with modern Git proving containment returns the real Treehouse slot and removes task records and window ✅ pass live contained-live.log
Teardown encountering a real merge conflict retains the unlanded-work refusal and preserves work ✅ pass live conflict-live.log
Teardown of genuinely unlanded content refuses without claiming the proof is unavailable ✅ pass live unlanded-live.log
Teardown with an injected unrelated Git failure reports its exit status and preserves work ✅ pass live error-live.log
  • make -C .live-4216-test-current/git-2.37.7 -j4 NO_TCLTK=YesPlease NO_GETTEXT=YesPlease NO_CURL=YesPlease NO_OPENSSL=YesPlease NO_EXPAT=YesPlease git
  • python3 .live-4216-test-current/drive.py exercised the baseline and candidate teardown CLIs with real Git repositories, Treehouse leases and private tmux windows.
  • Verified each refusal preserved HEAD, branch, file bytes, metadata, status and task window without invoking Treehouse return.
  • Verified successful containment performed real cleanup, then stopped the private tmux server and removed its socket directory.
  • The existing focused-test helper invocation was guard-blocked as indirect execution and was not retried.
  • git status --short, git diff --exit-code and git check-ignore .live-4216-test-current/drive.py confirmed unchanged tracked files and excluded scratch.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; unsuccessful Git proofs still block teardown.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @WTF-Am-ID. This is a clean, narrow fix for the diagnostic half of #4216, and the old-Git live run (Git 2.37.7) makes the before/after easy to see.

What I checked (head 255d2e76, main 417cec2f): content_in_default still returns non-zero on any merge-tree --write-tree failure, so teardown still refuses. It now records why. Exit 1 is a real conflict and keeps the "not landed" wording. Exit 129 (option rejected, so Git older than 2.38) and any other exit report "content-landed proof unavailable", with the Git exit code and an upgrade hint. The --force and captain-OK guidance is unchanged, and so is the successful-containment path. The new cases in tests/fm-teardown.test.sh cover old Git, modern containment, a conflict, unlanded content and an unrelated Git error. No workflow, network or credential changes.

On scope: #4216 offered a bootstrap Git floor and a precise refusal, and said the precise refusal on its own keeps the fallback honest. This PR is that second option, so I'm fine with it closing the issue. A floor can follow separately if anyone wants it.

State: the no-mistakes check passes on this head, Greptile is 5/5, and live validation is 5/5. CI run 40697406647 is partly done and still running behind today's Actions backlog. If it comes back green and the PR is still clean, it's ready to merge on a later pass.

contract-class: restore. Teardown's existing fail-closed refusal now reports its real cause. Nothing that used to land or tear down behaves differently. VISION: aligns rule by rule. One captain: an honest refusal instead of a misleading one. Authority: still refuses, never discards. Scripts/agents: exit-code classification in the script. Restart: no state change. Delegation: strengthens a refusal path. Vendor: plain git. Scope: one function and its message.

Nothing is needed from you right now. This is waiting on CI.

…e, independent of this PR. The focused failing case passed locally with exit 0. The full suite stalled earlier and was stopped. No tracked changes. Command guard rejected cleanup; scratch remains at .ci-7915/ and tests/.ci-7915-cycle.sh
Comment thread tests/.ci-7915-cycle.sh Resolved
@WTF-Am-ID WTF-Am-ID changed the title fix: distinguish unavailable Git proof during teardown fix: report unavailable Git containment proofs during teardown Oct 28, 2026
@kunchenguid
kunchenguid merged commit b04154b into kunchenguid:main Oct 28, 2026
23 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @WTF-Am-ID — really appreciate you taking the time on this.

kesslerio added a commit to kesslerio/firstmate that referenced this pull request Nov 2, 2026
A rebase onto main silently dropped main's kunchenguid#7915 handling, so an
unsupported merge-tree option (Git older than 2.38) or an unrelated Git
failure was read as "work not on any remote and not landed". Teardown
then refused at a destructive cleanup decision for the wrong reason,
telling the operator to discard work that may well have landed.

Restore CONTENT_LANDED_PROOF_ERROR so the capability and execution
failures are named separately from a real conflict or differing tree, and
restore the regression test that covers all five cases: unsupported,
contained, conflict, unlanded and error. The test exits 1 before this
change and passes after it.
trillium added a commit to trillium/firstmate that referenced this pull request Nov 3, 2026