Repository navigation
fix(posture): root-aware project trust for headless scheduler runs (#359) - #364
Merged
Merged
Conversation
…m the posture ladder (#359) The posture ladder raises TrustProject for trusted/auto/yolo, so a scheduler that needs --posture auto's approval semantics is forced to ingest the cloned repo's steering (AGENTS.md/CLAUDE.md, .mecatl/.claude rules, agent defs, skills, soul, slash commands, ALLOW rules, git snapshot). In a dark factory, whoever can push to the cloned ref then controls the agent's instructions (CWE-1427 / OWASP LLM01+LLM06). Add an operator-tier pin, --no-project-trust (+ settings.yaml no-project-trust:, operator-tier only, CLI out-ranks YAML), backed by Config.NoProjectIngest and the single expression ingestProjectTier(cfg) = cfg.TrustProject && !cfg.NoProjectIngest. Every ingestion consumer reads the helper; applyPosture/resolveTrust never set it, so the pin wins over the posture floor. It does NOT touch cfg.TrustProject, so the read-only subagent-shell trust gate keeps reading the real trust decision — the pin suppresses ingestion, not the shell. AGENTS.md/CLAUDE.md is gated too (the highest-value injection point; the scheduler supplies its own --instructions). Composition-only: no engine API change. Also clamp mecatequi's Summary.final_text to 4000 runes (rune-aware, ellipsis) so a scheduler scanning the merged log is not forced to scan unbounded model text; the full text stays in the durable event log and the git diff. ADR 0092. Load-bearing e2e: TestBuildNoProjectTrustSuppressesProjectAgentDefs drives real app.Build, pinned-vs-control. Gates: task lint/test/api:check/ docs/site:build green; mecademo prints a full offline session. Co-Authored-By: mecatl <[email protected]>
3 tasks
…rust # Conflicts: # llms.txt
…rust split (#359) Replaces the earlier --no-project-trust suppressor (which was fail-open: a forgotten flag on an untrusted clone silently trusted the repo) with the shape titlani's security review argued for: fail-safe by default. Split the overloaded TrustProject bool into two independent positive grants: - Ingestion axis (Config.ProjectIngestionGranted): admits the repo's project-tier steering (AGENTS.md/CLAUDE.md, .mecatl/.claude rules, agent defs, skills, soul, slash commands, ALLOW rules, git snapshot, model bindings). Single predicate projectIngestionAdmitted(cfg) = cfg.TrustProject && cfg.ProjectIngestionGranted. On HEADLESS roots the grant is OPT-IN (only an explicit --trust-project); on INTERACTIVE roots the posture ladder still grants it at auto/yolo, so a dev's own CLAUDE.md keeps working (no interactive regression). - Subagent-shell axis (Config.SubagentShellGranted): the read-only worktree shell, now keyed off posture >= auto on BOTH roots instead of TrustProject. Those tiers already give the main agent an allow-all shell, so a child shell is no more dangerous; trusted no longer grants it (it loosens nothing else). Decoupled from ingestion, so a scheduler gets the shell without the steering. - Config.Headless: explicit deployment identity set by each cmd root (mecated --headless, mecatequi/mecak8s headless default, mecatui false) — NOT inferred from the runtime-approver Interactive axis. applyPosture is now root-aware on it. - mecatequi gains --trust-project (default OFF), matching the other three roots — the positive opt-in a scheduler passes for a repo it trusts. --no-project-trust is removed entirely (no caller once headless is opt-in and interactive follows the ladder). Fail-safe default: `mecatequi --posture auto` over an untrusted clone now yields allow-all approvals + a working child shell but NO repo steering (scheduler supplies its own --instructions). A forgotten flag degrades to a less-steered agent, not a hijacked one. Composition-only: no engine API change (engine/ stays trust/posture/headless-unaware). ADR 0094 (supersedes 0092) documents the design and truth tables. Gates: task lint/test/api:check green; mecademo prints a full offline session. Co-Authored-By: mecatl <[email protected]>
…359) Document the two-axis trust redesign: ADR 0094 (Accepted) captures the opt-in-on-headless ingestion grant + the posture-derived subagent-shell grant + the Headless deployment-identity field + the truth tables, and supersedes ADR 0092's fail-open --no-project-trust suppressor (marked Superseded). Update the workspace-trust / mecatequi-ci / mecated / mecak8s usage docs and the user-docs deployment pages to the opt-in story, refresh the AGENTS.md gotcha and IMPLEMENTATION-NOTES, and regenerate llms.txt + the config reference. Co-Authored-By: mecatl <[email protected]>
The PR's Lint job fails on 6 spurious staticcheck SA5011 (possible nil deref) in permconfig/models_test.go and app/guardrails_test.go — files this branch does not touch, with the pointer nil-checked immediately before the deref (the SA5011 is a false positive). golangci-lint-action restores a staticcheck cache keyed the same across re-runs, poisoned by the large main merge (#362 provider-module split); the identical code passes golangci-lint run --timeout=8m locally (clean cache) and the engine-module lint (which skips the restored cache) passes in CI. This empty commit forces a fresh analysis. Co-Authored-By: mecatl <[email protected]>
…ct ladder interactive-only (#359) The #359 redesign (ADR 0094) keyed the read-only subagent shell off a new SubagentShellGranted grant (posture >= auto on both roots). titlani's review and the live e2e both caught that this is wrong in both directions, because the worktree child's shell runs `git worktree add` — a checkout that can execute an attacker-controlled filter driver from the repo's `.git` (the issue-#40 fork-time-RCE surface), which the main agent's Bash never does: - Over-trust: a headless `--posture auto` run on an UNTRUSTED clone would run `git worktree add` on a hostile `.git` (the ladder raised TrustProject unconditionally), re-opening the RCE the gate closes. - Under-trust: an interactive `--trust-project --posture strict` run (operator trusts the repo, wants approvals) silently lost the read-only subagent shell it had on main — caught by the live e2e's dirtyfork family (harness passes --trust-project, no --posture). Two corrections: 1. The shell gate reverts to cfg.TrustProject (main's behavior): the operator vouches for the repo's `.git`. The four shell consumers (buildSandboxedCommandRunner, subagentShellUntrustedReason, applyUntrustedMemberShellNote, buildWorktreeLister) + bashScopeMissReason read TrustProject again; the SubagentShellGranted field is removed. 2. applyPosture's TrustProject floor is now INTERACTIVE-only: on a HEADLESS root the ladder (trusted/auto/yolo) does NOT raise TrustProject, so only an explicit --trust-project sets it there. This makes the headless fail-safe default coherent: an untrusted clone gets NO ingestion AND NO subagent shell without the explicit opt-in; on an interactive root the ladder keeps raising it (a dev's own repo keeps ingestion + shell, matching main — titlani's point #1). Final semantics: ingestion = cfg.TrustProject && cfg.ProjectIngestionGranted (ingestion opt-in on headless, ladder-granted interactive); shell = cfg.TrustProject (workspace trust, unchanged from main). On headless the two are coincident via the explicit flag; the deliberate capability loss (a headless untrusted run gets no child shell) is the fail-safe trade. Truth tables + the shell-gate / diagnostics-facts / posture-build tests updated. Gates: task lint/test/api:check green; mecademo prints a full offline session; engine/ stays trust/posture/headless-unaware. Co-Authored-By: mecatl <[email protected]>
Complete the #359 correction after the live e2e and titlani review. The intermediate ProjectIngestionGranted/SubagentShellGranted split did not have a valid independent production state once an untrusted headless repository deliberately loses both project steering and the read-only worktree shell. It also introduced an ordering bug: applyPosture derived one grant before resolveTrust, so a later trustedWorkspaces/remembered trust decision could enable the shell while leaving ingestion disabled. Use one effective TrustProject decision instead: - the posture ladder raises trust only on INTERACTIVE roots; - HEADLESS roots require explicit, declared, or remembered trust; - every successful trust source intentionally admits both project-tier steering (through the named projectIngestionAdmitted seam) and the read-only worktree shell; - an untrusted headless auto/yolo run gets neither steering nor shell; - interactive posture behavior remains byte-compatible with main. Make --print-posture use the same root-aware projection as Build, move posture narration after the authoritative trust fold, and add real-Build coverage for declared trust plus shell presence/absence across headless and interactive roots. Audit all read-only fork/workspace git paths: worktree creation/listing and snapshots are trust-gated or hardened; mutating branches use force-copy with no fork-time git. Preserve ADR lifecycle: mark intermediate ADR 0094 superseded and add ADR 0095 for the final root-aware single-grant design. Reconcile AGENTS, implementation/usage/user docs, regenerate llms.txt, and keep ADR 0092 superseded. Gates: task lint/test/api:check/docs/site:build green; mecademo prints the full offline approval/result flow. Independent spec/security/ architecture/QA/standards review found no blockers. Co-Authored-By: mecatl <[email protected]>
…agnostic (ADR 0096) The --print-posture flag reported posture via a second, parallel PostureProjection that re-ran foldOperatorPosture → resolvePosture → applyPosture → resolveTrust outside Build. That projection could drift from the live server silently, and the flag was a print-and-exit CLI hack distinct from the structured `operator posture` startup diagnostic Build already emits after the real trust fold. ADR 0096: there is no special print-and-exit CLI. The authoritative observation surface is the `operator posture` startup diagnostic (narratePosture), which runs once inside Build after resolveTrust and carries the resolved tier plus the fully folded root-aware trust_project/project_ingestion decision — the SAME provenance as the running server. Removes config.printPosture, the flag registration + help metadata, the print-and-exit branch, renderPostureReport, and the PostureProjection/ResolvePostureProjection composition projection. ResolveAuthoritativePosture stays for mecatui embedded posture and the mecated fast-path refusal; it no longer folds workspace trust (Build owns that, surfaced by the diagnostic). The root-aware trust design (ADR 0095) is carried forward unchanged; only the reporting decision changes. Gates: task lint/test green. Co-Authored-By: mecatl <[email protected]>
The #359 rule was reached through four ADRs in one day (0092 suppressor -> 0094 two-axis grants -> 0095 root-aware one-fold -> 0096 reporting), three stamped Superseded before any shipped. Following the chain landed on 0096, which only carries the reporting-surface decision and does not restate the trust rule — the authoritative content (root-aware ladder, the one-fold TrustProject decision, the behavior table, the git threat model) sat in 0095, marked Superseded. Consolidate: 0095 is now Accepted and carries the final rule plus a short revision-history note recording the rejected intermediate shapes (the 0092 suppressor and the 0094 two-axis split) and why they were rejected. 0092 and 0094 are Superseded and point to 0095. 0096 no longer claims to supersede 0095 — it is an orthogonal reporting-surface decision (drop --print-posture for the startup diagnostic) that relates to 0095 rather than superseding it. README index updated so there is one authoritative trust ADR plus the standalone 0096. No code change. matlatl strict link gate + docs/lint green. Co-Authored-By: mecatl <[email protected]>
…rust # Conflicts: # llms.txt
…rust # Conflicts: # cmd/mecatequi/flags.go # llms.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #359. Part of the dark-factory epic (stacklok/stacklok-epics#297); addresses the CWE-1427 / OWASP LLM01+LLM06 gap surfaced by titlani#40.
Problem
Unattended schedulers need
--posture auto, but the posture ladder previously raisedTrustProjecton every root. Onmecatequi—which did not have--trust-project—the only usable posture silently admitted the cloned repo's steering: AGENTS/CLAUDE instructions, project permission ALLOWs, rules, agents, skills, soul, slash commands, git snapshot, and model bindings.Final design: one root-aware workspace-trust decision (ADR 0095)
TrustProjectis the single effective positive workspace-trust decision:--trust-project, user-globaltrustedWorkspaces:, or undrifted remembered trust may admit the repo.projectIngestionAdmittedseam) and the read-only worktree shell..git.Config.Headlessis explicit deployment identity, not inferred from the runtime-approverInteractiveaxis. All four roots map it.mecatequinow has--trust-projectdefault OFF. The temporary--no-project-trustsuppressor/YAML key are removed.Posture reporting (ADR 0096)
There is no
--print-postureflag. The authoritative observation surface is the structuredoperator posturestartup diagnosticapp.Buildemits once after the real trust fold (narratePosture), carrying the resolved tier plus the final root-awaretrust_project/project_ingestiondecision — the same provenance as the running server, so it cannot drift from the live decision the way a parallel projection could. The earlier--print-postureflag and its parallelPostureProjectionare removed.Git trust-boundary audit
Read-only fork/workspace git paths are trust-gated, force-copy/no-git, or hardened: worktree creation is only wired through the trust-gated runner; read-only member isolation requires it; worktree listing and snapshots are trust-gated; forker git keeps
gitenv.Scrub(envscrub.Scrub(...)); mutating member/Parallel forks are force-copy with no fork-time git.The threat is attacker-controlled repo-local git configuration (filter/diff drivers, hooks/core.hooksPath, core.fsmonitor, aliases);
.gitattributesnames drivers but does not define commands by itself.Other issue requirement
mecatequiSummary.final_textis clamped to 4000 runes. Full text remains in--out-eventsand the git diff.Verification
task lint,task test,task api:check,task docs,task site:build— greengo run ./cmd/mecademo— full offline approval/result flowRegression coverage includes the exhaustive root-aware truth table, real-Build declared-trust ingestion + shell, headless-vs-interactive shell factory guard, the
operator posturestartup diagnostic's root-aware fields (TestBuildOperatorYAMLPostureSeam), the stable rules live-e2e assertion, and dirtyfork compatibility.ADRs: 0096 (Accepted), 0095 (Superseded — reporting only), 0094 (Superseded), 0092 (Superseded).