feat(platformctl): automated truth-verification layer — lint --cross-refs + drift-check #772

Closed
ollama wants to merge 3 commits from deepseek/audit-2026-06-08 into main
Collaborator

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

Canary Context Pack

Product story

Every audit burns tokens on the same checks: "is INDEX.yaml consistent with modules?", "are ADR numbers unique?", "do referenced ADRs exist?", "are images drifted?". This PR makes these checks automatic — zero tokens, instant feedback, CI-enforceable.

What changed

  • New command: platformctl lint --cross-refs — 4 static integrity checks:
    1. INDEX.yaml ↔ module manifests (lifecycle, criticality, area, host)
    2. ADR numbering (duplicate detection)
    3. ADR references (phantom ADR detection across all docs)
    4. Runbook coverage (missing runbooks, orphan runbooks)
  • New command: platformctl drift-check [module|--all] — compare image_observed against live Docker digests via SSH
  • Both follow existing platformctl patterns (transport, plan.py primitives, exit codes)

Why it changed

DeepSeek audit 2026-06-08 identified that the #1 systemic risk is the platform not knowing when it lies about itself. These commands prevent the drift that every manual audit has been rediscovering.

Files touched

  • control-plane/platformctl/lint.py (new, 283 lines)
  • control-plane/platformctl/drift_check.py (new, 224 lines)
  • control-plane/platformctl/cli.py (added 2 commands + formatters)

Relevant context

  • DeepSeek audit: state/audit/deepseek-2026-06-08-multiperspective.md
  • Bug fixes depend on this: #752, #756, #760, #765
  • Strategic improvements depend on this: #767, #771 (both superseded by this PR which implements them together)

Runtime evidence

  • platformctl lint --cross-refs runs on Mac and RS2000, identical results
  • platformctl drift-check honcho-api tested; SSH transport works through existing Tailscale infrastructure
  • 1282 existing tests pass (zero regressions)
  • Lint output validated with --json mode for CI integration

Known constraints

  • drift-check requires platform-host-agent SSH key setup (same as health and plan commands)
  • lint is fully offline — no runtime dependencies

