Skip to content

session: a restored task has no landing time on its record, so it is dated in the future and the tasks place drops it #530

Closed

Description

@santoshkumarradha

What happened

2026-09-03, base dev@f38d6c01a.

A task restored from a checkpoint is dated in the future, and the tasks place then drops
it off the page.
A piece of work that ran for twelve minutes and finished twenty minutes
before the window was closed comes back, on the next open, stamped twelve minutes from
now — and the place's own date window reads that as tomorrow and does not draw the row
at all. The task that needed a person went missing from the tasks place entirely while its
shorter siblings sat above it saying now.

Both halves of that come from the same hole: a landing time is being derived from when a
window opened, because the record does not carry one.

The derivation, in internal/tui3/place_tasks.go's taskNodeEnded:

at := node.began
if at.IsZero() {
	at = node.met
}
...
return at.Add(node.elapsed)

met is the moment this terminal first heard of the node. For a node replayed out of a
checkpoint that is the moment the person sat down, so met + elapsed is a landing time in
the future. The drop is one line in internal/tui3/tasksplace.go's readTasks:

if !r.win.Holds(tasksEntryAt(item.entry, now)) {
	continue
}

UsageWindow.Holds (internal/session/usage_spend.go) is !at.Before(From) && at.Before(next bucket after To), so an instant past the end of today is not held and the
row is skipped — not filed under earlier, not folded: gone.

The now on the siblings is the same absence seen from the other side: tasksEntryAt
answers the moment of the reading for a row with no stamp, which is right for a window
that cannot judge an undated row and wrong for sinceAt, which then prints now over
work that nothing is doing.

This issue is the ENGINE half only

The surface half is already landing in the ui/polish-v0 wave: taskNodeEnded stops
falling back to met for a restored node, and the age field reads a stamp rather than
substituting the reading's clock, so a row with no recorded landing time draws nothing
where it used to draw now (the emptiness law). That change makes the surface honest and
makes it read the record only. It cannot make the record right, and that is what is left.

The coordinator's ruling is that a landing time is a fact of the record, carried across
the restore, and never derived from the window's open time.
So this issue is the whole of
what remains, and none of it is in internal/tui3.

Where

