Decide gates the way terragucci does, with chant's gate modules #15

Open
opened 2026-10-21 03:08:50 +00:00 by lex00 · 0 comments
Collaborator

(bug, shows once the sandbox runs terragucci past 0.4.10; #10 is unblocked)
Part of the terraform-plane epic (arugula-salad/arugula#1141). Lands after terragucci's next release, the first built on chant 0.124.41 or later (chant#4287); npm's newest is still 0.4.40, on chant 0.124.24.

sluice decides gates with a line-for-line port of terragucci 0.4.0's decideGate (src/services/ledger.ts) and writes resolutions itself. The record format is still accepted by chant 0.124.27 and terragucci 0.4.39. The decision isn't. Each of these makes the inbox say one thing and the wave do another:

  • Involvement (0.4.13, #1044 there): an approval from the PR author, a commit author or the agent's requester doesn't count, and their deny is dropped (terragucci apply.ts beforeGateRules/resolutionRefusal, involved.ts). sluice marks the row approved and resumes; terragucci writes a fresh pending fact and waits; a new row appears. The pending record's excluded names them.

  • approval_rules (0.4.35): the outcome line is wave N waits (rules): ... (apply.ts:3574), which parseOutcome doesn't read, and after the first approval terragucci exits 1 with approval_rules not met (apply.ts:3470), so the run is marked failed.

  • require_signed: isSealed() (src/console/routes.tsx:49) checks only approval === "sealed", so the button writes lines that never count. Related to #8.

  • Spent approvals (0.4.11): _gates/tf-apply/applied.jsonl makes a spent approval of another digest "waiting", not "refused". The port has no applied input.

  • State migrations (0.4.5): wave 1 can wait on _gates/tf-migrate.jsonl with migration <name> waits: ... (apply.ts:3625). sluice parses wave 0, files a tf-apply approval and watches the wrong ledger.

  • Decision-point gates (apply.point, chant ws-091): only chant workspace points answer passes them; a resolution from sluice counts for nothing while its port says approved.

  • Base gate (0.4.40, terragucci#1202): each wave takes the stricter of --gate and the top-level gate at the first parent (environmentWaveGates, apply.ts:1195). sluice reads the config at the run's sha (executor.ts configAtSha), so a merge that loosens the gate to never still waits under 0.4.40+ while sluice's config says never. The plan note warns about a loosening since 0.4.40 (report/stage.ts gateLoosening); sluice's console doesn't.

  • Under gate: never a wave still waits for cost.approve_above, on_failure: approve, a policy hold, an environment's own gate, and wave 1 of a migration (terragucci guides/run-without-approvals.mdx, #1203).

  • Next release: approval_rules are judged by chant's quorum (terragucci#1217 deleted approval-rules.ts), and in pr-review mode a reviewer's role counts only when .chant/trust.json grants it to their principal, github:<lowercased login> (forgejo@<host>:<login> on Forgejo; apply.ts reviewerPrincipal). A grant to a bare login no longer counts. actorOf writes github: on Forgejo estates too. Policy argv and answers come from chant's gate-policy (#1218), and a policy hold makes the gate wait for an approval of the plan's own digest, even under gate: never (chant#4294).

Porting stops being the way to keep up: terragucci now delegates most of this to chant, and chant's modules import into Bun. Bundled from the 0.124.41 tarball:

  • @intentius/chant/op/gate-quorum (13KB, node:crypto; also re-exported from gate-decision): use it.
  • gate-decision: its pure parts. trustRolesAt, gateSignersAt and identityGatesAt spawn git; pass them text read from the forge.
  • gate-policy: leave it to the sandbox (it spawns the policy engine).
    Pin whatever sluice imports to the chant version the pinned terragucci uses.

Done when:

  • The watcher decides with @intentius/chant/gate-decision (latestResolutionForPlan, isApprovalSpent, parseAppliedGateLines; bundle-safe since chant #3763/#3778) instead of the port, and verifies seals with its gateSealRefusal before resuming.
  • The outcome comes from TG_OUTCOME_JSON (#10), including excluded, rules and the gate's ledger, so a migration gate files against tf-migrate.
  • The console refuses an involved approver before writing, and shows who is excluded and which rules remain.
  • A point gate shows its question and candidates and doesn't offer Approve.
  • approval_rules are judged with gate-quorum (quorumOf, mapping roots to targets and not_author to notAuthor; quorumRuleProgress, quorumWaiting), and the base decision plus spent approvals with decideGateApproval({ spend: true }) (waiting and mismatched map to refused). Involvement (involved.ts) is still ported; chant doesn't have it. The pending fact keeps roots/not_author in approval_rules (approval.ts ruleReport), so the inbox can keep parsing it.
  • Principals are forgejo@<host>:<login> on Forgejo estates.
  • The run page shows the base's gate, warns when a change loosens it, and never skips the inbox because the run's own config says never.
  • Tests cover each case above against fixture ledgers, including each gate: never hold and a loosening merge.

From a review of sluice against terragucci 0.4.39 and chant 0.124.27 (2026-10-20). Proposal for the maintainer; PRs would come from lex00/sluice.

Updated 2026-10-22 for terragucci main (pins chant 0.124.41, terragucci#1212–#1223) and chant 0.124.41–0.124.42.

(bug, shows once the sandbox runs terragucci past 0.4.10; #10 is unblocked) Part of the terraform-plane epic (arugula-salad/arugula#1141). Lands after terragucci's next release, the first built on chant 0.124.41 or later (chant#4287); npm's newest is still 0.4.40, on chant 0.124.24. sluice decides gates with a line-for-line port of terragucci 0.4.0's `decideGate` (`src/services/ledger.ts`) and writes resolutions itself. The record format is still accepted by chant 0.124.27 and terragucci 0.4.39. The decision isn't. Each of these makes the inbox say one thing and the wave do another: - Involvement (0.4.13, #1044 there): an approval from the PR author, a commit author or the agent's requester doesn't count, and their deny is dropped (terragucci `apply.ts` `beforeGateRules`/`resolutionRefusal`, `involved.ts`). sluice marks the row approved and resumes; terragucci writes a fresh pending fact and waits; a new row appears. The pending record's `excluded` names them. - `approval_rules` (0.4.35): the outcome line is `wave N waits (rules): ...` (`apply.ts:3574`), which `parseOutcome` doesn't read, and after the first approval terragucci exits 1 with `approval_rules not met` (`apply.ts:3470`), so the run is marked failed. - `require_signed`: `isSealed()` (`src/console/routes.tsx:49`) checks only `approval === "sealed"`, so the button writes lines that never count. Related to #8. - Spent approvals (0.4.11): `_gates/tf-apply/applied.jsonl` makes a spent approval of another digest "waiting", not "refused". The port has no `applied` input. - State migrations (0.4.5): wave 1 can wait on `_gates/tf-migrate.jsonl` with `migration <name> waits: ...` (`apply.ts:3625`). sluice parses wave 0, files a tf-apply approval and watches the wrong ledger. - Decision-point gates (`apply.point`, chant ws-091): only `chant workspace points answer` passes them; a resolution from sluice counts for nothing while its port says approved. - Base gate (0.4.40, terragucci#1202): each wave takes the stricter of `--gate` and the top-level `gate` at the first parent (`environmentWaveGates`, `apply.ts:1195`). sluice reads the config at the run's sha (`executor.ts` `configAtSha`), so a merge that loosens the gate to `never` still waits under 0.4.40+ while sluice's config says `never`. The plan note warns about a loosening since 0.4.40 (`report/stage.ts` `gateLoosening`); sluice's console doesn't. - Under `gate: never` a wave still waits for `cost.approve_above`, `on_failure: approve`, a policy hold, an environment's own gate, and wave 1 of a migration (terragucci `guides/run-without-approvals.mdx`, #1203). - Next release: `approval_rules` are judged by chant's quorum (terragucci#1217 deleted `approval-rules.ts`), and in pr-review mode a reviewer's role counts only when `.chant/trust.json` grants it to their principal, `github:<lowercased login>` (`forgejo@<host>:<login>` on Forgejo; `apply.ts` `reviewerPrincipal`). A grant to a bare login no longer counts. `actorOf` writes `github:` on Forgejo estates too. Policy argv and answers come from chant's `gate-policy` (#1218), and a policy hold makes the gate wait for an approval of the plan's own digest, even under `gate: never` (chant#4294). Porting stops being the way to keep up: terragucci now delegates most of this to chant, and chant's modules import into Bun. Bundled from the 0.124.41 tarball: - `@intentius/chant/op/gate-quorum` (13KB, node:crypto; also re-exported from `gate-decision`): use it. - `gate-decision`: its pure parts. `trustRolesAt`, `gateSignersAt` and `identityGatesAt` spawn git; pass them text read from the forge. - `gate-policy`: leave it to the sandbox (it spawns the policy engine). Pin whatever sluice imports to the chant version the pinned terragucci uses. Done when: - The watcher decides with `@intentius/chant/gate-decision` (`latestResolutionForPlan`, `isApprovalSpent`, `parseAppliedGateLines`; bundle-safe since chant #3763/#3778) instead of the port, and verifies seals with its `gateSealRefusal` before resuming. - The outcome comes from `TG_OUTCOME_JSON` (#10), including `excluded`, rules and the gate's ledger, so a migration gate files against `tf-migrate`. - The console refuses an involved approver before writing, and shows who is excluded and which rules remain. - A point gate shows its question and candidates and doesn't offer Approve. - `approval_rules` are judged with `gate-quorum` (`quorumOf`, mapping roots to targets and not_author to notAuthor; `quorumRuleProgress`, `quorumWaiting`), and the base decision plus spent approvals with `decideGateApproval({ spend: true })` (waiting and mismatched map to refused). Involvement (`involved.ts`) is still ported; chant doesn't have it. The pending fact keeps `roots`/`not_author` in `approval_rules` (`approval.ts` `ruleReport`), so the inbox can keep parsing it. - Principals are `forgejo@<host>:<login>` on Forgejo estates. - The run page shows the base's gate, warns when a change loosens it, and never skips the inbox because the run's own config says `never`. - Tests cover each case above against fixture ledgers, including each `gate: never` hold and a loosening merge. From a review of sluice against terragucci 0.4.39 and chant 0.124.27 (2026-10-20). Proposal for the maintainer; PRs would come from lex00/sluice. Updated 2026-10-22 for terragucci main (pins chant 0.124.41, terragucci#1212–#1223) and chant 0.124.41–0.124.42.
lex00 changed title from Decide gates the way terragucci 0.4.39 does to Decide gates the way terragucci does, with chant's gate modules 2026-10-23 02:48:44 +00:00
Sign in to join this conversation.
No labels
terraform-plane
No milestone
No project
No assignees
1 participant
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
jhgaylor/sluice#15
No description provided.