fix: bug: hire-an-agent TOML editor corrupts existing [agents.X] block on re-run (#886) #891
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#891
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-886"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #886
Changes
AI Review
Summary
The direction is right — replacing ad-hoc regex surgery with a proper TOML parse/modify/write cycle is the correct fix for the corruption bug. But two blockers prevent merging as-is.
Blockers
critical
lib/hire-agent.sh:540:import tomli_wwill raiseModuleNotFoundErrorat runtime. The agents Dockerfile installs onlynetworkxvia pip (docker/agents/Dockerfile:5).tomli_wis a third-party package and is not present. Everyhire-agentinvocation will hard-crash at the Python snippet before any TOML work is attempted. Fix: addtomli_wto thepip3 install --break-system-packagesline in the Dockerfile alongsidenetworkx.high
lib/hire-agent.sh:584:tomli_w.dumps(data)strips ALL comments from the project TOML on every run. The project template (bin/disinto:396-411) contains documentation comments — the# Local-model agents (optional)example block and the# [mirrors]stub — that guide operators through manual configuration. After the firsthire-agentinvocation these comments are permanently gone with no warning. This is a silent regression: the bug being fixed is corruption on re-run, but the fix introduces a different form of destruction (comment loss) on first run. Fix: also addtomli_wto the Dockerfile (blocker 1) and either document this trade-off explicitly or use a comment-preserving strategy (e.g.,tomlkitpreserves formatting and comments end-to-end).Notes (non-blocking)
lib/hire-agent.sh:558-559: Step 1 (commented-block removal regex) is unnecessary when using a proper TOML parser —tomllibtreats#lines as comments and ignores them. The regex runs before parsing but fixes nothingtomllibcannot already handle. It can be removed without changing behaviour once the dependency issue is resolved.lib/hire-agent.sh:580:int(poll_interval)will raiseValueErrorwith no error message if the shell passes a non-numeric string. Low risk in practice, but the existingTOMLDecodeErrorhandler pattern could wrap this too.Verdict
REQUEST_CHANGES — tomli_w is not installed in the Docker image; will crash with ModuleNotFoundError on every hire-agent run
Reviewed at
8943af4| AGENTS.mdAI Review: REQUEST_CHANGES — tomli_w is not installed in the Docker image; will crash with ModuleNotFoundError on every hire-agent run
AI Re-review (round 2)
Previous Findings
lib/hire-agent.sh:540:import tomli_wraised ModuleNotFoundError → FIXED: replaced withimport tomlkit;tomlkitadded to Dockerfile pip install alongsidenetworkxlib/hire-agent.sh:584:tomli_w.dumps()strips all comments → FIXED:tomlkit.dumps(doc)preserves comments and formatting end-to-endint(poll_interval)bare ValueError → NOT ADDRESSED (non-blocking, low risk in practice)Verification
tomlkitis both reader and writer that preserves comments and formatting; the parse→modify→write cycle now leaves operator docs (example blocks, stubs) intact on every rundoc["agents"][section_name] = {...}correctly upserts on re-run without duplicating or corrupting the block — the core bug is fixeddoc.add("agents", tomlkit.table())is the correct tomlkit idiom for a new top-level table when the key is absent# [agents.X]lines before parsing; tomlkit treats them as comments anyway, so this is redundant but not harmfulVerdict
APPROVE — Both blockers from previous review are fixed: tomlkit installed in Dockerfile, tomlkit.dumps() preserves comments end-to-end
Reviewed at
cf99bdc| Previous:8943af4| AGENTS.mdAI Re-review (round 2): APPROVE — Both blockers from previous review are fixed: tomlkit installed in Dockerfile, tomlkit.dumps() preserves comments end-to-end