checkwright 0.18.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "checkwright",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "Vendors pinned Checkwright kit source into your repository and commits it — a coding-agent-assisted delivery methodology (gate SDK, evidence-stamped lifecycle, agent context economics).",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -19,6 +19,6 @@
19
19
  "README.md"
20
20
  ],
21
21
  "checkwright": {
22
- "commit": "34f2c6ec76213852bf599d74047546b670099fcd"
22
+ "commit": "067554a870ff564d90726c3cd5d042c266ae75f8"
23
23
  }
24
24
  }
@@ -105,6 +105,7 @@ check-root-tiering
105
105
  check-workflow-tiering
106
106
  check-action-pinning
107
107
  check-action-run-shell
108
+ check-action-gh-repo
108
109
  check-commit-msg
109
110
  check-commit-subject
110
111
  check-tree-terms
@@ -130,6 +130,15 @@ correct operation. So: **checked projections carry the header; local capture
130
130
  carries none.** That asymmetry is the substantive content of the
131
131
  tracked-vs-gitignored axis, not a convenience.
132
132
 
133
+ **It follows that a tracked member which drains, drains header-preservingly.**
134
+ The tier admits accumulation buffers as well as one-shot projections — a
135
+ surface any session appends to and one session empties at a boundary — and for
136
+ those the reclaim path cannot be local capture's `: > <file>`, which erases the
137
+ header and reds this gate on the very commit that drains. Truncate to the
138
+ header instead. Every draining member of this tier already does:
139
+ `WORKFLOW-STATE.txt` at the iteration boundary, `gap-inbox.md` at close,
140
+ `tightened-gates.txt` at the tag.
141
+
133
142
  **The header form.** A checked projection's first line is `# contract: `
134
143
  followed by one of two ruled payloads:
135
144
 
@@ -546,6 +555,67 @@ mechanism, so a second injector adds no second copy of the awk replace logic:
546
555
  a gate: exercised end-to-end wherever an installer that rides it runs
547
556
  (doctrine-kit and lifecycle-kit `smoke/install.sh`).
548
557
 
558
+ ### lib/declaration.sh
559
+
560
+ The tightened-gates declaration grammar — **two container arms over one token
561
+ predicate**, sourced by three callers. The token predicate is a bare gate name
562
+ (`DECL_TOKEN_RE`); the container is the only thing that differs between the arms,
563
+ which is what keeps two surfaces from re-opening the same defect from opposite
564
+ directions.
565
+
566
+ - **The markdown arm** — a note's `## <section>` bullet lead tokens
567
+ (`decl_section_bullets` for the container alone, `decl_section_tokens` for the
568
+ verdict). A bullet's
569
+ lead token is the backticked, unbolded bare gate name directly after the bullet
570
+ marker; a bullet shaped any other way yields *no* token rather than a stripped
571
+ one, which is what makes the bolded and bold-and-backticked spellings visible
572
+ instead of silent.
573
+ - **The record arm** — a declaration file's data lines, one bare gate name each
574
+ (`decl_record_tokens`). That surface is deliberately markup-free, so the
575
+ spelling question does not arise on it at all. A missing file is the empty set
576
+ rather than an error: a tree that has never declared one is not thereby
577
+ malformed.
578
+
579
+ The status a caller branches on: **0** resolved, with the declared set on stdout
580
+ (empty for an explicit `None`); **1** unparsed while not `None`, with the
581
+ offending lines on stdout — which is empty when the section held no bullet at
582
+ all; **2** the named section is absent. The record arm has no `None` body and so
583
+ no status 2.
584
+
585
+ The markdown arm reports the **trichotomy** the grammar defines: an explicit
586
+ `None` body (the resolved empty set), a non-empty token list, or
587
+ unparsed-and-not-`None`. The third arm is the one that earns the helper. A
588
+ non-`none` section yielding zero tokens must not become "no allowed reds": on a
589
+ green battery that passes silently over a note naming several gates, and on a red
590
+ one it fails *loudly with a false message*, accusing the note of an omission it
591
+ did not make. The assertion is not leniently disarmed there — it is severed from
592
+ the artifact it claims to read. So the helper refuses, and the refusal is what
593
+ closes the class permanently: no future markup variant can disarm the assertion,
594
+ only red it.
595
+
596
+ Callers, all three named: `bin/upgrade-smoke.sh` at its declaration-resolve step
597
+ uses both arms (§upgrade-smoke); this repo's `check-tightened-gates-grammar`
598
+ uses the markdown arm's verdict at each note it walks; and
599
+ `scripts/check-release-bump.sh` uses the markdown arm's *container* alone,
600
+ counting bullets across all three of the note's fixed sections. That third caller
601
+ is why the container and the token predicate are separable rather than one pass:
602
+ Behavior-changes lead tokens are legitimately prose phrases, so the bump
603
+ derivation needs the bullets without the token predicate. Before this helper the
604
+ container was stated three times and two of the statements already disagreed —
605
+ `section_bullets` matched `- ` at column zero where the smoke matched an
606
+ optionally-indented `-` or `*` — so the section a bump was derived from and the
607
+ section an allowed-red set was parsed from were not guaranteed to be the same
608
+ section. A sourced library, not a gate, so it owes no `good/`+`bad/` pair; its
609
+ runtime lock-in is `gate-tests/lib-declaration.test.sh`, direct because the
610
+ record arm has no caller fixture to ride. That arm's only caller is the smoke's
611
+ untagged branch, and the smoke is a `bin/` tool that forgoes a pair — so a
612
+ corpus fixture would leave the arm the standing pre-release assertion depends on
613
+ entirely unexercised.
614
+
615
+ The helper carries no section name and no gate name of its own — both are the
616
+ caller's arguments, and it takes no configuration. That is where the seam falls:
617
+ the parsing is kit mechanism, the parsed content is the consumer's.
618
+
549
619
  ### lib/test-hermetic.sh