Everything below is internal/session.

  • TaskNode.started (search started time.Time in task_run.go) is the only real
    start, and it is set exactly once, at the transition to TaskRunning in
    TaskGraph.startLocked (search node.started = time.Now()). It is not written to the
    checkpoint.
    taskRecord in task_store.go carries ElapsedMS and no stamp at all,
    and the comment on the neighbouring elapsed field concedes the consequence in so many
    words: "a node rehydrated from a checkpoint has no started to measure from and this is
    the age it had."
  • TaskNode.runStart() in taskground.go (search func (n *TaskNode) runStart)
    already makes the same guess the surface was making — time.Now().Add(-n.elapsed) — and
    says so: "its window is measured back from now, which lands LATER than the truth." It
    chooses that direction deliberately for its own purpose (a ground overlap: a false alarm
    costs more than a quiet miss), so it is evidence that the fact is missing rather than a
    second bug, but it is a second reader that would rather have the stamp.
  • TaskIndexEntry.EndedAt in task_index.go is the durable landing time — "when it
    landed, and it is zero for a row merged in live"
    — and it survives a restart only for
    a node whose row actually reached the project's tasks.jsonl
    . For a row rebuilt from
    the graph, (*TaskNode).indexEntryLocked (search A landed node's EndedAt is now minus nothing) stamps it entry.EndedAt = time.Now(), and its own comment concedes the shape:
    the original stamp is "where the file's row is", which is precisely what a node whose
    session died before the row was written does not have.
  • TaskNotice in task_contract.go carries Elapsed time.Duration and no landing or
    starting stamp — its only time.Time is Deadline, a proposal field — so even where the
    engine does know when the work landed, the surface has nothing to read it out of.

The fix

Three changes, all in internal/session, and the shape is one sentence: the record keeps
the stamps, and everything downstream prefers them to time.Now().

  1. taskRecord grows a landing stamp (and, for the same money, a start), written when the
    node is snapshotted and restored onto TaskNode when it is rehydrated. It is an added,
    omitted-when-empty JSON field, so taskFileVersion does not move and an older
    checkpoint decodes exactly as it always did — the same discipline runRecord already
    follows for Kind.
  2. (*TaskNode).indexEntryLocked prefers the node's own restored stamp over time.Now(),
    and stamps time.Now() only where it genuinely is the landing instant — the live
    transition, which is what (*Agent).recordTaskIndex is for.
  3. TaskNotice grows EndedAt (and StartedAt) beside Elapsed, so a surface drawing a
    restored row has a fact to draw instead of a subtraction to perform.

TaskNode.runStart() keeps its guess as a fallback and should use the restored stamp when
there is one; the comment there should stop describing the guess as the only option.

What a person sees: a task that landed at 23:28 says it landed at 23:28 whether they are
looking at it at 23:30 or the following week, it sits in the tasks place under the day it
actually landed on, and a task whose landing time genuinely was never recorded draws no
age at all
rather than now.

Replication

Deterministic (no model, no key that is ever used). Everything is in the repository.

  1. make build, then make a throwaway home with a conversation in it:
    make demo-home DEMO_HOME=/tmp/aforge-stamp and quit the surface it opens.

  2. Beside any conversation's transcript.jsonl under
    /tmp/aforge-stamp/.aforge/v3/projects/*/*/, write the checkpoint a task that ran for
    twelve minutes and landed leaves behind — this is exactly what taskRecord writes
    today, and the thing to notice is that there is nowhere in it to put when:

    {"type":"tasks","version":1,"seq":10,
     "nodes":[{"id":1,"title":"Rotate the staging certificate","state":"unverified",
               "elapsed_ms":720000}],
     "runs":[]}

    Leave that project's tasks.jsonl absent, which is what a session that died before its
    index row was written looks like.

  3. Reopen that conversation
    (cd /tmp/aforge-stamp/<project> && HOME=/tmp/aforge-stamp <repo>/bin/aforge, enter on
    the card) and open the tasks place with /history.

What a developer sees today: the row is not on the page. The head sentence counts the
work the window holds and this task is not among it, because the surface has dated it
<the moment you pressed enter> + 12m and the window ends at the end of today. Widen the
window with shift+← as far as it goes and it does not come back — a future stamp is past
every window's far edge, not behind its near one. Meanwhile any row in that place with no
stamp at all reads now.

Field (real models, needs OPENROUTER_API_KEY, a few cents and a few minutes). The
product version, and the one that was actually hit: in a conversation, hand aforge a task
and let it land — one that ends needs your look is the case that hurts, because that row
is the one somebody has to come back to. Quit with ctrl+c twice. Reopen the same
conversation and open the tasks place. The task is not on it. Its shorter siblings, if any
are undated, say now.

Acceptance

  • e2e: through the real surface on the deterministic home above — after reopening the
    conversation, the tasks place draws the row Rotate the staging certificate, and its age
    cell reads the age measured from the landing time on its own record (12m past the
    recorded landing, not now and not a future instant). Today the string
    Rotate the staging certificate does not appear on the page at all.
  • e2e: the control — a checkpoint carrying elapsed_ms and no landing stamp (every
    file written before this change) still resumes, and its row draws no age cell at all:
    the page must not contain now for that row, and the row must still be on the page. That
    is the emptiness law, and it is what the surface half in ui/polish-v0 already does once
    the record stops lying to it.
  • Unit: a checkpoint written by taskStore and read back reproduces the node's landing
    time exactly — restored.EndedAt == original.EndedAt — and the round trip of a
    checkpoint written before this field existed still decodes at taskFileVersion 1 with
    a zero stamp and a preserved ElapsedMS.
  • Unit: the structural law — every path that stamps a TaskIndexEntry.EndedAt with
    time.Now() is the live landing transition. A rebuilt row takes the record's stamp when
    it has one, so (*TaskNode).indexEntryLocked on a restored node returns the recorded
    instant rather than the instant it was called.
  • The manual pages that describe reading a task's age
    (internal/manual/chat/reading-a-task-page.md, internal/manual/chat/tasks.md) quote
    the new behaviour — a landing time is what the record says, and no recorded time draws
    nothing — and the change entry's invalidates names what people believed before.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added
    bug
    area:session
    on Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:sessionbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions