checkwright 0.18.0 → 0.19.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 +2 -2
- package/payload/gate-sdk/README.md +1 -0
- package/payload/gate-sdk/SPEC.md +288 -13
- package/payload/gate-sdk/bin/upgrade-smoke.sh +35 -15
- package/payload/gate-sdk/checks/check-action-gh-repo.sh +321 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/bad/args +3 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/bad/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/bad/tree/workflows/publish.yml +78 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/args +4 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/action.yml +11 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/not-actions.yml +10 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/workflows/arms.yml +93 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/workflows/root-env.yml +18 -0
- package/payload/gate-sdk/gate-tests/check-action-gh-repo/good/tree/workflows/valves.yml +39 -0
- package/payload/gate-sdk/gate-tests/lib-declaration.test.sh +112 -0
- package/payload/gate-sdk/lib/declaration.sh +59 -0
- package/payload/lifecycle-kit/templates/stages/build.md +15 -0
- package/payload/site-kit/SPEC.md +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "checkwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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": "
|
|
22
|
+
"commit": "bc0c215c998a47058140c5ac1b897261d107cb5b"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/payload/gate-sdk/SPEC.md
CHANGED
|
@@ -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
|
|
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.
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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 "$
|
|
145
|
-
echo "upgrade-smoke: FAIL — TO (${ver:-$TO}) reddened gate(s) but
|
|
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
|
-
|
|
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
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# graph: couples=.github/workflows/*.yml,.github/workflows/*.yaml,.github/ISSUE_TEMPLATE/*.yml,docs/_config.yml,kit:templates/*.yml,kit:templates/*.yaml dir=one valve=none tier=precommit
|
|
3
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — a job whose run: bodies invoke gh establishes a repository context: a checkout before the first call, GH_REPO in scope, or --repo on every call
|
|
4
|
+
#
|
|
5
|
+
# usage: check-action-gh-repo.sh [scan-root]
|
|
6
|
+
# scan-root: the walked tree (default '.'). Requires GNU awk (3-arg match).
|
|
7
|
+
set -uo pipefail
|
|
8
|
+
|
|
9
|
+
SDK="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
10
|
+
# shellcheck source=../lib/gate.sh
|
|
11
|
+
source "$SDK/lib/gate.sh"
|
|
12
|
+
|
|
13
|
+
SCANROOT="${1:-.}"
|
|
14
|
+
[[ -d "$SCANROOT" ]] || { echo "check-action-gh-repo: scan root not found: $SCANROOT" >&2; exit 2; }
|
|
15
|
+
|
|
16
|
+
listing="$(gate_find "$SCANROOT" -type f \( -name '*.yml' -o -name '*.yaml' \))"; st=$?
|
|
17
|
+
fail_closed "$st" ACTION-GH-REPO gate_find
|
|
18
|
+
mapfile -t files < <(printf '%s' "$listing")
|
|
19
|
+
|
|
20
|
+
if [[ ${#files[@]} -eq 0 ]]; then
|
|
21
|
+
echo "ACTION-GH-REPO: clean (no YAML under $SCANROOT — 0 job(s) to check)"
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
WALK='
|
|
26
|
+
function ind(s, n) { n = match(s, /[^ ]/); return (n == 0) ? -1 : n - 1 }
|
|
27
|
+
|
|
28
|
+
function keyof(s, t) {
|
|
29
|
+
t = s
|
|
30
|
+
sub(/^[ ]*/, "", t)
|
|
31
|
+
if (t !~ /^[^ :]+[ ]*:/) return ""
|
|
32
|
+
sub(/[ ]*:.*$/, "", t)
|
|
33
|
+
return t
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — the trigger and the --repo arm share one detector, so the arm is universally quantified over the detected set rather than satisfied by a witness
|
|
37
|
+
function scanlogical(s, ln, t, n, i, c, prefix, w, ok, ext, j, cut, hasrepo) {
|
|
38
|
+
t = s
|
|
39
|
+
sub(/^[ \t]+/, "", t)
|
|
40
|
+
if (substr(t, 1, 1) == "#") return
|
|
41
|
+
n = length(s)
|
|
42
|
+
for (i = 1; i < n; i++) {
|
|
43
|
+
if (substr(s, i, 2) != "gh") continue
|
|
44
|
+
c = substr(s, i + 2, 1)
|
|
45
|
+
if (c ~ /[A-Za-z0-9_.-]/) continue
|
|
46
|
+
prefix = substr(s, 1, i - 1)
|
|
47
|
+
sub(/[ \t]+$/, "", prefix)
|
|
48
|
+
ok = 0
|
|
49
|
+
if (prefix == "") ok = 1
|
|
50
|
+
else {
|
|
51
|
+
c = substr(prefix, length(prefix))
|
|
52
|
+
if (index("|&;(`!{", c) > 0) ok = 1
|
|
53
|
+
else {
|
|
54
|
+
w = prefix
|
|
55
|
+
sub(/^.*[ \t]/, "", w)
|
|
56
|
+
if (w == "then" || w == "else" || w == "do" || w == "elif") ok = 1
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!ok) continue
|
|
60
|
+
ext = substr(s, i + 2)
|
|
61
|
+
cut = length(ext)
|
|
62
|
+
for (j = 1; j <= length(ext); j++) {
|
|
63
|
+
c = substr(ext, j, 1)
|
|
64
|
+
if (c == ";" || c == "|" || c == "&") { cut = j - 1; break }
|
|
65
|
+
}
|
|
66
|
+
ext = substr(ext, 1, cut)
|
|
67
|
+
hasrepo = (ext ~ /(^|[ \t])--repo([ \t=]|$)/) ? 1 : 0
|
|
68
|
+
printf "G\t%d\t%d\n", ln, hasrepo
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — backslash continuations are joined before matching, so a call split across lines is one unit and its --repo is found wherever on the call it sits
|
|
73
|
+
function endrun( i, s, acc, accln) {
|
|
74
|
+
inrun = 0
|
|
75
|
+
acc = ""; accln = 0
|
|
76
|
+
for (i = 0; i < rn; i++) {
|
|
77
|
+
s = rbuf[i]
|
|
78
|
+
if (acc == "") accln = rln[i]
|
|
79
|
+
if (s ~ /\\$/) { sub(/\\$/, "", s); acc = acc s " "; continue }
|
|
80
|
+
scanlogical(acc s, accln)
|
|
81
|
+
acc = ""
|
|
82
|
+
}
|
|
83
|
+
if (acc != "") scanlogical(acc, accln)
|
|
84
|
+
rn = 0
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — the marker binds by its own indentation: at or left of the job-id column it precedes a job, at the step dash column it precedes a step, inside a step it binds that step
|
|
88
|
+
function marker(line, ln, c, r) {
|
|
89
|
+
if (line !~ /gh-repo-exempt/) return
|
|
90
|
+
r = ""
|
|
91
|
+
if (line ~ /gh-repo-exempt[ \t]*:/) {
|
|
92
|
+
r = line
|
|
93
|
+
sub(/^.*gh-repo-exempt[ \t]*:[ \t]*/, "", r)
|
|
94
|
+
sub(/[ \t]+$/, "", r)
|
|
95
|
+
}
|
|
96
|
+
if (r == "") { printf "XBAD\t%d\n", ln; return }
|
|
97
|
+
if (!injobs) return
|
|
98
|
+
c = ind(line)
|
|
99
|
+
if (jobcol >= 0 && c <= jobcol) { pendjob = r; return }
|
|
100
|
+
if (curjob == "") { pendjob = r; return }
|
|
101
|
+
if (insteps) {
|
|
102
|
+
if (stepdashcol < 0 || c <= stepdashcol) { pendstep = r; return }
|
|
103
|
+
if (stepcol >= 0) { printf "SX\t%s\n", r; return }
|
|
104
|
+
pendstep = r
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
printf "JX\t%s\n", r
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function stepkey(rest, col, ln, k, v, u) {
|
|
111
|
+
k = keyof(rest)
|
|
112
|
+
if (k == "") return
|
|
113
|
+
v = rest
|
|
114
|
+
sub(/^[^:]*:[ \t]*/, "", v)
|
|
115
|
+
sub(/[ \t]+$/, "", v)
|
|
116
|
+
if (k == "uses") {
|
|
117
|
+
gsub(/^["\047]+|["\047]+$/, "", v)
|
|
118
|
+
sub(/[ \t].*$/, "", v)
|
|
119
|
+
u = v
|
|
120
|
+
sub(/@.*$/, "", u)
|
|
121
|
+
if (u == "actions/checkout") printf "C\t%d\n", ln
|
|
122
|
+
return
|
|
123
|
+
}
|
|
124
|
+
if (k == "env") { envscope = "step"; envcol = col; return }
|
|
125
|
+
if (k != "run") return
|
|
126
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — a folded body is scanned line-wise like a literal one, and a plain scalar as a single logical line: both over-detect, the stated safe direction
|
|
127
|
+
if (v ~ /^[|>][-+]?[0-9]*$/) { inrun = 1; runkeycol = col; rbi = -1; rn = 0; return }
|
|
128
|
+
if (v != "") scanlogical(v, ln)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
BEGIN { jobcol = -1; jobkeycol = -1; stepcol = -1; stepdashcol = -1; envscope = ""; curjob = ""; pendjob = ""; pendstep = ""; inrun = 0; injobs = 0; insteps = 0 }
|
|
132
|
+
|
|
133
|
+
{
|
|
134
|
+
line = $0
|
|
135
|
+
sub(/\r$/, "", line)
|
|
136
|
+
|
|
137
|
+
if (inrun) {
|
|
138
|
+
if (line ~ /^[ \t]*$/) { rbuf[rn] = ""; rln[rn] = FNR; rn++; next }
|
|
139
|
+
c = ind(line)
|
|
140
|
+
if (c > runkeycol) {
|
|
141
|
+
if (rbi < 0) rbi = c
|
|
142
|
+
rbuf[rn] = substr(line, rbi + 1); rln[rn] = FNR; rn++
|
|
143
|
+
next
|
|
144
|
+
}
|
|
145
|
+
endrun()
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (line ~ /^[ \t]*$/) next
|
|
149
|
+
if (line ~ /^[ ]*#/) { marker(line, FNR); next }
|
|
150
|
+
|
|
151
|
+
c = ind(line)
|
|
152
|
+
|
|
153
|
+
if (envscope != "") {
|
|
154
|
+
if (c > envcol) {
|
|
155
|
+
if (line ~ /^[ ]*GH_REPO[ ]*:/) print (envscope == "workflow" ? "W" : (envscope == "job" ? "JE" : "SE"))
|
|
156
|
+
next
|
|
157
|
+
}
|
|
158
|
+
envscope = ""
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (c == 0) {
|
|
162
|
+
topkey = keyof(line)
|
|
163
|
+
injobs = (topkey == "jobs")
|
|
164
|
+
curjob = ""; stepcol = -1; insteps = 0
|
|
165
|
+
if (topkey == "env") { envscope = "workflow"; envcol = 0 }
|
|
166
|
+
next
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!injobs) next
|
|
170
|
+
if (jobcol < 0) jobcol = c
|
|
171
|
+
|
|
172
|
+
if (c == jobcol) {
|
|
173
|
+
curjob = keyof(line)
|
|
174
|
+
if (curjob == "") next
|
|
175
|
+
printf "J\t%s\t%d\n", curjob, FNR
|
|
176
|
+
if (pendjob != "") { printf "JX\t%s\n", pendjob }
|
|
177
|
+
pendjob = ""; pendstep = ""
|
|
178
|
+
jobkeycol = -1; stepcol = -1; stepdashcol = -1; insteps = 0
|
|
179
|
+
next
|
|
180
|
+
}
|
|
181
|
+
if (curjob == "") next
|
|
182
|
+
if (jobkeycol < 0) jobkeycol = c
|
|
183
|
+
|
|
184
|
+
if (c == jobkeycol) {
|
|
185
|
+
stepcol = -1
|
|
186
|
+
k = keyof(line)
|
|
187
|
+
insteps = (k == "steps")
|
|
188
|
+
if (k == "env") { envscope = "job"; envcol = c }
|
|
189
|
+
next
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!insteps) next
|
|
193
|
+
|
|
194
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — a new step is a dash at the step-list column alone, so a nested list under with:/strategy: is not read as a step
|
|
195
|
+
if (match(line, /^[ ]*-[ ]+/)) {
|
|
196
|
+
if (stepdashcol < 0) stepdashcol = c
|
|
197
|
+
if (c == stepdashcol) {
|
|
198
|
+
stepcol = RLENGTH
|
|
199
|
+
printf "S\t%d\n", FNR
|
|
200
|
+
if (pendstep != "") { printf "SX\t%s\n", pendstep }
|
|
201
|
+
pendstep = ""
|
|
202
|
+
stepkey(substr(line, stepcol + 1), stepcol, FNR)
|
|
203
|
+
next
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (stepcol >= 0 && c == stepcol) stepkey(substr(line, c + 1), c, FNR)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
END { if (inrun) endrun() }
|
|
210
|
+
'
|
|
211
|
+
|
|
212
|
+
walked=0; subject=0; composite=0; outside=0
|
|
213
|
+
armed=0; inert=0; exempt=0; calls=0
|
|
214
|
+
findings=(); bare=()
|
|
215
|
+
|
|
216
|
+
curfile=""; wenv=0
|
|
217
|
+
job=""; jobline=0; jexempt=0; jenv=0
|
|
218
|
+
checkouts=(); iln=(); irepo=(); ienv=()
|
|
219
|
+
senv=0; sexempt=0; sln=(); srepo=()
|
|
220
|
+
have_job=0; have_step=0
|
|
221
|
+
|
|
222
|
+
finish_step() {
|
|
223
|
+
(( have_step )) || return 0
|
|
224
|
+
have_step=0
|
|
225
|
+
local i
|
|
226
|
+
if (( sexempt == 0 && ${#sln[@]} > 0 )); then
|
|
227
|
+
for i in "${!sln[@]}"; do
|
|
228
|
+
iln+=("${sln[$i]}"); irepo+=("${srepo[$i]}")
|
|
229
|
+
if (( wenv || jenv || senv )); then ienv+=(1); else ienv+=(0); fi
|
|
230
|
+
done
|
|
231
|
+
fi
|
|
232
|
+
senv=0; sexempt=0; sln=(); srepo=()
|
|
233
|
+
return 0
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — the three arms are disjoined per job and each is universally quantified over the job's detected set
|
|
237
|
+
finish_job() {
|
|
238
|
+
(( have_job )) || return 0
|
|
239
|
+
finish_step
|
|
240
|
+
have_job=0
|
|
241
|
+
if (( jexempt )); then exempt=$((exempt + 1)); return 0; fi
|
|
242
|
+
if (( ${#iln[@]} == 0 )); then inert=$((inert + 1)); return 0; fi
|
|
243
|
+
armed=$((armed + 1)); calls=$((calls + ${#iln[@]}))
|
|
244
|
+
local first="${iln[0]}" i allenv=1 allrepo=1
|
|
245
|
+
for i in "${iln[@]}"; do (( i < first )) && first="$i"; done
|
|
246
|
+
if (( ${#checkouts[@]} > 0 )); then
|
|
247
|
+
for i in "${checkouts[@]}"; do (( i < first )) && return 0; done
|
|
248
|
+
fi
|
|
249
|
+
for i in "${ienv[@]}"; do (( i )) || allenv=0; done
|
|
250
|
+
for i in "${irepo[@]}"; do (( i )) || allrepo=0; done
|
|
251
|
+
(( allenv || allrepo )) && return 0
|
|
252
|
+
findings+=("$curfile:$jobline: job '$job' first invokes gh at line $first with no repository context")
|
|
253
|
+
return 0
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
for f in "${files[@]}"; do
|
|
257
|
+
[[ -n "$f" ]] || continue
|
|
258
|
+
walked=$((walked + 1))
|
|
259
|
+
# spec: gate-sdk/SPEC.md §check-action-gh-repo — the Actions-shape predicate is split in two: the gate's unit is a job under jobs:, and a runs:-shaped composite action inherits its caller's repository context
|
|
260
|
+
if grep -qE '^jobs:' "$f"; then
|
|
261
|
+
subject=$((subject + 1))
|
|
262
|
+
elif grep -qE '^runs:' "$f"; then
|
|
263
|
+
composite=$((composite + 1))
|
|
264
|
+
continue
|
|
265
|
+
else
|
|
266
|
+
outside=$((outside + 1))
|
|
267
|
+
continue
|
|
268
|
+
fi
|
|
269
|
+
|
|
270
|
+
stream="$(awk "$WALK" "$f")"; st=$?
|
|
271
|
+
fail_closed "$st" ACTION-GH-REPO "awk walk($f)"
|
|
272
|
+
|
|
273
|
+
curfile="$f"
|
|
274
|
+
wenv=0
|
|
275
|
+
grep -qx 'W' <<< "$stream" && wenv=1
|
|
276
|
+
|
|
277
|
+
while IFS=$'\t' read -r kind a b; do
|
|
278
|
+
case "$kind" in
|
|
279
|
+
J) finish_job
|
|
280
|
+
job="$a"; jobline="$b"; jexempt=0; jenv=0
|
|
281
|
+
checkouts=(); iln=(); irepo=(); ienv=(); have_job=1 ;;
|
|
282
|
+
JE) jenv=1 ;;
|
|
283
|
+
JX) jexempt=1 ;;
|
|
284
|
+
S) finish_step; have_step=1 ;;
|
|
285
|
+
SE) senv=1 ;;
|
|
286
|
+
SX) sexempt=1 ;;
|
|
287
|
+
C) checkouts+=("$a") ;;
|
|
288
|
+
G) sln+=("$a"); srepo+=("$b"); have_step=1 ;;
|
|
289
|
+
XBAD) bare+=("$f:$a: a gh-repo-exempt marker with no reason") ;;
|
|
290
|
+
esac
|
|
291
|
+
done <<< "$stream"
|
|
292
|
+
finish_job
|
|
293
|
+
done
|
|
294
|
+
|
|
295
|
+
red=0
|
|
296
|
+
|
|
297
|
+
if [[ ${#findings[@]} -gt 0 ]]; then
|
|
298
|
+
red=1
|
|
299
|
+
echo "check-action-gh-repo: a job invokes gh with no way to resolve a target"
|
|
300
|
+
echo "repository, so every call in it dies before its first request — on a tag,"
|
|
301
|
+
echo "where nothing else in the battery runs:"
|
|
302
|
+
printf ' %s\n' "${findings[@]}"
|
|
303
|
+
echo " help: add an actions/checkout step before the first gh call, or set"
|
|
304
|
+
echo " GH_REPO: \${{ github.repository }} on the workflow, the job, or the"
|
|
305
|
+
echo " invoking step's env:, or pass --repo on every gh call in the job."
|
|
306
|
+
echo " A job standing outside all three takes '# gh-repo-exempt: <reason>'."
|
|
307
|
+
fi
|
|
308
|
+
|
|
309
|
+
if [[ ${#bare[@]} -gt 0 ]]; then
|
|
310
|
+
red=1
|
|
311
|
+
echo "check-action-gh-repo: a gh-repo-exempt marker carries no reason, so it records"
|
|
312
|
+
echo "that an arm was stood outside of without saying which one or why:"
|
|
313
|
+
printf ' %s\n' "${bare[@]}"
|
|
314
|
+
echo " help: write the marker as '# gh-repo-exempt: <reason>' naming the arm the"
|
|
315
|
+
echo " job stands outside of, or delete it and satisfy an arm."
|
|
316
|
+
fi
|
|
317
|
+
|
|
318
|
+
[[ "$red" -eq 1 ]] && exit 1
|
|
319
|
+
|
|
320
|
+
echo "ACTION-GH-REPO: clean ($armed job(s) invoking gh across $subject Actions-shaped file(s) of $walked walked, all resolving a repository; $calls invocation(s) detected, $inert job(s) invoking none, $exempt exempt, $composite composite-action file(s) and $outside non-Actions file(s) skipped)"
|
|
321
|
+
exit 0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
job 'release' first invokes gh at line 35 with no repository context
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: reject-cases
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v[0-9]*'
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
# The attested miss, reproduced as it shipped: this job took down v0.17.0's
|
|
12
|
+
# release on its first live run, dying in seconds on "failed to run git: fatal:
|
|
13
|
+
# not a git repository" before its first API call — no Release created, no
|
|
14
|
+
# assets attached. It checks nothing out, sets GH_TOKEN and TAG but no GH_REPO,
|
|
15
|
+
# and passes no --repo, so gh has nothing to resolve a target repository from.
|
|
16
|
+
release:
|
|
17
|
+
needs: pack
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
permissions:
|
|
20
|
+
contents: write
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
23
|
+
with:
|
|
24
|
+
name: installer-package
|
|
25
|
+
path: dist
|
|
26
|
+
|
|
27
|
+
- name: attach the tarball and its checksum to the Release
|
|
28
|
+
env:
|
|
29
|
+
GH_TOKEN: ${{ github.token }}
|
|
30
|
+
TAG: ${{ github.ref_name }}
|
|
31
|
+
run: |
|
|
32
|
+
set -euo pipefail
|
|
33
|
+
name="$(basename dist/*.tgz)"
|
|
34
|
+
( cd dist && sha256sum "$name" > "$name.sha256" )
|
|
35
|
+
if ! gh release view "$TAG" >/dev/null 2>&1; then
|
|
36
|
+
gh release create "$TAG" --title "$TAG" --notes ""
|
|
37
|
+
fi
|
|
38
|
+
gh release upload "$TAG" "dist/$name" "dist/$name.sha256" --clobber
|
|
39
|
+
|
|
40
|
+
# The mixed-call case the arm is designed against. One call carries --repo and
|
|
41
|
+
# the next does not, so a witness-seeking arm would pass this job; the arm is
|
|
42
|
+
# universally quantified over the detected set, so the unprefixed call fails it.
|
|
43
|
+
mixed:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- name: two calls, one prefixed
|
|
47
|
+
env:
|
|
48
|
+
GH_TOKEN: ${{ github.token }}
|
|
49
|
+
run: |
|
|
50
|
+
set -euo pipefail
|
|
51
|
+
gh release view v1.0.0 --repo owner/repo
|
|
52
|
+
gh release upload v1.0.0 dist/asset.tgz
|
|
53
|
+
|
|
54
|
+
# A checkout establishes a git remote only for the calls that follow it.
|
|
55
|
+
# Ordered after the first call it establishes nothing, and the ordering
|
|
56
|
+
# comparison is free once both line numbers are in hand.
|
|
57
|
+
late_checkout:
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
steps:
|
|
60
|
+
- name: call before the checkout
|
|
61
|
+
env:
|
|
62
|
+
GH_TOKEN: ${{ github.token }}
|
|
63
|
+
run: |
|
|
64
|
+
gh issue list --state open
|
|
65
|
+
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
|
|
66
|
+
|
|
67
|
+
# A bare marker is its own failure class with its own help: line. The valve's
|
|
68
|
+
# whole value is the sentence saying which arm the author stands outside of, so
|
|
69
|
+
# a marker with no reason exempts nothing and reds on the marker itself.
|
|
70
|
+
bare_valve:
|
|
71
|
+
runs-on: ubuntu-latest
|
|
72
|
+
# gh-repo-exempt:
|
|
73
|
+
steps:
|
|
74
|
+
- name: an unexplained exemption
|
|
75
|
+
env:
|
|
76
|
+
GH_TOKEN: ${{ github.token }}
|
|
77
|
+
run: |
|
|
78
|
+
gh issue list --state open
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ACTION-GH-REPO: clean (6 job(s) invoking gh across 3 Actions-shaped file(s) of 5 walked, all resolving a repository; 11 invocation(s) detected, 1 job(s) invoking none, 1 exempt, 1 composite-action file(s) and 1 non-Actions file(s) skipped)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# A composite action carries no job of its own and inherits the calling job's
|
|
2
|
+
# repository context, so the assertion belongs to the caller. Skipped and counted.
|
|
3
|
+
name: composite
|
|
4
|
+
description: a runs:-shaped file with a gh call and no jobs: key
|
|
5
|
+
|
|
6
|
+
runs:
|
|
7
|
+
using: composite
|
|
8
|
+
steps:
|
|
9
|
+
- shell: bash
|
|
10
|
+
run: |
|
|
11
|
+
gh issue list --state open
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Another CI schema spelling a shell step run:. It carries neither a top-level
|
|
2
|
+
# jobs: nor a top-level runs: key, so it is outside the scan entirely — gate-sdk
|
|
3
|
+
# ships no template for it and owns no contract over it.
|
|
4
|
+
version: 2
|
|
5
|
+
|
|
6
|
+
workflows:
|
|
7
|
+
build:
|
|
8
|
+
steps:
|
|
9
|
+
- run: |
|
|
10
|
+
gh release create v1.0.0
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
name: accept-cases
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v[0-9]*'
|
|
7
|
+
|
|
8
|
+
permissions: {}
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
# The env arm on its narrowest sub-arm. The attested miss's repair sets GH_REPO
|
|
12
|
+
# on the invoking step, not at workflow or job root, so a gate implementing only
|
|
13
|
+
# the two outer lookups would red the one job it exists for.
|
|
14
|
+
step_env:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
20
|
+
with:
|
|
21
|
+
name: installer-package
|
|
22
|
+
path: dist
|
|
23
|
+
|
|
24
|
+
- name: attach the tarball to the Release
|
|
25
|
+
env:
|
|
26
|
+
GH_TOKEN: ${{ github.token }}
|
|
27
|
+
GH_REPO: ${{ github.repository }}
|
|
28
|
+
TAG: ${{ github.ref_name }}
|
|
29
|
+
run: |
|
|
30
|
+
set -euo pipefail
|
|
31
|
+
if ! gh release view "$TAG" >/dev/null 2>&1; then
|
|
32
|
+
gh release create "$TAG" --title "$TAG" --notes ""
|
|
33
|
+
fi
|
|
34
|
+
gh release upload "$TAG" dist/asset.tgz --clobber
|
|
35
|
+
|
|
36
|
+
job_env:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
env:
|
|
39
|
+
GH_REPO: ${{ github.repository }}
|
|
40
|
+
steps:
|
|
41
|
+
- name: the job-level lookup
|
|
42
|
+
env:
|
|
43
|
+
GH_TOKEN: ${{ github.token }}
|
|
44
|
+
run: |
|
|
45
|
+
gh issue list --state open
|
|
46
|
+
|
|
47
|
+
# The checkout arm: the uses: ref before the @ is actions/checkout and its line
|
|
48
|
+
# precedes the job's first detected invocation.
|
|
49
|
+
checkout_arm:
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
|
|
53
|
+
- name: a call the checkout above establishes a remote for
|
|
54
|
+
env:
|
|
55
|
+
GH_TOKEN: ${{ github.token }}
|
|
56
|
+
run: |
|
|
57
|
+
gh label create site-health --color b60205 \
|
|
58
|
+
--description "Live-site monitoring probe failure" 2>/dev/null || true
|
|
59
|
+
open_num="$(gh issue list --label site-health --state open --json number)"
|
|
60
|
+
echo "$open_num"
|
|
61
|
+
|
|
62
|
+
# The --repo arm, universally quantified: every detected invocation carries it,
|
|
63
|
+
# including one whose --repo sits on a continuation line, which is only found
|
|
64
|
+
# because backslash continuations are joined before matching.
|
|
65
|
+
repo_arm:
|
|
66
|
+
runs-on: ubuntu-latest
|
|
67
|
+
steps:
|
|
68
|
+
- name: every call prefixed
|
|
69
|
+
env:
|
|
70
|
+
GH_TOKEN: ${{ github.token }}
|
|
71
|
+
run: |
|
|
72
|
+
set -euo pipefail
|
|
73
|
+
gh release view v1.0.0 --repo owner/repo
|
|
74
|
+
gh release upload v1.0.0 dist/asset.tgz \
|
|
75
|
+
--clobber --repo owner/repo
|
|
76
|
+
if ! gh release view v2.0.0 --repo owner/repo; then
|
|
77
|
+
echo "absent"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
# Whole-word matching at command position. None of these is a gh invocation, so
|
|
81
|
+
# this job is counted as invoking none rather than armed: ghost and gh-pages are
|
|
82
|
+
# other words, a leading # is always a shell comment, and a bare gh inside a
|
|
83
|
+
# string is not in command position.
|
|
84
|
+
not_invocations:
|
|
85
|
+
runs-on: ubuntu-latest
|
|
86
|
+
steps:
|
|
87
|
+
- name: tokens that are not the gh command
|
|
88
|
+
run: |
|
|
89
|
+
set -euo pipefail
|
|
90
|
+
ghost --version
|
|
91
|
+
git push origin gh-pages
|
|
92
|
+
# gh release create v9.9.9
|
|
93
|
+
echo "the gh CLI is not invoked here"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: accept-root-env
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
env:
|
|
7
|
+
GH_REPO: ${{ github.repository }}
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
# The workflow-root lookup, the outermost of the env arm's three.
|
|
11
|
+
workflow_env:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- name: no job- or step-level GH_REPO of its own
|
|
15
|
+
env:
|
|
16
|
+
GH_TOKEN: ${{ github.token }}
|
|
17
|
+
run: |
|
|
18
|
+
gh issue list --state open
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: accept-valves
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
# A job-level valve. The marker sits at the job's own key column, so it binds
|
|
8
|
+
# the job and stands the whole of it outside every arm.
|
|
9
|
+
whole_job:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
# gh-repo-exempt: the remote is established by a hand-rolled git clone, which
|
|
12
|
+
# is outside the gate's theory of how a repository context is set.
|
|
13
|
+
steps:
|
|
14
|
+
- name: a call the gate does not reach
|
|
15
|
+
env:
|
|
16
|
+
GH_TOKEN: ${{ github.token }}
|
|
17
|
+
run: |
|
|
18
|
+
git clone https://github.com/owner/repo .
|
|
19
|
+
gh issue list --state open
|
|
20
|
+
|
|
21
|
+
# A step-level valve. The marker sits inside the step's keys, so it drops that
|
|
22
|
+
# step's invocations alone; the job's other calls stay in the detected set and
|
|
23
|
+
# are held to the arms.
|
|
24
|
+
one_step:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- name: the exempted step
|
|
28
|
+
env:
|
|
29
|
+
GH_TOKEN: ${{ github.token }}
|
|
30
|
+
# gh-repo-exempt: this call targets a foreign repository resolved from a
|
|
31
|
+
# runtime input, so no tree-readable declaration can name it.
|
|
32
|
+
run: |
|
|
33
|
+
gh issue list --state open
|
|
34
|
+
|
|
35
|
+
- name: a sibling still held to the arms
|
|
36
|
+
env:
|
|
37
|
+
GH_TOKEN: ${{ github.token }}
|
|
38
|
+
run: |
|
|
39
|
+
gh issue list --repo owner/repo --state open
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Direct unit test of gate-sdk/lib/declaration.sh — the two container arms and
|
|
3
|
+
# the resolve/refuse trichotomy (gate-sdk/SPEC.md §lib/declaration.sh).
|
|
4
|
+
#
|
|
5
|
+
# Why a direct test: the record arm has no caller fixture to ride. Its only
|
|
6
|
+
# caller is bin/upgrade-smoke.sh's untagged branch, and the smoke is a bin tool
|
|
7
|
+
# whose contract forgoes a good/bad pair — so a corpus fixture would leave the
|
|
8
|
+
# arm the standing pre-release assertion depends on entirely unexercised. The
|
|
9
|
+
# markdown arm's callers do carry fixtures; its status-2 and empty-section arms
|
|
10
|
+
# are still checked here, being unreachable from a well-formed corpus.
|
|
11
|
+
#
|
|
12
|
+
# Run by run-gate-tests.sh (any <tests-dir>/*.test.sh; must exit 0).
|
|
13
|
+
set -uo pipefail
|
|
14
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
15
|
+
|
|
16
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # gate-sdk/
|
|
17
|
+
# shellcheck source=../lib/declaration.sh
|
|
18
|
+
source "$DIR/lib/declaration.sh"
|
|
19
|
+
|
|
20
|
+
fails=0
|
|
21
|
+
tmp="$(mktemp -d)"
|
|
22
|
+
trap 'rm -rf "$tmp"' EXIT
|
|
23
|
+
|
|
24
|
+
note() { printf '%s\n' "$2" > "$tmp/$1.md"; printf '%s\n' "$tmp/$1.md"; }
|
|
25
|
+
|
|
26
|
+
# $1=label $2=want-status $3=want-stdout $4...=the call
|
|
27
|
+
expect() {
|
|
28
|
+
local label="$1" want_st="$2" want_out="$3"; shift 3
|
|
29
|
+
local out st
|
|
30
|
+
out="$("$@")"; st=$?
|
|
31
|
+
if [[ "$st" -ne "$want_st" ]]; then
|
|
32
|
+
echo " FAIL [$label]: want status $want_st, got $st -- $out"; fails=$((fails + 1)); return
|
|
33
|
+
fi
|
|
34
|
+
if [[ "$out" != "$want_out" ]]; then
|
|
35
|
+
echo " FAIL [$label]: want stdout '$want_out', got '$out'"; fails=$((fails + 1))
|
|
36
|
+
fi
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# --- the markdown arm ------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
f="$(note canonical '## Tightened gates
|
|
42
|
+
|
|
43
|
+
- `check-alpha` — tightened.
|
|
44
|
+
- `check-beta` — landed new.
|
|
45
|
+
|
|
46
|
+
## Renamed knobs
|
|
47
|
+
|
|
48
|
+
None.')"
|
|
49
|
+
expect "markdown/token-list" 0 'check-alpha
|
|
50
|
+
check-beta' decl_section_tokens "$f" "Tightened gates"
|
|
51
|
+
expect "markdown/container-keeps-bullets-only" 0 '- `check-alpha` — tightened.
|
|
52
|
+
- `check-beta` — landed new.' decl_section_bullets "$f" "Tightened gates"
|
|
53
|
+
|
|
54
|
+
f="$(note none '## Tightened gates
|
|
55
|
+
|
|
56
|
+
None. A trailing clause ruling out a near-miss rides the explicit empty set.
|
|
57
|
+
|
|
58
|
+
## Renamed knobs
|
|
59
|
+
|
|
60
|
+
None.')"
|
|
61
|
+
expect "markdown/explicit-none" 0 '' decl_section_tokens "$f" "Tightened gates"
|
|
62
|
+
|
|
63
|
+
# The two spellings the corpus actually carried: bolded, and bold-and-backticked.
|
|
64
|
+
# Neither may be silently stripped to a token — that is the whole defect.
|
|
65
|
+
f="$(note bolded '## Tightened gates
|
|
66
|
+
|
|
67
|
+
- **check-alpha** — bolded.
|
|
68
|
+
- **`check-beta`** — bold-and-backticked.')"
|
|
69
|
+
expect "markdown/bolded-refused" 1 '- **check-alpha** — bolded.
|
|
70
|
+
- **`check-beta`** — bold-and-backticked.' decl_section_tokens "$f" "Tightened gates"
|
|
71
|
+
|
|
72
|
+
# A non-`None` section holding no bullet at all is the silent-empty case: it
|
|
73
|
+
# refuses with nothing to print, rather than resolving to an empty declared set.
|
|
74
|
+
f="$(note prose-only '## Tightened gates
|
|
75
|
+
|
|
76
|
+
Several gates moved this release.')"
|
|
77
|
+
expect "markdown/prose-only-refused" 1 '' decl_section_tokens "$f" "Tightened gates"
|
|
78
|
+
|
|
79
|
+
f="$(note absent '## Renamed knobs
|
|
80
|
+
|
|
81
|
+
None.')"
|
|
82
|
+
expect "markdown/section-absent" 2 '' decl_section_tokens "$f" "Tightened gates"
|
|
83
|
+
|
|
84
|
+
# `None` is read off the section's first non-blank line, so a later line opening
|
|
85
|
+
# with the word does not turn a real declaration into an empty set.
|
|
86
|
+
f="$(note none-later '## Tightened gates
|
|
87
|
+
|
|
88
|
+
- `check-alpha` — tightened.
|
|
89
|
+
|
|
90
|
+
None of the above affects a vendored tree that shadows it.')"
|
|
91
|
+
expect "markdown/none-only-at-head" 0 'check-alpha' decl_section_tokens "$f" "Tightened gates"
|
|
92
|
+
|
|
93
|
+
# --- the record arm --------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
printf '# contract: x.md §y\ncheck-alpha\ncheck-beta\n' > "$tmp/decl.txt"
|
|
96
|
+
expect "record/data-lines" 0 'check-alpha
|
|
97
|
+
check-beta' decl_record_tokens "$tmp/decl.txt"
|
|
98
|
+
|
|
99
|
+
printf '# contract: x.md §y\n' > "$tmp/header-only.txt"
|
|
100
|
+
expect "record/header-only-is-empty-set" 0 '' decl_record_tokens "$tmp/header-only.txt"
|
|
101
|
+
|
|
102
|
+
expect "record/missing-file-is-empty-set" 0 '' decl_record_tokens "$tmp/nonexistent.txt"
|
|
103
|
+
|
|
104
|
+
printf '# contract: x.md §y\n- `check-alpha` — markup\n' > "$tmp/marked-up.txt"
|
|
105
|
+
expect "record/markup-refused" 1 '- `check-alpha` — markup' decl_record_tokens "$tmp/marked-up.txt"
|
|
106
|
+
|
|
107
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
108
|
+
echo "lib-declaration.test: $fails assertion(s) failed"
|
|
109
|
+
exit 1
|
|
110
|
+
fi
|
|
111
|
+
echo "lib-declaration.test: ok (markdown arm resolves a token list and an explicit None, refuses the bolded and bold-and-backticked spellings and a bulletless non-None section, reports an absent section; None is read at the section head only; record arm resolves data lines, treats a header-only and a missing file as the empty set, and refuses a marked-up line)"
|
|
112
|
+
exit 0
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# spec: gate-sdk/SPEC.md §lib/declaration.sh — the tightened-gates declaration grammar: two container arms over one token predicate, reporting the resolve/refuse trichotomy on the statuses named there. Sourced, never executed.
|
|
3
|
+
|
|
4
|
+
DECL_TOKEN_RE='^[A-Za-z][A-Za-z0-9-]*$'
|
|
5
|
+
|
|
6
|
+
decl_section_bullets() {
|
|
7
|
+
awk -v sec="$2" '
|
|
8
|
+
/^##[[:space:]]/ { insec = ($0 ~ "^##[[:space:]]+" sec "[[:space:]]*$"); if (insec) found = 1; next }
|
|
9
|
+
insec && /^[[:space:]]*[-*][[:space:]]+/ { print }
|
|
10
|
+
END { exit(found ? 0 : 1) }
|
|
11
|
+
' "$1"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
decl_section_is_none() {
|
|
15
|
+
awk -v sec="$2" '
|
|
16
|
+
/^##[[:space:]]/ { insec = ($0 ~ "^##[[:space:]]+" sec "[[:space:]]*$"); if (insec) found = 1; next }
|
|
17
|
+
insec && !seen && /[^[:space:]]/ { seen = 1; none = ($0 ~ /^[[:space:]]*[Nn]one([^A-Za-z0-9]|$)/) }
|
|
18
|
+
END { exit(found && none ? 0 : 1) }
|
|
19
|
+
' "$1"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
decl_section_tokens() {
|
|
23
|
+
local file="$1" sec="$2" bullets st line tok n=0 bad=()
|
|
24
|
+
bullets="$(decl_section_bullets "$file" "$sec")"; st=$?
|
|
25
|
+
[[ "$st" -eq 0 ]] || return 2
|
|
26
|
+
decl_section_is_none "$file" "$sec" && return 0
|
|
27
|
+
while IFS= read -r line; do
|
|
28
|
+
[[ "$line" =~ [^[:space:]] ]] || continue
|
|
29
|
+
tok=""
|
|
30
|
+
[[ "$line" =~ ^[[:space:]]*[-*][[:space:]]+\`([^\`]*)\` ]] && tok="${BASH_REMATCH[1]}"
|
|
31
|
+
if [[ -n "$tok" && "$tok" =~ $DECL_TOKEN_RE ]]; then
|
|
32
|
+
printf '%s\n' "$tok"; n=$((n + 1))
|
|
33
|
+
else
|
|
34
|
+
bad+=("$line")
|
|
35
|
+
fi
|
|
36
|
+
done <<<"$bullets"
|
|
37
|
+
[[ ${#bad[@]} -eq 0 && "$n" -gt 0 ]] && return 0
|
|
38
|
+
[[ ${#bad[@]} -gt 0 ]] && printf '%s\n' "${bad[@]}"
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
decl_record_tokens() {
|
|
43
|
+
local file="$1" line bad=()
|
|
44
|
+
[[ -f "$file" ]] || return 0
|
|
45
|
+
while IFS= read -r line; do
|
|
46
|
+
[[ "$line" == '#'* ]] && continue
|
|
47
|
+
[[ "$line" =~ [^[:space:]] ]] || continue
|
|
48
|
+
if [[ "$line" =~ $DECL_TOKEN_RE ]]; then
|
|
49
|
+
printf '%s\n' "$line"
|
|
50
|
+
else
|
|
51
|
+
bad+=("$line")
|
|
52
|
+
fi
|
|
53
|
+
done < "$file"
|
|
54
|
+
if [[ ${#bad[@]} -gt 0 ]]; then
|
|
55
|
+
printf '%s\n' "${bad[@]}"
|
|
56
|
+
return 1
|
|
57
|
+
fi
|
|
58
|
+
return 0
|
|
59
|
+
}
|
|
@@ -69,6 +69,21 @@ widening asserted behavior, user-facing semantics) stops and surfaces to the
|
|
|
69
69
|
user — never pick a "conservative alternative" silently. A *cross-component
|
|
70
70
|
causal gap* is not a TODO: stop, resolve it this session, update the spec.
|
|
71
71
|
|
|
72
|
+
**Declare a gate you land or tighten, in the unit that lands it.** A unit that
|
|
73
|
+
lands a new gate or makes an existing one stricter appends that gate's bare name
|
|
74
|
+
to the tightened-gates declaration surface,
|
|
75
|
+
`<workflow-dir>/tightened-gates.txt` (gate-sdk/SPEC.md §upgrade-smoke), in the
|
|
76
|
+
same commit. Build is the only stage that knows what it tightened at the moment
|
|
77
|
+
it tightens it, so the declaration is written from knowledge rather than
|
|
78
|
+
reconstructed later from a red — and an assertion that discovers its own
|
|
79
|
+
allowed-red set from the gate it was supposed to check is its own trigger. The
|
|
80
|
+
surface accumulates across the iterations batched into one release; the release
|
|
81
|
+
step composes the note's Tightened-gates section from it and drains it at the
|
|
82
|
+
tag, so nothing here loads the release runbook. Only gates a consumer's vendored
|
|
83
|
+
tree can actually run are declared: a gate living solely in your own gates
|
|
84
|
+
directory never reaches a vendored tree and is not part of any release's
|
|
85
|
+
allowed-red set.
|
|
86
|
+
|
|
72
87
|
**Run the system; don't reason about it** — when a running system is
|
|
73
88
|
reachable, reproduce first, read second. Recorded evidence rots: a static
|
|
74
89
|
trace in a task body is a dated hypothesis to re-verify, not a premise. A
|
package/payload/site-kit/SPEC.md
CHANGED
|
@@ -161,9 +161,9 @@ line naming the dependency (ruby plus the kramdown-parser-gfm gem, or a
|
|
|
161
161
|
`SITE_KIT_RENDERER` override) — a gate that cannot run its oracle refuses, never
|
|
162
162
|
a false clean. That dependency joins the *consumer's* toolchain only when the
|
|
163
163
|
consumer registers this gate; it stays outside env-probe's probe-set floor, and
|
|
164
|
-
`docs/install.md`'s Requirements prose states the tier
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
`docs/install.md`'s Requirements prose states the tier. A consumer with no
|
|
165
|
+
published docs site simply omits the gate by the registry-not-array convention
|
|
166
|
+
and never installs the dependency.
|
|
167
167
|
|
|
168
168
|
The false-positive floor is the assertion's hard boundary, deliberately set. The
|
|
169
169
|
backtick symptom rests on a property of well-formed markdown: every backtick
|