550
620
 
551
621
  The bespoke-test hermeticity bootstrap, sourced as the first act of every
@@ -677,22 +747,72 @@ regenerates the generated artifacts — the contract's consumer phase-A steps
677
747
  consumer's `git status` shows changes only under the kit roots and the two
678
748
  regenerated artifacts — the pre-commit hook and the graph) and then, over the
679
749
  phase-B battery, that the **red set is a subset of TO's tightened-gates
680
- declaration** — the `docs/posts/` note whose front-matter `release:` names TO's
681
- version, parsed for the bullet lead tokens docs/install.md owns. A new N+1 gate
750
+ declaration**. A new N+1 gate
682
751
  is *not* in this consumer's `gates.list` (the phase-A sync never re-runs the
683
752
  installer, so it does not run in phase B); the smoke asserts the declaration's
684
753
  sufficiency for the gates that *do* run, and the upgrade skill
685
754
  (lifecycle-kit/SPEC.md §templates/upgrade.md) is the executor that registers the
686
- new ones. When TO is unreleased — the `HEAD` default resolving no version — no
687
- note names it and the red set must be empty: every run is then the standing
688
- pre-release assertion that the working tree upgrades cleanly from the last tag. A
689
- red gate absent from the declaration, or a missing/unparseable note while reds
690
- exist, is a fail (exit 1); usage/environment failure is exit 2 (the gate exit
691
- convention). A `bin/` tool, not a gate — no `good/`+`bad/` fixture pair is owed;
755
+ new ones. A
756
+ red gate absent from the declaration, or a declaration that does not parse while
757
+ reds exist, is a fail (exit 1); usage/environment failure is exit 2 (the gate exit
758
+ convention). A malformed declaration is a contract violation rather than a broken
759
+ environment, which is why it takes exit 1 and not 2.
760
+ A `bin/` tool, not a gate — no `good/`+`bad/` fixture pair is owed;
692
761
  the `upgrade` validate suite running it (scripts/evidence-config.sh) is its
693
762
  evidence, at ~2× run-consumer-smoke's cost since it runs the battery twice in
694
763
  scratch (accepted as validate-stage cost, never pre-commit).
695
764
 
765
+ **The declaration resolves on two arms, both over §lib/declaration.sh's one
766
+ token predicate.** A **tagged TO** resolves its version from the `v*` tag
767
+ pointing at it and its declaration from the `docs/posts/` note whose front-matter
768
+ `release:` names that version — the Tightened-gates section's bullet lead tokens,
769
+ whose grammar docs/install.md owns. An **untagged TO** — the `HEAD` default, and
770
+ so every run of the standing pre-release assertion — reads
771
+ `<workflow-dir>/tightened-gates.txt` out of TO's tree instead. It is *this* arm
772
+ that makes the assertion satisfiable by an iteration that tightens something: the
773
+ old rule resolved no version, so no note, so an empty declared set, so a red set
774
+ that had to be empty — which no tightening iteration can be until the moment it
775
+ is tagged. The empty-declaration rule survives as the narrow case (an empty
776
+ declared set still forces an empty red set), not as the universal one.
777
+
778
+ **The declaration surface**, `<workflow-dir>/tightened-gates.txt`, is a tracked
779
+ checked projection (§The workflow directory) whose path derives from
780
+ `GATE_SDK_WORKFLOW_DIR` — no knob of its own, since a knob naming this file would
781
+ add a way to configure the assertion away without adding a way to satisfy it
782
+ honestly. It always exists, header-only when the declared set is empty, so
783
+ "absent" is never a state a reader must interpret. Its data lines are one bare
784
+ gate name each and nothing else: no markup, no prose, no ordering significance —
785
+ a rationale column would be a field the smoke never reads and the note's bullet
786
+ prose already owns. Only gates that ship **inside a kit** are declared, because
787
+ those are the only ones a consumer's vendored tree runs; a gate living solely in
788
+ the consumer's own gates directory cannot appear in a vendored tree and is not
789
+ part of any release's allowed-red set. Being tracked is load-bearing rather than
790
+ incidental: the smoke reads the file out of a `git archive` of TO, which carries
791
+ tracked content only.
792
+
793
+ Its **producer** is the build stage that lands or tightens a gate, appending the
794
+ name in the same unit (lifecycle-kit/templates/stages/build.md). Build is the
795
+ only stage that knows what it tightened at the moment it tightens it, so the
796
+ declaration is written from knowledge rather than reconstructed from a red — and
797
+ an assertion that discovers its allowed-red set from the gate it was meant to
798
+ check is its own trigger. A gate that lands **new** is appended too: docs/install.md
799
+ defines the note's section as one bullet per gate that landed new or got
800
+ stricter, so a surface holding only strictly-tightened gates would make the
801
+ composition lossy. It costs the assertion nothing — containment is red ⊆
802
+ declared, so a declared gate that never reds is inert.
803
+
804
+ It **accumulates**, and that shape is chosen rather than inherited. Tightened
805
+ gates is a *release*-level aggregate, not an iteration-level one: several
806
+ internal iterations batching into one external release is a shape this repo
807
+ wants, and under it a build stage authoring note prose directly would write into
808
+ an artifact that does not exist yet and whose version it cannot know. Appending
809
+ to a buffer composed once at the release boundary is correct under batching and
810
+ degenerates gracefully to the one-iteration-one-release case. So an iteration
811
+ closing on `release none` or a deferral carries its declarations forward, which
812
+ is exactly what the next release's note must inherit. RELEASING.md §The procedure
813
+ composes the note's Tightened-gates section from it at step 1 and drains it —
814
+ truncating to the header, never clearing the file — at the tag in step 4.
815
+
696
816
  Knobs — config-via-env in the `<KIT>_<KNOB>` shape, defaults this repo's layout,
697
817
  each read exactly once at the resolve step:
698
818
 
@@ -711,10 +831,18 @@ the script pre-upgrade; it is consumed by the validate session's evidence file
711
831
  (this repo) or the operator's go/no-go on a consumer tree. The
712
832
  `GATE_SDK_UPGRADE_*` knobs are produced by the invoking environment (defaults
713
833
  emitted by the script itself, so the zero-config run works here) and read only
