Skip to content

multi-engine B2: colour from the drift record #995

Closed

Description

@lex00

Replace per-engine colour logic with one fixed (status, read) table over chant's drift record (chant C1, INTENTIUS/chant#4451). Stop working out which read answered from chant's note text (src/terraform-plan.ts:26-31, src/choudoufu-chant-read.ts:139-148) and read rootReads (chant C2, INTENTIUS/chant#4452). Settle the UNOWNED disagreement with chant. Accepted when chant, choudoufu, plain Terraform and Pulumi members all colour from the record, and an unknown status renders neutral and labelled.

Part of #993.

Acceptance: read verdict lines and recorded artifacts, never exit codes alone. Anything that needs an emulator corpus, an estate run or a real cloud is run by the maintainer by hand. Red-first only for new guards.

Activity

  1. added
    multi-engine
    on Oct 25, 2026
  2. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    B2 landed in two repos.

    • behold integration/choudoufu-engine: merge 416ff0f (unit unit/b2-colour-from-record).
    • chant integration/choudoufu-engine: merge 9d2c384d6 (unit unit/b2-workspace-drift-read), which adds chant workspace drift.

    tsc --noEmit is clean in behold, in chant packages/core, and in lexicons/terraform (apart from the TS6059 messages that were already there). No test was run.

    chant: chant workspace drift

    chant workspace drift --member <name> [--read <state|plan|refresh|live-read|ownership>] [--resource <addr>] [--env <env>] [--components] [--stream] [-o <file>] is in packages/core/src/workspace/drift-cli.ts. B5 uses exactly these flag names.

    • A chant member runs its own chant lifecycle diff <env> --live --json through liveDiffDriftRecords, plus mergeDeepDrift when there is a deep result. --components adds components status <env> --live --json through componentStatusDriftRecords. A chant member needs --env.
    • A terraform or choudoufu member runs a new level-0 command, chant lifecycle drift, in the member's reader project (packages/core/src/cli/handlers/lifecycle-drift.ts). That command calls a new optional LexiconPlugin.readDrift, so core never imports the lexicon. The terraform lexicon implements readDrift in lexicons/terraform/src/drift-read.ts:
      • a stock root: show -json over state, or with --read plan the plan read. A plan that fails falls back to state, with fellBackFrom: "plan".
      • a live root: live-plan -json plus live-ls, or with --read plan live-plan with a plan beside it. A plan that fails falls back to ownership, with fellBackFrom: "live+plan".
      • --resource: passes choudoufu live-plan -resource=<addr>'s stream through, decoded by C1, with the workspace member's name put in member.
      • init is never run.
    • Each record's node is placed with graphNodeFor on the member's source graph, which comes from the per-member graph cache.
    • Output: the default is one drift document with contract: 1, chant and member. When the read could not run, the document has error: {code, message} and no records, and the command exits 1. --stream prints the C1 NDJSON stream.
    • drift.schema.json gains contract, member and error.
    • drift is now a reader conformance command (READ_CONTRACT_COMMANDS). The suite reads --member app, and app has no drift read, so that read reaches no account.
    • Docs: a new section in reference/drift-record.mdx, and a row plus a paragraph in workspace-read-contract.mdx.

    behold

    • src/drift-tone.ts holds the one fixed (status, read) table, DRIFT_TONE_TABLE and toneFor, with a cell for every pair. An unknown status or read is neutral with unknown: true and an "unknown ..." label.
      • An ownership read's in-sync is "bound (ownership only)".
      • A state read's recorded is neutral.
      • A state read that says in-sync or drifted is neutral and labelled, because chant would refuse that record.
    • B5's toneFor in src/drift-stream.ts is now this table. Stream frames carry unknown, and the card gets data-drift-unknown (web/app.js, web/drift-stream.js). web/drift-stream.js also matches a node that already has the member prefix, which is what chant prints.
    • src/drift-line.ts keeps a status outside chant's list instead of refusing the line.
    • src/workspace-reader.ts: drift is now in BEHOLD_READS, read as read("drift", driftArgs(ask)). It shares driftArgs with B5's driftStreamArgv.
    • src/drift-overlay.ts:
      • driftDocumentOf checks each record with the stream decoder.
      • paintDrift paints _status, _drift and _unobserved. When two records land on one card, chant's rollup order decides.
      • paintWorkspaceDrift makes one read per member.
    • /api/overlay on a declared workspace whose chant is at or above DRIFT_RECORD_CHANT_FLOOR (0.124.53, not released yet) paints terraform and pulumi members from the record. With ?drift=1 it also paints chant and choudoufu members, at the cost of a second live read. The result is in meta.driftRecord.
    • src/choudoufu-live.ts: REASON_TONE is removed. verdictFor now gives each address the status chant's adapter gives it, through omissionStatus, and takes the table's tone for read ownership. Each card also carries _drift.
    • src/component-status.ts: the reconciliation switch is now reconciliationStatus (chant's componentStatusDriftRecords mapping), coloured by the table. A new componentLooksDeployed keeps the Floci re-apply guard from counting a pending row as deployed.
    • Which read answered a root now comes from the IR's rootReads, in planRootAnswers (src/terraform-plan.ts) and rootAnswerOf(ir, root) (src/choudoufu-chant-read.ts). The note parsing is gone. planCardRows reads the reason from readReason, not from the note.
    • The AGENTS.md section "Colour from the drift record (multi-engine B2: colour from the drift record #995)" covers all of this.

    Decisions

    1. UNOWNED: behold follows chant C1. An UNOWNED omission with no unowned[] row is now not-observed and neutral (it was warn). With its unowned[] row it is still unclaimed and warn.
    2. B3 follow-up: behold keeps its choudoufu card ids (<member>/<address>) because saved layouts are keyed on them. One alias table, built from chant's graph for the choudoufu member (choudoufuCardAliases and cardIdFor in src/drift-overlay.ts), maps chant's <member>/<root>/<path> onto the card the entry's or record's address names. The change-set overlay (overlayFrom and readChangeSetOverlay) and drift records both use it. A node the table doesn't know keeps chant's id and is listed.
    3. Following chant's component-status mapping changes two colours. A component that is unrecorded but live is now drifted (warn), where it was good. One that is unrecorded and not live is now pending (accent), where it was neutral.
    4. Cost: by default the drift record paints only the members that have no live read of their own (terraform, pulumi). Chant and choudoufu members already colour through the same table on their existing reads. Painting them from the record too needs ?drift=1, because that costs a second live read.
    5. Without rootReads (any released chant today), a stock root reports no plan answer, and a choudoufu re-check reads as live-plan alone. This is because note parsing is gone. It is correct against chant's integration branch.

    Still missing

    • Tests written and not run. In behold: src/drift-tone.test.ts (the table, including unknown to neutral) and src/drift-overlay.test.ts (chant, choudoufu, plain Terraform and Pulumi members coloured from the record in one pass through the real reader, the alias table and the paint). Updated expectations are in choudoufu-live, choudoufu-chant-read, terraform-plan, instance-cards, component-status, change-set-overlay and drift-stream. In chant: packages/core/src/workspace/drift-cli.test.ts and the conformance e2e's command lists.
    • The member-kind e2e is a vitest flow over recorded drift documents. It is not a shell e2e against a served workspace, and no emulator or estate was run.
    • DRIFT_RECORD_CHANT_FLOOR is a guess at the next chant release (0.124.53). Correct it when that release is cut.
    • In the reader conformance test, drift runs only when the installed chant's suite lists it. behold's pinned chant (0.124.52) doesn't, so it is skipped until the pin moves.
    • Pulumi members colour from the record once chant C3 adds a pulumi row to DRIFT_READS_BY_KIND (chant drift-cli.ts) and the pulumi lexicon's readDrift. Until then workspace drift answers no-drift-read for them, and behold's table needs nothing more.
    • chant's scripts/docs-sentences-baseline.json was not regenerated.
    • The maintainer needs to run by hand: workspace drift against a real terraform root and a choudoufu estate, the per-resource path, and the behold overlay with ?drift=1.
  3. added a commit that references this issue on Oct 25, 2026
  4. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    Regression fix merged on behold integration/choudoufu-engine at 4fb9076 (unit/b2-fix-regressions). Nine tests that pass on main failed after B2, and all of them pass now.

    • The plan acceptance tests (4) and choudoufu-route choudoufu member: attribute drift a plan would revert is invisible in the overlay, the card stays green #404 (3) failed because the pinned chant (0.124.52) puts no rootReads on the graph. rootReads is still read first. When the IR has no rootReads, chant's per-root notes are parsed as before. The switch is on whether the field is present, not on the chant version (src/terraform-plan.ts parsePlanNotes, src/choudoufu-chant-read.ts rootAnswerOfNotes).
    • component-status (2): the tests were right and B2's mapping was wrong for this lens. An unrecorded row stays a presence colour, the same as tier 3's live boolean: good when live, neutral when not. An infra component with no artifact to record is deployed by design (CI executor 3/3: the forge pipeline as the designated prod apply executor #165). The other verdicts still colour through the (status, read) table. reconciliationStatus, C1's mapping, is kept for drift records only. This reverses decision 3 in my earlier comment.

    Run with vitest: the three failing files pass (85 tests). The other test files B2 touched pass too (119 passed, 7 skipped). No test failed once and then passed on a re-run.

  5. added a commit that references this issue on Oct 25, 2026
  6. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    Merged on behold integration/choudoufu-engine at bac693d (unit/b2-fix-rootreads-words). Against local integration chant (9d2c384d6, stamped 0.124.53), the plan acceptance test 'without provider credentials falls back to the state read' failed. chant's rootReads already carries the fallback and its reason (fellBackTo: state, reason: no-credentials). behold was writing that reason code into the note as-is, so the note said 'no-credentials' instead of 'no provider credentials'. It now puts the reason into words. Nothing is needed on the chant side.

    I also fixed beholdNodeModules so the scratch project still gets its node_modules link when chant is symlinked in from a local build.

    vitest, six files (terraform-plan.acceptance, choudoufu-route, component-status, terraform-plan, choudoufu-chant-read, terraform-member): 138 passed against local chant installed with install-local-chant.sh, and 138 passed against released chant 0.124.52. No test failed once and then passed on a re-run.

  7. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    Path 1 of the multi-engine engine tier is on main: choudoufu e5023addda, chant 1cf732818, behold e765bf6 (each a merge commit of integration/choudoufu-engine, tree identical to the tested tip). chant, choudoufu and plain Terraform members colour from the drift record on main. Left open for the Pulumi half: Pulumi members colour from the same (status, read) table once path 2 reaches main.

  8. lex00 commented on Oct 25, 2026

    @lex00
    ContributorAuthor

    Path 2 of the multi-engine engine tier is on main: plunge d6db28acdf, chant 867a12c65, behold 9f7066e (merge commits of integration/pulumi-engine, trees identical to the tested tips; path 1 was already on main). Pulumi members now colour from the same (status, read) table as chant, choudoufu and Terraform members; drift-tone and drift-overlay tests pass at epic-ready on both paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    multi-engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions