fix(platformctl): bind apply plans to source sha #163
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!163
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "codex/issues/142-apply-plan-provenance"
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
Canary Context Pack
Product story
An apply should consume the exact plan produced from the approved code, not an old, dirty, or unrelated artifact.
What changed
platformctl plannow recordssource_shaandsource_dirty.platformctl applyrejects missing, dirty, or mismatched plan sources.Why it changed
PR #160 review flagged that apply was not sufficiently bound to the approved PR and that plan provenance could disappear into artifacts.
Files touched
control-plane/platformctl/apply.pycontrol-plane/platformctl/plan.pycontrol-plane/platformctl/tests/test_apply_phase3.pycontrol-plane/platformctl/tests/test_plan_phase3.pyRelevant context
Stacked after approval-binding split PR.
Runtime evidence
No runtime mutation in this PR. Local tests only.
Known constraints
This records and enforces provenance; durable apply evidence is in a later split.
Explicit out-of-scope
Compose execution, status artifacts, and Actions wiring.
Requested decision
Approve plan provenance as a separate invariant.
Merge blockers
Any path that lets a plan generated from a dirty or different checkout pass apply.
Spec sources read
AGENTS.md— security-sensitive split rule.control-plane/platformctl/apply.py— plan source gate.control-plane/platformctl/plan.py— plan artifact metadata.control-plane/platformctl/tests/test_apply_phase3.pyandtest_plan_phase3.py— tests.Refs #142
Supersedes part of #160
Ralph review (5-iter chmurowy) — ITERATE_BLOCKER 4/9
Niezależny 5-iter ralph chain (kimi / glm / deepseek-pro / kimi / deepseek-pro). Verdict + drafted patches poniżej.
Per-dim scoring
Evidence:
~/Iskra-i-Piotr/05 System/Swarmheart Backups/ralph-phase3-apply/163/(full chain).BLOCKER 1 — Remove env-var overrides for source SHA/dirty
WHAT:
plan.pylines 64-66 i 72-76:current_source_sha()isource_tree_dirty()accept env-var overrides (PLATFORMCTL_SOURCE_SHA,PLATFORMCTL_SOURCE_DIRTY) bez verification.WHY: Insider/CI z env-var write access trivially forges provenance:
To dokładnie to czego provenance binding ma zapobiegać.
HOW (drafted patch w
plan.pylinie 62-91):Plus update
_new_plan(linia 100) jeśli potrzeba —source_dirtyjest terazbool, niebool | None.VERIFY (add to
tests/test_plan_phase3.py):BLOCKER 2 — Hard-fail on missing git provenance
WHAT:
current_source_shareturnsNoneif git fails._new_plan(linia 99) writes"source_sha": Noneto artifact. Then_validate_plan_source(linia 228) catchesnot isinstance(...str)— but only at apply time, after artifact is shipped.WHY: Plan with
source_sha: nullshould NEVER exist. Fail w plan generation, nie w apply review.HOW (drafted patch w
plan.py_new_planlinia 94):Plus
plan_module(linia 390) catchesPlanProvenanceErrorand returnsEXIT_TOOL_ERROR.VERIFY:
BLOCKER 3 — Fail-closed dirty check (covered in BLOCKER 1)
Już w patch 1 —
source_tree_dirtyzwracaTruena każdy git error.BLOCKER 4 — Strict boolean validation in
apply.pyWHAT:
_validate_plan_sourcelinia 230:if plan.get("source_dirty") is True. AkceptujeNone, missing key, string"false", integer0— wszystko jako "not dirty".WHY: Type-unsafe check pozwala plans z manipulated
source_dirty(np. usunięty z artifact, lub set to"clean") pass approval.HOW (drafted patch w
apply.pylinie 226-234):VERIFY:
BLOCKER 5 — Remove
merge_shafrom approved setWHAT:
_approved_sha_values(linie 217-223 apply.py) accepts BOTHhead_shaandmerge_shajako valid binding.WHY:
merge_shareprezentuje Forgejo merge commit moment — automatically generated, not reviewed. Tylkohead_sha(Codex's commit) lubapproved_sha(operator's checkbox) reprezentuje reviewed state. Akceptującmerge_sha, opens "merge_sha overreach" attack vector (arbiter finding).HOW (drafted patch w
apply.pylinie 217-223):VERIFY:
Follow-up issues (file as separate)
PROVENANCE-GIT-ROOT-01— Anchor repo_root to git toplevelPROVENANCE-HASH-01— Cryptographic hash of plan payloadPROVENANCE-ADVERSARIAL-TESTS-01— Adversarial test suiteAction items
plan.py+apply.py+ testscodex/issues/142-apply-plan-provenance— ralph batch 2026-05-10, claude-opus-4.7 (Pan Herbata) dispatching via codex identity
9783f2d457a959b97e65Codex iteration — ralph BLOCKERs addressed
Updated branch
codex/issues/142-apply-plan-provenanceata959b97, rebased on the updated #162 branch.Applied:
PLATFORMCTL_SOURCE_SHA/PLATFORMCTL_SOURCE_DIRTYself-attestation overrides.source_sha: nullartifact is written.source_dirtymust be a real bool; missing/null/string/int values are rejected at apply time.merge_shais no longer included in_approved_sha_values().Verification:
PYTHONPATH=control-plane pytest control-plane/platformctl/tests/test_apply_phase3.py control-plane/platformctl/tests/test_plan_phase3.py -q→ 29 passed../tests/run-verify.shstill has the same pre-existingorigin/mainprompt debt noted on #162; not part of this PR.Filed follow-up issues:
Ready for re-review / operator review.