From c0637aaad88fbc32b9a306c1077e3f7612427891 Mon Sep 17 00:00:00 2001 From: Kirill Turanskiy Date: Mon, 13 Jul 2026 14:15:27 +0300 Subject: [PATCH] test(loom): compare worker cwd by identity --- .../evidence/MACOS-CWD-CANONICAL.red.json | 11 ++++ .../evidence/MACOS-CWD-CANONICAL.tdd.json | 57 +++++++++++++++++++ .../production_readiness_coverage_test.go | 6 +- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 .agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.red.json create mode 100644 .agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.tdd.json diff --git a/.agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.red.json b/.agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.red.json new file mode 100644 index 000000000..5eae880cf --- /dev/null +++ b/.agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.red.json @@ -0,0 +1,11 @@ +{ + "task_id": "MACOS-CWD-CANONICAL", + "stack": "GO", + "observed_at": "2026-07-13T10:03:34.817897Z", + "source": "GitHub Actions run 29241241316, job 86787538057, cross-platform-tests-macos-14 artifact 8275553191", + "test_file": "internal/handlers/loom/production_readiness_coverage_test.go", + "test_name": "TestCliWorker_ProductionReadinessStructuredArgsAndCWD", + "protected_invariant": "The CLI worker executes the child process in the requested existing working directory even when the operating system reports a different canonical spelling for that directory.", + "failure_reason": "macOS returned the physical /private/var path for a t.TempDir requested through the equivalent /var path, so exact string equality rejected the correct directory identity.", + "runner_stdout_excerpt": "expected: /var/folders/.../TestCliWorker_ProductionReadinessStructuredArgsAndCWD.../001\nactual: /private/var/folders/.../TestCliWorker_ProductionReadinessStructuredArgsAndCWD.../001\n--- FAIL: TestCliWorker_ProductionReadinessStructuredArgsAndCWD (0.01s)" +} diff --git a/.agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.tdd.json b/.agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.tdd.json new file mode 100644 index 000000000..3f38629e7 --- /dev/null +++ b/.agent/specs/macos-cwd-canonical/evidence/MACOS-CWD-CANONICAL.tdd.json @@ -0,0 +1,57 @@ +{ + "task_id": "MACOS-CWD-CANONICAL", + "stack": "GO", + "verdict": "PASS_LOCAL_PENDING_MACOS_CI", + "red": { + "observed_at": "2026-07-13T10:03:34.817897Z", + "test_file": "internal/handlers/loom/production_readiness_coverage_test.go", + "test_name": "TestCliWorker_ProductionReadinessStructuredArgsAndCWD", + "failure_reason": "The exact-string assertion rejected equivalent /var and /private/var spellings of the same macOS temporary directory.", + "runner_stdout_excerpt": "expected /var/folders/...; actual /private/var/folders/...; one test failed", + "source": "GitHub Actions run 29241241316, job 86787538057, artifact 8275553191" + }, + "green": { + "observed_at": "2026-07-13T11:14:13.6535708Z", + "implementation": "Stat both existing paths and assert os.SameFile directory identity.", + "scoped_target_passed": 1, + "module_regressions": 0, + "windows_runner": "go test target and full internal/handlers/loom package: PASS", + "linux_alias_replay": "TMPDIR symlink alias produced a physical child cwd; target test PASS in golang:1.26-bookworm" + }, + "refactor": { + "applied": false, + "reason": "The GREEN test-only change is already the minimum standard-library identity check." + }, + "prove_it": { + "mutation": "Temporarily restore the old assert.Equal path-string comparison.", + "substituted_files": [], + "failed_tests": 1, + "runner_stdout_excerpt": "expected /tmp/engram-cwd-alias/...; actual /tmp/...; TestCliWorker_ProductionReadinessStructuredArgsAndCWD FAIL", + "reverted_at": "2026-07-13T11:14:13.6535708Z", + "post_revert_green": true + }, + "coverage": { + "package": "github.com/thebtf/engram/internal/handlers/loom", + "percent": 86.9, + "threshold": 80, + "status": "PASS" + }, + "behavior_signal": { + "name": "cross-platform worker CWD identity", + "measurement": "The exact test must pass on windows-latest, ubuntu-latest, and macos-14 for the candidate head.", + "status": "LOCAL_PROXY_GREEN_PENDING_REMOTE_MACOS" + }, + "external_sources": { + "go_same_file": "https://pkg.go.dev/os#SameFile", + "go_eval_symlinks": "https://pkg.go.dev/path/filepath#EvalSymlinks", + "decision": "Use os.SameFile because filepath.Abs does not guarantee a unique name and the tested invariant is directory identity, not path spelling.", + "context7": "USED", + "parallel": "USED", + "tavily": "BLOCKED_OAUTH_AUTHORIZATION_REQUIRED" + }, + "infrastructure_notes": [ + "The first WSL alias replay never reached tests because required modules were absent and WSL had no network route.", + "A second WSL attempt exposed that the base toolchain was Go 1.22.2 and auto-download state lived in the default module cache.", + "The accepted alias replay used the cached golang:1.26-bookworm image and the existing host module cache with GOPROXY=off." + ] +} diff --git a/internal/handlers/loom/production_readiness_coverage_test.go b/internal/handlers/loom/production_readiness_coverage_test.go index 1bf481fe6..f937e194b 100644 --- a/internal/handlers/loom/production_readiness_coverage_test.go +++ b/internal/handlers/loom/production_readiness_coverage_test.go @@ -80,7 +80,11 @@ func TestCliWorker_ProductionReadinessStructuredArgsAndCWD(t *testing.T) { } require.NoError(t, json.Unmarshal([]byte(result.Content), &state)) assert.Equal(t, []string{"--role", "maker", "--model", "test-model", "--effort", "high"}, state.Args) - assert.Equal(t, cwd, state.CWD) + requestedDir, err := os.Stat(cwd) + require.NoError(t, err) + reportedDir, err := os.Stat(state.CWD) + require.NoError(t, err) + assert.True(t, os.SameFile(requestedDir, reportedDir), "worker CWD %q must identify requested directory %q", state.CWD, cwd) assert.Equal(t, "structured-env", state.Env) assert.Equal(t, "structured prompt", state.Prompt) assert.GreaterOrEqual(t, result.DurationMS, int64(0))