feat(memory): add control plane foundation #679

Merged
pdurlej merged 1 commit from codex/m07-memory-foundation into main 2026-06-02 07:35:39 +02:00
Collaborator

Canary status: missing - fire canary 3+3 manually before merge

Summary

Adds the first Memory Control Plane foundation: reviewed SQL migration artifact, platformctl memory read helpers, checkpoint hook endpoints, and tests.

Closes #661
Closes #663
Refs #662

I am intentionally not closing #460/#461: those remain docs/spec verification issues unless Claude/operator confirms their AC separately. I am also not closing #662 yet because this PR adds hook endpoints and registration documentation, but does not install them into live Claude/Codex harness config.

Canary Context Pack

Product story

Codex and Claude need external task memory so future sessions can reconstruct state without transcript paste, while keeping live Postgres and runtime hooks behind explicit gates.

What changed

  • Added migrations/20260601_memory_control_plane.sql for task runs, checkpoints, task events, and procedure registry tables.
  • Added append-only triggers for checkpoint/procedure/event tables.
  • Added platformctl memory brief, procedures, and contradictions.
  • Added platformctl memory hook session-start/pre-compact/post-compact/pre-tool-use.
  • Added tests for migration completeness, false-green prevention, procedure seed parsing, checkpoint roundtrip, and sacred-path pre-tool guard.

Why it changed

M07 needs concrete schema and local command surfaces before live Postgres apply or harness registration can be safely gated.

Files touched

  • migrations/20260601_memory_control_plane.sql
  • control-plane/platformctl/memory.py
  • control-plane/platformctl/cli.py
  • control-plane/platformctl/tests/test_memory_control_plane.py
  • state/memory/hooks/README.md

Relevant context

  • decisions/0025-memory-control-plane.md
  • state/memory/task-run-schema.md
  • state/memory/procedure-registry-schema.md
  • state/memory/CODEX_TASK_PACKET.md
  • state/memory/CODEX_CHECKPOINT.md
  • state/memory/procedures-seed-v0.md

Runtime evidence

No live Postgres migration was applied. No runtime hook was installed. Verification is local only.

Known constraints

pre-compact writes a local checkpoint artifact when invoked; it does not connect to Postgres. Live Postgres apply remains operator-gated.

Explicit out-of-scope

  • Live Postgres apply
  • Runtime hook installation
  • Honcho mutation
  • Iskra memory mutation
  • Closing #460/#461 without their separate docs AC verification

Requested decision

Review whether this is sufficient as the M07 local foundation and migration artifact before a later live apply gate.

Merge blockers

  • Secret-valued columns in memory tables
  • Non-append-only checkpoint/procedure/event tables
  • Hidden live DB dependency
  • Any destructive/runtime operation

Spec sources read

  • decisions/0025-memory-control-plane.md - architecture and invariants
  • state/memory/task-run-schema.md - task/checkpoint schema
  • state/memory/procedure-registry-schema.md - procedure registry schema
  • state/memory/procedures-seed-v0.md - seed procedures
  • state/memory/CODEX_TASK_PACKET.md - packet contract
  • state/memory/CODEX_CHECKPOINT.md - checkpoint contract
  • control-plane/platformctl/cli.py - CLI conventions

Validation

  • uv run pytest control-plane/platformctl/tests/test_memory_control_plane.py - 10 passed
  • PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli memory brief --json - exit 0
  • PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli validate all --json - exitCode 0
  • python3 -m py_compile control-plane/platformctl/memory.py control-plane/platformctl/cli.py - passed

Notes

uv refreshed tracked control-plane/platformctl.egg-info/* files in the local worktree during validation, but those generated changes are intentionally unstaged and not part of this PR.

Canary status: missing - fire canary 3+3 manually before merge ## Summary Adds the first Memory Control Plane foundation: reviewed SQL migration artifact, `platformctl memory` read helpers, checkpoint hook endpoints, and tests. Closes #661 Closes #663 Refs #662 I am intentionally not closing #460/#461: those remain docs/spec verification issues unless Claude/operator confirms their AC separately. I am also not closing #662 yet because this PR adds hook endpoints and registration documentation, but does not install them into live Claude/Codex harness config. ## Canary Context Pack ### Product story Codex and Claude need external task memory so future sessions can reconstruct state without transcript paste, while keeping live Postgres and runtime hooks behind explicit gates. ### What changed - Added `migrations/20260601_memory_control_plane.sql` for task runs, checkpoints, task events, and procedure registry tables. - Added append-only triggers for checkpoint/procedure/event tables. - Added `platformctl memory brief`, `procedures`, and `contradictions`. - Added `platformctl memory hook session-start/pre-compact/post-compact/pre-tool-use`. - Added tests for migration completeness, false-green prevention, procedure seed parsing, checkpoint roundtrip, and sacred-path pre-tool guard. ### Why it changed M07 needs concrete schema and local command surfaces before live Postgres apply or harness registration can be safely gated. ### Files touched - `migrations/20260601_memory_control_plane.sql` - `control-plane/platformctl/memory.py` - `control-plane/platformctl/cli.py` - `control-plane/platformctl/tests/test_memory_control_plane.py` - `state/memory/hooks/README.md` ### Relevant context - `decisions/0025-memory-control-plane.md` - `state/memory/task-run-schema.md` - `state/memory/procedure-registry-schema.md` - `state/memory/CODEX_TASK_PACKET.md` - `state/memory/CODEX_CHECKPOINT.md` - `state/memory/procedures-seed-v0.md` ### Runtime evidence No live Postgres migration was applied. No runtime hook was installed. Verification is local only. ### Known constraints `pre-compact` writes a local checkpoint artifact when invoked; it does not connect to Postgres. Live Postgres apply remains operator-gated. ### Explicit out-of-scope - Live Postgres apply - Runtime hook installation - Honcho mutation - Iskra memory mutation - Closing #460/#461 without their separate docs AC verification ### Requested decision Review whether this is sufficient as the M07 local foundation and migration artifact before a later live apply gate. ### Merge blockers - Secret-valued columns in memory tables - Non-append-only checkpoint/procedure/event tables - Hidden live DB dependency - Any destructive/runtime operation ## Spec sources read - `decisions/0025-memory-control-plane.md` - architecture and invariants - `state/memory/task-run-schema.md` - task/checkpoint schema - `state/memory/procedure-registry-schema.md` - procedure registry schema - `state/memory/procedures-seed-v0.md` - seed procedures - `state/memory/CODEX_TASK_PACKET.md` - packet contract - `state/memory/CODEX_CHECKPOINT.md` - checkpoint contract - `control-plane/platformctl/cli.py` - CLI conventions ## Validation - `uv run pytest control-plane/platformctl/tests/test_memory_control_plane.py` - 10 passed - `PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli memory brief --json` - exit 0 - `PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli validate all --json` - exitCode 0 - `python3 -m py_compile control-plane/platformctl/memory.py control-plane/platformctl/cli.py` - passed ## Notes `uv` refreshed tracked `control-plane/platformctl.egg-info/*` files in the local worktree during validation, but those generated changes are intentionally unstaged and not part of this PR.
feat(memory): add control plane foundation
All checks were successful
canary-required / collect-diff (pull_request) Successful in 3s
platformctl plan / auto-apply scope (pull_request) Successful in 17s
pyfallow / Pyfallow gate (control-plane) (pull_request) Successful in 15s
python-ci / Python 3.11 (pull_request) Successful in 36s
python-ci / Python 3.12 (pull_request) Successful in 38s
python-ci / Python 3.13 (pull_request) Successful in 37s
base-is-main / guard (pull_request) Successful in 1s
patchwarden-client-dry-run / collect-diff (pull_request) Successful in 3s
canary-required / canary (pull_request) Successful in 13s
patchwarden-client-dry-run / dry-run (pull_request) Successful in 16s
patchwarden-pr-sanity / sanity (pull_request) Successful in 5m4s
patchwarden-pr-sanity / collect-diff (pull_request) Successful in 3s
ec142d8890
Author
Collaborator

Patchwarden PR sanity

  • Status: advisory_findings
  • PR: 679
  • Commit: ec142d8890c72a9c476fac6ed7bd67a93bc41bc2
  • Security-sensitive label: present
  • Authority: advisory model review plus deterministic blockers only
  • 3+3 canary: still alive; this does not replace it

Deterministic findings

No deterministic findings.

Model reviewers

global-glm / glm-5.1:cloud

  • Status: ok

  • Verdict: NOT_OK

  • high task_checkpoint.completed type mismatch between SQL schema and Python checkpoint writer

    • Evidence: In migrations/20260601_memory_control_plane.sql line 89: completed text NOT NULL DEFAULT ''defines completed as scalar text. In control-plane/platformctl/memory.py line 167:"completed": completed or [] writes completed as a JSON array
    • Next: Change SQL schema completed text NOT NULL DEFAULT '' to completed text[] NOT NULL DEFAULT '{}' to match the Python array format and align with changed_files/followups pattern.
  • medium Missing indexes on foreign key columns in migration

    • Evidence: migrations/20260601_memory_control_plane.sql creates tables task_run_event (task_id REFERENCES task_run), task_checkpoint (task_id REFERENCES task_run), memory_procedure_version (slug REFERENCES memory_procedure), memory_procedure_event (sl
    • Next: Add CREATE INDEX statements for FK columns: task_run_event(task_id), task_checkpoint(task_id), memory_procedure_version(slug), memory_procedure_event(slug), memory_procedure_event(task_id), memory_procedure_embedding(slug).
  • low Hardcoded repo name in memory_brief output

    • Evidence: control-plane/platformctl/memory.py line 148: "repo": "pdurlej/platform" is hardcoded rather than derived from git or passed as parameter.
    • Next: Either derive repo from git remote or accept repo as a parameter with pdurlej/platform as default.

global-deepseek / deepseek-v4-pro:cloud

  • Status: ok
  • Verdict: OK
  • Findings: none

redteam / kimi-k2.6:cloud

  • Status: error
  • Verdict: -
  • Note: ReadTimeout: The read operation timed out
  • Findings: none

Policy notes

  • GLM 5.1 + DeepSeek V4 Pro are the operator-required model mix for this bot.
  • Optional red-team model is enabled only when PLATFORMCTL_PR_SANITY_REDTEAM_MODEL is configured.
  • Auto-merge is not enabled here.
<!-- patchwarden-pr-sanity:pdurlej/platform:PR-679 --> # Patchwarden PR sanity - Status: `advisory_findings` - PR: `679` - Commit: `ec142d8890c72a9c476fac6ed7bd67a93bc41bc2` - Security-sensitive label: `present` - Authority: advisory model review plus deterministic blockers only - 3+3 canary: still alive; this does not replace it ## Deterministic findings No deterministic findings. ## Model reviewers ### `global-glm` / `glm-5.1:cloud` - Status: `ok` - Verdict: `NOT_OK` - **`high`** task_checkpoint.completed type mismatch between SQL schema and Python checkpoint writer - Evidence: `In migrations/20260601_memory_control_plane.sql line 89: `completed text NOT NULL DEFAULT ''` defines completed as scalar text. In control-plane/platformctl/memory.py line 167: `"completed": completed or []` writes completed as a JSON array` - Next: Change SQL schema `completed text NOT NULL DEFAULT ''` to `completed text[] NOT NULL DEFAULT '{}'` to match the Python array format and align with changed_files/followups pattern. - **`medium`** Missing indexes on foreign key columns in migration - Evidence: `migrations/20260601_memory_control_plane.sql creates tables task_run_event (task_id REFERENCES task_run), task_checkpoint (task_id REFERENCES task_run), memory_procedure_version (slug REFERENCES memory_procedure), memory_procedure_event (sl` - Next: Add CREATE INDEX statements for FK columns: task_run_event(task_id), task_checkpoint(task_id), memory_procedure_version(slug), memory_procedure_event(slug), memory_procedure_event(task_id), memory_procedure_embedding(slug). - **`low`** Hardcoded repo name in memory_brief output - Evidence: `control-plane/platformctl/memory.py line 148: `"repo": "pdurlej/platform"` is hardcoded rather than derived from git or passed as parameter.` - Next: Either derive repo from git remote or accept repo as a parameter with pdurlej/platform as default. ### `global-deepseek` / `deepseek-v4-pro:cloud` - Status: `ok` - Verdict: `OK` - Findings: none ### `redteam` / `kimi-k2.6:cloud` - Status: `error` - Verdict: `-` - Note: ReadTimeout: The read operation timed out - Findings: none ## Policy notes - GLM 5.1 + DeepSeek V4 Pro are the operator-required model mix for this bot. - Optional red-team model is enabled only when `PLATFORMCTL_PR_SANITY_REDTEAM_MODEL` is configured. - Auto-merge is not enabled here.
pdurlej deleted branch codex/m07-memory-foundation 2026-06-02 07:35:39 +02:00
Sign in to join this conversation.
No reviewers
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 milestone
No project
No assignees
1 participant
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!679
No description provided.