@soleur/opencode 3.385.0 → 3.386.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 +1 -1
- package/scripts/lib/bearer-fetch.sh +87 -0
- package/skills/brainstorm-techniques/references/standing-delegation.md +15 -1
- package/skills/ship/SKILL.md +2 -2
- package/skills/ship/references/operator-holds.md +95 -9
- package/skills/ship/references/pr-overlap.md +1 -1
- package/skills/ship/scripts/hold-gate-eval.sh +213 -35
package/package.json
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck disable=SC2034 # BC_* are the helper's outputs, read by the sourcing script
|
|
3
|
+
# bearer-fetch.sh -- SOURCED helper (never executed): read ONE read-only bearer token from the secret store and send ONE
|
|
4
|
+
# hardened HTTPS GET with it. Consumer: skills/ship/scripts/hold-gate-eval.sh (the `web-acceptance` gate). Suite:
|
|
5
|
+
# plugins/soleur/test/bearer-fetch.test.sh. Precedent for the token handling: skills/trigger-cron/scripts/trigger.sh.
|
|
6
|
+
#
|
|
7
|
+
# Why this file exists beside scripts/lib/bearer-curl.sh (the repository-root helper, `bc_curl`, used by the workflow YAML
|
|
8
|
+
# and CI): this plugin ships to customer machines, which have the plugin directory and nothing of the repository root, so
|
|
9
|
+
# it cannot source a repo-root script (ADR-280 already records that the plugin cannot source scripts/lib). Same name, a
|
|
10
|
+
# different helper: the repo-root one SENDS a request for a workflow; this one reads ONE secret by name and sends ONE GET.
|
|
11
|
+
# Both hide the same family of curl environment variables (the list below is kept equal to _bc_send's in the root helper).
|
|
12
|
+
# ADR-280's stdin-config form (`--config -`) is not used here: the 0600 config file lives in a private 0700 scratch
|
|
13
|
+
# directory the caller made (hold-gate-eval.sh uses mktemp -d) and is removed right after curl returns, on every path.
|
|
14
|
+
# bc_read_token and bc_get are GENERIC: any UPPER_SNAKE secret name and any https URL. The closed union of secret names
|
|
15
|
+
# that may be read lives in the TypeScript reader (apps/web-platform/lib/internal-auth-named.ts), not here.
|
|
16
|
+
#
|
|
17
|
+
# API (all return 0 on success, non-zero on ANY failure; no function prints anything on stdout):
|
|
18
|
+
# bc_read_token <SECRET_NAME> reads `doppler secrets get <name> --plain --project soleur --config prd` (project and
|
|
19
|
+
# config are fixed here, never a parameter, never the environment), applies the shape
|
|
20
|
+
# guard and leaves the value in BC_TOKEN (unexported). The value is never printed.
|
|
21
|
+
# bc_get <scratch-dir> <url> GET <url> with the bearer on a 0600 curl config written under <scratch-dir> (never on
|
|
22
|
+
# argv). Sets BC_STATUS (3-digit HTTP status, 000 when curl did not get one), BC_RC (curl's
|
|
23
|
+
# exit status) and BC_BODY (path of the response body). Returns 0 only when curl itself
|
|
24
|
+
# succeeded and produced a status; the HTTP status is the CALLER's to interpret (this
|
|
25
|
+
# function never reads a 4xx or 5xx as success or failure).
|
|
26
|
+
# bc_clear forgets the token.
|
|
27
|
+
# BC_ERR why bc_read_token returned non-zero, for the caller's wording (never the value): `missing` (no
|
|
28
|
+
# secret-store tool, a bad name, the read failed or was empty), `shape` (a value was read but
|
|
29
|
+
# failed the 48 to 256 character guard) or `xtrace`. Empty after a success. Set silently.
|
|
30
|
+
#
|
|
31
|
+
# Hardening, in one place: refuse under xtrace (a traced run would print the credential), a token-shape guard (48 to 256
|
|
32
|
+
# characters of [A-Za-z0-9._~+/=-], the same bounds as TOKEN_RE in the verify route; the token is written into a curl config
|
|
33
|
+
# line, so a quote or newline would inject a directive), `--disable` first (no ~/.curlrc),
|
|
34
|
+
# `--noproxy '*'`, `--proto =https`, `--max-redirs 0` (a redirect is a status, never followed), bounded connect time,
|
|
35
|
+
# total time and body size, no retry (a retry turns a throttled answer into a later success), and the environment
|
|
36
|
+
# variables that subvert TLS, name resolution or the loaded libraries hidden from curl only (the caller's own environment is not mutated).
|
|
37
|
+
|
|
38
|
+
# Refuse to be loaded under xtrace. `return` ends a `source`; `exit` covers a direct execution.
|
|
39
|
+
case "$-" in
|
|
40
|
+
*x*)
|
|
41
|
+
printf 'bearer-fetch: refusing to run under xtrace: this helper handles a live credential and -x would print it (see #7797). No secret has been read.\n' >&2
|
|
42
|
+
return 78 2>/dev/null || exit 78 # mut:xtrace-source
|
|
43
|
+
;;
|
|
44
|
+
esac
|
|
45
|
+
|
|
46
|
+
BC_TOKEN=""; BC_STATUS="000"; BC_RC=1; BC_BODY=""; BC_ERR=""
|
|
47
|
+
|
|
48
|
+
bc_shape_ok() { # <value>: 0 only for a plausible bearer token (never echoes it)
|
|
49
|
+
local LC_ALL=C
|
|
50
|
+
[ "${#1}" -ge 48 ] || return 1
|
|
51
|
+
[ "${#1}" -le 256 ] || return 1
|
|
52
|
+
case "${1:-}" in ''|*[!A-Za-z0-9._~+/=-]*) return 1 ;; esac
|
|
53
|
+
return 0
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
bc_clear() { BC_TOKEN=""; }
|
|
57
|
+
|
|
58
|
+
bc_read_token() { # <SECRET_NAME>
|
|
59
|
+
local name="${1:-}" tok="" to=()
|
|
60
|
+
BC_TOKEN=""; BC_ERR="missing"
|
|
61
|
+
case "$-" in *x*) BC_ERR="xtrace"; return 1 ;; esac # mut:xtrace-read
|
|
62
|
+
case "$name" in ''|*[!A-Z0-9_]*) return 1 ;; esac
|
|
63
|
+
command -v doppler >/dev/null 2>&1 || return 1
|
|
64
|
+
if command -v timeout >/dev/null 2>&1; then to=(timeout 10); elif command -v gtimeout >/dev/null 2>&1; then to=(gtimeout 10); fi
|
|
65
|
+
tok="$(${to[@]+"${to[@]}"} doppler secrets get "$name" --plain --project soleur --config prd 2>/dev/null </dev/null)" || return 1
|
|
66
|
+
if [ -n "$tok" ] && ! bc_shape_ok "$tok"; then BC_ERR="shape"; fi # mut:err-shape
|
|
67
|
+
bc_shape_ok "$tok" || return 1 # mut:shape
|
|
68
|
+
BC_TOKEN="$tok"; BC_ERR=""
|
|
69
|
+
return 0
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
bc_get() { # <scratch-dir> <https-url>
|
|
73
|
+
local scratch="${1:-}" url="${2:-}" cfg body
|
|
74
|
+
BC_STATUS="000"; BC_RC=1; BC_BODY=""
|
|
75
|
+
case "$-" in *x*) return 1 ;; esac
|
|
76
|
+
[ -n "$BC_TOKEN" ] || return 1
|
|
77
|
+
[ -d "$scratch" ] || return 1
|
|
78
|
+
case "$url" in https://*) ;; *) return 1 ;; esac # mut:scheme
|
|
79
|
+
cfg="$scratch/bc.cfg"; body="$scratch/bc.body"
|
|
80
|
+
rm -f "$cfg" "$body"
|
|
81
|
+
( umask 077 && printf 'header = "Authorization: Bearer %s"\n' "$BC_TOKEN" > "$cfg" ) || { rm -f "$cfg"; return 1; }
|
|
82
|
+
BC_STATUS="$(env -u SSLKEYLOGFILE -u CURL_CA_BUNDLE -u SSL_CERT_FILE -u SSL_CERT_DIR -u CURL_HOME -u HOSTALIASES -u LOCALDOMAIN -u RES_OPTIONS -u OPENSSL_CONF -u OPENSSL_MODULES -u LD_PRELOAD -u LD_AUDIT -u LD_LIBRARY_PATH curl --disable --noproxy '*' --proto =https --max-redirs 0 --connect-timeout 5 --max-time 15 --max-filesize 4096 -sS -o "$body" -w '%{http_code}' --config "$cfg" "$url" 2>/dev/null </dev/null)"; BC_RC=$?
|
|
83
|
+
rm -f "$cfg"
|
|
84
|
+
[[ "$BC_STATUS" =~ ^[0-9]{3}$ ]] || BC_STATUS="000"
|
|
85
|
+
[ -f "$body" ] && BC_BODY="$body"
|
|
86
|
+
[ "$BC_RC" -eq 0 ] && [ "$BC_STATUS" != "000" ]
|
|
87
|
+
}
|
|
@@ -207,11 +207,12 @@ Stop conditions: {STOP_CONDITIONS}
|
|
|
207
207
|
## 3. `Gate:` v1 grammar
|
|
208
208
|
|
|
209
209
|
One predicate per line, closed set. An unknown kind, an unreadable probe, a missing or invalid delegation or a timeout
|
|
210
|
-
means the hold STANDS (the evaluator exits 1 for an invalid delegation
|
|
210
|
+
means the hold STANDS (the evaluator exits 1 for an invalid delegation or a gate that is false or needs a person, 2 for anything it cannot evaluate, and 3 when no `Delegation:` line is recorded and no non-reserved hold carries a `web-acceptance` gate: the prose path, see the web-acceptance exception below). Adding a kind is a CTO ruling plus a test row.
|
|
211
211
|
|
|
212
212
|
```text
|
|
213
213
|
Gate: pr-merged <N>
|
|
214
214
|
Gate: no-inflight-run <workflow-file>
|
|
215
|
+
Gate: web-acceptance <key> <64 lowercase hex>
|
|
215
216
|
```
|
|
216
217
|
|
|
217
218
|
`command` and `run-green` are deferred. The first real consumer re-adds them, and only by CTO ruling.
|
|
@@ -219,6 +220,19 @@ Gate: no-inflight-run <workflow-file>
|
|
|
219
220
|
`pr-merged` needs state MERGED on the repository's default branch and the merge commit reachable from HEAD.
|
|
220
221
|
`no-inflight-run` needs no run of that workflow in any of the statuses queued, in_progress, waiting, requested or pending,
|
|
221
222
|
and is true only at that instant (it is evaluated again right before arming).
|
|
223
|
+
`web-acceptance` needs the founder's recorded decision for exactly that legal text to be `accepted`: `<key>` names a text
|
|
224
|
+
committed under `apps/web-platform/server/legal-acceptance/texts/`, `<hash>` is the sha256 of that committed file, and the
|
|
225
|
+
evaluator checks the hash against the committed file itself, then asks the web application (read-only token, fixed address).
|
|
226
|
+
`none` or a changed text keeps the hold (exit 1); `declined`, `changes_requested` and an expired text (its `valid_until` day is past)
|
|
227
|
+
need a person and a revised text (exit 1); `invalid`, a check that is not available or unreachable, and any answer that is not exactly the
|
|
228
|
+
expected shape leave the hold standing as unevaluable (exit 2). The hold's own `Hold:` line must name the gate's key as a whole word (a letter, digit, hyphen or underscore beside it makes it a longer word), or the
|
|
229
|
+
gate is unevaluable (exit 2); a `web-acceptance` gate is never evaluated in an envelope (`--file` mode). The web-acceptance exception to
|
|
230
|
+
"a delegation is cited": it is its own evidence and needs no `Delegation:` line. With no `Delegation:` line, a plan whose every
|
|
231
|
+
non-reserved hold carries only web acceptances is evaluated here (exit 0, 1 or 2, never 3); a plan that mixes a web acceptance with another
|
|
232
|
+
kind of gate, or with a hold that has no gate, is exit 2; a plan with no web acceptance on a non-reserved hold (reserved-only and gate-less
|
|
233
|
+
plans included) is exit 3 and keeps the prose path. A recorded Yes authorizes no production act and grants no merge, deploy or spend
|
|
234
|
+
authority: the gate discharges a hold like any other gate, and it backs only a hold on that legal acceptance for a text written for that hold.
|
|
235
|
+
Procedure and the meaning of each printed reason: [operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md) section 1.
|
|
222
236
|
|
|
223
237
|
## 4. What this does NOT bypass
|
|
224
238
|
|
package/skills/ship/SKILL.md
CHANGED
|
@@ -1946,7 +1946,7 @@ Replace `BRANCH_NAME` with the actual branch name.
|
|
|
1946
1946
|
|
|
1947
1947
|
4.5. **Technical-ruling body check:** `${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/technical-ruling-gate.sh --pr-body <live body>` via the recipe in [decision-challenges-render.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/decision-challenges-render.md) (it prints `gate-rc=`): 0 — proceed to Phase 6.45; 1 remedy; 2 never ready past it.
|
|
1948
1948
|
|
|
1949
|
-
5. **A recorded operator HOLD is a condition, not an outcome — evaluate it here, at the draft exit, from `## Operator Holds` in the plan file (never from conversation), by [operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md).** Run `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/hold-gate-eval.sh" --plan <plan file>`: 0 every hold discharged or none recorded (a no-op) — continue to Phase 6.45; 1 or 2 (any other status — 124, 127, 137 — is treated as 2) a hold STANDS — stop and name **that condition**; 3 no delegation recorded —
|
|
1949
|
+
5. **A recorded operator HOLD is a condition, not an outcome — evaluate it here, at the draft exit, from `## Operator Holds` in the plan file (never from conversation), by [operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md).** Run `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/hold-gate-eval.sh" --plan <plan file>`: 0 every hold discharged or none recorded (a no-op) — continue to Phase 6.45; 1 or 2 (any other status — 124, 127, 137 — is treated as 2) a hold STANDS — stop and name **that condition**; 3 no delegation recorded — by hand per the reference (`web-acceptance`-only: holds reference s.1). An unreachable plan file, an unevaluable condition or a hold with no gate is never an all-clear (route a person-only hold to the Undeferred Operator-Step Gate). Record each verdict in the PR body, and evaluate again at the start of Phase 6.45, before the plan is archived. **Why:** PR #7470.
|
|
1950
1950
|
|
|
1951
1951
|
**If no open PR exists:**
|
|
1952
1952
|
|
|
@@ -1994,7 +1994,7 @@ Emit rule-application telemetry:
|
|
|
1994
1994
|
echo 'SOLEUR_RULE_APPLIED rule=wg-kb-artifacts-archived-in-pr note=`soleur:ship` Phase 6.45 archives KB artifacts into the PR before any merge site'
|
|
1995
1995
|
```
|
|
1996
1996
|
|
|
1997
|
-
Before Phase 6.45 archives the plan and rulings file, run `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/pr-overlap-preflight.sh" --mode merge` (add `--vehicle <N|this>` from the `overlap vehicle` row of decision-challenges.md when it exists): exit 10 or 12 stops arming; 2 retries once then continues with the notice; 0, 11, 13 continue. If the plan has a `## Operator Holds` section with a `Delegation:` line, run `hold-gate-eval.sh --plan <plan>` again now ([operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md)): exit 1 or 2 stops arming.
|
|
1997
|
+
Before Phase 6.45 archives the plan and rulings file, run `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/pr-overlap-preflight.sh" --mode merge` (add `--vehicle <N|this>` from the `overlap vehicle` row of decision-challenges.md when it exists): exit 10 or 12 stops arming; 2 retries once then continues with the notice; 0, 11, 13 continue. If the plan has a `## Operator Holds` section with a `Gate:`/`Delegation:` line, run `hold-gate-eval.sh --plan <plan>` again now ([operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md)): exit 1 or 2 stops arming.
|
|
1998
1998
|
|
|
1999
1999
|
In that line `hold-gate-eval.sh` is `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/hold-gate-eval.sh"`, and any exit other than 0 (including 124, 127 or 137) stops arming; the plan and the rulings file are read from their live paths here because Phase 6.45 has not archived them yet.
|
|
2000
2000
|
|
|
@@ -26,6 +26,8 @@ Envelope: <path>[#<title>]
|
|
|
26
26
|
Gate: pr-merged <N>
|
|
27
27
|
Gate: no-inflight-run <workflow-file>
|
|
28
28
|
- Hold: Operator-reserved: <a decision only the operator may make, in their words>
|
|
29
|
+
- Hold: <the operator's words> [Text name (added by the plan's author): <key>]
|
|
30
|
+
Gate: web-acceptance <key> <64 lowercase hex>
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
**A gate says WHEN a hold's condition is true, never WHO the hold is reserved to.** Some holds reserve a decision to the
|
|
@@ -38,8 +40,85 @@ evaluator prints `Reserved for you: <words> - only you can clear this`, does not
|
|
|
38
40
|
only by the operator saying so, and the CTO then removes or rewrites the line. Words in the middle of a hold do not reserve
|
|
39
41
|
it.
|
|
40
42
|
|
|
41
|
-
The grammar has
|
|
42
|
-
consumer re-adds them, and only by CTO ruling. A `Gate:` line of any other kind is an unknown kind, and the hold
|
|
43
|
+
The grammar has three kinds, `pr-merged`, `no-inflight-run` and `web-acceptance`. `command` and `run-green` are deferred: the
|
|
44
|
+
first real consumer re-adds them, and only by CTO ruling. A `Gate:` line of any other kind is an unknown kind, and the hold
|
|
45
|
+
stands.
|
|
46
|
+
|
|
47
|
+
**`web-acceptance <key> <hash>`** discharges a hold by the founder's recorded decision on a legal text, never by anyone's
|
|
48
|
+
reading of prose. `<key>` is the file name (without `.md`) of a text committed under
|
|
49
|
+
`apps/web-platform/server/legal-acceptance/texts/`; `<hash>` is the sha256 of that committed file, 64 lowercase hex characters
|
|
50
|
+
(compute it with `git show HEAD:apps/web-platform/server/legal-acceptance/texts/<key>.md | sha256sum`).
|
|
51
|
+
The evaluator hashes the committed file (the `HEAD` blob) itself, and asks the web application, with a read-only token read
|
|
52
|
+
from the secret store, whether the configured founder accepted exactly that hash. Both tokens are validated first, by the same
|
|
53
|
+
rule as the database (a key of 1 to 63 lowercase letters, digits and hyphens that does not start with a hyphen; a lowercase hash
|
|
54
|
+
of exactly 64 characters): a path character, an uppercase hex digit, a missing or extra token makes the hold
|
|
55
|
+
`Could not check` and nothing is requested. A tab inside a `Hold:` or `Gate:` line is read as one space, so it can never split
|
|
56
|
+
the line. A hold is discharged only for an `accepted` answer whose record passed its checksum, whose echoed hash equals the
|
|
57
|
+
gate's hash, and whose hash equals the committed text's hash.
|
|
58
|
+
|
|
59
|
+
**Name the text key in the `Hold:` line.** The `Hold:` line (the one line, not the lines under it) must contain the gate's key
|
|
60
|
+
as a whole word, in any case, after control characters and invisible marks are removed (the whole line counts, even past the 160-character
|
|
61
|
+
display cut, so the check proves the plan's author named the text, not that the operator saw it named). A letter, digit, hyphen or underscore directly beside the key makes it part of a longer word: `wa-key` is named by
|
|
62
|
+
`Wait for wa-key` or `(WA-KEY)` but not by `wa-key-two`, `xwa-key`, `wa-keys` or `wa-key_x`. The operator's quoted words are
|
|
63
|
+
never rewritten to add it: the plan's author adds the key in a **separate clause marked as the author's**, after the operator's
|
|
64
|
+
words, for example `- Hold: "do not ship until the founder accepts the terms update" [Text name (added by the plan's author): terms-update]`.
|
|
65
|
+
A hold that does not name the key is `Could not check` ("this wait does not name the legal text it is about; ask the plan's
|
|
66
|
+
author to put the text name <key> in the hold's words") and nothing is requested, with or without a `Delegation:` line. Every
|
|
67
|
+
`web-acceptance` gate on the hold needs its own key named. This stops a decision about one text from clearing a wait about
|
|
68
|
+
something else. It is a lexical check: it proves the words and the gate point at the same key, not that the words faithfully
|
|
69
|
+
describe the text, so reviewing the pairing stays the author's and the CTO's job. A `web-acceptance` gate is never evaluated in
|
|
70
|
+
`--file` mode (an envelope backs a production step; a recorded decision on a legal text cannot): it is `Could not check` there.
|
|
71
|
+
A plan file that contains a NUL byte or any other control byte except tab, carriage return and line feed is `Could not check`
|
|
72
|
+
before anything is read (exit 2).
|
|
73
|
+
|
|
74
|
+
If the text's front matter (the first `---` block, from the first line of the file) carries `valid_until: YYYY-MM-DD` and that day
|
|
75
|
+
is before today (UTC), the hold stands as a person's matter and nothing is requested. A repeated `valid_until:` line keeps the last
|
|
76
|
+
value, as the web application's reader does; a `valid_until:` line outside the front matter is ignored. A `valid_until` that is not
|
|
77
|
+
a real calendar day written `YYYY-MM-DD` (`soon`, `2099-1-1`, `2026-13-01`, `2099-99-99`, `2026-02-30`) is `Could not check`
|
|
78
|
+
("the saved text is damaged"), and so is a `valid_until:` line with no value; no `valid_until` line at all means no expiry. The recorded decision date is informational: it is read from the
|
|
79
|
+
answer, which the database's checksum protects, and a date in the future is not used as evidence of anything.
|
|
80
|
+
|
|
81
|
+
What each reason means (the evaluator prints these words, and only these):
|
|
82
|
+
|
|
83
|
+
| Printed reason | Meaning | Exit |
|
|
84
|
+
|---|---|---|
|
|
85
|
+
| `the text was changed after this check was written` | the text was revised after the gate was written; the gate names an old text | 1 |
|
|
86
|
+
| `no decision recorded for this text version` | the founder has not decided this text yet | 1 |
|
|
87
|
+
| `declined; a revised text is needed` | the founder said No: a person decides, and this exact text can never be accepted later | 1 |
|
|
88
|
+
| `the accepted text has passed its last valid day; a revised text is needed` | the text's `valid_until` day is past | 1 |
|
|
89
|
+
| second line `Needs you: the founder asked for changes. You read the note yourself, not an agent session: <runbook path>` | the founder asked for changes: the operator reads the note by the runbook, the agent never does; printed whenever any web-acceptance gate on the hold says so, whatever the other gates say | 1 |
|
|
90
|
+
| `the saved decision looks damaged` | the stored decision no longer matches its checksum; never read as "no decision" | 2 |
|
|
91
|
+
| `the check is not available right now (not switched on, or temporarily down)` | the check answers 503: its token and founder id are not set yet, the saved texts could not be read, or the database failed | 2 |
|
|
92
|
+
| `the check did not accept my sign-in` | the token read from the secret store was refused (401) | 2 |
|
|
93
|
+
| `the live app does not know this text yet` | the text is committed but not deployed yet (a text added in the same change is a post-merge hold) | 2 |
|
|
94
|
+
| `answer not understood` | a 400 or 502, or a body that is not exactly the four expected fields once each, in the expected types, with a plain UTC date | 2 |
|
|
95
|
+
| `I could not reach the check (HTTP <status>, curl rc <n>)` | timeout, name or connection failure, a body over the size limit, a redirect, any other status; numbers only, never the body or the credential | 2 |
|
|
96
|
+
| `no saved sign-in value was found` | no secret-store tool, the read failed, or the value is empty | 2 |
|
|
97
|
+
| `the saved sign-in value looks wrong (too short or odd characters)` | a value was read but is not 48 to 256 characters of the allowed set | 2 |
|
|
98
|
+
| `I could not load the sign-in helper` / `I will not read the sign-in value while commands are being traced` | the helper file is missing, or the run is being traced (a trace would print the credential) | 2 |
|
|
99
|
+
| `I have no tool here to check that the text is unchanged` | no sha256 tool on this machine | 2 |
|
|
100
|
+
| `the saved text is not in the project` | no committed regular file for the key | 2 |
|
|
101
|
+
| `the saved text is damaged` | a carriage return in it, or a `valid_until` that is not a real calendar day | 2 |
|
|
102
|
+
| `this wait does not name the legal text it is about; ask the plan's author to put the text name <key> in the hold's words` | the `Hold:` line does not contain the gate's key as a whole word | 2 |
|
|
103
|
+
| `The file holds a control character I cannot read safely…` (no per-hold line) | a NUL or other control byte in the plan or envelope file | 2 |
|
|
104
|
+
| `a recorded decision on a legal text cannot back a production step` | a `web-acceptance` gate in an envelope (`--file` mode) | 2 |
|
|
105
|
+
|
|
106
|
+
**What ship does with each.** Exit 0 for a web-acceptance hold: record the `Done:` line (it carries the decision date) in the PR
|
|
107
|
+
body. Exit 1 with `no decision recorded`: print the full card link `https://app.soleur.ai/dashboard/approvals/legal/<key>` (not a
|
|
108
|
+
relative path: the founder opens it from a message) so the founder can decide, and offer to defer with an issue (the hold stays).
|
|
109
|
+
Exit 1 with `declined`, `passed its last valid day` or `Needs you`: the answer for that text is terminal, so say that a revised text (a new hash,
|
|
110
|
+
a new gate) is needed; never retry, never re-ask for the same text. For `Needs you` say that the founder asked for changes and
|
|
111
|
+
that the operator, not an agent session, reads the note by the path on the line. Exit 1 with `the text was changed after this
|
|
112
|
+
check was written`: the plan's gate must be rewritten for the committed text (compute the new hash with the one-liner above),
|
|
113
|
+
by the plan's author. Exit 2: the hold stands, named in one plain sentence from the table, and never retried into a pass.
|
|
114
|
+
|
|
115
|
+
**What a web-acceptance gate is for, and not for.** It discharges a hold like any other gate: the hold stands until the
|
|
116
|
+
founder's recorded decision on exactly that text is `accepted`, and then the hold is cleared. It grants no authority of its own:
|
|
117
|
+
a recorded Yes is not a merge approval, a deploy approval or a spend approval, and it does not stand in for an
|
|
118
|
+
`Operator-reserved:` hold (those always stand). The canonical use is a hold of the form "do not ship until the founder has
|
|
119
|
+
accepted this text". The pairing of the hold's words with the gate's key is checked lexically (above); the residual is a hold
|
|
120
|
+
whose words name a key that the author attached to a gate for a text that was accepted for another purpose. So never reuse an
|
|
121
|
+
old acceptance for a new hold: write a new text and a new gate.
|
|
43
122
|
|
|
44
123
|
A read-only check is never a hold line: write the `Gate:` when `pr-merged` or `no-inflight-run` fits; otherwise the CTO runs it ([standing-delegation.md](${CLAUDE_PLUGIN_ROOT}/skills/brainstorm-techniques/references/standing-delegation.md) section 9) and records it as `Checked:` or `Unverified:` in a `## Class R Checks` section beside this one, never `Operator-reserved:` for the read itself (an `Unverified:` read that a merge or deploy depends on makes the act it gates an `Operator-reserved:` hold: section 9 Records) and never a `Hold:` with no `Gate:`. A read result never satisfies a `Gate:` and removes no hold line.
|
|
45
124
|
|
|
@@ -58,6 +137,12 @@ Rules the evaluator applies to this section:
|
|
|
58
137
|
and compares the count with the lines it parsed inside readable sections; any difference is exit 2. A line inside a code
|
|
59
138
|
fence is an example and is ignored; only a fence of the same character, at least as long, closes it.
|
|
60
139
|
- A hold with no `Gate:` line is "Needs a person" (section 2).
|
|
140
|
+
- **No `Delegation:` line, and a `web-acceptance` gate** (CTO ruling F3): a web acceptance is its own evidence, so it needs no
|
|
141
|
+
delegation. With no `Delegation:` line, a plan whose every non-reserved hold carries at least one gate and only
|
|
142
|
+
`web-acceptance` gates is evaluated (never exit 3); a plan that puts a `web-acceptance` gate beside any other kind of gate,
|
|
143
|
+
or beside a hold with no gate, is exit 2 (every hold stands, nothing is probed); a plan with no `web-acceptance` gate on a
|
|
144
|
+
non-reserved hold, reserved-only and gate-less plans included, keeps exit 3 and the prose path. An `Operator-reserved:` hold
|
|
145
|
+
stands in every case, whatever gates it carries.
|
|
61
146
|
|
|
62
147
|
The operator's wording stays beside the gates so a gate that weakens a hold is visible in review. Whether a gate
|
|
63
148
|
faithfully encodes a hold is the CTO's authoring and review's check; the evaluator only measures the gate.
|
|
@@ -73,17 +158,18 @@ bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/hold-gate-eval.sh" --plan <plan
|
|
|
73
158
|
| Exit | Meaning | Action |
|
|
74
159
|
|---|---|---|
|
|
75
160
|
| 0 | Every hold is discharged, or none is recorded (an absent or empty section is a no-op) | Continue to Phase 6.45 and the arming in Phase 6.5 |
|
|
76
|
-
| 1 | At least one hold STANDS (a gate is false, or the delegation is invalid) | Stop and name that condition, in one plain sentence to the operator |
|
|
77
|
-
| 2 | A hold could not be evaluated or is reserved to the operator (unknown gate kind, unreadable probe, unreadable delegation, no `Envelope:` line, two `Delegation:` lines, a hold outside a readable section, a section that parses to zero holds, no time-limit tool, an `Operator-reserved:` hold) | It STANDS. Say so in one plain sentence; never retry it into a pass |
|
|
78
|
-
| 3 | No `Delegation:` line is recorded: legacy prose holds | Evaluate by hand per section 3 |
|
|
161
|
+
| 1 | At least one hold STANDS (a gate is false, a web acceptance is undecided, declined or changes-requested, or the delegation is invalid) | Stop and name that condition, in one plain sentence to the operator; for a web acceptance, follow "What ship does with each" in section 1 |
|
|
162
|
+
| 2 | A hold could not be evaluated or is reserved to the operator (unknown gate kind, unreadable probe, unreadable delegation, no `Envelope:` line, two `Delegation:` lines, a hold outside a readable section, a section that parses to zero holds, no time-limit tool, an `Operator-reserved:` hold, a web acceptance mixed with other kinds and no delegation, a web acceptance that could not be asked) | It STANDS. Say so in one plain sentence; never retry it into a pass |
|
|
163
|
+
| 3 | No `Delegation:` line is recorded and no non-reserved hold carries a `web-acceptance` gate: legacy prose holds | Evaluate by hand per section 3 |
|
|
79
164
|
| any other status (127 script not found, 124 timed out, 137 killed) | The check did not run | Treat it as 2: the hold STANDS and was not checked. Say so; never read it as a no-op |
|
|
80
165
|
|
|
81
166
|
Before naming a standing hold (exit 1 or 2), class it per section 8.1b of [technical-ruling-delegation.md](../../brainstorm-techniques/references/technical-ruling-delegation.md): a hold that rests on an evidence judgement is a technical ruling and goes to the CTO first; a plain unmet gate (a date, CI, a missing tool) and an `Operator-reserved:` hold are named as they are.
|
|
82
167
|
|
|
83
168
|
Exit 3 is decided before every other structure and tool check, so a plan written in the earlier prose format keeps the prose
|
|
84
|
-
path whatever else it contains.
|
|
169
|
+
path whatever else it contains; the one exception is a plan that carries a `web-acceptance` gate on a non-reserved hold (section 1).
|
|
85
170
|
|
|
86
|
-
A hold with no `Gate:` line is reported "Needs a person"
|
|
171
|
+
A hold with no `Gate:` line is reported "Needs a person" (a declined or changes-requested web acceptance is reported the same
|
|
172
|
+
way, with its reason in parentheses): route it to the Undeferred Operator-Step Gate rather than
|
|
87
173
|
improvising a gate. A condition only a human can settle (a subjective call, an external party) is a genuine operator gate,
|
|
88
174
|
because a PR body is not an operator-visible surface. The standing delegation is verified first, through
|
|
89
175
|
`${CLAUDE_PLUGIN_ROOT}/scripts/delegation-verify.sh` (its exit status AND its first line must both say valid); anything else
|
|
@@ -166,8 +252,8 @@ required checks green, the review evidence (the `Reviewed-By-Soleur` trailer, an
|
|
|
166
252
|
## 4. Timing: twice, and the receipt after a delegated act
|
|
167
253
|
|
|
168
254
|
Evaluate at the draft exit AND again at the start of Phase 6.45, before the plan is archived, through the same command
|
|
169
|
-
(`hold-gate-eval.sh --plan <plan file>`; any exit
|
|
170
|
-
because once Phase 6.45 archives the plan its live path is gone and the evaluator would answer 2. Be honest about the gap: a
|
|
255
|
+
(`hold-gate-eval.sh --plan <plan file>`; exit 1, exit 2 and any status that is not a result (127, 124, 137) stop the arming, **exit 3 does not**: it means no gate here can be evaluated by this command, so the hand check done at the draft exit stands and nothing evaluable changed since). It runs there, not at the arming call itself,
|
|
256
|
+
because once Phase 6.45 archives the plan its live path is gone and the evaluator would answer 2. The second evaluation is for any plan whose `## Operator Holds` carries a hold with a `Gate:` or a `Delegation:` line (a web-acceptance-only plan has no `Delegation:` line): a review fix that edits the committed text after the first look changes its hash, and only this second look sees the stale gate. Be honest about the gap: a
|
|
171
257
|
predicate such as `no-inflight-run` is true only at the instant it is read, so a run that starts between that look and the
|
|
172
258
|
arming is not seen. The repository's required checks, not this look, are the final authority at the merge.
|
|
173
259
|
|
|
@@ -143,7 +143,7 @@ asserts that each block below is byte-equal to the one in the call site.
|
|
|
143
143
|
### Ship (start of Phase 6.45, before the plan and rulings file are archived)
|
|
144
144
|
|
|
145
145
|
```text
|
|
146
|
-
Before Phase 6.45 archives the plan and rulings file, run `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/pr-overlap-preflight.sh" --mode merge` (add `--vehicle <N|this>` from the `overlap vehicle` row of decision-challenges.md when it exists): exit 10 or 12 stops arming; 2 retries once then continues with the notice; 0, 11, 13 continue. If the plan has a `## Operator Holds` section with a `Delegation:` line, run `hold-gate-eval.sh --plan <plan>` again now ([operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md)): exit 1 or 2 stops arming.
|
|
146
|
+
Before Phase 6.45 archives the plan and rulings file, run `bash "${CLAUDE_PLUGIN_ROOT}/skills/ship/scripts/pr-overlap-preflight.sh" --mode merge` (add `--vehicle <N|this>` from the `overlap vehicle` row of decision-challenges.md when it exists): exit 10 or 12 stops arming; 2 retries once then continues with the notice; 0, 11, 13 continue. If the plan has a `## Operator Holds` section with a `Gate:`/`Delegation:` line, run `hold-gate-eval.sh --plan <plan>` again now ([operator-holds.md](${CLAUDE_PLUGIN_ROOT}/skills/ship/references/operator-holds.md)): exit 1 or 2 stops arming.
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
Phase 6.45 moves the plan and the rulings file to archive/, so the merge-mode run, the `overlap vehicle` lookup and the hold re-evaluation must happen before it: afterwards the files are no longer where the call expects them.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC2015,SC2018,SC2019 # A && B || C is the check idiom; tr A-Z is the portable ASCII lowering
|
|
2
|
+
# shellcheck disable=SC2015,SC2016,SC2018,SC2019 # A && B || C is the check idiom; tr A-Z is the portable ASCII lowering
|
|
3
3
|
# The /ship Phase 6 step 5 hold evaluator: turns the recorded `Gate:` predicates of `## Operator Holds` (or of a
|
|
4
4
|
# Production Envelope's `Preconditions:`) into a mechanical verdict, so a hold is discharged by evidence and never
|
|
5
5
|
# by a model's reading of prose. Procedure and wording: skills/ship/references/operator-holds.md. Format source:
|
|
@@ -7,9 +7,12 @@
|
|
|
7
7
|
#
|
|
8
8
|
# Property: plan mode verifies the delegation, and a hold is discharged only if a Standing Delegation is cited
|
|
9
9
|
# (verifier rc 0 AND a first line `delegation: valid`) and EVERY one of its `Gate:` predicates is a known kind that
|
|
10
|
-
# evaluates true now.
|
|
11
|
-
#
|
|
10
|
+
# evaluates true now. The one exception to "a delegation is cited" is a plan whose every non-reserved hold carries
|
|
11
|
+
# nothing but `web-acceptance` gates (below): the gate IS the evidence, so no delegation is needed. Any other state
|
|
12
|
+
# leaves it standing: an unknown kind, an unreadable probe, a missing, ambiguous or invalid delegation, a missing
|
|
13
|
+
# envelope, a timeout, a missing time-limit tool, a hold with no gate.
|
|
12
14
|
# --file mode does not verify a delegation (the caller just did); it only measures one envelope's `Preconditions:` gates.
|
|
15
|
+
# A `web-acceptance` gate is never evaluated in --file mode: a recorded decision on a legal text cannot back a production step.
|
|
13
16
|
#
|
|
14
17
|
# Usage:
|
|
15
18
|
# hold-gate-eval.sh --plan <plan.md> evaluate `## Operator Holds`
|
|
@@ -24,7 +27,19 @@
|
|
|
24
27
|
# Delegation: <comment url> exactly one; without it no hold can be discharged here (exit 3)
|
|
25
28
|
# Envelope: <path>[#<title>] REQUIRED beside a Delegation line; passed to the verifier
|
|
26
29
|
# - Hold: <the operator's words, verbatim>
|
|
27
|
-
# Gate: pr-merged <N> | no-inflight-run <workflow-file>
|
|
30
|
+
# Gate: pr-merged <N> | no-inflight-run <workflow-file> | web-acceptance <key> <64 lowercase hex>
|
|
31
|
+
# `web-acceptance <key> <hash>` is true only when the founder's recorded decision for exactly that text is `accepted`:
|
|
32
|
+
# <key> is the file name (minus .md) of a committed text under apps/web-platform/server/legal-acceptance/texts/ and <hash>
|
|
33
|
+
# the sha256 of that committed file (HEAD blob). The hold's own `Hold:` line must name <key> as a whole token (CTO ruling D1:
|
|
34
|
+
# a decision about one text must not clear a wait about something else), or the gate is UNEVAL. If the text's front matter
|
|
35
|
+
# carries `valid_until: YYYY-MM-DD` and that day is past, the gate is PERSON (a revised text is needed). It asks
|
|
36
|
+
# https://app.soleur.ai/api/internal/legal-acceptance/<key>?hash=<hash> with a read-only bearer token read from the secret
|
|
37
|
+
# store (lib/bearer-fetch.sh); the base URL is a literal. `none` or a text that changed since the gate was written is FALSE
|
|
38
|
+
# (stands); `declined` and `changes_requested` are PERSON (a person must decide; stands, exit 1, a revised text is needed);
|
|
39
|
+
# `invalid` (the record failed its checksum), an unavailable check, a rejected sign-in and every answer that is not exactly
|
|
40
|
+
# the four-key shape are UNEVAL (exit 2). Key and hash shapes are the same predicate as the database CHECK (migration 184)
|
|
41
|
+
# and KEY_RE / TEXT_HASH_RE in server/legal-acceptance/canonical.ts (WA_KEY_RE and WA_HASH_RE below). The reason table is in
|
|
42
|
+
# skills/ship/references/operator-holds.md. A recorded Yes authorizes no production act.
|
|
28
43
|
# `command` and `run-green` are deferred. The first real consumer re-adds them, and only by CTO ruling. A `Gate:`
|
|
29
44
|
# line of any other kind is an unknown kind: it exits 2 and the hold stands. Markers (`Hold:`, `Gate:`,
|
|
30
45
|
# `Delegation:`, `Envelope:`) are read in any case, with or without the list dash and a space before the colon.
|
|
@@ -37,6 +52,10 @@
|
|
|
37
52
|
# a missing time-limit tool);
|
|
38
53
|
# 3 no `Delegation:` line anywhere in the hold sections: legacy prose holds. Decided BEFORE every structure
|
|
39
54
|
# and tool check, so the caller keeps its prose evaluation (operator-holds.md section 3).
|
|
55
|
+
# A hold that needs a person's decision (a declined or changes-requested web acceptance, or no gate at all) is printed
|
|
56
|
+
# `Needs a person: ... - only a person can settle this`, with the reason in parentheses when there is one.
|
|
57
|
+
# A changes-requested web acceptance adds a second line, `Needs you: the founder asked for changes. Read the note yourself,
|
|
58
|
+
# not in an agent session: <path>`, so the reader of the note is named.
|
|
40
59
|
# stdout: when a delegation was checked, its verdict line first (`delegation: <valid|invalid|unverifiable>
|
|
41
60
|
# reason=<token>`); then one plain line per hold, then `holds: N discharged: M standing: K`. A `Done:` line carries
|
|
42
61
|
# the gate text that was true. Exit 2 and 1 are never converted to a pass by any caller; nothing here retries a
|
|
@@ -73,7 +92,9 @@ trap cleanup EXIT
|
|
|
73
92
|
die2() { printf '%s\n' "$1" >&2; exit 2; }
|
|
74
93
|
trim() { local s="$1"; s="${s#"${s%%[![:space:]]*}"}"; s="${s%"${s##*[![:space:]]}"}"; printf '%s' "$s"; }
|
|
75
94
|
# Control characters, C1 controls, zero-width and bidi marks and the line/paragraph separators are dropped (byte-wise: LC_ALL=C).
|
|
76
|
-
|
|
95
|
+
# clean_uncut is what the operator reads before the 160-character cut; clean_text is the printed form.
|
|
96
|
+
clean_uncut() { printf '%s' "$1" | tr -d '[:cntrl:]' | sed -e $'s/\xc2[\x80-\x9f]//g' -e $'s/\xe2\x80[\x8b-\x8f\xa8-\xae]//g' -e $'s/\xe2\x81[\xa6-\xa9]//g' -e $'s/\xef\xbb\xbf//g'; } # mut:clean-uncut
|
|
97
|
+
clean_text() { clean_uncut "$1" | cut -c1-160; } # mut:clean-text
|
|
77
98
|
|
|
78
99
|
VT=60
|
|
79
100
|
case "${HGE_VERIFY_TIMEOUT:-}" in ''|*[!0-9]*) ;; *) [ "$HGE_VERIFY_TIMEOUT" -ge 1 ] && [ "$HGE_VERIFY_TIMEOUT" -lt 60 ] && VT="$HGE_VERIFY_TIMEOUT" ;; esac
|
|
@@ -108,9 +129,23 @@ gh_json() { # <outfile> <gh args...>: 0 only when gh succeeded and printed valid
|
|
|
108
129
|
jq -e . "$out" >/dev/null 2>&1 </dev/null
|
|
109
130
|
}
|
|
110
131
|
|
|
111
|
-
known_kind() { case "$1" in pr-merged|no-inflight-run) return 0 ;; esac; return 1; }
|
|
132
|
+
known_kind() { case "$1" in pr-merged|no-inflight-run|web-acceptance) return 0 ;; esac; return 1; }
|
|
112
133
|
|
|
113
|
-
|
|
134
|
+
# web-acceptance: the key and hash shapes are the SAME predicate as the database CHECK (migration 184: key ~ '^[a-z0-9][a-z0-9-]{0,62}$',
|
|
135
|
+
# text_hash ~ '^[0-9a-f]{64}$') and KEY_RE / TEXT_HASH_RE in apps/web-platform/server/legal-acceptance/canonical.ts. A test extracts
|
|
136
|
+
# these two lines and compares them with those sources: change all of them together or none.
|
|
137
|
+
WA_KEY_RE='^[a-z0-9][a-z0-9-]{0,62}$'
|
|
138
|
+
WA_HASH_RE='^[0-9a-f]{64}$'
|
|
139
|
+
WA_TEXTS='apps/web-platform/server/legal-acceptance/texts'
|
|
140
|
+
WA_BASE='https://app.soleur.ai/api/internal/legal-acceptance' # mut:base-url
|
|
141
|
+
WA_TOKEN_NAME='LEGAL_ACCEPTANCE_VERIFY_TOKEN'
|
|
142
|
+
WA_RUNBOOK='knowledge-base/engineering/operations/runbooks/legal-acceptance-note-read.md'
|
|
143
|
+
WA_CANT='the saved text is not in the project'
|
|
144
|
+
WA_DMG='the saved text is damaged'
|
|
145
|
+
BEARER_LIB="$SCRIPT_DIR/../../../scripts/lib/bearer-fetch.sh"
|
|
146
|
+
WA_HASH=""
|
|
147
|
+
|
|
148
|
+
GRES=""; GWHY=""; GNOTE=""; GLINE=""; WA_HOLD_TEXT=""
|
|
114
149
|
gate_pr_merged() {
|
|
115
150
|
local n="$1" st sha base rc
|
|
116
151
|
[[ "$n" =~ ^[0-9]+$ ]] || { GRES=UNEVAL; GWHY="the earlier change is not named by a plain number"; return; }
|
|
@@ -149,14 +184,114 @@ gate_no_inflight() {
|
|
|
149
184
|
else GRES=TRUE; fi
|
|
150
185
|
}
|
|
151
186
|
|
|
152
|
-
|
|
187
|
+
wa_notu() { GRES=UNEVAL; GWHY="answer not understood"; }
|
|
188
|
+
wa_jq() { jq -e -s --arg h "$WA_HASH" "length == 1 and (.[0] | ($1))" "$BC_BODY" >/dev/null 2>&1 </dev/null; } # the filter is a program, the body the file; no stdin; exactly one JSON document
|
|
189
|
+
|
|
190
|
+
# decided_at is a plain UTC instant: the shape (\A..\z, so a trailing newline fails), then calendar ranges (year 2000 to 2099, month 01-12,
|
|
191
|
+
# day 01-31, hour <= 23, minute and second <= 59) and a round trip through the clock (2026-02-30 comes back as 2026-03-02 and fails).
|
|
192
|
+
WA_JQ_DEFS='def okts: type == "string"
|
|
193
|
+
and test("\\A[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|\\+00(:?00)?)\\z")
|
|
194
|
+
and (capture("\\A(?<y>[0-9]{4})-(?<mo>[0-9]{2})-(?<d>[0-9]{2})T(?<h>[0-9]{2}):(?<mi>[0-9]{2}):(?<s>[0-9]{2})")
|
|
195
|
+
| (.y >= "2000" and .y <= "2099" and .mo >= "01" and .mo <= "12" and .d >= "01" and .d <= "31" and .h <= "23" and .mi <= "59" and .s <= "59")
|
|
196
|
+
and ("\(.y)-\(.mo)-\(.d)T\(.h):\(.mi):\(.s)Z" as $t | (try ($t | fromdateiso8601 | todateiso8601) catch "") == $t)); '
|
|
197
|
+
# the answer must be exactly four scalar leaves at the top level, one per key (jq keeps the LAST of a repeated key, so a repeat, or an object that a later
|
|
198
|
+
# scalar replaces, could hide a value from the readers that come after it)
|
|
199
|
+
WA_JQ_ONCE='[inputs | select(length == 2)] as $l | ($l | length) == 4 and all($l[]; (.[0] | length) == 1) and ($l | map(.[0][0]) | unique | length) == 4'
|
|
200
|
+
|
|
201
|
+
# gate_web_acceptance <key> <hash>: TRUE only for an `accepted` answer with row_ok true whose echoed hash equals the gate hash, which
|
|
202
|
+
# in turn equals the sha256 of the committed text. Every verdict and reason is a row of the closed table in
|
|
203
|
+
# skills/ship/references/operator-holds.md (section 1, web-acceptance).
|
|
204
|
+
gate_web_acceptance() {
|
|
205
|
+
local rest="$1" key hash path ent top lh="" st d ok vu today
|
|
206
|
+
WA_HASH=""
|
|
207
|
+
key="${rest%% *}"; hash="${rest#* }"
|
|
208
|
+
if [[ "$rest" != *" "* ]] || ! [[ "$key" =~ $WA_KEY_RE ]] || ! [[ "$hash" =~ $WA_HASH_RE ]]; then GRES=UNEVAL; GWHY="the web acceptance is not written as a plain text name and fingerprint"; return; fi # mut:wa-shape
|
|
209
|
+
# CTO ruling D1: the hold's own words (cleaned of control and bidi characters, but NOT cut at the 160-character display limit, so a key beyond that limit still binds; accepted residual of the lexical rule) must name this text's key as a whole
|
|
210
|
+
# token, so a decision about one text cannot clear a wait about another thing. A letter, digit, hyphen or underscore beside the key makes it part of a longer word.
|
|
211
|
+
grep -Eq "(^|[^a-z0-9_-])${key}([^a-z0-9_-]|\$)" < <(clean_uncut "$WA_HOLD_TEXT" | tr 'A-Z' 'a-z') || { GRES=UNEVAL; GWHY="this wait does not name the legal text it is about; ask the plan's author to put the text name $key in the hold's words"; return; } # mut:wa-bind
|
|
212
|
+
WA_HASH="$hash"
|
|
213
|
+
path="$WA_TEXTS/$key.md"
|
|
214
|
+
top="$(git rev-parse --show-toplevel </dev/null 2>/dev/null)" || top="" # a pathspec is relative to the working directory, so list from the top
|
|
215
|
+
[ -n "$top" ] || { GRES=UNEVAL; GWHY="$WA_CANT"; return; }
|
|
216
|
+
ent="$(GIT_LITERAL_PATHSPECS=1 git -C "$top" ls-tree --full-tree HEAD -- "$path" </dev/null 2>/dev/null | head -1)"
|
|
217
|
+
case "$ent" in "100644 blob "*) ;; *) GRES=UNEVAL; GWHY="$WA_CANT"; return ;; esac # mut:wa-blob
|
|
218
|
+
git -C "$top" cat-file blob "HEAD:$path" > "$WORK/wa.txt" 2>/dev/null </dev/null || { GRES=UNEVAL; GWHY="$WA_CANT"; return; }
|
|
219
|
+
[ "$(tr -cd '\r' < "$WORK/wa.txt" | wc -c | tr -d ' ')" = 0 ] || { GRES=UNEVAL; GWHY="$WA_DMG"; return; } # mut:wa-cr
|
|
220
|
+
if command -v sha256sum >/dev/null 2>&1; then lh="$(sha256sum < "$WORK/wa.txt" 2>/dev/null | cut -c1-64)"
|
|
221
|
+
elif command -v shasum >/dev/null 2>&1; then lh="$(shasum -a 256 < "$WORK/wa.txt" 2>/dev/null | cut -c1-64)"; fi
|
|
222
|
+
[[ "$lh" =~ $WA_HASH_RE ]] || { GRES=UNEVAL; GWHY="I have no tool here to check that the text is unchanged"; return; }
|
|
223
|
+
[ "$lh" = "$hash" ] || { GRES=FALSE; GWHY="the text was changed after this check was written"; return; } # mut:local-hash
|
|
224
|
+
# CTO ruling D6: a text whose front matter names a last day (valid_until: YYYY-MM-DD) that is past needs a revised text. Absent = no expiry.
|
|
225
|
+
# Only the front matter (the block from line 1 to the next `---`) is read, and a repeated line keeps the LAST value, as parseLegalText does.
|
|
226
|
+
# The day must be a real calendar day (a round trip through the clock: 2026-02-30 and 2099-99-99 are damaged), compared in UTC.
|
|
227
|
+
vu="$(awk 'NR == 1 { if ($0 == "---") { f = 1; next } else exit } f && $0 == "---" { exit } f && /^valid_until:/ { v = $0; sub(/^valid_until:[ \t]*/, "", v); sub(/[ \t]+$/, "", v); got = 1; last = v } END { if (got) print "V:" last }' "$WORK/wa.txt" 2>/dev/null)"
|
|
228
|
+
if [ -n "$vu" ]; then
|
|
229
|
+
vu="${vu#V:}" # a valid_until line with no value is damaged (the shape check below refuses it), never "no expiry"
|
|
230
|
+
[[ "$vu" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || { GRES=UNEVAL; GWHY="$WA_DMG"; return; } # mut:wa-valid-shape
|
|
231
|
+
[ "$(jq -n -r --arg d "$vu" '($d + "T00:00:00Z") | try (fromdateiso8601 | todateiso8601 | .[0:10]) catch ""' </dev/null 2>/dev/null)" = "$vu" ] || { GRES=UNEVAL; GWHY="$WA_DMG"; return; } # mut:wa-valid-day
|
|
232
|
+
today="$(date -u +%F 2>/dev/null)" # mut:wa-today-utc
|
|
233
|
+
[[ "$today" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || { GRES=UNEVAL; GWHY="I could not read today's date"; return; }
|
|
234
|
+
if [[ "$vu" < "$today" ]]; then GRES=PERSON; GWHY="the accepted text has passed its last valid day; a revised text is needed"; return; fi # mut:wa-expired
|
|
235
|
+
fi
|
|
236
|
+
# shellcheck source=/dev/null
|
|
237
|
+
BC_ERR=""
|
|
238
|
+
case "$-" in *x*) GRES=UNEVAL; GWHY="I will not read the sign-in value while commands are being traced"; return ;; esac
|
|
239
|
+
[ -r "$BEARER_LIB" ] && . "$BEARER_LIB" 2>/dev/null || { GRES=UNEVAL; GWHY="I could not load the sign-in helper"; return; }
|
|
240
|
+
if ! bc_read_token "$WA_TOKEN_NAME"; then
|
|
241
|
+
GRES=UNEVAL
|
|
242
|
+
case "${BC_ERR:-}" in
|
|
243
|
+
shape) GWHY="the saved sign-in value looks wrong (too short or odd characters)" ;; # mut:err-shape
|
|
244
|
+
xtrace) GWHY="I will not read the sign-in value while commands are being traced" ;;
|
|
245
|
+
*) GWHY="no saved sign-in value was found" ;;
|
|
246
|
+
esac
|
|
247
|
+
return
|
|
248
|
+
fi
|
|
249
|
+
bc_get "$WORK" "$WA_BASE/$key?hash=$hash"; ok=$?
|
|
250
|
+
bc_clear
|
|
251
|
+
[ "$ok" -eq 0 ] || { GRES=UNEVAL; GWHY="I could not reach the check (HTTP $BC_STATUS, curl rc $BC_RC)"; return; } # mut:curl-fail
|
|
252
|
+
case "$BC_STATUS" in
|
|
253
|
+
200) ;;
|
|
254
|
+
503) GRES=UNEVAL; GWHY="the check is not available right now (not switched on, or temporarily down)"; return ;;
|
|
255
|
+
401) GRES=UNEVAL; GWHY="the check did not accept my sign-in"; return ;;
|
|
256
|
+
404) GRES=UNEVAL; GWHY="the live app does not know this text yet"; return ;;
|
|
257
|
+
400|502) wa_notu; return ;;
|
|
258
|
+
*) GRES=UNEVAL; GWHY="I could not reach the check (HTTP $BC_STATUS, curl rc $BC_RC)"; return ;; # mut:status-default
|
|
259
|
+
esac
|
|
260
|
+
wa_jq 'type == "object" and (keys == ["decided_at","row_ok","status","text_hash"])' || { wa_notu; return; } # mut:body-keys
|
|
261
|
+
jq -e -n --stream "$WA_JQ_ONCE" "$BC_BODY" >/dev/null 2>&1 </dev/null || { wa_notu; return; } # mut:body-dupkeys
|
|
262
|
+
wa_jq '(.text_hash | type) == "string" and .text_hash == $h' || { wa_notu; return; } # mut:echo-hash
|
|
263
|
+
# the status is compared INSIDE jq against the closed set, so "accepted\n" or "accepted\u0000" can never turn into "accepted" in the shell
|
|
264
|
+
st="$(jq -r '.status as $s | if $s | IN("accepted","declined","changes_requested","invalid","none") then $s else "-" end' "$BC_BODY" </dev/null 2>/dev/null)" # mut:st-allow
|
|
265
|
+
case "$st" in
|
|
266
|
+
accepted|declined|changes_requested) wa_jq "$WA_JQ_DEFS"'(.row_ok | type) == "boolean" and .row_ok == true and (.decided_at | okts)' || { wa_notu; return; } ;; # mut:row-ok
|
|
267
|
+
invalid) wa_jq '(.row_ok | type) == "boolean" and .row_ok == false and ((.decided_at | type) == "string" or .decided_at == null)' || { wa_notu; return; } ;;
|
|
268
|
+
none) wa_jq '.row_ok == null and .decided_at == null' || { wa_notu; return; } ;;
|
|
269
|
+
*) wa_notu; return ;; # mut:body-status
|
|
270
|
+
esac
|
|
271
|
+
case "$st" in
|
|
272
|
+
accepted)
|
|
273
|
+
d="$(jq -r '.decided_at[0:10]' "$BC_BODY" </dev/null 2>/dev/null)"
|
|
274
|
+
[[ "$d" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || { wa_notu; return; }
|
|
275
|
+
GRES=TRUE; GWHY=""; GNOTE="decided $d" ;;
|
|
276
|
+
declined) GRES=PERSON; GWHY="declined; a revised text is needed" ;; # mut:st-declined
|
|
277
|
+
changes_requested) GRES=PERSON; GWHY=""; GLINE="Needs you: the founder asked for changes. You read the note yourself, not an agent session: $WA_RUNBOOK" ;; # mut:st-changes
|
|
278
|
+
none) GRES=FALSE; GWHY="no decision recorded for this text version" ;; # mut:st-none
|
|
279
|
+
invalid) GRES=UNEVAL; GWHY="the saved decision looks damaged" ;; # mut:st-invalid
|
|
280
|
+
esac
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
eval_gate() { # <gate text after `Gate:`> -> GRES (TRUE|FALSE|PERSON|UNEVAL), GWHY, GNOTE
|
|
153
284
|
local text="$1" kind rest
|
|
154
|
-
GRES=UNEVAL; GWHY="I do not know this kind of condition, so it stays on hold"
|
|
285
|
+
GRES=UNEVAL; GWHY="I do not know this kind of condition, so it stays on hold"; GNOTE=""; GLINE=""
|
|
155
286
|
kind="${text%%[[:space:]]*}"; rest="$(trim "${text#"$kind"}")"
|
|
156
287
|
known_kind "$kind" || { GRES=UNEVAL; return; } # mut:unknown-kind
|
|
157
288
|
case "$kind" in
|
|
158
289
|
pr-merged) gate_pr_merged "$rest" ;;
|
|
159
290
|
no-inflight-run) gate_no_inflight "$rest" ;;
|
|
291
|
+
web-acceptance)
|
|
292
|
+
# CTO ruling D1: an envelope backs a production step; a founder's recorded decision on a legal text cannot
|
|
293
|
+
if [ "$MODE" = file ]; then GRES=UNEVAL; GWHY="a recorded decision on a legal text cannot back a production step"; return; fi # mut:wa-file
|
|
294
|
+
gate_web_acceptance "$rest" ;; # mut:wa-case
|
|
160
295
|
esac
|
|
161
296
|
}
|
|
162
297
|
|
|
@@ -207,7 +342,7 @@ NORM_AWK='
|
|
|
207
342
|
while (match(s, /^([ \t]+|[>*+_-]+|[0-9]+[.)]([ \t]|$))/)) s = substr(s, RLENGTH + 1)
|
|
208
343
|
return s
|
|
209
344
|
}
|
|
210
|
-
function val(s) { s = substr(s, index(s, ":") + 1); sub(/^[*_ \t]+/, "", s); return trim(s) }
|
|
345
|
+
function val(s) { s = substr(s, index(s, ":") + 1); gsub(/\t/, " ", s); sub(/^[*_ \t]+/, "", s); return trim(s) } # mut:tab-val
|
|
211
346
|
'
|
|
212
347
|
|
|
213
348
|
# marker_count <file>: prints how many unfenced `Hold:` or `Gate:` marker lines the file has.
|
|
@@ -253,18 +388,28 @@ parse_items() {
|
|
|
253
388
|
' "$1"
|
|
254
389
|
}
|
|
255
390
|
|
|
256
|
-
print_result_line() { # <verdict> <text> <why> <gate text>
|
|
391
|
+
print_result_line() { # <verdict> <text> <why> <gate text> <notes>
|
|
257
392
|
local gsuffix=""
|
|
258
393
|
[ -z "${4:-}" ] || gsuffix=" - checked: $(clean_text "$4")" # mut:done-gates
|
|
394
|
+
[ -z "${5:-}" ] || gsuffix="$gsuffix ($5)"
|
|
259
395
|
case "$1" in
|
|
260
396
|
OK) printf 'Done: %s%s\n' "$(clean_text "$2")" "$gsuffix" ;;
|
|
261
397
|
WAIT) printf 'Still waiting: %s - %s\n' "$(clean_text "$2")" "$3" ;;
|
|
262
|
-
NEEDS) printf 'Needs a person: %s - only a person can settle this\n' "$(clean_text "$2")"
|
|
398
|
+
NEEDS) if [ -n "${3:-}" ]; then printf 'Needs a person: %s - only a person can settle this (%s)\n' "$(clean_text "$2")" "$3"
|
|
399
|
+
else printf 'Needs a person: %s - only a person can settle this\n' "$(clean_text "$2")"; fi ;;
|
|
263
400
|
RESERVED) printf 'Reserved for you: %s - only you can clear this\n' "$(clean_text "$2")" ;;
|
|
264
401
|
*) printf 'Could not check: %s - %s\n' "$(clean_text "$2")" "$3" ;;
|
|
265
402
|
esac
|
|
266
403
|
}
|
|
267
404
|
|
|
405
|
+
# reserved_hold <the hold's words>: 0 when they BEGIN with `Operator-reserved:` however it is spelt (see the header).
|
|
406
|
+
reserved_hold() {
|
|
407
|
+
local lt rn
|
|
408
|
+
lt="$(printf '%s' "$1" | tr 'A-Z' 'a-z')"
|
|
409
|
+
rn="$(printf '%s' "$lt" | tr -cd 'a-z0-9' | cut -c1-16)" # mut:reserved-norm
|
|
410
|
+
[ "$rn" = operatorreserved ]
|
|
411
|
+
}
|
|
412
|
+
|
|
268
413
|
# stall_unchecked <sentence> <why>: every hold stays on hold because the record itself cannot be used (exit 2).
|
|
269
414
|
stall_unchecked() {
|
|
270
415
|
local i text
|
|
@@ -285,6 +430,27 @@ stand_all() {
|
|
|
285
430
|
exit 2
|
|
286
431
|
}
|
|
287
432
|
|
|
433
|
+
# classify_no_delegation: there is no `Delegation:` line. Sets NODELEG=1 when the plan is evaluated here anyway (CTO ruling F3):
|
|
434
|
+
# every non-reserved hold carries at least one gate and ONLY `web-acceptance` gates. A plan that mixes a `web-acceptance` gate with
|
|
435
|
+
# another kind of gate, or with a hold that has no gate, cannot ride the prose path and cannot be evaluated either: exit 2. A plan
|
|
436
|
+
# with no `web-acceptance` gate on a non-reserved hold (reserved-only and gate-less plans included) leaves NODELEG=0: exit 3.
|
|
437
|
+
# An `Operator-reserved:` hold is skipped here (its gates are never probed) and always stands in the evaluation loop.
|
|
438
|
+
classify_no_delegation() {
|
|
439
|
+
local i text g k wa=0 other=0 ng
|
|
440
|
+
while IFS=$'\t' read -r _ i text; do
|
|
441
|
+
reserved_hold "$text" && continue # mut:wa-reserved-skip
|
|
442
|
+
ng=0
|
|
443
|
+
while IFS= read -r g; do
|
|
444
|
+
ng=$((ng + 1)); k="${g%%[[:space:]]*}"
|
|
445
|
+
if [ "$k" = web-acceptance ]; then wa=$((wa + 1)); else other=$((other + 1)); fi
|
|
446
|
+
done < <(awk -F'\t' -v i="$i" '$1 == "GATE" && $2 == i { print $3 }' "$WORK/items")
|
|
447
|
+
[ "$ng" -gt 0 ] || other=$((other + 1)) # mut:wa-gateless
|
|
448
|
+
done < <(grep '^HOLD' "$WORK/items")
|
|
449
|
+
[ "$wa" -gt 0 ] || return 0 # mut:wa-none
|
|
450
|
+
[ "$other" -eq 0 ] || stall_unchecked "A recorded web decision sits beside another kind of condition and no standing approval is recorded, so I am treating every hold as still on hold." "web decisions and other conditions cannot be mixed without a standing approval" # mut:wa-mixed
|
|
451
|
+
NODELEG=1 # mut:wa-eval
|
|
452
|
+
}
|
|
453
|
+
|
|
288
454
|
split_file_title() { # --file "<path>#<title>": the title becomes the section; naming it twice is a usage error
|
|
289
455
|
case "$FILE" in
|
|
290
456
|
*'#'*)
|
|
@@ -324,6 +490,10 @@ read_head_blob() {
|
|
|
324
490
|
}
|
|
325
491
|
if [ "$MODE" = file ]; then read_head_blob "$FILE"; SRC="$WORK/head.md"; fi # mut:file-head
|
|
326
492
|
|
|
493
|
+
# A NUL, or any other C0 control byte except TAB, CR and LF, anywhere in the file: some awk implementations stop reading a line at a NUL, which would let a
|
|
494
|
+
# Gate line be cut short, so nothing is read from such a file. Decided before the sections are split (and before the no-delegation exit).
|
|
495
|
+
if ! tr -d '\000-\010\013\014\016-\037' < "$SRC" | cmp -s - "$SRC"; then echo "The file holds a control character I cannot read safely, so I am treating every hold as still on hold."; exit 2; fi # mut:ctl-bytes
|
|
496
|
+
|
|
327
497
|
need_tools() { # after the no-delegation exit: nothing below can run without these
|
|
328
498
|
command -v jq >/dev/null 2>&1 || die2 "jq is not installed, so no hold can be checked"
|
|
329
499
|
command -v gh >/dev/null 2>&1 || die2 "the GitHub command line tool is not installed, so no hold can be checked"
|
|
@@ -353,30 +523,36 @@ if [ "$MODE" = plan ]; then
|
|
|
353
523
|
exit 0
|
|
354
524
|
fi
|
|
355
525
|
ND="$(grep -c '^DELEG' "$WORK/items" || true)"; NE="$(grep -c '^ENVF' "$WORK/items" || true)"; NH="$(grep -c '^HOLD' "$WORK/items" || true)"
|
|
356
|
-
|
|
526
|
+
NODELEG=0
|
|
527
|
+
[ "$ND" -gt 0 ] || classify_no_delegation
|
|
528
|
+
[ "$ND" -gt 0 ] || [ "$NODELEG" -eq 1 ] || { echo "No standing approval is recorded, so the usual check applies."; [ "$NH" -eq 0 ] || echo "holds: $NH discharged: 0 standing: $NH"; exit 3; } # mut:no-deleg
|
|
357
529
|
PARSED="$(grep -c '^\(HOLD\|GATE\|ORPHAN\)' "$WORK/items" || true)"
|
|
358
530
|
[ "$(marker_count "$SRC")" -eq "$PARSED" ] || { echo "I found a hold that is not inside a hold section I can read, so I am treating every hold as still on hold."; echo "holds: $NH discharged: 0 standing: $NH"; exit 2; } # mut:stray-all
|
|
359
|
-
[ "$ND" -eq 1 ] || stall_unchecked "More than one standing approval is named, so I am treating every hold as still on hold." "the standing approval is not clear" # mut:deleg-multi
|
|
531
|
+
[ "$ND" -eq 1 ] || [ "$NODELEG" -eq 1 ] || stall_unchecked "More than one standing approval is named, so I am treating every hold as still on hold." "the standing approval is not clear" # mut:deleg-multi
|
|
360
532
|
[ "$CNT" -eq 1 ] || stall_unchecked "The plan has more than one hold section, so I am treating every hold as still on hold." "the plan is not clear"
|
|
361
|
-
[ "$NE" -eq 1 ] || stall_unchecked "The standing approval does not name exactly one
|
|
533
|
+
[ "$NE" -eq 1 ] || [ "$NODELEG" -eq 1 ] || stall_unchecked "The standing approval does not name exactly one written procedure it covers, so I am treating every hold as still on hold." "the standing approval is incomplete" # mut:envelope-req
|
|
362
534
|
need_tools
|
|
363
535
|
if grep -q '^ORPHAN' "$WORK/items"; then echo "A condition is written outside any hold, so I am treating every hold as still on hold."; echo "holds: $NH discharged: 0 standing: $NH"; exit 2; fi
|
|
364
536
|
[ "$NH" -gt 0 ] || { echo "I found a hold section but could not read any hold in it, so I am treating it as still on hold."; exit 2; } # mut:zero-holds
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
[ -f "$VERIFY" ] || { echo "I could not find the standing-approval checker, so every hold stays on hold."; echo "holds: $NH discharged: 0 standing: $NH"; exit 2; }
|
|
368
|
-
${TO60[@]+"${TO60[@]}"} bash "$VERIFY" verify --delegation "$DELEG" --envelope "$ENVF" </dev/null > "$WORK/verdict" 2>"$WORK/verdict.err"; VRC=$? # mut:stdin-verify
|
|
369
|
-
VLINE="$(head -1 "$WORK/verdict" 2>/dev/null)"; VSTATE=""; VTOKEN=""
|
|
370
|
-
if [[ "$VLINE" =~ ^delegation:\ (valid|invalid|unverifiable)\ reason=([a-z0-9-]+)$ ]]; then VSTATE="${BASH_REMATCH[1]}"; VTOKEN="${BASH_REMATCH[2]}"; fi
|
|
371
|
-
VOK=0; [ "$VSTATE" = valid ] && [ "$VRC" -eq 0 ] && VOK=1 # mut:deleg-rc
|
|
372
|
-
if [ "$VOK" -eq 1 ]; then
|
|
373
|
-
echo "delegation: valid reason=$VTOKEN"
|
|
537
|
+
if [ "$NODELEG" -eq 1 ]; then
|
|
538
|
+
echo "No standing approval is recorded, but every condition here is a decision the founder records on the web, so each one is checked directly."
|
|
374
539
|
else
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
[ "$
|
|
378
|
-
[
|
|
379
|
-
|
|
540
|
+
DELEG="$(awk -F'\t' '$1 == "DELEG" { print $2; exit }' "$WORK/items")"
|
|
541
|
+
ENVF="$(awk -F'\t' '$1 == "ENVF" { print $2; exit }' "$WORK/items")"
|
|
542
|
+
[ -f "$VERIFY" ] || { echo "I could not find the standing-approval checker, so every hold stays on hold."; echo "holds: $NH discharged: 0 standing: $NH"; exit 2; }
|
|
543
|
+
${TO60[@]+"${TO60[@]}"} bash "$VERIFY" verify --delegation "$DELEG" --envelope "$ENVF" </dev/null > "$WORK/verdict" 2>"$WORK/verdict.err"; VRC=$? # mut:stdin-verify
|
|
544
|
+
VLINE="$(head -1 "$WORK/verdict" 2>/dev/null)"; VSTATE=""; VTOKEN=""
|
|
545
|
+
if [[ "$VLINE" =~ ^delegation:\ (valid|invalid|unverifiable)\ reason=([a-z0-9-]+)$ ]]; then VSTATE="${BASH_REMATCH[1]}"; VTOKEN="${BASH_REMATCH[2]}"; fi
|
|
546
|
+
VOK=0; [ "$VSTATE" = valid ] && [ "$VRC" -eq 0 ] && VOK=1 # mut:deleg-rc
|
|
547
|
+
if [ "$VOK" -eq 1 ]; then
|
|
548
|
+
echo "delegation: valid reason=$VTOKEN"
|
|
549
|
+
else
|
|
550
|
+
[ -n "$VSTATE" ] || { VSTATE=unverifiable; VTOKEN=no-answer; }
|
|
551
|
+
FITS=no; [ "$VSTATE" = invalid ] && [ "$VRC" -eq 1 ] && FITS=fits
|
|
552
|
+
[ "$VSTATE" = valid ] && { VSTATE=unverifiable; VTOKEN=verifier-error; }
|
|
553
|
+
[ "$VSTATE" = invalid ] && [ "$FITS" != fits ] && { VSTATE=unverifiable; VTOKEN=verifier-error; }
|
|
554
|
+
stand_all "$VSTATE" "$VTOKEN" "$FITS" # mut:deleg-valid
|
|
555
|
+
fi
|
|
380
556
|
fi
|
|
381
557
|
else
|
|
382
558
|
[ "$CNT" -eq 1 ] || { echo "I could not find exactly one matching envelope section, so I am treating its conditions as not met."; exit 2; }
|
|
@@ -388,19 +564,21 @@ fi
|
|
|
388
564
|
|
|
389
565
|
DISCHARGED=0; STANDING=0; ANY_UNEVAL=0
|
|
390
566
|
while IFS=$'\t' read -r _ i text; do
|
|
391
|
-
|
|
392
|
-
rn="$(printf '%s' "$lt" | tr -cd 'a-z0-9' | cut -c1-16)" # mut:reserved-norm
|
|
393
|
-
case "$rn" in operatorreserved) print_result_line RESERVED "$text" ""; STANDING=$((STANDING + 1)); ANY_UNEVAL=1; continue ;; esac # mut:reserved
|
|
567
|
+
if reserved_hold "$text"; then print_result_line RESERVED "$text" ""; STANDING=$((STANDING + 1)); ANY_UNEVAL=1; continue; fi # mut:reserved
|
|
394
568
|
awk -F'\t' -v i="$i" '$1 == "GATE" && $2 == i { print $3 }' "$WORK/items" > "$WORK/g.$i"
|
|
395
569
|
ng="$(wc -l < "$WORK/g.$i" | tr -d ' ')"
|
|
396
|
-
HV=OK; WHY=""; GTXT=""
|
|
570
|
+
HV=OK; WHY=""; GTXT=""; GNOTES=""; HLINE=""
|
|
571
|
+
WA_HOLD_TEXT="$text"
|
|
397
572
|
[ "$ng" -gt 0 ] || HV=NEEDS # mut:zero-gates
|
|
398
573
|
while IFS= read -r gate; do
|
|
399
574
|
eval_gate "$gate"
|
|
400
575
|
GTXT="${GTXT:+$GTXT; }$gate"
|
|
401
|
-
|
|
576
|
+
[ -z "$GNOTE" ] || GNOTES="${GNOTES:+$GNOTES; }$GNOTE"
|
|
577
|
+
[ -z "$GLINE" ] || HLINE="$GLINE" # mut:hline-any
|
|
578
|
+
case "$GRES" in TRUE) ;; FALSE) [ "$HV" = OK ] && { HV=WAIT; WHY="$GWHY"; } ;; PERSON) [ "$HV" = OK ] && { HV=NEEDS; WHY="$GWHY"; } ;; *) HV=UNEVAL; WHY="$GWHY"; ANY_UNEVAL=1 ;; esac # mut:all-gates
|
|
402
579
|
done < "$WORK/g.$i"
|
|
403
|
-
print_result_line "$HV" "$text" "$WHY" "$GTXT"
|
|
580
|
+
print_result_line "$HV" "$text" "$WHY" "$GTXT" "$GNOTES"
|
|
581
|
+
[ "$HV" = OK ] || [ -z "$HLINE" ] || printf '%s\n' "$HLINE"
|
|
404
582
|
if [ "$HV" = OK ]; then DISCHARGED=$((DISCHARGED + 1)); else STANDING=$((STANDING + 1)); fi
|
|
405
583
|
done < <(grep '^HOLD' "$WORK/items")
|
|
406
584
|
|