Repository navigation
refactor(scheduler): own the subagent approval file's I/O in scheddomain - #1931
Merged
Merged
Conversation
The approval sidecar was written by hand in the TUI's tool coordinator and read by hand in the tools package, while the result file next to it already had owned helpers. The writer's copy swallowed a failed rename, which left a stale temp file and a parent that never saw the pending approval. - scheddomain gains WriteSubagentApprovalFile and ReadSubagentApprovalFile. Both sidecars now share one temp-file-and-rename JSON writer and one reader, and a failed rename removes the temp file. - writeSubagentApprovalSidecar logs a failed write with logger.Warn. - readSubagentApproval keeps only the Awaiting check and the summary trim. - The approval fixtures in tools and toolcoordinator tests go through the domain helpers. Resolves #1929
Contributor
|
🎉 This PR is included in version 0.266.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1929
Summary
The subagent approval sidecar was written by hand in
toolcoordinatorand read by hand intools, while the result file next to it already had owned helpers inscheddomain. The writer's copy ended with_ = os.Rename(tmp, path), so a failed rename was swallowed, left<path>.tmpbehind, and the parent never saw the pending approval. The temp-file-then-rename rule and the wire format now live in the scheduler domain that definesSubagentApprovalFile, the same as forSubagentResultFile. no docs ticket: internal-only refactorChanges
internal/scheduler/domain/subagent.go: newWriteSubagentApprovalFileandReadSubagentApprovalFilenext to the result-file pair. All four go through one privatewriteSidecarJSON(temp file, rename) and one genericreadSidecarJSON[T]. A failed rename now removes the temp file instead of leaving it behind - this applies to the result file too.toolcoordinator/approval_sidecar.go:writeSubagentApprovalSidecarcallsscheddomain.WriteSubagentApprovalFileand reports a failure withlogger.Warn, ascoordinator.godoes.tools/agent.go:readSubagentApprovalcallsscheddomain.ReadSubagentApprovalFileand keeps only theAwaitingcheck and the summary trim.tools/approve_subagent_test.gowrites its fixture throughWriteSubagentApprovalFile, andtoolcoordinator/approval_sidecar_test.goreads the sidecar back throughReadSubagentApprovalFile.internal/scheduler/domain/subagent_test.go: round trip, absent and malformed files, and a failed rename (the target is a non-empty directory) that must leave no temp file.Verification
go test ./...- all 129 packages pass.task precommit:run- mod tidy, mocks, fmt, lint:imports and golangci-lint pass with 0 issues.