Skip to content

feat(owner): resume the same tick session within a calendar day - #97

Open
anshulsao wants to merge 1 commit into
mainfrom
owner-tick-session-resume
Open

feat(owner): resume the same tick session within a calendar day#97
anshulsao wants to merge 1 commit into
mainfrom
owner-tick-session-resume

Conversation

@anshulsao

Copy link
Copy Markdown
Member

What

Owner ticks are sessionless today — cmdOwnerTick starts a fresh harness
session on every tick, cold-reading the charter + journal each time. This makes
the tick resume the same session within a local calendar day (fresh each new
day), so within-day ticks keep warm in-context continuity while the journal
remains the cross-day / cross-crash memory.

How

  • flowdbowners.tick_session_id, owners.tick_session_date added to the
    CREATE-TABLE DDL and as an idempotent ALTER TABLE migration; threaded through
    OwnerCols / scan / insert / update; new targeted SetOwnerTickSession() write
    (only its two columns + updated_at, so it can't clobber the concurrent
    tick_pid / last_tick_* bookkeeping).
  • harness — new interface methods SkipPermissionsRunSession(sid, prompt)
    (claude --session-id <id>, pins a resumable session at the deterministic
    (cwd, sid) transcript path) and SkipPermissionsResume(sid, prompt)
    (claude --resume <id>). Codex mirrors both via codex exec resume <id>
    (idempotent on the thread id). The argv exec is behind an injectable var for
    tests.
  • owner_tickcmdOwnerTick resumes when tick_session_date == today,
    otherwise mints a fresh pinned session id and records {id, today}. Overlap
    guard, scheduler (tick-due), self-pacing (owner next), and journal
    discipline are unchanged. Crash-safe: a dead tick exits; the next tick resumes
    same-day or cold-starts.

Why

Within-day continuity without a long-running process: warmer context and better
cache economics than cold-starting every tick, while a daily reset bounds
transcript growth and the durable journal keeps memory across resets/crashes.

Testing

go build ./..., go vet ./..., go test ./... all green. Added: flowdb
column + migration tests, owner_tick resume-vs-fresh tests (override the runner
to capture mode + session id), and claude argv tests (--session-id / --resume).

Verified end-to-end against the built binary with a throwaway echo owner whose
charter writes a per-session marker word + an in-session tick counter:

tick trigger session id marker in-session N
1 first 78646180… vellichor 0
2 same day 78646180… (unchanged) vellichor (recalled) 1
3 backdated to yesterday 048eefdd… (new) sassafras (no memory) 0

Tick 2 recalling "vellichor" and incrementing N is only possible from the
resumed in-context transcript; tick 3's new id + new marker confirms the
new-day-fresh branch.

Migration note

Purely additive (two nullable columns). Backward-compatible — an older binary
ignores the new columns.

🤖 Generated with Claude Code

Owner ticks were sessionless — a fresh harness session every tick, cold-reading
the charter + journal each time. This resumes the SAME session within a local
calendar day (fresh each new day), so within-day ticks keep warm context while
the journal stays the cross-day / cross-crash memory.

- flowdb: owners.tick_session_id + tick_session_date (CREATE-TABLE DDL and an
  idempotent ALTER migration); targeted SetOwnerTickSession write that can't
  clobber the concurrent tick_pid / last_tick bookkeeping.
- harness: SkipPermissionsRunSession (claude --session-id <id>, pins a resumable
  session) and SkipPermissionsResume (claude --resume <id>); codex mirrors both
  via `codex exec resume <id>`. argv builder is injectable for tests.
- owner_tick: cmdOwnerTick resumes when tick_session_date == today, else mints a
  fresh pinned session id and records {id, today}. Overlap guard, scheduler,
  self-pacing, and journal discipline unchanged; crash-safe (dead tick exits,
  next tick resumes same-day or cold-starts).

Verified end-to-end with a throwaway echo owner (marker word + in-session counter):
  tick 1 (fresh):         session A, marker=vellichor, in-session N=0
  tick 2 (same day):      session A UNCHANGED, marker=vellichor recalled, N=1
  tick 3 (backdated day): session B (new), marker=sassafras, N=0

Tests: go build/vet/test ./... green; added flowdb column/migration tests,
owner_tick resume-vs-fresh tests, and claude argv (--session-id/--resume) tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant