Skip to content

fix(workflows): make archon-adversarial-dev sed replacement macOS-safe#1155

Merged
Wirasm merged 3 commits intocoleam00:devfrom
LaplaceYoung:fix/workflow-macos-sed-1103
Apr 22, 2026
Merged

fix(workflows): make archon-adversarial-dev sed replacement macOS-safe#1155
Wirasm merged 3 commits intocoleam00:devfrom
LaplaceYoung:fix/workflow-macos-sed-1103

Conversation

@LaplaceYoung
Copy link
Copy Markdown
Contributor

@LaplaceYoung LaplaceYoung commented Apr 13, 2026

Summary

Fixes the archon-adversarial-dev init-workspace step for macOS BSD sed compatibility.

Issue #1103 reports that sed -i fails on macOS because BSD sed requires a backup extension, while GNU sed accepts bare -i.

This PR replaces the non-portable in-place edit with a portable temp-file pattern:

  • before: sed -i s/.../.../ file
  • after: sed s/.../.../ file > file.tmp && mv file.tmp file

Changes

  • .archon/workflows/defaults/archon-adversarial-dev.yaml
    • Updated init-workspace to write state.json via temp file (state.json.tmp) and atomic move.
  • packages/workflows/src/defaults/bundled-defaults.test.ts
    • Added regression test to assert the workflow uses portable temp-file sed and does not use bare sed -i for this replacement.

Validation

  • bun test packages/workflows/src/defaults/bundled-defaults.test.ts

Closes #1103

Summary by CodeRabbit

  • Chores

    • Improved reliability and portability of state updates in the adversarial development workflow by switching to an atomic, non-destructive update approach.
  • Tests

    • Added test coverage validating the updated state update behavior to prevent non-portable or unsafe in-place edits.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: abd22531-96e0-40e2-93f1-51964039ce3c

📥 Commits

Reviewing files that changed from the base of the PR and between f15853c and ee84db7.

📒 Files selected for processing (2)
  • packages/workflows/src/defaults/bundled-defaults.generated.ts
  • packages/workflows/src/defaults/bundled-defaults.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/workflows/src/defaults/bundled-defaults.test.ts

📝 Walkthrough

Walkthrough

Replaced an in-place sed -i update of SPRINT_COUNT_PLACEHOLDER in the bundled archon-adversarial-dev workflow with a non-in-place approach writing to state.json.tmp and moving it into place; updated the generated bundle and added a test asserting the new, portable pattern.

Changes

Cohort / File(s) Summary
Workflow YAML
/.archon/workflows/defaults/archon-adversarial-dev.yaml
Replaced sed -i in-place substitution with writing sed output to a temporary file (state.json.tmp) and mv-ing it back to state.json to avoid BSD sed incompatibility.
Bundled/generated workflow
packages/workflows/src/defaults/bundled-defaults.generated.ts
Updated the inlined BUNDLED_WORKFLOWS["archon-adversarial-dev"] content to reflect the same temporary-file sed + mv change.
Tests
packages/workflows/src/defaults/bundled-defaults.test.ts
Added a test asserting the workflow uses a STATE_TMP temporary file and non-in-place sed redirection and that the old sed -i form is not present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I’m a rabbit with a clipboard and a map,
Hop-patching sed so macOS won’t snap.
Temp files, a mv, no more brittle "i",
Now state.json sleeps without a cry. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(workflows): make archon-adversarial-dev sed replacement macOS-safe' clearly and concisely describes the main change: replacing non-portable sed syntax with a macOS-compatible approach in the archon-adversarial-dev workflow.
Description check ✅ Passed The PR description covers the problem, solution, and changes made, though it omits several required template sections like UX Journey, Architecture Diagram, Label Snapshot, Validation Evidence commands, Security Impact, Compatibility, Human Verification, and Rollback Plan.
Linked Issues check ✅ Passed The PR addresses #1103 by replacing non-portable 'sed -i' with a temp-file approach, adds regression tests, and generates updated bundled defaults, satisfying the linked issue's requirements.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the macOS sed compatibility issue in archon-adversarial-dev; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/workflows/src/defaults/bundled-defaults.test.ts (1)

122-129: Harden this regression test to cover all sed -i forms and the required mv step.

At Line 128, the negative assertion only blocks one exact literal. It can miss other sed -i variants, and the test currently doesn’t verify the atomic replace command itself.

Proposed test hardening
     expect(content).toContain('STATE_TMP="$ARTIFACTS/state.json.tmp"');
     expect(content).toContain(
       'sed "s/SPRINT_COUNT_PLACEHOLDER/$SPRINT_COUNT/" "$ARTIFACTS/state.json" > "$STATE_TMP"'
     );
