test(memory): pin sacred-path consistency between memory.py and safety.py #807
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
pdurlej/platform!807
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issues/memory-sacred-path-consistency"
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?
Problem
Sacred-path truth is split. The canonical repo-wide rules live in
control-plane/platformctl/safety.py(SACRED_EXACT_PATHS/SACRED_PREFIX_PATHS/SACRED_PATH_GLOBS/SACRED_NAME_GLOBS), and PR #806 generatedpolicies/sacred-paths.yamlfrom them with a drift test.But there is a third, independent source of truth that nothing guards against drift:
memory.py:20—SACRED_PATH_PATTERNS, a tuple of compiled regexes (.ssh,.codex,secret-material,runtime/legacy-import/env,open-loops.json).memory.py:235—pre_tool_guarduses them to block destructive memory-control-plane operations in thePreToolUsehook:operation in DESTRUCTIVE_OPERATIONS and any(pattern.search(normalized) ...).If
safety.pygains a new sacred concept that the memory hook should also cover,memory.pycan silently fall behind.Investigation (step 1)
Why it is regex-based, and whether it can reuse
safety.is_sacred_path. It cannot:pre_tool_guardnormalizes withstr(Path(path).expanduser())only (memory.py:234) — no.resolve().safety._normalizerunsPath(...).resolve(strict=False)(safety.py:132), resolving relative paths against the control-plane process CWD. Hook payloads carry raw, possibly-relative or remote (/home/openclaw/...) path strings matched on operation+path alone, so CWD resolution is wrong here.safety.pyis a host-specific absolute-path enforcement layer (safety.py:26-99);memory.pyis a coarse component match anywhere in a string.memory.pycovers~/.ssh+secret-material+open-loops.json(absent fromsafety.py), and intentionally ignores/etc/ssh/sshd_configand the/opt/...host paths (whichsafety.pyowns). So the literal property "no pathsafety.pytreats as sacred is missed bymemory.py" is false by design (e.g./etc/ssh/sshd_confighas no.sshcomponent).Decision (step 2): option (b) — keep regexes, add a consistency test
Deriving
memory.pyfromsafety.py(option a) would change protective behavior. The genuine, testable invariant is agreement where the scopes overlap — the only shared concept is the.codexcomponent.Test (step 3)
New file
control-plane/platformctl/tests/test_memory_sacred_consistency.py:safety.pyrule sharing the.codexcomponent is blocked by the memory destructive guard, derived fromsafety.py's own constants (SACRED_EXACT_PATHS + SACRED_PREFIX_PATHS) so new.codexrules are covered automatically. Includes an anti-vacuity check and a non-circular bidirectional anchor (safety.is_sacred_pathANDpre_tool_guardmust agree).secret-materials.md,my-open-loops.json); a tripwire tieslen(SACRED_PATH_PATTERNS)to the fixture set so the pattern tuple can't change without re-checking agreement.safety.py-only host paths (/etc/ssh/sshd_config,/opt/..., remote workspace) stay sacred undersafety.py, asserted positively so a future tightening ofmemory.pynever trips this test.Also a cross-reference comment at
memory.py:20so the third source of truth is intentional, not silent.Proof the guard is non-vacuous
Simulating removal of the
.codexpattern leaks 6safety.pysacred paths past the memory guard (~/.codex/AGENTS.md,~/.codex/config.toml,/home/openclaw/.codex/sessions/,~/.codex/archived_sessions/,~/.codex/automations/,~/.codex/sessions/) →test_safety_overlap_*fails.Verification
python3 -m pytest platformctl/tests/test_memory_sacred_consistency.py→ 23 passed.test_safety_phase3.py→ 128 passed (no regression).test_memory_control_plane.py(subprocessModuleNotFoundError: No module named 'click') are unrelated — confirmed identical on the clean baseline with this branch's source stashed.Classification
Class/security-sensitive (sacred-path enforcement) → tier/full canary + operator merge. No secret values touched.
🤖 Generated with Claude Code
Patchwarden PR sanity
Operator signal: 🛑 STOP - reviewer finding(s) must be addressed or explicitly accepted.
Automerge signal: ❌ NOT READY - no unattended merge or APPROVED review should be published.
Verdict: 🛑 STOP - a model reviewer reported actionable findings.
Next step: Address the reviewer finding(s), or leave a human decision explaining why the risk is accepted.
8077dbee837a933a08bc66f492816430d00ef0bfdd5advisory_findingsfindingspresentglm-5.2:cloud,deepseek-v4-pro:cloud,kimi-k2.7-code:cloudWhat I checked
2clean3Approval Handoff
not_ready_reviewer_findingsSignal Board
cleanfindingsnot_ready_reviewer_findingsineligibleautomation firstcontrol-plane/platformctl/memory.py,control-plane/platformctl/tests/test_memory_sacred_consistency.pyclass/security-sensitive,tier/fullclass/security-sensitiveis present.🧭 Merge authority: branch protection and automerge controller remain authoritative.
Required Fixes
No deterministic blockers.
Reviewer Details
Model reviewer lanes
global-glm/glm-5.2:cloudokOKglobal-deepseek/deepseek-v4-pro:cloudokOKredteam/kimi-k2.7-code:cloudStatus:
okVerdict:
NOT_OKhighSymlink/path-aliasing bypass of regex-only sacred guardmemory.py new comment at SACRED_PATH_PATTERNS deliberately rejects filesystem resolution ('Deliberately NOT derived from safety.is_sacred_path... matched on operation+path alone') and keeps component regex search on the raw string. test_memPolicy notes
Iskra judgment
pdurlej/platform#pull_request#807judge/p1,judge/patchwarden-candidateiskraviaopenclawRationale: This pins drift between independent sacred-path guard sources, reducing the chance that destructive memory-control-plane protections silently fall behind governance policy.
Caveat: The packet excerpt does not include the full diff or test output, so review should verify the pinned consistency check matches intended guard semantics.
Structured openclaw.judge.v0 payload
Iskra judgment
pdurlej/platform#pull_request#807judge/p1,judge/patchwarden-candidateiskraviaopenclawRationale: This PR appears to pin an important safety invariant between memory hook sacred-path handling and canonical repo-wide sacred-path policy, reducing silent drift in destructive-operation guards.
Caveat: The packet excerpt does not include the full diff or test output, so review should confirm the generated policy and regex coverage preserve intended behavior.
Structured openclaw.judge.v0 payload
Operator live approval present for #807: branch is current and all latest CI/Patchwarden contexts are green. Approval recorded by Iskra as merge actor for the sacred-path consistency test PR.