Skip to content

fix(posture): root-aware project trust for headless scheduler runs (#359) - #364

Merged
JAORMX merged 11 commits into
mainfrom
feat/359-no-project-trust
Aug 6, 2026
Merged

JAORMX merged 11 commits into
mainfrom
feat/359-no-project-trust

Conversation

@JAORMX

@JAORMX JAORMX commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #359. Part of the dark-factory epic (stacklok/stacklok-epics#297); addresses the CWE-1427 / OWASP LLM01+LLM06 gap surfaced by titlani#40.

Final design: ADR 0095 (root-aware project trust) supersedes the intermediate ADR 0092 and ADR 0094 designs; ADR 0096 (diagnostic-only posture reporting) supersedes 0095's reporting note. Review the final branch state, not the earlier commits in isolation.

Problem

Unattended schedulers need --posture auto, but the posture ladder previously raised TrustProject on every root. On mecatequi—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)

TrustProject is the single effective positive workspace-trust decision:

  • Interactive roots preserve current behavior: trusted/auto/yolo may raise the trust floor, so a developer's own repo keeps its instructions and read-only subagent shell.
  • Headless roots never receive trust from the posture ladder. Only explicit --trust-project, user-global trustedWorkspaces:, or undrifted remembered trust may admit the repo.
  • Every successful trust source admits both project steering (through the named projectIngestionAdmitted seam) and the read-only worktree shell.
  • An untrusted headless auto/yolo run gets neither steering nor the child shell. This deliberate fail-safe capability loss avoids running git against an unvouched .git.

Config.Headless is explicit deployment identity, not inferred from the runtime-approver Interactive axis. All four roots map it. mecatequi now has --trust-project default OFF. The temporary --no-project-trust suppressor/YAML key are removed.

Posture reporting (ADR 0096)

There is no --print-posture flag. The authoritative observation surface is the structured operator posture startup diagnostic app.Build emits once after the real trust fold (narratePosture), carrying the resolved tier plus the final root-aware trust_project/project_ingestion decision — the same provenance as the running server, so it cannot drift from the live decision the way a parallel projection could. The earlier --print-posture flag and its parallel PostureProjection are 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); .gitattributes names drivers but does not define commands by itself.

Other issue requirement

mecatequi Summary.final_text is clamped to 4000 runes. Full text remains in --out-events and the git diff.

Verification

  • task lint, task test, task api:check, task docs, task site:build — green
  • go run ./cmd/mecademo — full offline approval/result flow
  • Independent spec/security/architecture/QA/standards review — no blockers

Regression coverage includes the exhaustive root-aware truth table, real-Build declared-trust ingestion + shell, headless-vs-interactive shell factory guard, the operator posture startup 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).

…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]>
JAORMX and others added 3 commits August 5, 2026 10:12
…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]>
@JAORMX JAORMX changed the title feat(posture): --no-project-trust pin decouples project ingestion from the posture ladder (#359) feat(posture): opt-in project ingestion on headless roots, two-axis trust split (#359) Aug 5, 2026
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]>
@JAORMX JAORMX added the e2e-live Run the live e2e suite on this PR label Aug 5, 2026
JAORMX and others added 2 commits August 5, 2026 17:31
…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]>
@JAORMX JAORMX changed the title feat(posture): opt-in project ingestion on headless roots, two-axis trust split (#359) fix(posture): root-aware project trust for headless scheduler runs (#359) Aug 5, 2026
JAORMX and others added 4 commits August 5, 2026 20:56
…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:
#	cmd/mecatequi/flags.go
#	llms.txt
@JAORMX
JAORMX merged commit b044394 into main Aug 6, 2026
16 checks passed
@JAORMX
JAORMX deleted the feat/359-no-project-trust branch August 6, 2026 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-live Run the live e2e suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

posture: scheduler-driven runs need project-trust decoupled from the posture ladder

1 participant