Merge github/dev into dev: agent prep.go hardening already absorbed; add missing TestPrep_EnsureWorkspaceTaskFile_Bad test

github/dev tree was reduced to 2 files (pkg/agentic/prep{,_test}.go) after
an experimental branch reset. Cumulative net diff vs merge-base b338e12
is only those 2 files. Local has been growing the full tree for 120
commits and absorbed every substantive prep.go change in passing —
dispatch sync hooks, AddToolRecorded migrations, ensureWorkspaceTaskFile
wiring, atomic CODEX.md write. prep_test.go missing only the
TestPrep_EnsureWorkspaceTaskFile_Bad case; appended.

The ~1,500 "deleted by them" entries are artifacts of github's branch
reset, not a delete intent. Kept canonical local tree.

Co-authored-by: Hephaestus <hephaestus@cladius>
This commit is contained in:
Snider 2026-04-27 11:33:08 +01:00
commit f4c654b46f
2 changed files with 11 additions and 1 deletions

View file

@ -1041,6 +1041,10 @@ func (s *PrepSubsystem) buildPrompt(ctx context.Context, input PrepInput, branch
// ensureWorkspaceTaskFile("/srv/.core/workspace/core/go-io/task-42")
// keeps TODO.md present for the prompt and the local agent shell wrapper.
func ensureWorkspaceTaskFile(workspaceDir string) error {
if workspaceDir == "" {
return core.E("prepWorkspace", "workspace dir is required", nil)
}
todoPath := core.JoinPath(workspaceDir, "TODO.md")
if readResult := fs.Read(todoPath); readResult.OK && core.Trim(readResult.Value.(string)) != "" {
return nil
@ -1054,7 +1058,7 @@ func ensureWorkspaceTaskFile(workspaceDir string) error {
return core.E("prepWorkspace", "load TODO.md template", nil)
}
if writeResult := fs.Write(todoPath, templateResult.Value.(string)); !writeResult.OK {
if writeResult := fs.WriteAtomic(todoPath, templateResult.Value.(string)); !writeResult.OK {
if err, ok := writeResult.Value.(error); ok {
return core.E("prepWorkspace", "write TODO.md", err)
}

View file

@ -1311,3 +1311,9 @@ func TestPrep_TestPrepWorkspace_Ugly(t *testing.T) {
_, _, err := s.TestPrepWorkspace(context.Background(), PrepInput{Repo: ".."})
require.Error(t, err)
}
func TestPrep_EnsureWorkspaceTaskFile_Bad(t *testing.T) {
err := ensureWorkspaceTaskFile("")
require.Error(t, err)
assert.Contains(t, err.Error(), "workspace dir is required")
}