714
- at the resolve step. The tightened-gates declaration is produced by the release
715
- session (RELEASING.md) and consumed here (the allowed-red-set parse) and by the
716
- upgrade skill (the consumer checklist); its grammar owner is docs/install.md
717
- §The upgrade contract.
834
+ at the resolve step. The declaration path is derived from `GATE_SDK_WORKFLOW_DIR`
835
+ at the same step. The tightened-gates declaration is produced by the build stage
836
+ that lands or tightens a gate, appending to the declaration surface, and composed
837
+ by close into the note at the release boundary; it is consumed at three named
838
+ transitions — here at the resolve step on either arm (the allowed-red-set parse),
839
+ by close when it composes and drains, and by the upgrade skill reading the note
840
+ as the consumer's registration checklist. That third reader is unaffected by the
841
+ two-arm resolution: it reads the *note*, which is unchanged as an artifact, and
842
+ only the note's Tightened-gates section changed its source. The grammar's owner
843
+ is docs/install.md §The upgrade contract; its implementation is
844
+ §lib/declaration.sh, and this repo holds the corpus to it with
845
+ `check-tightened-gates-grammar`.
718
846
 
719
847
  ### gen-pre-commit
720
848
 
@@ -1538,7 +1666,10 @@ Invariant: every GitHub Actions `run:` **literal block scalar** in a scanned YAM
1538
1666
  file is ShellCheck-clean at `-S warning` under the dialect the step actually
1539
1667
  runs. It closes the class §check-shellcheck's target derivation leaves open — a
1540
1668
  workflow's `run:` body is shell that nothing lints, shellchecks, or executes
1541
- outside a push or a tag.
1669
+ outside a push or a tag. It is not the only gate on that surface:
1670
+ §check-action-gh-repo reads the same `run:` bodies for a **semantic** property
1671
+ ShellCheck is structurally blind to, so a reader arriving here should not
1672
+ conclude the `run:` surface has one gate.
1542
1673
 
1543
1674
  Kit mechanism rather than a consumer gate, and the deciding fact is that kits
1544
1675
  ship workflow templates carrying `run:` shell — §templates/gates-workflow.yml and
@@ -1672,6 +1803,150 @@ binary is exit 2, as §check-shellcheck models. A tree holding no YAML exits cle
1672
1803
  on a zero count, the counted inertness that makes this kit mechanism: a consumer
1673
1804
  running no GitHub Actions pays nothing for it.
1674
1805
 
1806
+ ### check-action-gh-repo
1807
+
1808
+ Invariant: in every Actions-shaped YAML file, a **job** whose `run:` bodies
1809
+ invoke `gh` establishes a repository context — the job contains a checkout step
1810
+ ordered before its first such invocation, or `GH_REPO` is set at workflow, job,
1811
+ or invoking-step level, or every detected invocation in the job carries
1812
+ `--repo`. A job satisfying none of them cannot resolve a target repository, and
1813
+ nothing else catches it until a tag fires.
1814
+
1815
+ The class is attested rather than hypothetical: it took down `v0.17.0`'s
1816
+ `release` job on its first live run, which died in seconds on `failed to run
1817
+ git: fatal: not a git repository` before its first API call, with no Release
1818
+ created and no assets attached. The failure mode is the worst-timed one
1819
+ available — green everywhere, red only at the tag, on the release path itself.
1820
+ §check-action-run-shell lints exactly that block and passes it: the shell is
1821
+ valid, the variables are quoted, the control flow is sound. The defect is
1822
+ **semantic**, an assumption about the runner's filesystem no syntactic linter can
1823
+ hold.
1824
+
1825
+ Kit mechanism rather than a consumer gate, and the deciding fact is
1826
+ §check-action-run-shell's: a *kit* ships a workflow template carrying `gh` calls
1827
+ in its `run:` bodies — site-kit's `templates/site-health.yml`, a copy-out
1828
+ consumers vendor. A consumer gate would cover one tree and leave every downstream
1829
+ vendor of that template unchecked, and that the template belongs to a *different
1830
+ kit* is what makes the argument decisive. Named `action-`, not
1831
+ `check-workflow-*`, for §check-action-pinning's reason.
1832
+
1833
+ **Scan set and the split predicate.** The walk is §check-action-pinning's —
1834
+ `gate_find` for `*.yml` / `*.yaml` from the scan root, shared prune set, no
1835
+ roster and **no new knob**. §check-action-run-shell's Actions-shape predicate is
1836
+ then split rather than borrowed whole, because this gate needs its two arms
1837
+ apart: a top-level `jobs:` key makes a file the subject; a `runs:`-shaped
1838
+ composite action is **skipped and counted**, having no job of its own and
1839
+ inheriting the calling job's repository context, so the assertion belongs to the
1840
+ caller; a file matching neither is outside the scan. Two lineages, named
1841
+ separately because they are separate — §check-action-pinning contributes the scan
1842
+ set and carries no Actions-shape predicate, §check-action-run-shell contributes
1843
+ the predicate and no bearing on the scan set.
1844
+
1845
+ **The detector — the trigger and the `--repo` arm are one.** The gate must
1846
+ already answer "does this line invoke `gh`" to arm at all, so the arm is
1847
+ evaluated per detected invocation and is *universally quantified over the
1848
+ detected set* rather than satisfied by a witness. One unprefixed call fails the
1849
+ arm by construction; there is no search for a positive example to be fooled by,
1850
+ and a job mixing prefixed and unprefixed calls — the false negative the arm was
1851
+ designed against — reds. Over each `run:` body in the job:
1852
+
1853
+ - **Logical lines.** Backslash continuations are joined before matching, so a
1854
+ call split across lines is one unit and its `--repo` is found wherever on the
1855
+ call it sits. A detected call's `--repo` is looked for only within that call's
1856
+ own extent, so a second call on the same logical line cannot lend the first one
1857
+ its flag.
1858
+ - **Command position.** A `gh` token counts only where a shell would read it as a
1859
+ command: opening a logical line, or following a command separator, an opener, or
1860
+ a command-introducing keyword. Whole-word matching keeps `ghost` and `gh-pages`
1861
+ out. The check owns the roster of separators, openers, and keywords, and
1862
+ **that roster is a calibration the in-tree corpus forced**, not decoration:
1863
+ `publish.yml`'s release job opens with `if ! gh release view`, and without the
1864
+ negation among the openers the gate would take a later call as the job's *first*
1865
+ invocation and run the checkout arm's ordering comparison against the wrong
1866
+ line.
1867
+ - **Comment lines.** A logical line whose first non-blank character is `#` is not
1868
+ a command line — a leading `#` in shell is always a comment. A trailing `#`
1869
+ comment is left in place, which over-detects and is the safe direction.
1870
+ - **Scalar forms.** A literal block scalar is scanned line-wise; a folded one is
1871
+ scanned the same way even though folding would join its lines, and a plain
1872
+ single-line scalar is scanned as one logical line. All three over-detect rather
1873
+ than skip, which is why this gate refuses none of the forms
1874
+ §check-action-run-shell refuses — it reads for one token, not for shell it must
1875
+ reassemble faithfully.
1876
+ - **The bias, stated rather than left implicit.** Every ambiguity resolves toward
1877
+ over-detection. A false positive costs a workflow author one `GH_REPO:` line or
1878
+ one exemption marker; a false negative is the release-path failure this gate
1879
+ exists for.
1880
+
1881
+ **The checkout arm and its honest limit.** A step satisfies it when its `uses:`
1882
+ ref before the `@` is `actions/checkout` **and** its line precedes the job's
1883
+ first detected invocation; a checkout ordered after the call establishes nothing,
1884
+ and the ordering comparison is free once both line numbers are in hand. Any other
1885
+ means of establishing a git remote — a hand-rolled `git clone`, a different
1886
+ checkout action — is outside the gate's theory and takes the valve. That limit is
1887
+ stated rather than papered over with a looser match, because a looser match is
1888
+ what turns a semantic assertion back into a syntactic one.
1889
+
1890
+ **The environment arm.** `GH_REPO` satisfies it when set at workflow-root `env:`,
1891
+ at `jobs.<id>.env:`, or on the `env:` of the step whose body carries the
1892
+ invocation. `gh` resolves its target repository from `GH_REPO` and from the git
1893
+ remote, so no other variable joins the arm; a consumer relying on a different
1894
+ mechanism takes the valve. The arm is the one the fixed instance used and the one
1895
+ that survives maintenance: a job-level `GH_REPO` cannot be undone by someone
1896
+ adding a new `gh` call, whereas per-call `--repo` can. **The step-level lookup is
1897
+ load-bearing, not completeness** — the fixed instance sets `GH_REPO` on the
1898
+ invoking step's `env:`, not at workflow or job root, so the one in-tree job this
1899
+ gate exists for passes on the *narrowest* of the three lookups, and a gate
1900
+ implementing only the outer two would red `publish.yml` on day one and read as a
1901
+ false positive.
1902
+
1903
+ **The arms are disjoined per job, and each is quantified over the whole detected
1904
+ set.** A job passes on the checkout arm, or because every detected invocation has
1905
+ `GH_REPO` in scope, or because every one carries `--repo` — never by pairing a
1906
+ `GH_REPO` step with a `--repo` step. Mixing them reds, which is a false positive
1907
+ one `env:` line or one marker resolves, and the alternative — a per-invocation
1908
+ disjunction — would let a job satisfy the invariant in a way no reader of it
1909
+ could state.
1910
+
1911
+ **The valve.** `# gh-repo-exempt: <reason>`, taking the kit's established
1912
+ `# <thing>-exempt:` marker shape. It binds by its own indentation: at or left of
1913
+ the job-id column it precedes a job, at the step-list dash column it precedes a
1914
+ step, and inside a step's keys it binds that step — a job-bound marker skips the
1915
+ job, a step-bound one drops that step's invocations from the detected set and
1916
+ leaves the job's others held to the arms. The reason is **required and
1917
+ non-empty**; a bare marker is its own failure class with its own `help:` line,
1918
+ since the valve's whole value is the sentence saying which arm the author is
1919
+ standing outside of. That requirement is a deliberate tightening, not
1920
+ conformance, and saying so is the honest form: no sibling enforces it —
1921
+ `check-test-hermetic` and `check-assertion-strength` match their marker with the
1922
+ colon and read no reason, `check-gate-fail-closed` matches a bare
1923
+ `fail-closed-exempt` without even requiring the colon, and there is no shared
1924
+ marker parser in `lib/gate.sh`. The tightening is worth its inconsistency here
1925
+ because this valve stands a job outside a *release-path* assertion, where an
1926
+ unexplained exemption is the failure mode the gate exists for; whether the
1927
+ siblings should follow is not this section's question.
1928
+
1929
+ **The walk is this gate's own, and §check-action-run-shell's extractor is not
1930
+ reusable here.** That extractor has no theory of `jobs:` at all: it partitions by
1931
+ *file*, and what it emits carries no job identity and none of the `uses:` or
1932
+ `env:` lines the arms read. This gate needs a job-partitioned walk carrying all
1933
+ three, so it is **not** the second consumer that section's standing
1934
+ rule waits for: its "a helper earns its place at a second consumer and there is
1935
+ none", and the matching `# spec:` comment at the extractor itself, stay true.
1936
+ Stated because the opposite reading is the natural one, and because
1937
+ §lib/declaration.sh met the *same* standing rule with the opposite answer — only
1938
+ the difference in what is being extracted decides it.
1939
+
1940
+ Tier `precommit`; the `# graph:` couples the surfaces §check-action-pinning
1941
+ couples, `dir=one` — a one-way audit. A tree holding no YAML, or no job invoking
1942
+ `gh`, exits clean on a zero count, the counted inertness that makes this kit
1943
+ mechanism rather than a consumer gate. The `bad/` fixture opens on the attested
1944
+ miss itself — the `v0.17.0` release job as it shipped — and carries further
1945
+ reject jobs for the arms that one does not exercise, so §When a gate earns its
1946
+ place's demand that a higher-false-positive
1947
+ gate wait for a real miss is met by a fixture that *is* the miss rather than an
1948
+ invention of one.
1949
+
1675
1950
  ### check-commit-msg
