Skip to content

refactor(scheduler): own the subagent approval file's I/O in scheddomain - #1931

Merged
edenreich merged 1 commit into
mainfrom
refactor/subagent-approval-file-io
Nov 22, 2026
Merged

edenreich merged 1 commit into
mainfrom
refactor/subagent-approval-file-io

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Resolves #1929

Summary

The subagent approval sidecar was written by hand in toolcoordinator and read by hand in tools, while the result file next to it already had owned helpers in scheddomain. The writer's copy ended with _ = os.Rename(tmp, path), so a failed rename was swallowed, left <path>.tmp behind, 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 defines SubagentApprovalFile, the same as for SubagentResultFile. no docs ticket: internal-only refactor

Changes

  • internal/scheduler/domain/subagent.go: new WriteSubagentApprovalFile and ReadSubagentApprovalFile next to the result-file pair. All four go through one private writeSidecarJSON (temp file, rename) and one generic readSidecarJSON[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: writeSubagentApprovalSidecar calls scheddomain.WriteSubagentApprovalFile and reports a failure with logger.Warn, as coordinator.go does.
  • tools/agent.go: readSubagentApproval calls scheddomain.ReadSubagentApprovalFile and keeps only the Awaiting check and the summary trim.
  • tools/approve_subagent_test.go writes its fixture through WriteSubagentApprovalFile, and toolcoordinator/approval_sidecar_test.go reads the sidecar back through ReadSubagentApprovalFile.
  • New 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.
  • With the temp-file cleanup removed, the failed-rename test fails, and it passes with the cleanup back.
  • task precommit:run - mod tidy, mocks, fmt, lint:imports and golangci-lint pass with 0 issues.

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
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Nov 22, 2026
@edenreich
edenreich marked this pull request as ready for review November 22, 2026 17:21
@edenreich
edenreich requested a review from a team as a code owner November 22, 2026 17:21
@edenreich
edenreich merged commit a9471a9 into main Nov 22, 2026
14 checks passed
@edenreich
edenreich deleted the refactor/subagent-approval-file-io branch November 22, 2026 17:52
@edenreich edenreich moved this from Todo to Done in 2026 Nov 22, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.266.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor subagent approval sidecar I/O into scheddomain

1 participant