memory(B): task_run + task_checkpoint + Codex packet templates (highest-impact fix for #17 flow loop) #460

Closed
opened 2026-05-24 23:35:21 +02:00 by claude · 3 comments
Collaborator

Why this matters (highest ROI of Memory Control Plane)

Per competitive brief + GPT 5.5 Pro consultation + operator's #17 flow loop:

"gadam z iskrą, wpadam na pomysł, iskra zapisuje, potem ja mówię tobie [claude] rozbuduj, a potem ty mi mówisz, wydeleguj do codexa, a potem codex się gubi, a potem ja mówię claude pomóż, a potem wklejam 2-3 serie rozmów, a potem codex kończy, ale dwa nowe follow-upy wpadają. i tak się kręci 😂"

Diagnosis (GPT + claude agreed):

  1. Za luźny task packet
  2. Brak stable task state
  3. Brak "when stuck" protocol
  4. Brak snapshotu "gdzie jestem po 40 minutach"
  5. Brak automatycznego odzyskania contextu przez claude

This issue ships A + B + C from that diagnosis. Targets the rescue cycle directly.

What to ship

Schema (main postgres:16.12-alpine)

create type task_run_status as enum (
  'planned', 'running', 'blocked', 'succeeded', 'failed', 'abandoned'
);

create table task_run (
  id uuid primary key default gen_random_uuid(),
  task_key text not null unique,
  cousin text not null,
  repo text,
  branch text,
  issue_ref text,
  pr_ref text,
  objective text not null,
  status task_run_status not null default 'planned',
  source_refs jsonb not null default '[]',
  created_at timestamptz not null default now(),
  started_at timestamptz,
  completed_at timestamptz
);

create type checkpoint_kind as enum (
  'session_start', 'handoff_created', 'task_start',
  'after_inspection', 'before_risky_change', 'after_mutation',
  'after_tests', 'blocked', 'rescue_request',
  'task_end', 'session_end', 'pre_compaction', 'post_compaction'
);

create table task_checkpoint (
  id uuid primary key default gen_random_uuid(),
  task_run_id uuid references task_run(id) on delete cascade,
  checkpoint_kind checkpoint_kind not null,
  sequence_no integer not null,
  cousin text not null,
  summary_md text not null,
  state_json jsonb not null default '{}',
  refs_json jsonb not null default '{}',
  created_at timestamptz not null default now(),
  unique (task_run_id, sequence_no)
);

Templates (markdown w state/templates/)

  • CODEX_TASK_PACKET.md (per GPT format in strategy doc)
  • CODEX_CHECKPOINT.md (minimal observable state)
  • CLAUDE_RESCUE_PROTOCOL.md (how claude reconstructs Codex state)

CLI (jeśli platformctl ready)

  • platformctl memory checkpoint create --task <id> --kind <kind> (writes to task_checkpoint)
  • platformctl memory brief --task <id> (reads all checkpoints + task_run + entity refs → reconstruction brief)

Coupling option (per claude answer Q2)

Start with option (c) no coupling: claude (Pan Herbatka) creates checkpoints in Codex's name based on observable artifacts (PR changes, commit msgs, transcript paste from operator). Zero infra change.

Escalate to option (a) shell wrapper (platformctl codex-task start/checkpoint/end) when platformctl has the subcommands AND operator wants automation.

Acceptance criteria

  • Schema migration: task_run + task_checkpoint tables in main Postgres
  • Templates committed: CODEX_TASK_PACKET.md + CODEX_CHECKPOINT.md + CLAUDE_RESCUE_PROTOCOL.md
  • ONE real W7/M07 task uses task envelope + checkpoints end-to-end
  • Success criterion: claude can reconstruct Codex state from checkpoint without pasted transcript
  • If platformctl: platformctl memory checkpoint create + platformctl memory brief --task <id> subcommands
  • Migration runbook for adding tables to main Postgres without disrupting Codex's W7 work

Dependencies

  • Issue A (Memory Control Plane ADR) — should land first or in parallel; this issue references the ADR's boundaries
  • No graph-lite needed (Issue D, later)
  • No procedural registry needed (Issue C, parallel OK)
  • No AGE needed (Issue E, much later)

Spec sources

  • state/strategy/memory-control-plane-2026-05-24.md
  • state/spike-understand-anything/07-gpt5pro-memory-architecture-brief.md
  • Operator #17 flow loop quote (głosówka 2026-05-24)
  • W3a/b/c restore drills (PR #430/#431/#432) — main Postgres restore proven

Out of scope

  • Procedural registry (Issue C, parallel)
  • Entity/alias/edge/claim graph (Issue D, post 2-3 weeks)
  • AGE migration (Issue E, post graph-lite usage)
  • Full automation of Codex wrapper (start with option (c) zero-coupling)

Tier per ADR-0007: Medium — schema + templates + 1 end-to-end test. Touches main Postgres (W3-tested), no production runtime risk.

## Why this matters (highest ROI of Memory Control Plane) Per competitive brief + GPT 5.5 Pro consultation + operator's #17 flow loop: > *"gadam z iskrą, wpadam na pomysł, iskra zapisuje, potem ja mówię tobie [claude] rozbuduj, a potem ty mi mówisz, wydeleguj do codexa, a potem codex się gubi, a potem ja mówię claude pomóż, a potem wklejam 2-3 serie rozmów, a potem codex kończy, ale dwa nowe follow-upy wpadają. i tak się kręci 😂"* Diagnosis (GPT + claude agreed): 1. Za luźny task packet 2. Brak stable task state 3. Brak "when stuck" protocol 4. Brak snapshotu "gdzie jestem po 40 minutach" 5. Brak automatycznego odzyskania contextu przez claude **This issue ships A + B + C from that diagnosis.** Targets the rescue cycle directly. ## What to ship ### Schema (main `postgres:16.12-alpine`) ```sql create type task_run_status as enum ( 'planned', 'running', 'blocked', 'succeeded', 'failed', 'abandoned' ); create table task_run ( id uuid primary key default gen_random_uuid(), task_key text not null unique, cousin text not null, repo text, branch text, issue_ref text, pr_ref text, objective text not null, status task_run_status not null default 'planned', source_refs jsonb not null default '[]', created_at timestamptz not null default now(), started_at timestamptz, completed_at timestamptz ); create type checkpoint_kind as enum ( 'session_start', 'handoff_created', 'task_start', 'after_inspection', 'before_risky_change', 'after_mutation', 'after_tests', 'blocked', 'rescue_request', 'task_end', 'session_end', 'pre_compaction', 'post_compaction' ); create table task_checkpoint ( id uuid primary key default gen_random_uuid(), task_run_id uuid references task_run(id) on delete cascade, checkpoint_kind checkpoint_kind not null, sequence_no integer not null, cousin text not null, summary_md text not null, state_json jsonb not null default '{}', refs_json jsonb not null default '{}', created_at timestamptz not null default now(), unique (task_run_id, sequence_no) ); ``` ### Templates (markdown w `state/templates/`) - `CODEX_TASK_PACKET.md` (per GPT format in strategy doc) - `CODEX_CHECKPOINT.md` (minimal observable state) - `CLAUDE_RESCUE_PROTOCOL.md` (how claude reconstructs Codex state) ### CLI (jeśli platformctl ready) - `platformctl memory checkpoint create --task <id> --kind <kind>` (writes to task_checkpoint) - `platformctl memory brief --task <id>` (reads all checkpoints + task_run + entity refs → reconstruction brief) ### Coupling option (per claude answer Q2) Start with **option (c) no coupling**: claude (Pan Herbatka) creates checkpoints in Codex's name based on observable artifacts (PR changes, commit msgs, transcript paste from operator). Zero infra change. Escalate to **option (a) shell wrapper** (`platformctl codex-task start/checkpoint/end`) when `platformctl` has the subcommands AND operator wants automation. ## Acceptance criteria - [ ] Schema migration: `task_run` + `task_checkpoint` tables in main Postgres - [ ] Templates committed: CODEX_TASK_PACKET.md + CODEX_CHECKPOINT.md + CLAUDE_RESCUE_PROTOCOL.md - [ ] ONE real W7/M07 task uses task envelope + checkpoints end-to-end - [ ] Success criterion: **claude can reconstruct Codex state from checkpoint without pasted transcript** - [ ] If platformctl: `platformctl memory checkpoint create` + `platformctl memory brief --task <id>` subcommands - [ ] Migration runbook for adding tables to main Postgres without disrupting Codex's W7 work ## Dependencies - Issue A (Memory Control Plane ADR) — should land first or in parallel; this issue references the ADR's boundaries - No graph-lite needed (Issue D, later) - No procedural registry needed (Issue C, parallel OK) - No AGE needed (Issue E, much later) ## Spec sources - `state/strategy/memory-control-plane-2026-05-24.md` - `state/spike-understand-anything/07-gpt5pro-memory-architecture-brief.md` - Operator #17 flow loop quote (głosówka 2026-05-24) - W3a/b/c restore drills (PR #430/#431/#432) — main Postgres restore proven ## Out of scope - Procedural registry (Issue C, parallel) - Entity/alias/edge/claim graph (Issue D, post 2-3 weeks) - AGE migration (Issue E, post graph-lite usage) - Full automation of Codex wrapper (start with option (c) zero-coupling) Tier per ADR-0007: **Medium** — schema + templates + 1 end-to-end test. Touches main Postgres (W3-tested), no production runtime risk.
Collaborator

M07 triage result: hold. Iskra's metadata-only domain reply recommends prioritizing #357/#459/#461 before task_run/task_checkpoint templates, with reason prioritize_memory_architecture_before_packet_templates. No runtime mutation was performed.

M07 triage result: hold. Iskra's metadata-only domain reply recommends prioritizing #357/#459/#461 before task_run/task_checkpoint templates, with reason `prioritize_memory_architecture_before_packet_templates`. No runtime mutation was performed.
Author
Collaborator

Status correction (claude, from a grounded plan-review) — this is OPEN, and "verify-then-close" must be docs-only.

The X3 plan logs #460 as "verified-then-closed" — factually wrong. Verified live: #460 is OPEN, carries the proposed (awaiting-human-review) label, codex_ready=false, and its acceptance criteria still include unsatisfied live-Postgres migration items ("Schema migration: task_run + task_checkpoint tables in main Postgres", "Migration runbook").

Bound the close step:

  • "verify then close" = confirm the docs/spec landed via the (confirmed-merged) PR #636 only.
  • It must NOT execute any main-Postgres migration to satisfy AC.
  • The live-DB apply for these tables remains operator-gated and is represented by #661's authored, un-applied migration.

Don't close this as a clerical formality while a live-DB AC is unmet. Cleanest: move the migration/runbook AC to #661 (where the gated apply lives) and close #460 on the spec-only AC — or leave it open behind the operator gate.

**Status correction (claude, from a grounded plan-review) — this is OPEN, and "verify-then-close" must be docs-only.** The X3 plan logs #460 as "verified-then-closed" — **factually wrong**. Verified live: #460 is **OPEN**, carries the `proposed` (awaiting-human-review) label, `codex_ready=false`, and its acceptance criteria still include **unsatisfied live-Postgres migration items** ("Schema migration: task_run + task_checkpoint tables in main Postgres", "Migration runbook"). **Bound the close step:** - "verify then close" = confirm the docs/spec landed via the (confirmed-merged) **PR #636 only**. - It must **NOT** execute any main-Postgres migration to satisfy AC. - The live-DB apply for these tables remains **operator-gated** and is represented by **#661's authored, un-applied migration**. Don't close this as a clerical formality while a live-DB AC is unmet. Cleanest: move the migration/runbook AC to #661 (where the gated apply lives) and close #460 on the spec-only AC — or leave it open behind the operator gate.
Author
Collaborator

Closing with evidence — spec deliverable landed.

  • state/memory/task-run-schema.md (task_run + task_checkpoint contract) + CODEX_TASK_PACKET.md + CODEX_CHECKPOINT.md on main via merged PR #636.
  • ↪️ The live-Postgres migration AC (creating the tables) is re-homed to #661 (impl) + #688 (operator-approved pending-applies tracker) — explicitly tracked + gated, NOT dropped.

Closing on the spec deliverable; the table creation is owned by #688 (close-on-live-verified). Verify-and-close, not close-on-assumption.

**Closing with evidence — spec deliverable landed.** - ✅ `state/memory/task-run-schema.md` (task_run + task_checkpoint contract) + `CODEX_TASK_PACKET.md` + `CODEX_CHECKPOINT.md` on `main` via **merged PR #636**. - ↪️ The live-Postgres migration AC (creating the tables) is **re-homed to #661 (impl) + #688 (operator-approved pending-applies tracker)** — explicitly tracked + gated, NOT dropped. Closing on the spec deliverable; the table creation is owned by #688 (close-on-live-verified). *Verify-and-close, not close-on-assumption.*
Sign in to join this conversation.
No labels
W6d-automerge-calibration
agent/claude-code
agent/codex
agent/hermes
agent/iskra
agent/ollama
agent/patchwarden
automerge-candidate
class/security-sensitive
cutover-gate
dependency/blocked
dependency/blocks-others
dependency/cross-repo
dependency/needs-confirmation
domain:agents
domain:ci
domain:docs
domain:forgejo
domain:infra
domain:memory
domain:runtime
domain:signal
domain:ux
flow/architecture
flow/blocked
flow/deployed
flow/done
flow/implementation
flow/intake
flow/maintained
flow/observed
flow/ready
flow/refining
flow/retired
flow/review
iterating
judge/codex-candidate
judge/hermes-candidate
judge/low-confidence
judge/needs-refinement
judge/operator-needed
judge/p0
judge/p1
judge/p2
judge/p3
judge/park
judge/patchwarden-candidate
judge/stale-priority
kind/adr
kind/bug
kind/chore
kind/feature
kind/infra
kind/ops
kind/refactor
kind/research
large-impact
merge/auto
merge/manual
merge/manual-dependency-conflict
merge/manual-failing-tests
merge/manual-merge-conflict
merge/manual-missing-review
merge/manual-operator-preference
merge/manual-red-zone
merge/manual-security-sensitive
merge/manual-unclear-scope
merge/manual-unknown
meta
mode:operator-only
mode:patchwarden-iskra-approved
mode:safe-auto
needs-operator-decision
needs-triage
not-ready
observed/erroring
observed/needs-followup
observed/pending
observed/retire-candidate
observed/unused
observed/used
operator-emotional
owner-attention
phase/02
phase/03
priority:p0
priority:p1
priority:p2
priority:p3
proposed
ready-for-agent
ready-for-operator
recovery
review:claude-reviewed
review:codex-reviewed
review:dziadek-reviewed
review:needs-human
risk/exposure
risk/process
risk/product
risk/runtime
safety:external-write
safety:no-prod-mutation
safety:prod-impact
safety:secret-touch
size/large
size/medium
size/small
size/tiny
size/unknown
source/adr
source/agent-generated
source/manual
source/operator-chat
source/voice-note
status:blocked
status:codex-ready
status:merged:pending-evidence
status:needs-evidence
status:operator-needed
status:parked
tier/full
tier/lite
tier/stacked
tier:0-platform-substrate
tier:1-iskra-value-layer
tier:2-tools-products-modules
type:bug
type:chore
type:docs
type:feat
type:policy
type:research
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pdurlej/platform#460
No description provided.