-    expect(content).not.toContain('sed -i "s/SPRINT_COUNT_PLACEHOLDER/$SPRINT_COUNT/"');
+    expect(content).toContain('mv "$STATE_TMP" "$ARTIFACTS/state.json"');
+    expect(content).not.toMatch(/\bsed\s+-i\b/);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/workflows/src/defaults/bundled-defaults.test.ts` around lines 122 -
129, The test for 'archon-adversarial-dev init-workspace should avoid
non-portable sed -i' is too narrow; update the assertions that inspect
BUNDLED_WORKFLOWS['archon-adversarial-dev'] (variable content) to assert there
is no use of any sed -i form (use a negative match against a regex covering -i,
-i''/"" and -i with an arg) and also assert the script uses the safe two-step
atomic replace: the redirected sed invocation (existing check for 'sed
"s/SPRINT_COUNT_PLACEHOLDER/$SPRINT_COUNT/" "$ARTIFACTS/state.json" >
"$STATE_TMP"') plus a subsequent mv of the temp file into place (e.g., contains
mv "$STATE_TMP" "$ARTIFACTS/state.json"). Ensure these checks reference the same
content variable and the test name 'archon-adversarial-dev init-workspace should
avoid non-portable sed -i'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/workflows/src/defaults/bundled-defaults.test.ts`:
- Around line 122-129: The test for 'archon-adversarial-dev init-workspace
should avoid non-portable sed -i' is too narrow; update the assertions that
inspect BUNDLED_WORKFLOWS['archon-adversarial-dev'] (variable content) to assert
there is no use of any sed -i form (use a negative match against a regex
covering -i, -i''/"" and -i with an arg) and also assert the script uses the
safe two-step atomic replace: the redirected sed invocation (existing check for
'sed "s/SPRINT_COUNT_PLACEHOLDER/$SPRINT_COUNT/" "$ARTIFACTS/state.json" >
"$STATE_TMP"') plus a subsequent mv of the temp file into place (e.g., contains
mv "$STATE_TMP" "$ARTIFACTS/state.json"). Ensure these checks reference the same
content variable and the test name 'archon-adversarial-dev init-workspace should
avoid non-portable sed -i'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5e15a5cf-eea3-4884-bed3-b7cb77e07e60

📥 Commits

Reviewing files that changed from the base of the PR and between eb75ab6 and f15853c.

📒 Files selected for processing (2)
  • .archon/workflows/defaults/archon-adversarial-dev.yaml
  • packages/workflows/src/defaults/bundled-defaults.test.ts

@Wirasm
Copy link
Copy Markdown
Collaborator

Wirasm commented Apr 21, 2026

Thanks for this, @LaplaceYoung — the fix is correct and the regression test is well-shaped.

One blocker before merge: the bundled-defaults file wasn't regenerated, and the PR's own test reads from there.

Per CLAUDE.md:

After adding, removing, or editing a default file, run bun run generate:bundled to refresh the embedded bundle. bun run validate (and CI) run check:bundled and will fail loudly if the generated file is stale.

Right now `packages/workflows/src/defaults/bundled-defaults.generated.ts` still contains the old `sed -i "s/..."` literal — so:

  • The new test in `bundled-defaults.test.ts` asserts the new pattern against `BUNDLED_WORKFLOWS['archon-adversarial-dev']`, which loads from the generated file → the test fails against its own PR.
  • `check:bundled` in `bun run validate` (first step in CI) catches the drift and fails before tests even run.

To unblock

From the repo root, on your branch:

```bash
bun run generate:bundled
git add packages/workflows/src/defaults/bundled-defaults.generated.ts
git commit -m "chore: regenerate bundled-defaults after adversarial-dev sed fix"
git push
```

Once that lands, `bun run validate` should pass locally and we can merge. Really appreciate the fix — this hit a real macOS pain point.

@LaplaceYoung
Copy link
Copy Markdown
Contributor Author

I didnot take my mac mini with me recently. So I wonder would u mind me seeking help from codex in the this PR?

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

1 similar comment
@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@LaplaceYoung
Copy link
Copy Markdown
Contributor Author

#1345 (comment)

Wirasm added 2 commits April 22, 2026 09:18
Sync generated bundle with the new temp-file sed pattern in
archon-adversarial-dev.yaml so check:bundled passes and binary
distributions ship the macOS-safe version.
@Wirasm
Copy link
Copy Markdown
Collaborator

Wirasm commented Apr 22, 2026

Pushed the regenerated bundle on your behalf (also merged in current dev, which changed the bundling mechanism from with { type: 'text' } imports to a generated file via #1263 — so the fix needed to flow through generate:bundled now). bun run validate passes locally.

PR #1345 closed as duplicate. Should be ready to merge once CI goes green.

@Wirasm Wirasm merged commit 817186d into coleam00:dev Apr 22, 2026
1 check 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.

archon-adversarial-dev: init-workspace 'sed -i' fails on macOS BSD sed

2 participants