fix(#847): preserve child pre_script during base forge composition - #866
fix(#847): preserve child pre_script during base forge composition#866fullsend-ai-coder[bot] wants to merge 2 commits into
Conversation
During base composition, mergeForgeBlocks inherits the base's forge.github.pre_script into the child. ResolveForge then unconditionally overwrites the child's top-level pre_script with the non-empty forge-level value, silently dropping the child's explicit declaration. This caused triage harnesses with custom pre_scripts to ignore their pre-script entirely. Fix: after mergeForgeBlocks, snapshot which forge-level scripts the child authored itself and clear any base-inherited forge-level pre_script/post_script entries when the child explicitly declared the corresponding top-level field. Child-authored forge-level scripts are preserved. Tests added: - mergeBaseIntoChild: child pre_script survives base forge - mergeBaseIntoChild: child forge pre_script is preserved - LoadWithBase: end-to-end with forge resolution - LoadWithBase: base forge pre_script inherited when child omits - runAgent: triage pre-script exits non-zero aborts - runAgent: triage pre-script exits zero proceeds to sandbox Closes #847
|
🤖 Finished Review · ✅ Success · Started 9:44 AM UTC · Completed 10:00 AM UTC |
|
Looks good to me Previous runLooks good to me Previous run (2)ReviewFindingsMedium
Low
Labels: PR fixes a bug in harness base composition (pre_script/post_script override), matching the type/bug label |
|
/fs-review |
|
🤖 Finished Review · ✅ Success · Started 10:31 AM UTC · Completed 10:45 AM UTC |
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 10:51 AM UTC · Completed 11:00 AM UTC |
- Add footnote to user guide merge rules table documenting the inherited forge-level scripts exception (#847) - Clone ForgeConfig before clearing inherited scripts to avoid mutating the base struct through a shared pointer from mergeForgeBlocks - Move forgeScriptSnapshot type before clearInheritedForgeScripts to follow codebase declaration ordering convention - Rename clearInheritedForgeScripts parameter to childForgeSnap for consistency with the call site - Trim clearInheritedForgeScripts doc comment to match package-internal helper style (4 lines vs 17) Addresses review feedback on #866
🔧 Fix agent — iteration 1 (human-triggered)Addressed all 5 review findings (1 medium, 4 low). Updated user guide merge table with footnote for forge script exception. Fixed shared-pointer mutation by cloning ForgeConfig before clearing inherited fields. Reordered type declaration, aligned parameter naming, and trimmed doc comment to match codebase conventions. Fixed (5):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 11:01 AM UTC · Completed 11:10 AM UTC |
|
This pull request has been automatically marked as stale because it has not had any activity in the last month. It will be closed in 2 weeks if no further activity occurs. Remove the |
Summary
pre_scriptwas silently overwritten by the base'sforge.<platform>.pre_scriptduringResolveForgemergeForgeBlocks, clear forge-levelpre_script/post_scriptentries inherited from the base when the child explicitly declared the corresponding top-level fieldrunAgenttests verifying pre-script abort on exit 1 and proceed on exit 0Related Issue
Closes #847
Changes
internal/harness/compose.go: AddedclearInheritedForgeScripts,snapshotChildForgeScripts, andforgeScriptSnapshotto detect and clear base-inherited forge-level scripts that would shadow the child's explicit top-levelpre_script/post_scriptinternal/harness/compose_test.go: Four new tests covering merge behavior and end-to-endLoadWithBasescenariosinternal/cli/prescript_run_test.go: Two newrunAgenttests for triage agent pre-script execution; refactorednewSkipHarnessDirto support arbitrary agent names vianewSkipHarnessDirForAgentdocs/ADRs/0045-forge-portable-harness-schema.md: Documented the inherited forge-level scripts exception in the merge rulesRoot cause
mergeBaseIntoChildcorrectly preserves the child's top-levelpre_scriptduring scalar merge. However, it also merges the base'sforgesection viamergeForgeBlocks. When the child has no forge section, it inherits the base's forge configs entirely — includingforge.github.pre_script. Later,ResolveForgeunconditionally overwrites the top-levelpre_scriptwith the non-empty forge-level value, silently dropping the child's explicit declaration.Testing
TestMergeBaseIntoChild_ChildPreScriptSurvivesBaseForge— child top-level pre_script survives when base has forge.github.pre_scriptTestMergeBaseIntoChild_ChildForgePreScriptPreserved— child-authored forge-level pre_script is preserved (not cleared)TestLoadWithBase_ChildPreScriptSurvivesBaseForgeResolution— end-to-end: child pre_script survives full LoadWithBase + ResolveForge pipelineTestLoadWithBase_BaseForgePreScriptInheritedWhenChildOmits— existing behavior unchanged: base forge pre_script inherited when child omitsTestRunAgent_TriagePreScriptExitsNonZero— triage agent aborts on pre-script exit 1TestRunAgent_TriagePreScriptExitsZero_ProceedsToSandbox— triage agent proceeds past pre-script on exit 0Checklist
!for breaking changes)Note: pre-commit hooks could not run (network unavailable in sandbox).
Manual verification of pre-commit is required.
Closes #847
Post-script verification
agent/847-triage-pre-script-forge)c887fc47c59d8b87b5282ca44044d2933d30df41..HEAD)