1676
1951
 
1677
1952
  Invariant: the prospective commit message (the `commit-msg` hook's `$1`) matches
@@ -7,6 +7,8 @@ SDK="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7
7
  source "$SDK/lib/gate.sh"
8
8
  # shellcheck source=../lib/consumer-smoke.sh
9
9
  source "$SDK/lib/consumer-smoke.sh"
10
+ # shellcheck source=../lib/declaration.sh
11
+ source "$SDK/lib/declaration.sh"
10
12
 
11
13
  # spec: gate-sdk/SPEC.md §upgrade-smoke — resolve the source repo, FROM, and TO (each knob read exactly here)
12
14
  REPO="${GATE_SDK_UPGRADE_REPO:-$(git -C "$SDK" rev-parse --show-toplevel 2>/dev/null)}"
@@ -109,26 +111,40 @@ fi
109
111
  git -C "$CONS" -c user.email=smoke@example.invalid -c user.name=smoke \
110
112
  commit -q --no-verify --allow-empty -m "phase A: kits at $TO"
111
113
 
112
- # spec: gate-sdk/SPEC.md §upgrade-smoke — step 3: the red set must be a subset of TO's tightened-gates declaration (the docs/posts note whose front-matter release: names TO's version). TO unreleased (HEAD) resolves no version → no note → the red set must be empty.
114
+ # spec: gate-sdk/SPEC.md §upgrade-smoke — step 3: the red set must be a subset of TO's tightened-gates declaration, resolved on two arms over lib/declaration.sh's one token predicate. TO tagged: the docs/posts note whose front-matter release: names the tag, its Tightened-gates lead tokens. TO untagged (the HEAD default): the declaration surface in TO's tree, appended by the build stage that landed or tightened the gate — so an untagged TO proves containment rather than emptiness.
113
115
  ver="$(git -C "$REPO" tag --points-at "$TO" --list 'v*' 2>/dev/null | head -1)"
114
- note=""
116
+ DECL_FILE="$TO_TREE/${GATE_SDK_WORKFLOW_DIR:-.workflow}/tightened-gates.txt"
117
+
118
+ decl_src=""; decl_out=""; decl_st=0
115
119
  if [[ -n "$ver" ]]; then
116
120
  shopt -s nullglob
117
121
  for f in "$TO_TREE"/docs/posts/*.md; do
118
- if grep -qE "^release:[[:space:]]+${ver}[[:space:]]*\$" "$f"; then note="$f"; break; fi
122
+ if grep -qE "^release:[[:space:]]+${ver}[[:space:]]*\$" "$f"; then decl_src="$f"; break; fi
119
123
  done
120
124
  shopt -u nullglob
125
+ if [[ -n "$decl_src" ]]; then
126
+ decl_out="$(decl_section_tokens "$decl_src" "Tightened gates")"; decl_st=$?
127
+ fi
128
+ elif [[ -f "$DECL_FILE" ]]; then
129
+ decl_src="$DECL_FILE"
130
+ decl_out="$(decl_record_tokens "$DECL_FILE")"; decl_st=$?
121
131
  fi
122
132
 
123
- allowed=()
124
- if [[ -n "$note" ]]; then
125
- body="$(awk '/^##[[:space:]]+Tightened gates[[:space:]]*$/{f=1;next} /^##[[:space:]]/{f=0} f' "$note")"
126
- if ! grep -qiE '^[[:space:]]*none\b' <<<"$body"; then
127
- mapfile -t allowed < <(printf '%s\n' "$body" \
128
- | sed -nE 's/^[[:space:]]*[-*][[:space:]]+`?([A-Za-z][A-Za-z0-9-]*)`?.*/\1/p' | sort -u)
129
- fi
133
+ if [[ "$decl_st" -eq 2 ]]; then
134
+ echo "upgrade-smoke: FAIL — TO ($ver) resolves note $decl_src, which carries no 'Tightened gates' section:" >&2
135
+ echo " every release note carries all three fixed sections (docs/install.md §The upgrade contract)." >&2
136
+ exit 1
137
+ fi
138
+ if [[ "$decl_st" -ne 0 ]]; then
139
+ echo "upgrade-smoke: FAIL — TO (${ver:-$TO})'s tightened-gates declaration does not parse, so it would resolve to a silently empty allowed-red set — $decl_src:" >&2
140
+ [[ -n "$decl_out" ]] && printf ' %s\n' "$decl_out" >&2
141
+ echo " a declaration is either an explicit 'None' or a non-empty set of bare gate names; in a note each is the backticked, unbolded lead token of a bullet (docs/install.md §The upgrade contract)." >&2
142
+ exit 1
130
143
  fi
131
144
 
145
+ allowed=()
146
+ mapfile -t allowed < <(printf '%s\n' "$decl_out" | grep -v '^[[:space:]]*$' | sort -u)
147
+
132
148
  out="$(run_battery)"; rc=$?
133
149
  red=()
134
150
  if [[ "$rc" -ne 0 ]] || ! grep -qE 'All [0-9]+ gates passed' <<<"$out"; then
@@ -141,10 +157,14 @@ if [[ "$rc" -ne 0 ]] || ! grep -qE 'All [0-9]+ gates passed' <<<"$out"; then
141
157
  read -r -a red <<<"${line#*FAILED: }"
142
158
  fi
143
159
 
144
- if [[ ${#red[@]} -gt 0 && -z "$note" ]]; then
145
- echo "upgrade-smoke: FAIL — TO (${ver:-$TO}) reddened gate(s) but no release note declares a tightened-gates set:" >&2
160
+ if [[ ${#red[@]} -gt 0 && -z "$decl_src" ]]; then
161
+ echo "upgrade-smoke: FAIL — TO (${ver:-$TO}) reddened gate(s) but declares no tightened-gates set anywhere:" >&2
146
162
  printf ' %s\n' "${red[@]}" >&2
147
- echo " an unreleased TO must upgrade green; a red gate needs a note bullet (docs/install.md §The upgrade contract)." >&2
163
+ if [[ -n "$ver" ]]; then
164
+ echo " no docs/posts note carries 'release: $ver'; a red gate needs a note bullet (docs/install.md §The upgrade contract)." >&2
165
+ else
166
+ echo " an untagged TO reads ${DECL_FILE#"$TO_TREE"/}, which TO's tree does not carry; the build stage that lands or tightens a gate appends its name there (gate-sdk/SPEC.md §upgrade-smoke)." >&2
167
+ fi
148
168
  exit 1
149
169
  fi
150
170
 
@@ -155,9 +175,9 @@ done
155
175
  if [[ ${#undeclared[@]} -gt 0 ]]; then
156
176
  echo "upgrade-smoke: FAIL — gate(s) went red that TO's tightened-gates declaration does not name:" >&2
157
177
  for g in "${undeclared[@]}"; do echo " $g" >&2; done
158
- echo " each red must be a bullet in the note's Tightened gates section, or the tree fixed (docs/install.md §The upgrade contract)." >&2
178
+ echo " each red must be named in $decl_src — a bullet in the note's Tightened gates section, or a data line of the declaration surface — or the tree fixed (docs/install.md §The upgrade contract)." >&2
159
179
  exit 1
160
180
  fi
161
181
 
162
- echo "UPGRADE-SMOKE: clean ($FROM → $TO; ${#fromroots[@]}→${#toroots[@]} kits vendored, phase A deterministic, red set ${#red[@]} ⊆ ${#allowed[@]} declared)"
182
+ echo "UPGRADE-SMOKE: clean ($FROM → $TO; ${#fromroots[@]}→${#toroots[@]} kits vendored, phase A deterministic, red set ${#red[@]} ⊆ ${#allowed[@]} declared by ${decl_src:-no declaration})"
163
183
  exit 0