feat(memory): register lifecycle hooks #681
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference
pdurlej/platform!681
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "codex/662-memory-lifecycle-hooks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Canary status: missing — fire canary 3+3 manually before merge
Summary
Adds the Memory Control Plane lifecycle hook registration layer for #662.
What changed
platformctl memory hook registerfor explicit settings files.SessionStart,PreCompact,PostCompact, andPreToolUsecommands additively.PreToolUseand codexbarSessionStart.pre-compactusable by lifecycle hooks without hand-fed task metadata by adding safe task/objective defaults.pre-tool-useread common harness JSON payloads from stdin, includingtool_name=Writestyle payloads.Canary Context Pack
Product story
Memory Control Plane hooks should be executable by harnesses instead of relying on agents remembering lifecycle instructions. This PR gives Claude/Codex surfaces a deterministic, repo-owned way to register those hooks without clobbering existing harness controls.
What changed
A small hook registration helper and CLI command were added under
platformctl. Existing hook endpoints were made safer for automatic lifecycle execution.Why it changed
Issue #662 requires hook registration for
claudeandcodexsurfaces, preserving existing hooks including RTKPreToolUseand codexbarSessionStart.Files touched
control-plane/platformctl/cli.pycontrol-plane/platformctl/memory.pycontrol-plane/platformctl/memory_hooks.pycontrol-plane/platformctl/tests/test_memory_control_plane.pystate/memory/hooks/README.mdRelevant context
decisions/0025-memory-control-plane.md§4state/memory/hooks/README.mdRuntime evidence
No runtime config was changed. No live Claude/Codex
$HOMEsettings were edited. No live Postgres migration was applied.Validation run locally:
Results:
py_compile: passtest_memory_control_plane.py: 16 passedplatformctl validate all --json: exitCode 0Known constraints
memory hook registeronly mutates the explicit--settingsfile when--writeis passed. It does not discover live harness config paths.Explicit out-of-scope
Requested decision
Review and merge if the additive registration contract and tests look correct.
Merge blockers
Spec sources read
decisions/0025-memory-control-plane.md— ADR lifecycle hook contract.state/memory/hooks/README.md— existing hook endpoint docs.control-plane/platformctl/memory.py— existing memory helpers and hook endpoints.control-plane/platformctl/cli.py— existing platformctl command conventions.control-plane/platformctl/tests/test_memory_control_plane.py— local regression test conventions.Closes #662
Patchwarden PR sanity
advisory_findings6819c0cd952c49eb9b8e0f4bac60a70bdeece2cf37cpresentDeterministic findings
No deterministic findings.
Model reviewers
global-glm/glm-5.1:cloudStatus:
okVerdict:
OKmediumstdin read will hang if pre-tool-use called without piped inputcontrol-plane/platformctl/cli.py lines 618-626:raw = click.get_text_stream('stdin').read()blocks indefinitely on TTY stdin when neither --operation nor --path is providedsys.stdin.isatty()to provide a clear error message instead of hanging. Document this behavior prominently if intentional.lowSame-day default task_id collisions possiblecontrol-plane/platformctl/memory.py lines 51-54:default_task_id()returnstask_YYYY_MM_DD_session_lifecycle- multiple sessions on the same day share the same task_idglobal-deepseek/deepseek-v4-pro:cloudStatus:
okVerdict:
NOT_OKhighpre_tool_guard_from_payload defaults to permissive operation/path when payload keys are missingcontrol-plane/platformctl/memory.py: new function pre_tool_guard_from_payload defaults operation to 'read' and path to '.' if no recognizable keys are present in the harness payload. This means a harness that sends an unexpected payload forlowpre-tool-use command may hang if invoked without arguments and without stdincontrol-plane/platformctl/cli.py: cmd_memory_hook_pre_tool_use now reads from stdin when --operation/--path are omitted. If the command is run interactively without piping input, it will block waiting for stdin, which could cause harness tiredteam/kimi-k2.6:cloudStatus:
okVerdict:
NOT_OKhighpre-tool-use guard bypass via empty string argumentscontrol-plane/platformctl/cli.pycmd_memory_hook_pre_tool_use:@click.option("--operation", default=None)and@click.option("--path", default=None)allow empty strings. The branchif operation and target_path:treats""as falsy,is not Nonechecks (and reject empty strings) so that partial or empty explicit arguments raise an error instead of falling back to stdin defaults.Policy notes
PLATFORMCTL_PR_SANITY_REDTEAM_MODELis configured.