Explicit out-of-scope

  • No runtime mutations
  • No secret access
  • No new dependencies (uses existing transport/plan/manifest modules)
  • Does not automatically fix findings (that's what the atomic issues are for)

Requested decision

Review and merge. This is the foundation for CI-enforced platform integrity.

Merge blockers

  • 1282 tests pass
  • Lint finds known issues (INDEX drift, duplicate ADR, phantom refs)
  • No regressions in existing commands

Spec sources read

  • control-plane/platformctl/cli.py — command structure, exit codes, patterns
  • control-plane/platformctl/plan.pycontainer_name, inspect_command, transport contract
  • control-plane/platformctl/health.py — SSH health check patterns
  • control-plane/platformctl/manifest.pyload_manifest, all_module_ids, find_modules_dir
  • control-plane/platformctl/transport/tailscale.py — SSH transport
  • modules/INDEX.yaml — data structure
  • decisions/ — ADR file patterns
  • state/audit/deepseek-2026-06-08-multiperspective.md — audit findings that motivated this

Verification

# Static checks (zero deps)
PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli lint --cross-refs --json | python3 -m json.tool

# Drift check (needs SSH)
PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli drift-check --all --json

# Existing tests
PYTHONPATH=control-plane uv run --project control-plane python -m pytest tests/ -q

Closes #767, closes #771

Canary status: missing — fire canary 3+3 manually before merge ## Canary Context Pack ### Product story Every audit burns tokens on the same checks: "is INDEX.yaml consistent with modules?", "are ADR numbers unique?", "do referenced ADRs exist?", "are images drifted?". This PR makes these checks automatic — zero tokens, instant feedback, CI-enforceable. ### What changed - **New command: `platformctl lint --cross-refs`** — 4 static integrity checks: 1. INDEX.yaml ↔ module manifests (lifecycle, criticality, area, host) 2. ADR numbering (duplicate detection) 3. ADR references (phantom ADR detection across all docs) 4. Runbook coverage (missing runbooks, orphan runbooks) - **New command: `platformctl drift-check [module|--all]`** — compare `image_observed` against live Docker digests via SSH - Both follow existing platformctl patterns (transport, plan.py primitives, exit codes) ### Why it changed DeepSeek audit 2026-06-08 identified that the #1 systemic risk is the platform not knowing when it lies about itself. These commands prevent the drift that every manual audit has been rediscovering. ### Files touched - `control-plane/platformctl/lint.py` (new, 283 lines) - `control-plane/platformctl/drift_check.py` (new, 224 lines) - `control-plane/platformctl/cli.py` (added 2 commands + formatters) ### Relevant context - DeepSeek audit: `state/audit/deepseek-2026-06-08-multiperspective.md` - Bug fixes depend on this: #752, #756, #760, #765 - Strategic improvements depend on this: #767, #771 (both superseded by this PR which implements them together) ### Runtime evidence - `platformctl lint --cross-refs` runs on Mac and RS2000, identical results - `platformctl drift-check honcho-api` tested; SSH transport works through existing Tailscale infrastructure - 1282 existing tests pass (zero regressions) - Lint output validated with `--json` mode for CI integration ### Known constraints - `drift-check` requires `platform-host-agent` SSH key setup (same as `health` and `plan` commands) - `lint` is fully offline — no runtime dependencies ### Explicit out-of-scope - No runtime mutations - No secret access - No new dependencies (uses existing transport/plan/manifest modules) - Does not automatically fix findings (that's what the atomic issues are for) ### Requested decision Review and merge. This is the foundation for CI-enforced platform integrity. ### Merge blockers - 1282 tests pass - Lint finds known issues (INDEX drift, duplicate ADR, phantom refs) - No regressions in existing commands ## Spec sources read - `control-plane/platformctl/cli.py` — command structure, exit codes, patterns - `control-plane/platformctl/plan.py` — `container_name`, `inspect_command`, transport contract - `control-plane/platformctl/health.py` — SSH health check patterns - `control-plane/platformctl/manifest.py` — `load_manifest`, `all_module_ids`, `find_modules_dir` - `control-plane/platformctl/transport/tailscale.py` — SSH transport - `modules/INDEX.yaml` — data structure - `decisions/` — ADR file patterns - `state/audit/deepseek-2026-06-08-multiperspective.md` — audit findings that motivated this ## Verification ```bash # Static checks (zero deps) PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli lint --cross-refs --json | python3 -m json.tool # Drift check (needs SSH) PYTHONPATH=control-plane uv run --project control-plane python -m platformctl.cli drift-check --all --json # Existing tests PYTHONPATH=control-plane uv run --project control-plane python -m pytest tests/ -q ``` Closes #767, closes #771
6 perspectives: architect, devops, engineer, tester, product, UX.
36 findings total: 19 immediately actionable by small models,
7 need investigation, 8 operator-gated.

Created 15 atomic Forgejo issues (#752-#766) for Gemini agents.
Audit report saved to state/audit/deepseek-2026-06-08-multiperspective.md
feat(platformctl): add lint --cross-refs and drift-check commands
All checks were successful
base-is-main / guard (pull_request) Successful in 2s
canary-required / collect-diff (pull_request) Successful in 5s
patchwarden-client-dry-run / collect-diff (pull_request) Successful in 4s
patchwarden-pr-sanity / collect-diff (pull_request) Successful in 4s
platformctl plan / auto-apply scope (pull_request) Successful in 20s
python-ci / Python 3.11 (pull_request) Successful in 45s
python-ci / Python 3.12 (pull_request) Successful in 47s
python-ci / Python 3.13 (pull_request) Successful in 46s
patchwarden-client-dry-run / dry-run (pull_request) Successful in 21s
patchwarden-pr-sanity / sanity (pull_request) Successful in 4m20s
pyfallow / Pyfallow gate (control-plane) (pull_request) Successful in 21s
canary-required / canary (pull_request) Successful in 15s
760b045cc0
- lint --cross-refs: static cross-reference integrity checks
  (INDEX.yaml vs manifests, ADR numbering, ADR references, runbook coverage)
- drift-check: compare declared image_observed vs live Docker digests via SSH
- Both commands follow existing platformctl patterns
- 1282 existing tests still green (zero regressions)
- Part of DeepSeek audit 2026-06-08 strategic improvements
First-time contributor

Patchwarden PR sanity

  • Status: advisory_findings
  • PR: 772
  • Commit: 2aa6d7bc855304ce7bb5a7dd6974cc5eb6891938
  • Security-sensitive label: missing
  • 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 KeyError crash in _check_index_consistency when manifest lacks nested classification

    • Evidence: control-plane/platformctl/lint.py lines ~155-160: m.data["spec"]["classification"]["area"]uses direct dict access while INDEX.yaml side uses.get()with defaults. If any module.yaml lacksspec.classification.area, this raises KeyErro
    • Next: Change m.data["spec"]["classification"]["area"] to m.data.get("spec", {}).get("classification", {}).get("area") or wrap in try/except KeyError to match the defensive pattern used for INDEX.yaml access.
  • low Weak type contract on transport parameter allows unsafe calls

    • Evidence: control-plane/platformctl/drift_check.py lines 42, 54, 67: transport: TailscaleTransport | Any | None = None— theAny type defeats type checking and could allow invalid transport objects at runtime.
    • Next: Remove Any from the union type. Use TailscaleTransport | None = None or define a Protocol for the transport interface if polymorphism is needed.

global-deepseek / deepseek-v4-pro:cloud

  • Status: ok

  • Verdict: OK

  • medium No tests for new lint and drift-check commands

    • Evidence: Diff adds 507 lines of new logic across lint.py and drift_check.py, but no test files are included. PR description only confirms existing tests pass, not that new functionality is covered.
    • Next: Add unit/integration tests for lint --cross-refs and drift-check before merging to ensure correctness and prevent regressions.
  • low Canary review not yet performed

    • Evidence: PR description states 'Canary status: missing — fire canary 3+3 manually before merge'. The canary process is required by project policy for medium/large changes.
    • Next: Complete the canary review (3+3 ensemble) before merging to satisfy governance requirements.

redteam / kimi-k2.6:cloud

  • Status: error
  • Verdict: -
  • Note: Ollama response had no message.content.
  • 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-772 --> # Patchwarden PR sanity - Status: `advisory_findings` - PR: `772` - Commit: `2aa6d7bc855304ce7bb5a7dd6974cc5eb6891938` - Security-sensitive label: `missing` - 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`** KeyError crash in _check_index_consistency when manifest lacks nested classification - Evidence: `control-plane/platformctl/lint.py lines ~155-160: `m.data["spec"]["classification"]["area"]` uses direct dict access while INDEX.yaml side uses `.get()` with defaults. If any module.yaml lacks `spec.classification.area`, this raises KeyErro` - Next: Change `m.data["spec"]["classification"]["area"]` to `m.data.get("spec", {}).get("classification", {}).get("area")` or wrap in try/except KeyError to match the defensive pattern used for INDEX.yaml access. - **`low`** Weak type contract on transport parameter allows unsafe calls - Evidence: `control-plane/platformctl/drift_check.py lines 42, 54, 67: `transport: TailscaleTransport | Any | None = None` — the `Any` type defeats type checking and could allow invalid transport objects at runtime.` - Next: Remove `Any` from the union type. Use `TailscaleTransport | None = None` or define a Protocol for the transport interface if polymorphism is needed. ### `global-deepseek` / `deepseek-v4-pro:cloud` - Status: `ok` - Verdict: `OK` - **`medium`** No tests for new lint and drift-check commands - Evidence: `Diff adds 507 lines of new logic across lint.py and drift_check.py, but no test files are included. PR description only confirms existing tests pass, not that new functionality is covered.` - Next: Add unit/integration tests for lint --cross-refs and drift-check before merging to ensure correctness and prevent regressions. - **`low`** Canary review not yet performed - Evidence: `PR description states 'Canary status: missing — fire canary 3+3 manually before merge'. The canary process is required by project policy for medium/large changes.` - Next: Complete the canary review (3+3 ensemble) before merging to satisfy governance requirements. ### `redteam` / `kimi-k2.6:cloud` - Status: `error` - Verdict: `-` - Note: Ollama response had no message.content. - 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.
fix(platformctl): address Patchwarden PR #772 review findings
All checks were successful
canary-required / collect-diff (pull_request) Successful in 5s
platformctl plan / auto-apply scope (pull_request) Successful in 20s
pyfallow / Pyfallow gate (control-plane) (pull_request) Successful in 17s
python-ci / Python 3.11 (pull_request) Successful in 40s
python-ci / Python 3.12 (pull_request) Successful in 42s
python-ci / Python 3.13 (pull_request) Successful in 42s
canary-required / canary (pull_request) Successful in 19s
base-is-main / guard (pull_request) Successful in 1s
patchwarden-client-dry-run / collect-diff (pull_request) Successful in 4s
patchwarden-pr-sanity / sanity (pull_request) Successful in 4m6s
patchwarden-client-dry-run / dry-run (pull_request) Successful in 19s
patchwarden-pr-sanity / collect-diff (pull_request) Successful in 4s
2aa6d7bc85
- Use shlex.quote() on image_ref in drift-check (command injection vector)
- Fix unreachable EXIT_UNKNOWN_PARTIAL branch (reorder conditions)
- Use safe .get() access pattern for spec/classification/area in lint.py
- Exit 1 when 'lint' runs without --cross-refs flag (no silent bypass)

All 1282 tests still green.
Owner

PR-zero queue collapse: closing this parked/conflicted mega-PR without merge. The part has now landed via narrower PR #783. The part should come back only as a fresh, smaller PR/issue with current tests and no stale Honcho/live assumptions. No runtime mutation was performed.

PR-zero queue collapse: closing this parked/conflicted mega-PR without merge. The part has now landed via narrower PR #783. The part should come back only as a fresh, smaller PR/issue with current tests and no stale Honcho/live assumptions. No runtime mutation was performed.
pdurlej closed this pull request 2026-06-17 23:17:20 +02:00
Owner

Correction to the previous close comment: shell interpolation stripped the inline command names.

Intended wording: the lint --cross-refs part has landed via narrower PR #783; the drift-check part should return only as a fresh, smaller PR/issue with current tests and no stale Honcho/live assumptions.

Correction to the previous close comment: shell interpolation stripped the inline command names. Intended wording: the `lint --cross-refs` part has landed via narrower PR #783; the `drift-check` part should return only as a fresh, smaller PR/issue with current tests and no stale Honcho/live assumptions.
All checks were successful
canary-required / collect-diff (pull_request) Successful in 5s
platformctl plan / auto-apply scope (pull_request) Successful in 20s
pyfallow / Pyfallow gate (control-plane) (pull_request) Successful in 17s
python-ci / Python 3.11 (pull_request) Successful in 40s
python-ci / Python 3.12 (pull_request) Successful in 42s
python-ci / Python 3.13 (pull_request) Successful in 42s
canary-required / canary (pull_request) Successful in 19s
base-is-main / guard (pull_request) Successful in 1s
Required
Details
patchwarden-client-dry-run / collect-diff (pull_request) Successful in 4s
patchwarden-pr-sanity / sanity (pull_request) Successful in 4m6s
Required
Details
patchwarden-client-dry-run / dry-run (pull_request) Successful in 19s
patchwarden-pr-sanity / collect-diff (pull_request) Successful in 4s

Pull request closed

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
3 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!772
No description provided.