Description
Parent epic: #338
Part of the debug-record epic (parent linked below). Lands after #286 and #334, because it stamps ids onto the call-log row that those two are correcting.
What a debugger hits today
There is no switch. Two environment pins exist, buried in the settings registry, with no flag, no slash command and no page a person would find first. With the bodies pin on, a 65 KB request is written twice per attempt, on the start row and again on the end row, into a call log that rotates at 32 MB, so one long turn evicts the failure the person came for. And nothing on disk joins anything: the call-log row has no session or run id, the transcript's call line has no call id, the lane journal has no request identity.
The law
One switch turns on the full record of a run without changing the run; every record it writes carries the run id and, for anything about a model call, the call id; the trace is a person's own data.
Fix shape
- The switch, three doors, one meaning: an environment pin
AFORGE_DEBUG=1, a--debugflag onchat,doandexec, and/debuginside a chat (turns the record on for the rest of the session). Behaviour of the run is unchanged. The old bodies pin keeps working for one release and means the same thing. - One recorder package, neutral name, one small interface: record a call body (request, response), a tool event, a decision with a reason. Nil-safe: when the switch is off every method is a no-op behind one nil check, and no feeder site pays more than that. No second logging library, no per-package levels.
- Two identities: a run id minted once per chat session and per headless invocation and carried on the context; a call id per model call, which the call log already mints per attempt. The run id is stamped on every call-log row, the transcript header, and lane journal lines; the call id on the call-log row, the transcript's call line, and the trace body file's name.
- The trace directory: one folder per run under the state root's
logs/trace/, holdingevents.jsonland one file per call body named by the call id. Files are private to the user. No authorization header or key is ever written. Bodies stop being written into the call log on or off; the request body is captured once per attempt. - Size law: a cap per run and a retention count over runs; when the cap is reached the run's trace says so on its last line and stops; when the count is exceeded the oldest run is pruned whole. Never a rotation that evicts a failure mid-run.
- A manual page under the chat corpus that a person finds by asking "how do I see what happened" or "debug log", naming the switch and where the record is.
Replication
AFORGE_CALL_LOG_BODIES=1 aforge chat --once "read notes.txt and tell me its second line" --yolo
aforge logs --tail 4Today: both rows of each attempt carry the full request body, no row carries a response body, and no row says which session it belonged to.
Acceptance (functional)
AFORGE_DEBUG=1 aforge chat --once "...", thenaforge chat --debug --once "...", then/debuginside a session: all three leave a trace folder for that run; with none of them, a run that succeeds leaves no trace folder and the call log gains its rows as before (a run that fails is call log: the one call that failed keeps its request and reply beside its error, without a switch #350's case: the failing call's evidence and nothing else).- Every call-log row written during the run carries the same run id as the transcript header; every transcript call line carries a call id that names one call-log row and one body file in the trace.
- No call-log row carries a request or response body, switch on or off; the trace holds them.
grep -i authorizationand the key's own value across the trace folder find nothing.- Trace files and folders are readable by the owner only.
- With the per-run cap set low, a run that exceeds it ends its trace with a line saying the cap was reached and keeps what it had; with the retention count set to two, a third run removes the oldest folder whole.
- The manual answers "how do I turn on the debug log" and "where is the debug record" with the switch and the folder.
- The old bodies pin still produces bodies, in the trace.
Drafted with CodeAF · reviewed and owned by the author
Activity
santoshkumarradha commentedon Sep 2, 2026
Landing plan (decided by the coordinator): this issue lands as four small PRs rather than one draft that rebases three times.
The feeders #340 and #341 start against PR A the moment it is on dev, because they write into the trace, not the ledger. This issue closes when D lands.
trace: every door opens the run's folder and writes its header (#339)
trace: one switch, one recorder, and a folder per run that is a perso…
trace: every door opens the run's folder and writes its header (#339)
trace: the run id is the scope of the switch, and a key nobody can sp…
trace: one switch, one recorder, and a folder per run that is a perso…
trace: every door opens the run's folder and writes its header (#339)
trace: the run id is the scope of the switch, and a key nobody can sp…
trace: an id is not a path, a guess is not an attribution, and retent…
changelog: name the path-traversal fix as the security fix it was (#339)
trace: one switch, one recorder, and a folder per run that is a perso…
trace: every door opens the run's folder and writes its header (#339)
trace: the run id is the scope of the switch, and a key nobody can sp…
trace: an id is not a path, a guess is not an attribution, and retent…
changelog: name the path-traversal fix as the security fix it was (#339)
trace: one switch, one recorder, and a folder per run that is a perso…
santoshkumarradha commentedon Sep 10, 2026
Consolidated into the epic #338 — and this one is largely done. PR #361 landed the foundation you specified: the switch (
AFORGE_DEBUG,--debug), the run folder withrun.jsonwritten at the door, the permissions, the exit line naming the folder, no folder when the switch is off, the size cap and the retention pruning;trace.Secretredacts credentials; the run id rides the context and is read back byinternal/provider/calllog.go:202, and the call id is the one the call log already mints per attempt.PR #361 said it was 'PR A of four' and that #339 closes when PR D lands. PRs B, C and D never landed, so rather than leave this open as a proxy for the other three, the remaining feeders are sequenced in the epic's consolidated plan (comment on #338, 2026-09-10) as three pull requests. Your foundation is not being redone; it is being fed.