@feigi/fleet-ctl 0.0.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/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Prove which head actually landed in a merge.
|
|
3
|
+
#
|
|
4
|
+
# Two proof paths, because a PR that is already current never gets rebased.
|
|
5
|
+
#
|
|
6
|
+
# rebase path (pre != post) — three legs, all required:
|
|
7
|
+
# 1. the pre-rebase head is NOT an ancestor of main (the old version did not land)
|
|
8
|
+
# 2. the rebased head IS an ancestor of main (the new version did)
|
|
9
|
+
# 3. the merge commit's second parent IS the rebased head
|
|
10
|
+
#
|
|
11
|
+
# no-rebase path (pre == post) — leg 1 is dropped, because legs 1 and 2 cannot
|
|
12
|
+
# both hold here: a commit is its own ancestor, so leg 2 (post IS an ancestor)
|
|
13
|
+
# makes leg 1 (pre is NOT an ancestor) fail by definition, and nothing can ever
|
|
14
|
+
# prove. Note leg 1 alone is perfectly satisfiable when pre == post — it holds
|
|
15
|
+
# whenever the merge has not landed. It is the *conjunction* that is impossible.
|
|
16
|
+
#
|
|
17
|
+
# Two gates carry the weight instead, and both are required on BOTH paths:
|
|
18
|
+
#
|
|
19
|
+
# headWasCurrent — the merge's first parent IS an ancestor of the merged head,
|
|
20
|
+
# which is what behind_by=0 means for a merge built on main.
|
|
21
|
+
# merge ∈ base — <merge> is reachable from $base, so that first parent really
|
|
22
|
+
# is a main tip and not something the caller made up.
|
|
23
|
+
#
|
|
24
|
+
# Both read structure off the merge object rather than off a ref, so the fetch
|
|
25
|
+
# below cannot establish them the way it can establish legs 1 and 2.
|
|
26
|
+
#
|
|
27
|
+
# Leg 1 is not a substitute for headWasCurrent: it proves the pre-rebase version
|
|
28
|
+
# did not land, not that the merged head was current, and it only bites a caller
|
|
29
|
+
# who reports `pre` honestly. headWasCurrent is derived from history alone, which
|
|
30
|
+
# is why it is required even on the rebase path — see run-merge-bot.md, "you are
|
|
31
|
+
# the only place currency is proven". Both paths also require exactly two parents,
|
|
32
|
+
# so an octopus merge cannot drag an unreviewed third parent along behind a second
|
|
33
|
+
# parent that looks right.
|
|
34
|
+
#
|
|
35
|
+
# The payload splits the checks into three kinds, because a flat object could not
|
|
36
|
+
# say which of its fields were load-bearing for the verdict it sits next to (#18):
|
|
37
|
+
#
|
|
38
|
+
# preconditions — every `die` above the verdict. They exit 2 with NO payload, so
|
|
39
|
+
# they never appear as a false field beside `proved`. `merge ∈
|
|
40
|
+
# base` is one of these: by the time anything is emitted it has
|
|
41
|
+
# already been proven true, which is why it is not a "gate".
|
|
42
|
+
# gates — the `gates` object. `proved` is true exactly when every value
|
|
43
|
+
# in it is true, so a consumer asserts all-true rather than
|
|
44
|
+
# inferring load-bearing-ness from `proofPath`. Membership is
|
|
45
|
+
# per-invocation: `preDidNotLand` (leg 1) is present only on the
|
|
46
|
+
# rebase path, because it is the leg the no-rebase path drops.
|
|
47
|
+
# observations — the flat fields. They are the raw readings, and a true one can
|
|
48
|
+
# sit next to `proved:true` without contradiction. The one that
|
|
49
|
+
# prompted all this is `preIsAncestor` on the no-rebase path: it
|
|
50
|
+
# reads true there, and leg 1 — which wants it false — is not a
|
|
51
|
+
# gate on that path at all. `firstParent` and `proofPath` are
|
|
52
|
+
# likewise informational.
|
|
53
|
+
set -eu
|
|
54
|
+
|
|
55
|
+
NAME=prove-merge
|
|
56
|
+
die() { printf '%s: %s\n' "$NAME" "$1" >&2; exit 2; }
|
|
57
|
+
|
|
58
|
+
# The escaping helpers (#119). json.sh's header holds the sourcing contract and
|
|
59
|
+
# the measurements behind it. Exit 1 out of THIS script means "the proof is a
|
|
60
|
+
# no", which the merge bot reads as a reason to refuse a merge, so a missing
|
|
61
|
+
# library must not be able to say it — which is why `[ -r ]` has to fire before
|
|
62
|
+
# the `.` can kill the shell.
|
|
63
|
+
json_lib="$(dirname "$0")/json.sh"
|
|
64
|
+
[ -r "$json_lib" ] || die "cannot read $json_lib — refusing to answer without the JSON escaping helpers"
|
|
65
|
+
# shellcheck source-path=SCRIPTDIR
|
|
66
|
+
# shellcheck source=json.sh
|
|
67
|
+
. "$json_lib" || die "$json_lib failed to load"
|
|
68
|
+
|
|
69
|
+
# The bounded, prompt-suppressed git transport (#92, #346, #347). The fetch
|
|
70
|
+
# below is unattended: with no bound it can prompt for a credential or a host
|
|
71
|
+
# key, or stall on a transport that connects and then goes quiet, and either
|
|
72
|
+
# holds a fleet slot until something outside kills it. net.sh's header holds the
|
|
73
|
+
# reasoning and the measurements. Sourced below json.sh so a lone copy of this
|
|
74
|
+
# script still blames json.sh, the name its missing-library test pins.
|
|
75
|
+
net_lib="$(dirname "$0")/net.sh"
|
|
76
|
+
[ -r "$net_lib" ] || die "cannot read $net_lib — refusing to answer without the bounded git transport"
|
|
77
|
+
# shellcheck source-path=SCRIPTDIR
|
|
78
|
+
# shellcheck source=net.sh
|
|
79
|
+
. "$net_lib" || die "$net_lib failed to load"
|
|
80
|
+
# Exit 1 is the answer "no"; anything else is git failing to answer, and a proof
|
|
81
|
+
# must never read a failure as a leg it likes.
|
|
82
|
+
is_ancestor() {
|
|
83
|
+
if git merge-base --is-ancestor "$1" "$2"; then echo true; else
|
|
84
|
+
[ $? -eq 1 ] || die "git merge-base --is-ancestor $1 $2 failed — cannot prove anything"
|
|
85
|
+
echo false
|
|
86
|
+
fi
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
[ $# -eq 3 ] || die "usage: prove-merge.sh <pre-rebase-head> <rebased-head> <merge-commit>"
|
|
90
|
+
pre=$1
|
|
91
|
+
post=$2
|
|
92
|
+
merge=$3
|
|
93
|
+
base=${BASE_REF:-origin/main}
|
|
94
|
+
|
|
95
|
+
echo "\$ git fetch --quiet origin" >&2
|
|
96
|
+
fetch_budget=$(net_fetch_budget)
|
|
97
|
+
fetch_rc=0
|
|
98
|
+
net_git "" "$fetch_budget" fetch --quiet origin || fetch_rc=$?
|
|
99
|
+
if [ "$fetch_rc" -ne 0 ]; then
|
|
100
|
+
# A killed fetch and a refused one are different facts and get different
|
|
101
|
+
# words. Without the split, a transport that stalled reads as a refusal,
|
|
102
|
+
# naming a cause this script never observed.
|
|
103
|
+
if net_stalled "$fetch_rc"; then
|
|
104
|
+
die "git fetch did not finish within ${fetch_budget}s and was killed — refusing to prove a merge on stale refs"
|
|
105
|
+
fi
|
|
106
|
+
die "fetch failed — refusing to prove a merge on stale refs"
|
|
107
|
+
fi
|
|
108
|
+
# Nothing below silences git: --quiet and 2>/dev/null discarded the only line
|
|
109
|
+
# that separates the causes, and both guards are silent when they succeed.
|
|
110
|
+
# --verify stays — without it a $base that names a FILE resolves and exits 0.
|
|
111
|
+
git rev-parse --verify "$base" >/dev/null || die "$base does not resolve"
|
|
112
|
+
|
|
113
|
+
for obj in "$pre" "$post" "$merge"; do
|
|
114
|
+
# Stops at what the guard observed: cat-file -e also fails on an object that
|
|
115
|
+
# is present but is not a commit, and on an object store it cannot read.
|
|
116
|
+
git cat-file -e "${obj}^{commit}" || die "cannot resolve $obj to a commit in this repository"
|
|
117
|
+
# -e above peels through a tag to reach the commit underneath, so an
|
|
118
|
+
# annotated tag clears that line even though $obj itself is not a commit —
|
|
119
|
+
# only the object at the far end of the peel is (#585). $pre and $post are
|
|
120
|
+
# then resolved UNPEELED by plain `git rev-parse` below, so a tag there hands
|
|
121
|
+
# back the tag object's own sha rather than the commit's, and the identity
|
|
122
|
+
# test later in this script compares that against a commit sha and can never
|
|
123
|
+
# match — every other leg still reads healthy, so the disproof carries no
|
|
124
|
+
# hint that the mismatch was in argument handling, not history. Checked here,
|
|
125
|
+
# on all three positions alike, so a tag is refused up front instead of
|
|
126
|
+
# reaching a verdict it was never fit to receive.
|
|
127
|
+
# Its own words, not a copy of the message above: -e already proved $obj
|
|
128
|
+
# resolves, so the only failure left here is git declining to answer at all,
|
|
129
|
+
# and the two guards would otherwise print the same line. Not decoration —
|
|
130
|
+
# under `set -eu` a bare failing assignment aborts with git's own 128, which
|
|
131
|
+
# is outside this script's 0/1/2 vocabulary (measured: rc=128, no diagnostic).
|
|
132
|
+
obj_type=$(git cat-file -t "$obj") || die "cannot read the type of $obj"
|
|
133
|
+
[ "$obj_type" = commit ] || die "$obj is a $obj_type, not a commit — refusing to treat it as one"
|
|
134
|
+
done
|
|
135
|
+
|
|
136
|
+
# Everything below reads structure off $merge, so an object the caller made up
|
|
137
|
+
# would otherwise prove whatever it was built to prove.
|
|
138
|
+
echo "\$ git merge-base --is-ancestor $merge $base" >&2
|
|
139
|
+
# Assigned first, not tested inline: `die` inside `$(...)` exits the subshell,
|
|
140
|
+
# and `[ ]` discards that status, so `set -e` never fires and a probe that could
|
|
141
|
+
# not answer falls through to the disproof below — a verdict never established.
|
|
142
|
+
# An assignment is a simple command, so its status is the substitution's (#267).
|
|
143
|
+
merge_anc=$(is_ancestor "$merge" "$base")
|
|
144
|
+
[ "$merge_anc" = true ] || die "$merge is not reachable from $base — that merge did not land"
|
|
145
|
+
|
|
146
|
+
pre_full=$(git rev-parse "$pre")
|
|
147
|
+
post_full=$(git rev-parse "$post")
|
|
148
|
+
|
|
149
|
+
echo "\$ git merge-base --is-ancestor $pre $base" >&2
|
|
150
|
+
pre_anc=$(is_ancestor "$pre_full" "$base")
|
|
151
|
+
echo " pre is-ancestor = $pre_anc" >&2
|
|
152
|
+
|
|
153
|
+
echo "\$ git merge-base --is-ancestor $post $base # expect SUCCESS" >&2
|
|
154
|
+
post_anc=$(is_ancestor "$post_full" "$base")
|
|
155
|
+
echo " post is-ancestor = $post_anc (want true)" >&2
|
|
156
|
+
|
|
157
|
+
# Trailing -- so a <merge> that also names a file is a revision, not an ambiguity.
|
|
158
|
+
# Captured first: the status of a substitution inside `set --` is discarded, and
|
|
159
|
+
# an empty result would trip `shift` and exit 1 — indistinguishable from a disproof.
|
|
160
|
+
parent_line=$(git rev-list --parents -n 1 "$merge" --) || die "cannot read the parents of $merge"
|
|
161
|
+
# Word-splitting is the point: "<merge> <parent>..." -> positional params.
|
|
162
|
+
# shellcheck disable=SC2086
|
|
163
|
+
set -- $parent_line
|
|
164
|
+
shift
|
|
165
|
+
parents=$#
|
|
166
|
+
[ "$parents" -ge 2 ] || die "$merge has no second parent — not a merge commit"
|
|
167
|
+
first=$1
|
|
168
|
+
second=$2
|
|
169
|
+
echo " ${merge}^1 = $first (${parents} parents)" >&2
|
|
170
|
+
echo " ${merge}^2 = $second" >&2
|
|
171
|
+
echo " claimed head = $post_full" >&2
|
|
172
|
+
|
|
173
|
+
echo "\$ git merge-base --is-ancestor $first $post_full" >&2
|
|
174
|
+
head_current=$(is_ancestor "$first" "$post_full")
|
|
175
|
+
|
|
176
|
+
if [ "$pre_full" = "$post_full" ]; then
|
|
177
|
+
proof_path=no-rebase
|
|
178
|
+
teeth=true
|
|
179
|
+
echo " no rebase (pre == post) — leg 1 dropped, headWasCurrent carries it" >&2
|
|
180
|
+
else
|
|
181
|
+
proof_path=rebase
|
|
182
|
+
if [ "$pre_anc" = false ]; then teeth=true; else teeth=false; fi
|
|
183
|
+
echo " rebase (pre != post) — pre is-ancestor = $pre_anc, so leg 1 = $teeth (wants false)" >&2
|
|
184
|
+
fi
|
|
185
|
+
echo " headWasCurrent = $head_current (want true, both paths)" >&2
|
|
186
|
+
|
|
187
|
+
# Named before the conjunction rather than tested inside it, so the verdict and
|
|
188
|
+
# the `gates` object below read the same booleans. Two spellings of one gate is
|
|
189
|
+
# how the payload drifts from what actually decided the answer.
|
|
190
|
+
if [ "$second" = "$post_full" ]; then second_is_head=true; else second_is_head=false; fi
|
|
191
|
+
if [ "$parents" -eq 2 ]; then two_parents=true; else two_parents=false; fi
|
|
192
|
+
# `$teeth` is a constant true on the no-rebase path, and it is left OUT of the
|
|
193
|
+
# object there rather than emitted as one: leg 1 is dropped on that path, and a
|
|
194
|
+
# gate that cannot fail is not a gate. Its absence is the machine-readable form
|
|
195
|
+
# of "leg 1 did not carry this proof".
|
|
196
|
+
gates="\"postIsAncestor\":$post_anc,\"secondParentIsHead\":$second_is_head,\"exactlyTwoParents\":$two_parents,\"headWasCurrent\":$head_current"
|
|
197
|
+
if [ "$proof_path" = rebase ]; then
|
|
198
|
+
gates="\"preDidNotLand\":$teeth,$gates"
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
# Derived FROM $gates, not restated: two independently hand-written booleans
|
|
202
|
+
# for the same invariant is how they drift apart, and only a fixture that
|
|
203
|
+
# happens to drive one gate false would ever have caught it. Every gate value
|
|
204
|
+
# above is the literal word `true` or `false`, and none of the keys contains
|
|
205
|
+
# "false" as a substring, so one match is exactly "some gate is false".
|
|
206
|
+
case $gates in
|
|
207
|
+
*false*) proved=false; rc=1 ;;
|
|
208
|
+
*) proved=true; rc=0 ;;
|
|
209
|
+
esac
|
|
210
|
+
echo "$NAME: proved=$proved (path=$proof_path)" >&2
|
|
211
|
+
|
|
212
|
+
# None of the three string fields is reachable today — `$second` and `$first`
|
|
213
|
+
# come from `git rev-parse`, 40 hex characters and nothing else, and
|
|
214
|
+
# `$proof_path` is this script's own `rebase`/`no-rebase` literal. They go
|
|
215
|
+
# through `jstr` for uniformity against a later edit that changes where a field
|
|
216
|
+
# comes from, the same reason inflight.sh wraps `$pr`, and it costs nothing
|
|
217
|
+
# (#119). Assigned before the printf, never inline in its argument list — a
|
|
218
|
+
# `$()` there sits outside this `|| die`, contributes an empty argument on
|
|
219
|
+
# failure, and printf still exits 0 with a malformed payload.
|
|
220
|
+
second_j=$(jstr "$second") && first_j=$(jstr "$first") && path_j=$(jstr "$proof_path") \
|
|
221
|
+
|| die "could not escape the proof fields for $merge"
|
|
222
|
+
# `$gates` interpolates whole rather than through a %s-per-field list: its keys
|
|
223
|
+
# are this script's own literals and its values are the `true`/`false` words
|
|
224
|
+
# is_ancestor emits, so nothing in it comes from the caller. It is built above,
|
|
225
|
+
# never here, for the same reason the escaped fields are.
|
|
226
|
+
printf '{"preIsAncestor":%s,"postIsAncestor":%s,"secondParent":"%s","firstParent":"%s","parentCount":%s,"proofPath":"%s","headWasCurrent":%s,"gates":{%s},"proved":%s}\n' \
|
|
227
|
+
"$pre_anc" "$post_anc" "$second_j" "$first_j" "$parents" "$path_j" "$head_current" "$gates" "$proved"
|
|
228
|
+
exit "$rc"
|