Repository navigation
Description
A REPORT CARRIES WHAT IT PROMISES. A node's report may be short, but it must
not end mid-sentence — and it must never end on an opening fence with the lines
it announced silently dropped.
What happens
A node whose last message ends in a fenced block reports the fence and nothing
inside it. Seen on fix/568-job-park (#574), 2/2 real-model runs of the task
that waits out its own long command: the checkpoint row's report read
The command finished, exit 0.
Its last line, verbatim:
— an opening fence, no content, no closing fence, and no mark that anything was
cut. The child's journal holds the whole answer.
Mechanism
internal/session/task_run.go:4945
func taskReport(child *Agent) string {
return firstLines(lastSaid(child), taskReportLines)
}lastSaid(task_run.go:4952) returns the child's final assistant message whole.firstLines(task_run.go:4964) keeps the firsttaskReportLinesnon-empty lines,
eachclipped totaskReportLineLimit, and joins them.taskReportLines = 3,
taskReportLineLimit = 300(task_run.go:121-122).
So the cut is a plain non-empty-line count. It is not markdown-aware, it does
not know a fence from prose, and a fence line ("```") counts as one of the three.
A reply that spends its first two lines on a sentence and opens a fence on the
third is reported as prose + a bare opening fence.
Two consequences, both of them the law being broken:
- The tail is dropped with no mark.
clip(internal/session/loop.go:2419)
marks its cut with…;firstLinesmarks nothing at all, so a three-line
report is indistinguishable from a complete one. - The report and the journal disagree by construction, not by data loss.
lastSaid(child)— the whole text — is still in hand at the same call site:
task_run.go:3863composes the report andtask_run.go:3875re-reads
lastSaid(child)fordeclaredFiles. The full text was never unavailable;
the composer simply throws it away. The node's journal
(TaskNode.setJournal,task_run.go:2589, pointed at by
taskURI(node.journalPath())inreportTaskNode,task_run.go:2779) keeps it.
The other caller has the same shape: task_audit.go:1039 (return wrote, taskReport(child)).
The composer's exact output for a fixture
Fixture reply (six lines):
The command finished, exit 0.
Its last line, verbatim:
all 41 checks passed
files: none
firstLines(reply, taskReportLines) returns, verbatim:
The command finished, exit 0.
Its last line, verbatim:
The closing fence, the line inside it, and the `files:` declaration are gone, and
nothing says so.
## Is dev affected
**Yes.** `fix/568-job-park` does not touch `internal/session/task_run.go` at all
(`git diff --stat origin/dev origin/fix/568-job-park` — the branch changes
`agent.go`, `jobs.go`, `jobstop.go`, `loop.go`, `promote.go`, `session.go`,
`steer.go`, `task_child_run.go` and adds `task_job_park.go`; `task_run.go` is not
in the list). The composer is byte-identical on `dev`. The branch only made it
easy to see, because a parked job makes a node likely to end its report quoting
command output in a fence.
## Replication — anything a stranger can run
No model, no key, no network. In `internal/session`, a `_test.go` in-package:
```go
func TestAReportKeepsTheFenceItOpens(t *testing.T) {
reply := "The command finished, exit 0.\n" +
"Its last line, verbatim:\n" +
"```\n" +
"all 41 checks passed\n" +
"```\n" +
"files: none\n"
got := taskReport... // firstLines(reply, taskReportLines)
if !strings.Contains(got, "all 41 checks passed") {
t.Errorf("the report lost the lines inside the fence:\n%s", got)
}
if strings.Count(got, "```")%2 != 0 {
t.Errorf("the report ends on an unclosed fence:\n%s", got)
}
}
go test ./internal/session/ -run TestAReportKeepsTheFenceItOpens -count=1.
Both assertions fail today; the logged report is the three lines quoted above.
(Verified this way in a throwaway worktree off origin/dev @ 2ca5dd7b9.)
Acceptance — end to end first
The real door is a finished node's checkpoint row report (TaskRecord.Report,
internal/session/task_store.go:224, filled from n.report at
task_store.go:695). Assert that for a node whose last message ends in a fenced
block, the row's report either contains the fenced content and its closing fence,
or ends on a mark that says it was cut — never on a bare "```". A unit test on
the composer alone is not enough; #184 is the worked example of unit-green and
end-to-end-broken.
Queued for after the WIP freeze; do not start without the coordinator.
Drafted with CodeAF · reviewed and owned by the author
Activity
session: a report carries the fenced tail it promised, and says when …