fix(curator): stop curator actions from serializing a zero timestamp
session-memory's extracted actions never set Action.At, so the wire
carried time.Time's zero value ("0001-01-01") and the Curators
dashboard rendered it as "105694 wks ago". Stamp the action with the
curator's clock at the producer, and backfill any zero Action.At in
activityTracker.record from the pass's own timestamp so an engine
with no clock (skillcurator) can't hit the same bug.
Closes archie-core-z6wy
This commit is contained in:
1 parent
7b1cef53eb
commit
adf06e9efe
5 files changed
+34
No files matched your search
@@ -91,6 +91,7 @@
|
||||
{"_type":"issue","id":"archie-core-g7tm","title":"telegram: finalize the reply through a live context, matching the error branch","description":"The success path calls live.finalize(turnCtx, reply) with the raw cancellable turn context (telegram.go:582), while the error branch two lines above deliberately uses context.WithoutCancel(turnCtx). If /stop lands during finalize, the rich edit, the plain-text retry, and the split-send fallback all abort with context.Canceled (go-telegram/bot builds requests with NewRequestWithContext), so the authoritative reply is never delivered and the live message keeps the ▌ cursor forever. The reply is persisted to the ledger, so the loss is delivery-level — but the user sees a frozen half-answer.\n\nFailure: a long tool-using turn is /stop-ped as it completes; turnCtx is cancelled mid-finalize; every send fails on the dead context; the chat shows the last live frame with a blinking cursor and no final answer.\n\nFound by code-review of PR #476 (feat/467, merged 98e8dda).","design":"live.finalize(context.WithoutCancel(turnCtx), reply) — the one-liner the error branch already uses. Consider making finalize take a live context internally rather than trusting each caller to remember.","acceptance_criteria":"A /stop landing mid-finalize still delivers the authoritative reply and drops the cursor; a test covers the cancellable-context finalize path.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-14T14:43:08Z","created_by":"Sam Catlow","updated_at":"2026-08-14T15:07:36Z","started_at":"2026-08-14T14:53:28Z","closed_at":"2026-08-14T15:03:28Z","close_reason":"Fixed in internal/channels/telegram/live.go and telegram.go: finalize/abandon strip context cancellation before sending (mirroring each other), ToolCall escapes Markdown metacharacters via bot.EscapeMarkdown, splitLongMessage splits on rune boundaries. All new/changed tests verified red-then-green; task check clean; adversarial review pass found no blocking issues.","external_ref":"https://github.com/samcharles93/archie-core/issues/484","labels":["code-review","streaming","telegram"],"dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-tb3a","title":"Fix streaming review blockers for inline tool calls","description":"Resolve the four evidence-gated findings in merged inline tool-call streaming: preserve the authoritative Telegram reply when final edits fail; keep Telegram network I/O off the model FullStream consumer and cancellable; correlate tool inputs with results and render a bounded redacted parameter summary; snapshot show_tool_calls per live reply to avoid reload races. Add regression tests for every path and run task check plus lint/race validation.","acceptance_criteria":"Regression tests fail on the merged implementation and pass after the fix. Final edit failure falls back to normal split delivery. Delta and ToolCall callbacks do not wait on Telegram HTTP and stop cancels in-flight rendering. Completed tool events include bounded redacted parameters correlated by tool-call ID. Reload cannot race an in-flight reply's show_tool_calls setting. task check passes, golangci-lint reports no new findings, and focused race tests pass.","notes":"Implemented in worktree /tmp/archie-core-tb3a on branch fix/archie-core-tb3a. Added cancellable async Telegram rendering, final edit failure fallback through normal split delivery, call-ID-correlated bounded conservative parameter summaries, atomic per-reply show_tool_calls snapshots, SSE/UI parameter rendering, rebuilt ui/dist, and regression tests. Validation: GOFLAGS=-buildvcs=false task check passed; golangci-lint --new-from-rev=HEAD ./... reported 0 issues; focused race suite passed; fresh adversarial reviewer reported PASS with zero findings. Plain task check is blocked in linked worktrees by Go VCS stamping exit 128, hence buildvcs override.\n2026-08-24 reconciliation: the close reason's 'worktree left uncommitted' is stale. The work did land on main via ba33527 (Merge pull request #477 from samcharles93/fix/archie-core-tb3a); verified on main: gateway/stream.go sensitiveParameterKey+redactToolParameters, telegram/live.go per-reply showToolCalls snapshot, webui/api_chat.go gating. The /tmp/archie-core-tb3a worktree and its branch are gone, as expected.\n","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T18:05:35Z","created_by":"Sam Catlow","updated_at":"2026-08-24T07:29:09Z","started_at":"2026-08-13T18:05:39Z","closed_at":"2026-08-13T18:35:26Z","close_reason":"Completed and independently reviewed; worktree left uncommitted per conservative repository policy.","external_ref":"https://github.com/samcharles93/archie-core/issues/485","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-dzx","title":"Remove duplicate archie-agent safe.directory setup","description":"## Problem\\ncmd/archie-agent/main.go configures git safe.directory inline and then calls markWorktreeSafe, so startup writes the same global git configuration twice.\\n\\n## Scope\\nKeep markWorktreeSafe as the single tested production path and remove the older inline exec.Command block/import. Add regression coverage proving startup wiring has exactly one authoritative safe-directory call.\\n\\n## Acceptance\\n- archie-agent startup invokes markWorktreeSafe exactly once\\n- no second inline safe.directory command remains in main.go\\n- cmd/archie-agent tests and repository quality gate pass","acceptance_criteria":"Single tested safe.directory setup path remains; duplicate inline command is removed; tests and task check pass","notes":"Red proof: TestMainConfiguresWorktreeSafetyOnce failed with 2 setup paths before implementation. Green proof: go test/vet/build ./cmd/archie-agent/... passed; golangci-lint --new-from-rev=HEAD reported 0 issues. Fresh adversarial review found no blockers. Full task check was not run because the working tree contains unrelated in-progress changes and task check rewrites files; scoped package gate used per repository protocol.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T16:10:09Z","created_by":"Sam Catlow","updated_at":"2026-08-13T16:13:48Z","started_at":"2026-08-13T16:10:24Z","closed_at":"2026-08-13T16:13:48Z","close_reason":"Removed duplicate inline safe.directory setup; markWorktreeSafe is now the single tested production path","external_ref":"https://github.com/samcharles93/archie-core/issues/470","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-z6wy","title":"Curator action timestamps rendered as '105694 wks ago'","description":"Curator actions built without an explicit At (e.g. sessioncurator before this fix, and skillcurator) serialized time.Time's zero value to the dashboard, which rendered as a nonsense relative time. Fixed by stamping sessioncurator's action with its clock and backfilling any zero Action.At in activityTracker.record from the pass timestamp.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:52:20Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:52:24Z","closed_at":"2026-09-02T11:52:24Z","close_reason":"Fixed: sessioncurator now stamps Action.At from its clock; activityTracker.record backfills any zero Action.At from the pass timestamp as a defense in depth for engines with no clock (skillcurator).","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-enfj","title":"[EPIC] Dynamic workflow routing: route task intent to the cheapest sufficient workflow","description":"workflow.Route() (internal/domain/workflow/workflow.go:237) only checks an explicit t.Workflow, then label match, then falls back unconditionally to 'implement' -- the heaviest workflow. There is no content/intent-based routing at all. task_spawn's own tool schema actively overpromises: 'workflow: ... Omit to let the daemon route it' (internal/gateway/task_tools.go:240), implying real routing exists when it means only 'check labels, then give up and run the heaviest workflow anyway'.\n\nConfirmed via production task 6 (2026-09-02): a chat-spawned task whose entire content was 'this is just a test, close it when you receive it' ran the full implement pipeline (prepare, baseline, plan, build, commit-push) end to end, burning 669,421 tokens and ~7 minutes, when nothing about the request needed a worktree, a plan, or a build at all.\n\nNeeds a design doc before any code lands per CLAUDE.md's scope-discipline rule (no settled design exists).","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T11:29:07Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:40:00Z","closed_at":"2026-09-02T11:40:00Z","close_reason":"Implemented internal/domain/workflow/triage.go: a cheap classify-only-once AgentStage (still runs StagePrepareWorktree -- AgentStage requires tc.Dir to mount into the container, no cheaper primitive exists) that either closes a task needing no code change (reusing the CloseIssue/StatusMerged pattern feasibility.go's OnResult already established for the same ctx-less constraint) or sets tc.Task.Workflow and requeues under the chosen workflow (implement/tdd/feasibility, defaulting to implement for a missing/unrecognized choice). Route()'s fallback (workflow.go) now prefers reg[\"triage\"] over reg[\"implement\"] when registered, falling back unchanged when it isn't -- fully backward compatible. Registered in skillbuild.builtins(). 9 new tests (triage_test.go, routing_test.go) plus the design doc at docs/prds/dynamic-workflow-triage.md. task check clean.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-rwzo","title":"Token usage totals mislead: raw prompt sum not netted against cache hits","description":"Confirmed on production task 6 (2026-09-02, carina): dashboard/PR summary showed '14 iterations · 405,004 tokens · 400,021 prompt · 4,983 completion · 360,018 cached'. Cross-checked against the per-iteration daemon log: nothing is double-counted or hardcoded -- the totals are the correct sum of 14 real, separately-billed API calls with growing context. But 360,018 of the 400,021 'prompt tokens' shown were cache hits (billed at a steep discount), not full price -- real fresh spend was ~40,003 tokens. Showing only the raw prompt-token sum makes every agent run's cost read roughly 10x worse than what was actually billed, everywhere this aggregate surfaces (PR body, dashboard timeline).\n\nSeparately (real, not just cosmetic cost): StageBaselineGate's retry-mission prompt re-injected the ENTIRE go test ./... output -- hundreds of lines covering every passing package -- into every retry iteration's prompt, not just the failing ones. Direct mechanical contributor to the growing per-iteration prompt sizes.","design":"TaskContext.RunUsage (in-memory, not persisted -- Task.TokensUsed remains authoritative) accumulates agentexec.Usage across every agent run in one workflow execution. formatTokenUsage(total, usage) renders 'N tokens (F fresh + C cached)' with a plain fallback. extractFailingGateOutput(s) strips go test 'ok' package lines, only when it recognizes --- FAIL:/FAIL\\t markers, else returns input unchanged. Known gap: a task resumed after a daemon restart mid-workflow loses RunUsage and falls back to the plain total -- an honest degrade, not a bug; persisting the breakdown would need a store migration for a purely presentational value, not worth it yet.","acceptance_criteria":"PR bodies and the dashboard timeline show a fresh-vs-cached breakdown (or an equivalent net figure) instead of a raw prompt-token sum, falling back gracefully when no usage breakdown is available. Gate-retry mission prompts drop passing-package output, keeping only failure-relevant content, with graceful degradation for non-Go gates or unrecognized output shapes. task check passes.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:28:39Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:28:49Z","closed_at":"2026-09-02T11:28:49Z","close_reason":"Added TaskContext.RunUsage + accumulateUsage (agent.go, implement.go's baseline-fix branch) and formatTokenUsage (workflow.go), wired into implement.go's and tdd.go's PR-body footers plus ui/src/tasks/timeline-event.js's agent_finish rendering (raw prompt replaced with computed fresh = prompt - cached). Added extractFailingGateOutput (workflow.go) trimming go test 'ok' package lines from StageBaselineGate's retry mission, degrading to unchanged output when no --- FAIL:/FAIL\\t marker survives the filter. 5 new Go tests, 1 updated JS test. task check clean, 100/100 JS tests.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-n2pv","title":"Dashboard Logs page never surfaces per-task attempt-log detail","description":"internal/webui/api_tasks_logs.go's handleTaskLogs (GET /api/tasks/{id}/logs) was fully working -- internal/logging/reader.go's decode() already captures every JSON field generically into Entry.Fields (stage, tokens, iterations, model, stop_reason, everything). But no frontend code called it: ui/src/logs/logs.js (the dashboard's only Logs page) exclusively called api.logs(), the daemon-wide feed, which only carries the daemon's own component-scoped Info/Warn/Error lines -- never the rich per-stage/per-agent-run detail that lives in a task's own per-attempt log file. An operator could never see why a specific task took as long as it did, what each workflow stage did, or its token spend breakdown from the dashboard, even though the daemon already recorded and could already serve all of it. Discovered while investigating production task 6 (2026-09-02, archie-core-95dj).","acceptance_criteria":"A task's persisted attempt log (stage timings, iteration counts, token/prompt/completion/cached breakdowns, model) is visible from the dashboard task view. Reuses the daemon-wide log page's row-rendering logic rather than duplicating it. Handles disabled/empty/error states without crashing. task check (including task test:ui) passes.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:26:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:26:52Z","closed_at":"2026-09-02T11:26:52Z","close_reason":"Added ui/src/base/log-row.js (row rendering extracted out of logs.js, shared -- second consumer per CLAUDE.md), ui/src/tasks/task-logs.js (taskLogPanel handling loading/error/disabled/empty/populated states), api.taskLogs() in ui/src/base/api.js, and a collapsible 'Attempt log' section wired into each task's existing timeline drill-down in ui/src/tasks/tasks.js -- lazily fetched on first expand. New tests: ui/test/log-row.test.js, ui/test/task-logs.test.js. task check clean, 100/100 JS tests.","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
|
||||
@@ -53,6 +53,13 @@ func (t *activityTracker) record(name string, at time.Time, actions []Action) {
|
||||
|
||||
merged := make([]Action, 0, len(actions)+len(a.Recent))
|
||||
for _, action := range slices.Backward(actions) {
|
||||
// A curator engine may not stamp its own actions (no clock
|
||||
// dependency wired in); the pass's own "at" is the authoritative
|
||||
// time for every action it produced, so backfill rather than let
|
||||
// a zero time.Time reach the wire as "105694 wks ago".
|
||||
if action.At.IsZero() {
|
||||
action.At = at
|
||||
}
|
||||
merged = append(merged, action)
|
||||
}
|
||||
merged = append(merged, a.Recent...)
|
||||
|
||||
@@ -70,6 +70,28 @@ func TestActivityTrackerAccumulatesAcrossRuns(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A curator engine that has no clock of its own (skillcurator) leaves
|
||||
// Action.At zero. record must backfill it from the pass's own timestamp so
|
||||
// it never reaches the wire as time.Time's zero value, which the dashboard
|
||||
// renders as a nonsense "105694 wks ago".
|
||||
func TestActivityTrackerBackfillsZeroActionTime(t *testing.T) {
|
||||
tr := newActivityTracker()
|
||||
at := time.Date(2026, 1, 1, 12, 0, 0, 0, time.UTC)
|
||||
|
||||
tr.record("c", at, []Action{{Type: "skill.normalized", Detail: "d", Reason: "r"}})
|
||||
|
||||
got, ok := tr.snapshot("c")
|
||||
if !ok {
|
||||
t.Fatalf("snapshot(c) ok = false, want true")
|
||||
}
|
||||
if got.Recent[0].At.IsZero() {
|
||||
t.Fatalf("Recent[0].At is zero, want backfilled to %v", at)
|
||||
}
|
||||
if !got.Recent[0].At.Equal(at) {
|
||||
t.Fatalf("Recent[0].At = %v, want %v", got.Recent[0].At, at)
|
||||
}
|
||||
}
|
||||
|
||||
func TestActivityTrackerCapsRecentActions(t *testing.T) {
|
||||
tr := newActivityTracker()
|
||||
at := time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
@@ -171,6 +171,7 @@ func (c *Curator) reviewOne(ctx context.Context, engine domainmemory.MemoryEngin
|
||||
}
|
||||
|
||||
return &curator.Action{
|
||||
At: c.host.Clock.Now(),
|
||||
Type: ActionExtracted,
|
||||
Detail: fmt.Sprintf("%s: wrote %d observation(s)", sessionID, len(facts)),
|
||||
Reason: "session active since last pass",
|
||||
|
||||
@@ -157,6 +157,9 @@ func TestPassExtractsAndWritesObservations(t *testing.T) {
|
||||
if len(res.Actions) != 1 || res.Actions[0].Type != ActionExtracted {
|
||||
t.Fatalf("Actions = %#v, want one %s", res.Actions, ActionExtracted)
|
||||
}
|
||||
if want := time.Unix(1000, 0); !res.Actions[0].At.Equal(want) {
|
||||
t.Errorf("Actions[0].At = %v, want %v (from the curator's clock, not zero)", res.Actions[0].At, want)
|
||||
}
|
||||
if len(engine.writes) != 1 {
|
||||
t.Fatalf("writes = %#v, want exactly 1", engine.writes)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user