@rt-tools/agent-kit 0.37.1 → 0.39.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/README.md +5 -5
- package/assets/checks/action-of.mjs +154 -0
- package/assets/checks/board-runs.github.mjs +40 -5
- package/assets/checks/check-board.github.mjs +38 -7
- package/assets/checks/check-state-next.mjs +22 -10
- package/assets/checks/check-turn-map.mjs +26 -6
- package/assets/checks/check-work-steps.mjs +4 -173
- package/assets/checks/decide.mjs +285 -0
- package/assets/checks/decision-table.json +21432 -0
- package/assets/checks/decision-table.mjs +495 -0
- package/assets/checks/epic-window.mjs +98 -0
- package/assets/checks/flow-condition.mjs +64 -0
- package/assets/checks/flow-data.mjs +135 -0
- package/assets/checks/flow-forecast.mjs +334 -0
- package/assets/checks/flow-guard-run.mjs +90 -0
- package/assets/checks/flow-guard.mjs +496 -0
- package/assets/checks/flow-model.mjs +271 -0
- package/assets/checks/flow-override.mjs +130 -0
- package/assets/checks/flow-plan.mjs +206 -0
- package/assets/checks/flow-scaffold.mjs +224 -0
- package/assets/checks/flow-step.mjs +495 -0
- package/assets/checks/flow-sync.mjs +296 -0
- package/assets/checks/flow-syntax.mjs +292 -0
- package/assets/checks/flow-verdict.mjs +227 -0
- package/assets/checks/merge-read.mjs +239 -0
- package/assets/checks/owner-nudges.mjs +389 -0
- package/assets/checks/push-inputs.mjs +59 -16
- package/assets/checks/record-count.mjs +437 -0
- package/assets/checks/record-recount.mjs +187 -0
- package/assets/checks/record-turn.mjs +155 -0
- package/assets/checks/task-flow-script.mjs +318 -0
- package/assets/checks/tree-assignment.mjs +26 -7
- package/assets/checks/work-result.mjs +362 -0
- package/assets/checks/work-steps-lib.mjs +205 -0
- package/assets/commands/night.md +6 -6
- package/assets/defaults/gate-map.sh +39 -12
- package/assets/defaults/merges.sh +48 -0
- package/assets/defaults/project.sh +6 -5
- package/assets/defaults/turn-map.md +23 -22
- package/assets/docs/GLOSSARY.md +5 -1
- package/assets/hooks/ask-judge.md +67 -0
- package/assets/hooks/browser-guard-device-id.sh +11 -9
- package/assets/hooks/browser-guard-no-asking.sh +12 -6
- package/assets/hooks/browser-guard-no-listing.sh +13 -7
- package/assets/hooks/browser-guard-no-other-drivers.sh +25 -17
- package/assets/hooks/browser-guard-require-select.sh +15 -15
- package/assets/hooks/commit-msg.sh +13 -3
- package/assets/hooks/conscience-guard.sh +9 -25
- package/assets/hooks/decide.sh +141 -0
- package/assets/hooks/deny-tail.sh +16 -11
- package/assets/hooks/dev-server-guard.sh +27 -20
- package/assets/hooks/dispatch.sh +47 -4
- package/assets/hooks/docs-guard.sh +31 -200
- package/assets/hooks/end-conversation-guard.sh +12 -21
- package/assets/hooks/epic-stop-guard.sh +54 -152
- package/assets/hooks/exam-guard.sh +32 -65
- package/assets/hooks/facts-docs.sh +221 -0
- package/assets/hooks/facts-flow.sh +173 -0
- package/assets/hooks/facts.sh +374 -0
- package/assets/hooks/flow-step-guard.sh +93 -0
- package/assets/hooks/git-guard-delivery-body.sh +4 -4
- package/assets/hooks/git-guard-delivery-conflict.sh +16 -10
- package/assets/hooks/git-guard-delivery-draft.sh +3 -3
- package/assets/hooks/git-guard-delivery-epic.sh +18 -9
- package/assets/hooks/git-guard-delivery-folder.sh +32 -7
- package/assets/hooks/git-guard-delivery-merge.sh +2 -2
- package/assets/hooks/git-guard-delivery-merged.sh +12 -1
- package/assets/hooks/git-guard-delivery-pipeline.sh +1 -1
- package/assets/hooks/git-guard-delivery-rerun.sh +44 -0
- package/assets/hooks/git-guard-delivery-signature.sh +82 -45
- package/assets/hooks/git-guard-delivery-task.sh +47 -0
- package/assets/hooks/git-guard-delivery.sh +112 -101
- package/assets/hooks/git-guard-discard.sh +8 -18
- package/assets/hooks/git-guard-main.sh +13 -19
- package/assets/hooks/git-guard-no-verify.sh +56 -16
- package/assets/hooks/git-guard-push-ahead.sh +39 -6
- package/assets/hooks/git-guard-push-marks.sh +262 -13
- package/assets/hooks/git-guard-push-tests.sh +58 -52
- package/assets/hooks/git-guard-tree-assignment.sh +7 -4
- package/assets/hooks/guard-note.sh +8 -6
- package/assets/hooks/handoff-entry-guard.sh +19 -38
- package/assets/hooks/handoff-write.sh +3 -1
- package/assets/hooks/hook-input.sh +0 -41
- package/assets/hooks/metric-marks.sh +19 -7
- package/assets/hooks/observe.sh +1 -1
- package/assets/hooks/override-write-guard.sh +27 -9
- package/assets/hooks/pre-push.sh +40 -12
- package/assets/hooks/prose-style-guard.sh +6 -19
- package/assets/hooks/pull-merges.sh +76 -0
- package/assets/hooks/push-ahead-call-guard.sh +447 -0
- package/assets/hooks/push-set.sh +38 -8
- package/assets/hooks/qa-dataid-guard.sh +7 -17
- package/assets/hooks/record-turn.sh +52 -0
- package/assets/hooks/rerun-guard.sh +11 -16
- package/assets/hooks/reuse-first-guard.sh +7 -21
- package/assets/hooks/role-calls.sh +25 -3
- package/assets/hooks/rule-source-guard.sh +54 -21
- package/assets/hooks/skill-gate-rearm.sh +18 -5
- package/assets/hooks/skill-gate.sh +156 -20
- package/assets/hooks/skill-loaded.sh +18 -3
- package/assets/hooks/sql-guard-target.sh +2 -2
- package/assets/hooks/sql-guard-write.sh +12 -12
- package/assets/hooks/sql-guard.sh +58 -16
- package/assets/hooks/task-context-load.sh +3 -1
- package/assets/hooks/task-flow-context.sh +5 -18
- package/assets/hooks/task-flow-draft-guard.sh +25 -74
- package/assets/hooks/task-flow-guard.sh +28 -130
- package/assets/hooks/tree-assignment-guard.sh +25 -14
- package/assets/hooks/turn-entry-load.sh +3 -1
- package/assets/hooks/turn-exit-guard.sh +92 -452
- package/assets/hooks/turn-exit-role.sh +3 -1
- package/assets/hooks/turn-judge.md +113 -0
- package/assets/hooks/window-fill-guard.sh +22 -41
- package/assets/patterns/doc-style-human.md +36 -76
- package/assets/patterns/git-workflow-commit.azure.md +9 -155
- package/assets/patterns/git-workflow-commit.github.md +11 -269
- package/assets/patterns/git-workflow-commit.gitlab.md +9 -161
- package/assets/patterns/git-workflow-docker.md +8 -231
- package/assets/patterns/git-workflow-freshness.md +8 -56
- package/assets/patterns/git-workflow-merge.md +6 -176
- package/assets/patterns/git-workflow-migration.md +5 -75
- package/assets/patterns/git-workflow-pr-body.github.md +6 -159
- package/assets/patterns/git-workflow-pr-ready.md +9 -70
- package/assets/patterns/git-workflow-pr.azure.md +13 -285
- package/assets/patterns/git-workflow-pr.github.md +13 -251
- package/assets/patterns/git-workflow-pr.gitlab.md +13 -286
- package/assets/patterns/git-workflow-restart.md +5 -42
- package/assets/patterns/git-workflow-secrets.md +10 -76
- package/assets/patterns/git-workflow-stack.md +7 -207
- package/assets/patterns/status-report-table.github.md +1 -1
- package/assets/patterns/task-flow-archive.md +12 -233
- package/assets/patterns/task-flow-close.md +16 -292
- package/assets/patterns/task-flow-cycle.md +13 -39
- package/assets/patterns/task-flow-graph.needs-graph.md +8 -62
- package/assets/patterns/task-flow-handoff.md +13 -161
- package/assets/patterns/task-flow-resume.md +18 -218
- package/assets/patterns/task-flow-start.md +9 -247
- package/assets/patterns/turn-entry-map.md +2 -2
- package/assets/pitfalls/agent-kit-extend.md +200 -0
- package/assets/pitfalls/agent-kit.2.md +323 -0
- package/assets/pitfalls/angular-patterns.md +98 -0
- package/assets/pitfalls/browser-verification.md +265 -0
- package/assets/pitfalls/component-structure.md +98 -0
- package/assets/pitfalls/dependencies.md +92 -0
- package/assets/pitfalls/deploy-flow.azure.md +171 -0
- package/assets/pitfalls/deploy-flow.github.md +211 -0
- package/assets/pitfalls/deploy-flow.gitlab.md +173 -0
- package/assets/pitfalls/doc-style-human.md +112 -0
- package/assets/pitfalls/doc-style.2.md +286 -0
- package/assets/pitfalls/entity-conventions.needs-admin.md +96 -0
- package/assets/pitfalls/entity-models.md +89 -0
- package/assets/pitfalls/epic-flow.md +92 -0
- package/assets/pitfalls/git-workflow-commit.azure.md +190 -0
- package/assets/pitfalls/git-workflow-commit.github.md +307 -0
- package/assets/pitfalls/git-workflow-commit.gitlab.md +196 -0
- package/assets/pitfalls/git-workflow-docker.md +275 -0
- package/assets/pitfalls/git-workflow-freshness.md +88 -0
- package/assets/pitfalls/git-workflow-hosting.azure.md +31 -0
- package/assets/pitfalls/git-workflow-hosting.github.md +32 -0
- package/assets/pitfalls/git-workflow-hosting.gitlab.md +31 -0
- package/assets/pitfalls/git-workflow-merge.md +220 -0
- package/assets/pitfalls/git-workflow-migration.md +103 -0
- package/assets/pitfalls/git-workflow-pr-body.github.md +185 -0
- package/assets/pitfalls/git-workflow-pr-ready.md +104 -0
- package/assets/pitfalls/git-workflow-pr.2.azure.md +172 -0
- package/assets/pitfalls/git-workflow-pr.2.github.md +184 -0
- package/assets/pitfalls/git-workflow-pr.2.gitlab.md +180 -0
- package/assets/pitfalls/git-workflow-pr.azure.md +159 -0
- package/assets/pitfalls/git-workflow-pr.github.md +107 -0
- package/assets/pitfalls/git-workflow-pr.gitlab.md +151 -0
- package/assets/pitfalls/git-workflow-push.azure.md +30 -0
- package/assets/pitfalls/git-workflow-push.github.md +30 -0
- package/assets/pitfalls/git-workflow-push.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-queue.azure.md +30 -0
- package/assets/pitfalls/git-workflow-queue.github.md +30 -0
- package/assets/pitfalls/git-workflow-queue.gitlab.md +30 -0
- package/assets/pitfalls/git-workflow-restart.md +72 -0
- package/assets/pitfalls/git-workflow-secrets.md +114 -0
- package/assets/pitfalls/git-workflow-stack.md +254 -0
- package/assets/pitfalls/git-workflow.2.azure.md +291 -0
- package/assets/pitfalls/git-workflow.2.github.md +294 -0
- package/assets/pitfalls/git-workflow.2.gitlab.md +278 -0
- package/assets/pitfalls/lib-layers.md +114 -0
- package/assets/pitfalls/lists.md +117 -0
- package/assets/pitfalls/mockups.needs-mockups.md +87 -0
- package/assets/pitfalls/navigation.md +94 -0
- package/assets/pitfalls/observability.needs-app.md +186 -0
- package/assets/pitfalls/platform-access.md +94 -0
- package/assets/pitfalls/queue-audit.github.md +78 -0
- package/assets/pitfalls/reuse-first.md +201 -0
- package/assets/pitfalls/spec-driven.2.md +318 -0
- package/assets/pitfalls/styling-bem.2.md +125 -0
- package/assets/pitfalls/task-flow-archive.md +265 -0
- package/assets/pitfalls/task-flow-close.2.md +166 -0
- package/assets/pitfalls/task-flow-close.md +167 -0
- package/assets/pitfalls/task-flow-cycle.md +73 -0
- package/assets/pitfalls/task-flow-graph.needs-graph.md +98 -0
- package/assets/pitfalls/task-flow-handoff.md +200 -0
- package/assets/pitfalls/task-flow-handover.md +30 -0
- package/assets/pitfalls/task-flow-owner.md +58 -0
- package/assets/pitfalls/task-flow-plan.md +29 -0
- package/assets/pitfalls/task-flow-resume.md +257 -0
- package/assets/pitfalls/task-flow-start.md +287 -0
- package/assets/pitfalls/task-flow.2.md +303 -0
- package/assets/pitfalls/task-flow.md +4 -4
- package/assets/pitfalls/testing.2.md +279 -0
- package/assets/pitfalls/turn-conduct.md +16 -17
- package/assets/pitfalls/typescript-conventions.md +161 -0
- package/assets/pitfalls/write-a-skill.md +128 -0
- package/assets/rules/angular-patterns.md +21 -86
- package/assets/rules/autonomous-work.md +2 -2
- package/assets/rules/browser-verification.md +28 -256
- package/assets/rules/component-structure.md +25 -87
- package/assets/rules/dependencies.md +20 -78
- package/assets/rules/deploy-flow.azure.md +26 -156
- package/assets/rules/deploy-flow.github.md +34 -200
- package/assets/rules/deploy-flow.gitlab.md +27 -159
- package/assets/rules/doc-style.md +32 -286
- package/assets/rules/entity-conventions.needs-admin.md +26 -82
- package/assets/rules/entity-models.md +14 -63
- package/assets/rules/epic-flow.md +24 -63
- package/assets/rules/git-workflow-hosting.azure.md +26 -0
- package/assets/rules/git-workflow-hosting.github.md +38 -0
- package/assets/rules/git-workflow-hosting.gitlab.md +27 -0
- package/assets/rules/git-workflow-push.azure.md +28 -0
- package/assets/rules/git-workflow-push.github.md +28 -0
- package/assets/rules/git-workflow-push.gitlab.md +28 -0
- package/assets/rules/git-workflow-queue.azure.md +23 -0
- package/assets/rules/git-workflow-queue.github.md +30 -0
- package/assets/rules/git-workflow-queue.gitlab.md +23 -0
- package/assets/rules/git-workflow.azure.md +21 -282
- package/assets/rules/git-workflow.github.md +24 -284
- package/assets/rules/git-workflow.gitlab.md +21 -269
- package/assets/rules/lib-layers.md +30 -103
- package/assets/rules/lists.md +21 -105
- package/assets/rules/mockups.needs-mockups.md +25 -64
- package/assets/rules/navigation.md +10 -69
- package/assets/rules/observability.needs-app.md +43 -172
- package/assets/rules/platform-access.md +28 -75
- package/assets/rules/queue-audit.github.md +25 -52
- package/assets/rules/reuse-first.md +20 -195
- package/assets/rules/spec-driven.md +35 -308
- package/assets/rules/styling-bem.md +20 -117
- package/assets/rules/task-flow-handover.md +24 -0
- package/assets/rules/task-flow-owner.md +34 -0
- package/assets/rules/task-flow-plan.md +38 -0
- package/assets/rules/task-flow.md +22 -300
- package/assets/rules/testing.md +32 -273
- package/assets/rules/turn-conduct.md +105 -106
- package/assets/rules/turn-entry.md +2 -2
- package/assets/rules/typescript-conventions.md +41 -147
- package/assets/samples/tasks/_template/plan.md +30 -6
- package/assets/samples/tasks/_template/progress.md +0 -1
- package/assets/skills/agent-kit-extend.md +25 -168
- package/assets/skills/agent-kit.md +27 -299
- package/assets/skills/write-a-skill.md +20 -106
- package/assets/task-flow/flow.js +184 -0
- package/assets/task-flow/flow.md +101 -0
- package/assets/task-flow/measure/agreement.mjs +24 -0
- package/assets/task-flow/measure/ci.mjs +184 -0
- package/assets/task-flow/measure/copy.mjs +22 -0
- package/assets/task-flow/measure/epic-of.mjs +50 -0
- package/assets/task-flow/measure/epic-text.mjs +35 -0
- package/assets/task-flow/measure/epic.mjs +114 -0
- package/assets/task-flow/measure/folder.mjs +16 -0
- package/assets/task-flow/measure/footprint.mjs +28 -0
- package/assets/task-flow/measure/grill.mjs +21 -0
- package/assets/task-flow/measure/host.mjs +8 -0
- package/assets/task-flow/measure/owner.mjs +27 -0
- package/assets/task-flow/measure/plan.mjs +27 -0
- package/assets/task-flow/measure/pr.mjs +20 -0
- package/assets/task-flow/measure/progress.mjs +50 -0
- package/assets/task-flow/measure/session.mjs +252 -0
- package/assets/task-flow/measure/task.mjs +23 -0
- package/assets/task-flow/measure/text.mjs +77 -0
- package/assets/task-flow/source/git.mjs +254 -0
- package/assets/task-flow/source/host.mjs +277 -0
- package/assets/task-flow/source/marks.mjs +56 -0
- package/assets/task-flow/source/owner.mjs +94 -0
- package/assets/task-flow/source/records.mjs +116 -0
- package/assets/task-flow/source/session.mjs +269 -0
- package/assets/task-flow/source/steps.mjs +28 -0
- package/assets/task-flow/source/tree.mjs +42 -0
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +30 -0
- package/bin/agent-kit.js.map +1 -1
- package/lib/agent-checks.d.ts +55 -0
- package/lib/agent-checks.d.ts.map +1 -0
- package/lib/agent-checks.js +221 -0
- package/lib/agent-checks.js.map +1 -0
- package/lib/assets.d.ts.map +1 -1
- package/lib/assets.js +7 -2
- package/lib/assets.js.map +1 -1
- package/lib/cargo.d.ts +29 -0
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +27 -1
- package/lib/cargo.js.map +1 -1
- package/lib/cascade.d.ts.map +1 -1
- package/lib/cascade.js +3 -1
- package/lib/cascade.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +78 -2
- package/lib/commands.js.map +1 -1
- package/lib/config.d.ts +18 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +18 -1
- package/lib/config.js.map +1 -1
- package/lib/epic-window-send.d.ts +74 -0
- package/lib/epic-window-send.d.ts.map +1 -0
- package/lib/epic-window-send.js +166 -0
- package/lib/epic-window-send.js.map +1 -0
- package/lib/hooks-map.d.ts +4 -0
- package/lib/hooks-map.d.ts.map +1 -1
- package/lib/hooks-map.js +2 -2
- package/lib/hooks-map.js.map +1 -1
- package/lib/integrity.d.ts +3 -0
- package/lib/integrity.d.ts.map +1 -1
- package/lib/integrity.js +7 -0
- package/lib/integrity.js.map +1 -1
- package/lib/metric-lines.d.ts +2 -1
- package/lib/metric-lines.d.ts.map +1 -1
- package/lib/metric-lines.js +49 -1
- package/lib/metric-lines.js.map +1 -1
- package/lib/metric-send-mark.d.ts +6 -3
- package/lib/metric-send-mark.d.ts.map +1 -1
- package/lib/metric-send-mark.js +15 -5
- package/lib/metric-send-mark.js.map +1 -1
- package/lib/metric-send.d.ts +6 -2
- package/lib/metric-send.d.ts.map +1 -1
- package/lib/metric-send.js +47 -13
- package/lib/metric-send.js.map +1 -1
- package/lib/metrics.d.ts +17 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +26 -15
- package/lib/metrics.js.map +1 -1
- package/lib/observations.js +3 -3
- package/lib/observations.js.map +1 -1
- package/lib/outcomes.d.ts +5 -2
- package/lib/outcomes.d.ts.map +1 -1
- package/lib/outcomes.js +5 -4
- package/lib/outcomes.js.map +1 -1
- package/lib/push-gate.d.ts +13 -0
- package/lib/push-gate.d.ts.map +1 -1
- package/lib/push-gate.js +11 -7
- package/lib/push-gate.js.map +1 -1
- package/lib/push-set-usefulness.d.ts +78 -0
- package/lib/push-set-usefulness.d.ts.map +1 -0
- package/lib/push-set-usefulness.js +225 -0
- package/lib/push-set-usefulness.js.map +1 -0
- package/lib/sync.d.ts +10 -0
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +14 -1
- package/lib/sync.js.map +1 -1
- package/lib/work-result.d.ts +43 -0
- package/lib/work-result.d.ts.map +1 -0
- package/lib/work-result.js +39 -0
- package/lib/work-result.js.map +1 -0
- package/package.json +1 -1
- package/assets/hooks/claim-guard.sh +0 -212
- package/assets/hooks/grill-gate-ask.sh +0 -26
- package/assets/hooks/grill-gate-bypass.sh +0 -61
- package/assets/hooks/grill-gate-options.sh +0 -50
- package/assets/hooks/grill-gate.sh +0 -482
- package/assets/hooks/postmortem-guard.sh +0 -124
- package/assets/hooks/proposal-guard.sh +0 -154
- package/assets/hooks/stand-login-guard.sh +0 -107
- package/assets/hooks/turn-exit-epic.sh +0 -173
- package/assets/hooks/turn-exit-patterns.sh +0 -123
- package/assets/hooks/turn-exit-verdict.sh +0 -149
- package/assets/hooks/waiting-turn-guard.sh +0 -320
- package/assets/hooks/work-start-guard.sh +0 -175
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# Exit codes: 0 — the set is green; 1 — a check is red; 3 — the run did not start (no profile, no
|
|
15
15
|
# repository, edits outside the index). Not 2: to a hook that code means "refuse", and this command
|
|
16
16
|
# refuses nothing.
|
|
17
|
+
#
|
|
18
|
+
# Requires: hooks/git-guard-push-marks.sh, hooks/facts.sh
|
|
17
19
|
not_started=3
|
|
18
20
|
|
|
19
21
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -42,12 +44,30 @@ command -v rt_push_over_budget >/dev/null 2>&1 || rt_push_over_budget() { return
|
|
|
42
44
|
command -v rt_push_set_over_budget >/dev/null 2>&1 || rt_push_set_over_budget() { return 0; }
|
|
43
45
|
command -v rt_push_mark_drop >/dev/null 2>&1 || rt_push_mark_drop() { return 0; }
|
|
44
46
|
command -v rt_push_select >/dev/null 2>&1 || rt_push_select() { cat; }
|
|
47
|
+
command -v rt_push_subjects >/dev/null 2>&1 || rt_push_subjects() { cat >/dev/null; }
|
|
48
|
+
command -v rt_push_subject_of >/dev/null 2>&1 || rt_push_subject_of() { printf unknown; }
|
|
49
|
+
command -v rt_push_note_not_run >/dev/null 2>&1 || rt_push_note_not_run() { return 0; }
|
|
45
50
|
# The line of a run for the metrics. No file — the checks run and record nothing.
|
|
46
51
|
# shellcheck disable=SC1091
|
|
47
52
|
[ -f "$rt_hooks_dir/metric-marks.sh" ] && . "$rt_hooks_dir/metric-marks.sh" 2>/dev/null
|
|
48
53
|
command -v rt_run_note >/dev/null 2>&1 || rt_run_note() { return 0; }
|
|
49
54
|
command -v rt_tree_sign >/dev/null 2>&1 || rt_tree_sign() { return 0; }
|
|
50
55
|
|
|
56
|
+
# The steps and their choice run on the node the tree pins, as at the push: the shell that starts
|
|
57
|
+
# the run may carry another one. A pinned node that is not installed, with another node in PATH,
|
|
58
|
+
# starts no step.
|
|
59
|
+
# shellcheck disable=SC1091
|
|
60
|
+
command -v rt_node_pinned_dir >/dev/null 2>&1 || { [ -f "$rt_hooks_dir/facts.sh" ] && . "$rt_hooks_dir/facts.sh" 2>/dev/null; }
|
|
61
|
+
if command -v rt_node_pinned_dir >/dev/null 2>&1; then
|
|
62
|
+
node_line="$(rt_node_pin_mismatch "$root")"
|
|
63
|
+
if [ -n "$node_line" ]; then
|
|
64
|
+
printf 'push ahead: %s\n' "$node_line" >&2
|
|
65
|
+
exit "$not_started"
|
|
66
|
+
fi
|
|
67
|
+
node_dir="$(rt_node_pinned_dir "$root")"
|
|
68
|
+
[ -n "$node_dir" ] && PATH="$node_dir:$PATH"
|
|
69
|
+
fi
|
|
70
|
+
|
|
51
71
|
# A mark vouches for the tree of the head, and the checks run over the working copy: with edits
|
|
52
72
|
# outside the index the run would write marks for content that does not leave.
|
|
53
73
|
rt_push_mark_clean || {
|
|
@@ -57,14 +77,23 @@ rt_push_mark_clean || {
|
|
|
57
77
|
|
|
58
78
|
base="$(rt_push_base "${RT_MAIN_BRANCH:-main}")"
|
|
59
79
|
skip_code="${RT_SKIP_CODE:-7}"
|
|
80
|
+
# The steps run against a ref pinned at the commit of the base, and the push takes that ref while the
|
|
81
|
+
# record fits its head: a branch merged, removed, moved or put next to this one during the set
|
|
82
|
+
# changes nothing for the push.
|
|
83
|
+
command -v rt_push_base_pin >/dev/null 2>&1 && base="$(rt_push_base_pin "$base")"
|
|
84
|
+
command -v rt_push_base_label >/dev/null 2>&1 || rt_push_base_label() { printf '%s' "${1:-none}"; }
|
|
60
85
|
|
|
61
86
|
if command -v rt_push_adds_nothing >/dev/null 2>&1 && rt_push_adds_nothing "$base"; then
|
|
62
|
-
printf 'push ahead: the head adds no commit to %s — there is nothing to run, the push passes\n' "$base"
|
|
87
|
+
printf 'push ahead: the head adds no commit to %s — there is nothing to run, the push passes\n' "$(rt_push_base_label "$base")"
|
|
63
88
|
exit 0
|
|
64
89
|
fi
|
|
65
90
|
|
|
66
|
-
printf 'push ahead: base %s, tree %s\n' "$
|
|
91
|
+
printf 'push ahead: base %s, tree %s\n' "$(rt_push_base_label "$base")" "$(git rev-parse --short 'HEAD^{tree}')"
|
|
67
92
|
sign="$(rt_tree_sign .)"
|
|
93
|
+
# Whether the change touched the subject of each step, for the run lines; a step the selection
|
|
94
|
+
# drops leaves a line of its own.
|
|
95
|
+
subjects="$(rt_push_checks "$base" | rt_push_subjects "$base")"
|
|
96
|
+
rt_push_note_not_run "$sign" "$base" "$subjects"
|
|
68
97
|
|
|
69
98
|
red=""
|
|
70
99
|
marked=""
|
|
@@ -91,16 +120,16 @@ while IFS= read -r check; do
|
|
|
91
120
|
out="$over"
|
|
92
121
|
fi
|
|
93
122
|
if [ "$status" -eq 0 ]; then
|
|
94
|
-
rt_run_note "$sign" "$started" green "$check"
|
|
123
|
+
rt_run_note "$sign" "$started" green "$check" "$base" "$(rt_push_subject_of "$subjects" "$check")"
|
|
95
124
|
rt_push_mark_put "$check" "$base" "$key_before"
|
|
96
125
|
marked="${marked}${marked:+
|
|
97
126
|
}${check}"
|
|
98
127
|
printf '+ green in %ss: %s\n' "$took" "$check"
|
|
99
128
|
elif [ "$status" -eq "$skip_code" ]; then
|
|
100
|
-
rt_run_note "$sign" "$started" skipped "$check"
|
|
129
|
+
rt_run_note "$sign" "$started" skipped "$check" "$base" "$(rt_push_subject_of "$subjects" "$check")"
|
|
101
130
|
printf '~ nothing to look at: %s\n' "$check"
|
|
102
131
|
else
|
|
103
|
-
rt_run_note "$sign" "$started" red "$check"
|
|
132
|
+
rt_run_note "$sign" "$started" red "$check" "$base" "$(rt_push_subject_of "$subjects" "$check")"
|
|
104
133
|
red="${red}${red:+
|
|
105
134
|
}${check}"
|
|
106
135
|
printf '✗ red in %ss: %s\n%s\n' "$took" "$check" "$(printf '%s' "$out" | tail -n 25)"
|
|
@@ -121,8 +150,12 @@ if [ -n "$set_over" ]; then
|
|
|
121
150
|
fi
|
|
122
151
|
|
|
123
152
|
if [ -n "$red" ]; then
|
|
153
|
+
# A red run refuses nothing: it reports. The code is the number of red checks, at most 100, and
|
|
154
|
+
# the push guard refuses the push by the marks this run did not write.
|
|
124
155
|
printf '\npush ahead: red —\n%s\n' "$red"
|
|
125
|
-
|
|
156
|
+
red_count="$(printf '%s\n' "$red" | grep -c .)"
|
|
157
|
+
[ "$red_count" -gt 100 ] && red_count=100
|
|
158
|
+
exit "$red_count"
|
|
126
159
|
fi
|
|
127
160
|
printf '\npush ahead: the set is green, the push passes from the marks\n'
|
|
128
161
|
exit 0
|
|
@@ -8,6 +8,35 @@
|
|
|
8
8
|
# FAIL-OPEN: no network, no remote, no git — the base falls back to the main branch or to nothing,
|
|
9
9
|
# and a mark that cannot be read counts as absent. Either way the set runs, never less of it.
|
|
10
10
|
|
|
11
|
+
# Whether a remote branch stands on this one by the own copy `$2`. It does when the copy lies on
|
|
12
|
+
# its first-parent line — it was taken from this one and went on by plain commits — or when no
|
|
13
|
+
# merge of the host brought the copy in: a neighbour took this one in itself. A copy a merge of the
|
|
14
|
+
# host brought in leaves it a base, the merge reached by the first parent or through a merge of a
|
|
15
|
+
# session: that is the branch of an epic a request carried the copy into.
|
|
16
|
+
# A branch under the head or at it is no branch standing on this one: what the head holds already
|
|
17
|
+
# passed the set; nor is one at the commit of the copy: a branch pushed before its first commit
|
|
18
|
+
# still lies at the tip it was taken from. The lists are held in variables and matched by `case`,
|
|
19
|
+
# so a caller with `pipefail` gets the same answer.
|
|
20
|
+
rt_push_base_on_copy() {
|
|
21
|
+
local ref="$1" own host="$3" line merge parent
|
|
22
|
+
own="$(git rev-parse --verify --quiet "$2")" || return 1
|
|
23
|
+
[ "$own" != "$(git rev-parse --verify --quiet "$ref")" ] || return 1
|
|
24
|
+
git merge-base --is-ancestor "$ref" HEAD 2>/dev/null && return 1
|
|
25
|
+
git merge-base --is-ancestor "$own" "$ref" 2>/dev/null || return 1
|
|
26
|
+
line="$(git rev-list --first-parent "$ref" --not "$own^@" 2>/dev/null)"
|
|
27
|
+
case "$line" in *"$own"*) return 0 ;; esac
|
|
28
|
+
# A merge of the host anywhere in the branch whose second side brought the copy keeps it a
|
|
29
|
+
# base: a session that synced its epic with the remote one merged the host's merge in as is.
|
|
30
|
+
for merge in $(git rev-list --merges --fixed-strings --committer="$host" "$ref" --not "$own" 2>/dev/null); do
|
|
31
|
+
git merge-base --is-ancestor "$own" "$merge^1" 2>/dev/null && continue
|
|
32
|
+
line="$(git rev-parse "$merge^@" 2>/dev/null)"
|
|
33
|
+
for parent in ${line#*$'\n'}; do
|
|
34
|
+
git merge-base --is-ancestor "$own" "$parent" 2>/dev/null && return 1
|
|
35
|
+
done
|
|
36
|
+
done
|
|
37
|
+
return 0
|
|
38
|
+
}
|
|
39
|
+
|
|
11
40
|
# The base the contribution is counted against. Prints `origin/<branch>` or nothing.
|
|
12
41
|
#
|
|
13
42
|
# The base is the remote branch the head has the fewest commits over: what the head carries past
|
|
@@ -26,7 +55,8 @@
|
|
|
26
55
|
#
|
|
27
56
|
# Three kinds of branches are no base, because they are this branch's own content:
|
|
28
57
|
# - its own remote copy — the set answers for the whole contribution, not for the last commit;
|
|
29
|
-
# - a branch that stands on that copy — it
|
|
58
|
+
# - a branch that stands on that copy — it holds the copy on its first-parent line or took it in
|
|
59
|
+
# with no merge of the host bringing it, and lies neither under the head nor at it;
|
|
30
60
|
# - a branch the host merged into this one by a request. Without that the branch of an epic was
|
|
31
61
|
# counted against its last merged task, and nothing checked the epic against the main branch
|
|
32
62
|
# before the push. The host's merge is told by the committer of the commit: the host signs
|
|
@@ -34,18 +64,32 @@
|
|
|
34
64
|
# A tree whose host signs otherwise names the signature in `RT_PUSH_HOST_COMMITTER`.
|
|
35
65
|
#
|
|
36
66
|
# What this trusts: a branch on the remote got there through this set. The answer is read from the
|
|
37
|
-
# remote refs of the working copy after one fetch
|
|
38
|
-
#
|
|
67
|
+
# remote refs of the working copy after one fetch, and it works on the first push, when no request
|
|
68
|
+
# is open yet. A head that is no branch gets the main branch.
|
|
69
|
+
#
|
|
70
|
+
# A ref of the copy is a candidate only while the host still holds its branch: one call of
|
|
71
|
+
# `git ls-remote --heads` per call of this function, the name matched whole. The fetch keeps
|
|
72
|
+
# `--no-prune` — a prune in one copy changes what a neighbouring copy measures — so a branch the
|
|
73
|
+
# host removed after its merge stays as a ref here. Taken as the base, it gave the set one base and
|
|
74
|
+
# the push another once a neighbour pruned the copy: a green set of half an hour was refused as
|
|
75
|
+
# «No green mark». With no answer from the host the refs of the copy decide, and a line on stderr
|
|
76
|
+
# says so.
|
|
39
77
|
rt_push_base() {
|
|
40
|
-
local main="$1" branch own ref name count best best_count merge merged='' host
|
|
78
|
+
local main="$1" branch own ref name count best best_count merge merged='' host live answered=1
|
|
41
79
|
host="${RT_PUSH_HOST_COMMITTER:-GitHub <noreply@github.com>}"
|
|
42
80
|
git fetch --quiet --no-prune origin 2>/dev/null
|
|
43
81
|
git rev-parse --verify --quiet "refs/remotes/origin/$main" >/dev/null 2>&1 || return 0
|
|
82
|
+
live="$(git ls-remote --heads origin 2>/dev/null)" || answered=0
|
|
83
|
+
live="$(printf '%s\n' "$live" | cut -f2)"
|
|
84
|
+
[ "$answered" = 1 ] ||
|
|
85
|
+
printf 'push base: the host did not answer — the base is taken from the refs of the copy\n' >&2
|
|
44
86
|
|
|
45
87
|
best="origin/$main"
|
|
46
88
|
best_count="$(git rev-list --count "refs/remotes/origin/$main..HEAD" 2>/dev/null)"
|
|
47
89
|
case "$best_count" in '' | *[!0-9]*) printf '%s' "$best" && return 0 ;; esac
|
|
48
|
-
|
|
90
|
+
# shellcheck disable=SC1091
|
|
91
|
+
command -v rt_fact_branch >/dev/null 2>&1 || . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/facts.sh" 2>/dev/null
|
|
92
|
+
branch="$(rt_fact_branch)"
|
|
49
93
|
[ -n "$branch" ] || { printf '%s' "$best" && return 0; }
|
|
50
94
|
|
|
51
95
|
own="refs/remotes/origin/$branch"
|
|
@@ -67,10 +111,9 @@ $(git for-each-ref --merged "$merge^2" --no-merged "$merge^1" --format='%(refnam
|
|
|
67
111
|
'' | HEAD | "$main" | "$branch" | *[!A-Za-z0-9._/-]*) continue ;;
|
|
68
112
|
esac
|
|
69
113
|
printf '%s\n' "$merged" | grep -qxF -- "$ref" && continue
|
|
70
|
-
# A branch
|
|
71
|
-
|
|
72
|
-
[ -n "$own" ] &&
|
|
73
|
-
git merge-base --is-ancestor "$own" "$ref" 2>/dev/null && continue
|
|
114
|
+
# A branch the host no longer holds is no base: its ref outlives it in the copy.
|
|
115
|
+
[ "$answered" = 0 ] || printf '%s\n' "$live" | grep -qxF -- "refs/heads/$name" || continue
|
|
116
|
+
[ -n "$own" ] && rt_push_base_on_copy "$ref" "$own" "$host" && continue
|
|
74
117
|
if ! git merge-base --is-ancestor "$ref" HEAD 2>/dev/null; then
|
|
75
118
|
[ -n "$(git rev-list -n 1 --first-parent --merges --fixed-strings --committer="$host" \
|
|
76
119
|
"HEAD..$ref" 2>/dev/null)" ] || continue
|
|
@@ -107,12 +150,14 @@ rt_push_mark_clean() {
|
|
|
107
150
|
# Whether the head adds nothing to its base: every commit of it already lies in that branch on the
|
|
108
151
|
# remote. Such a push sends content the set already judged there, and running the set over it costs
|
|
109
152
|
# its whole length and can find nothing — a branch of an epic just taken from the main branch paid
|
|
110
|
-
# forty minutes for a tree equal to the main one.
|
|
153
|
+
# forty minutes for a tree equal to the main one. The base is a remote ref, or the ref the run ahead
|
|
154
|
+
# pinned at the commit of one; a base that is neither answers «it adds».
|
|
111
155
|
rt_push_adds_nothing() {
|
|
112
|
-
local base="$1" count
|
|
156
|
+
local base="$1" ref count
|
|
113
157
|
[ -n "$base" ] || return 1
|
|
114
|
-
|
|
115
|
-
|
|
158
|
+
case "$base" in refs/rt-kit/push-base/*) ref="$base" ;; *) ref="refs/remotes/$base" ;; esac
|
|
159
|
+
git rev-parse --verify --quiet "$ref" >/dev/null 2>&1 || return 1
|
|
160
|
+
count="$(git rev-list --count "$ref..HEAD" 2>/dev/null)"
|
|
116
161
|
[ "$count" = 0 ]
|
|
117
162
|
}
|
|
118
163
|
|
|
@@ -154,6 +199,160 @@ rt_push_mark_dir() {
|
|
|
154
199
|
printf '%s/rt-kit/push-green' "$common"
|
|
155
200
|
}
|
|
156
201
|
|
|
202
|
+
# The base of the run ahead, pinned for the branch. The run ahead picks the base, puts a ref of its
|
|
203
|
+
# own at its commit and gives the steps of the set that ref, not the remote one: a remote ref moves
|
|
204
|
+
# with every fetch and vanishes with a prune, the pinned one stands until the next run ahead of the
|
|
205
|
+
# branch. A record next to it keeps the tree of the head, the name of the base, its commit and the
|
|
206
|
+
# head commit. The push guard and the git hook take the pinned ref while the record fits the head,
|
|
207
|
+
# and pick the base anew otherwise. A record fits a head with the same tree or a head that lies over
|
|
208
|
+
# the recorded one: a commit after the set — the task folder taken apart, a line in a plan — keeps
|
|
209
|
+
# the marks of the steps that do not read it.
|
|
210
|
+
#
|
|
211
|
+
# Without the record the push picked its base by itself. On 21.11 a set of half an hour took the
|
|
212
|
+
# ref of a branch the host had removed as its base; a neighbouring copy pruned the refs, the push
|
|
213
|
+
# picked the main branch and refused as «No green mark». Records and refs are kept per branch: the
|
|
214
|
+
# branches of a chain run ahead one after another in one copy. The records lie in the directory of
|
|
215
|
+
# the working copy, the refs in the shared refs — a branch is worked in one copy at a time.
|
|
216
|
+
rt_push_base_branch() {
|
|
217
|
+
# shellcheck disable=SC1091
|
|
218
|
+
command -v rt_fact_branch >/dev/null 2>&1 || . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/facts.sh" 2>/dev/null
|
|
219
|
+
rt_fact_branch 2>/dev/null
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
# The pinned ref of a branch. It is named by a number, not by the branch: the ref stands in every
|
|
223
|
+
# line of the set that names the base, and the profile reads those lines by words — `visual-gate`,
|
|
224
|
+
# `e2e` — that a branch name may carry. A line of light checks then passed for a heavy one, and its
|
|
225
|
+
# mark outlived a commit of the paths a heavy step does not read.
|
|
226
|
+
rt_push_base_ref() {
|
|
227
|
+
[ -n "$1" ] || return 1
|
|
228
|
+
printf 'refs/rt-kit/push-base/%s' "$(printf '%s' "$1" | cksum | cut -d' ' -f1)"
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
# Removes the records and the refs of branches the copy no longer holds: nothing else removes them,
|
|
232
|
+
# and a pinned ref keeps its commits from the collection of garbage.
|
|
233
|
+
rt_push_base_sweep() {
|
|
234
|
+
local dir file branch
|
|
235
|
+
dir="$(git rev-parse --path-format=absolute --git-dir 2>/dev/null)/rt-kit/push-base.d"
|
|
236
|
+
[ -d "$dir" ] || return 0
|
|
237
|
+
find "$dir" -type f 2>/dev/null | while IFS= read -r file; do
|
|
238
|
+
branch="${file#"$dir"/}"
|
|
239
|
+
git show-ref --verify --quiet "refs/heads/$branch" 2>/dev/null && continue
|
|
240
|
+
git update-ref -d "$(rt_push_base_ref "$branch")" 2>/dev/null
|
|
241
|
+
rm -f "$file" 2>/dev/null
|
|
242
|
+
done
|
|
243
|
+
return 0
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
rt_push_base_record_path() {
|
|
247
|
+
local dir branch
|
|
248
|
+
dir="$(git rev-parse --path-format=absolute --git-dir 2>/dev/null)" || return 1
|
|
249
|
+
branch="$(rt_push_base_branch)"
|
|
250
|
+
[ -n "$branch" ] || return 1
|
|
251
|
+
printf '%s/rt-kit/push-base.d/%s' "$dir" "$branch"
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
# Pins the base `$1` for the branch: writes the record and the ref, prints the ref. No branch, or a
|
|
255
|
+
# base with no commit — prints `$1` itself, and the set runs against the remote ref as before.
|
|
256
|
+
rt_push_base_pin() {
|
|
257
|
+
local path tree sha head branch ref
|
|
258
|
+
[ -n "$1" ] || return 0
|
|
259
|
+
branch="$(rt_push_base_branch)"
|
|
260
|
+
tree="$(git rev-parse --verify --quiet 'HEAD^{tree}' 2>/dev/null)"
|
|
261
|
+
head="$(git rev-parse --verify --quiet HEAD 2>/dev/null)"
|
|
262
|
+
sha="$(git rev-parse --verify --quiet "$1^{commit}" 2>/dev/null)"
|
|
263
|
+
path="$(rt_push_base_record_path)"
|
|
264
|
+
ref="$(rt_push_base_ref "$branch")"
|
|
265
|
+
rt_push_base_sweep
|
|
266
|
+
if [ -z "$branch" ] || [ -z "$tree" ] || [ -z "$head" ] || [ -z "$sha" ] || [ -z "$path" ] ||
|
|
267
|
+
! mkdir -p "${path%/*}" 2>/dev/null ||
|
|
268
|
+
! git update-ref "$ref" "$sha" 2>/dev/null ||
|
|
269
|
+
! printf '%s\n%s\n%s\n%s\n' "$tree" "$1" "$sha" "$head" > "$path" 2>/dev/null; then
|
|
270
|
+
printf '%s' "$1"
|
|
271
|
+
return 0
|
|
272
|
+
fi
|
|
273
|
+
printf '%s' "$ref"
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
# Whether the record of the branch fits the head: the same tree, or a head that lies over the
|
|
277
|
+
# recorded one by plain commits. A merge over the recorded head brings content of other branches —
|
|
278
|
+
# the branch of the epic moved and taken in — and the base is picked anew: counted from the old
|
|
279
|
+
# base, that content would pass for this branch's own. Prints the name of the base and its commit
|
|
280
|
+
# on two lines.
|
|
281
|
+
rt_push_base_fits() {
|
|
282
|
+
local path tree name sha head
|
|
283
|
+
path="$(rt_push_base_record_path)" || return 1
|
|
284
|
+
[ -f "$path" ] || return 1
|
|
285
|
+
{ IFS= read -r tree && IFS= read -r name && IFS= read -r sha && IFS= read -r head; } < "$path" || return 1
|
|
286
|
+
case "$name" in origin/?*) ;; *) return 1 ;; esac
|
|
287
|
+
git cat-file -e "$sha^{commit}" 2>/dev/null || return 1
|
|
288
|
+
if [ "$tree" != "$(git rev-parse --verify --quiet 'HEAD^{tree}' 2>/dev/null)" ]; then
|
|
289
|
+
git merge-base --is-ancestor "$head" HEAD 2>/dev/null || return 1
|
|
290
|
+
[ "$(git rev-list --merges --count "$head..HEAD" 2>/dev/null)" = 0 ] || return 1
|
|
291
|
+
fi
|
|
292
|
+
printf '%s\n%s\n' "$name" "$sha"
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
# Prints the pinned ref of the branch when the record fits the head, with the ref put back at the
|
|
296
|
+
# recorded commit if anything moved it. The remote refs are fetched first, as a pick does: light
|
|
297
|
+
# steps read the main branch by its remote ref. No record, or one that does not fit — no answer.
|
|
298
|
+
rt_push_base_recorded() {
|
|
299
|
+
local fit sha ref
|
|
300
|
+
fit="$(rt_push_base_fits)" || return 1
|
|
301
|
+
sha="$(printf '%s\n' "$fit" | sed -n 2p)"
|
|
302
|
+
ref="$(rt_push_base_ref "$(rt_push_base_branch)")" || return 1
|
|
303
|
+
git fetch --quiet --no-prune origin 2>/dev/null
|
|
304
|
+
[ "$(git rev-parse --verify --quiet "$ref" 2>/dev/null)" = "$sha" ] ||
|
|
305
|
+
git update-ref "$ref" "$sha" 2>/dev/null || return 1
|
|
306
|
+
printf '%s' "$ref"
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
# The base `$1` picked anew, or the pinned ref when the record names that very base at the commit
|
|
310
|
+
# it stands on now: a record that stopped fitting — an amended commit of unread paths — keeps its
|
|
311
|
+
# marks while the base did not move.
|
|
312
|
+
rt_push_base_same() {
|
|
313
|
+
local path name sha ref
|
|
314
|
+
path="$(rt_push_base_record_path)" || { printf '%s' "$1"; return 0; }
|
|
315
|
+
name="$(sed -n 2p "$path" 2>/dev/null)"
|
|
316
|
+
sha="$(sed -n 3p "$path" 2>/dev/null)"
|
|
317
|
+
ref="$(rt_push_base_ref "$(rt_push_base_branch)")"
|
|
318
|
+
if [ -n "$1" ] && [ "$name" = "$1" ] && [ -n "$sha" ] &&
|
|
319
|
+
[ "$(git rev-parse --verify --quiet "$1^{commit}" 2>/dev/null)" = "$sha" ] &&
|
|
320
|
+
{ [ "$(git rev-parse --verify --quiet "$ref" 2>/dev/null)" = "$sha" ] ||
|
|
321
|
+
git update-ref "$ref" "$sha" 2>/dev/null; }; then
|
|
322
|
+
printf '%s' "$ref"
|
|
323
|
+
return 0
|
|
324
|
+
fi
|
|
325
|
+
printf '%s' "$1"
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
# A base as a person reads it: a pinned ref is named by the remote branch it stands for and its
|
|
329
|
+
# commit, any other base by itself.
|
|
330
|
+
rt_push_base_label() {
|
|
331
|
+
local path
|
|
332
|
+
case "$1" in
|
|
333
|
+
refs/rt-kit/push-base/*)
|
|
334
|
+
path="$(rt_push_base_record_path)" && [ -f "$path" ] &&
|
|
335
|
+
printf '%s pinned at %s' "$(sed -n 2p "$path")" "$(sed -n 3p "$path" | cut -c1-9)" && return 0
|
|
336
|
+
;;
|
|
337
|
+
esac
|
|
338
|
+
printf '%s' "${1:-none}"
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
# The base the last run ahead of this branch judged, for the refusal: the base, and «another
|
|
342
|
+
# history» when the record does not fit the head. No record — nothing.
|
|
343
|
+
rt_push_base_last() {
|
|
344
|
+
local path name
|
|
345
|
+
path="$(rt_push_base_record_path)" || return 0
|
|
346
|
+
[ -f "$path" ] || return 0
|
|
347
|
+
name="$(sed -n 2p "$path" 2>/dev/null)"
|
|
348
|
+
[ -n "$name" ] || return 0
|
|
349
|
+
if rt_push_base_fits >/dev/null; then
|
|
350
|
+
printf '%s pinned at %s' "$name" "$(sed -n 3p "$path" | cut -c1-9)"
|
|
351
|
+
else
|
|
352
|
+
printf '%s (another history)' "$name"
|
|
353
|
+
fi
|
|
354
|
+
}
|
|
355
|
+
|
|
157
356
|
rt_push_mark_has() {
|
|
158
357
|
local key dir
|
|
159
358
|
rt_push_mark_clean || return 1
|
|
@@ -202,6 +401,56 @@ rt_push_select() {
|
|
|
202
401
|
printf '%s\n' "$steps"
|
|
203
402
|
}
|
|
204
403
|
|
|
404
|
+
# Whether the change touched the subject of each step: a line `<mark><TAB><step>` per step on stdin,
|
|
405
|
+
# the mark one of `touched`, `idle`, `unknown`, `not-run`. A step of the table of reads is judged by
|
|
406
|
+
# the rule `rt_push_select` uses; for the rest the tree declares the paths by `rt_push_subject`. No
|
|
407
|
+
# program or a failure of it — every step is `unknown`: the metrics report says so instead of zero.
|
|
408
|
+
rt_push_subjects() {
|
|
409
|
+
local steps root program declared step path marks
|
|
410
|
+
steps="$(cat)"
|
|
411
|
+
root="${CLAUDE_PROJECT_DIR:-.}"
|
|
412
|
+
program="$root/${RT_CHECKS_DIR:-tools}/push-inputs.mjs"
|
|
413
|
+
if [ -n "$1" ] && [ -f "$program" ]; then
|
|
414
|
+
declared="$(mktemp 2>/dev/null)"
|
|
415
|
+
if [ -n "$declared" ]; then
|
|
416
|
+
if command -v rt_push_subject >/dev/null 2>&1; then
|
|
417
|
+
while IFS= read -r step; do
|
|
418
|
+
[ -n "$step" ] || continue
|
|
419
|
+
rt_push_subject "$step" | while IFS= read -r path; do
|
|
420
|
+
[ -n "$path" ] && printf '%s\t%s\n' "$path" "$step"
|
|
421
|
+
done
|
|
422
|
+
done <<<"$steps" >"$declared"
|
|
423
|
+
fi
|
|
424
|
+
marks="$(printf '%s\n' "$steps" | (cd "$root" && node "$program" subject "$1" --declared "$declared" 2>/dev/null))"
|
|
425
|
+
rm -f "$declared"
|
|
426
|
+
if [ -n "$marks" ]; then
|
|
427
|
+
printf '%s\n' "$marks"
|
|
428
|
+
return 0
|
|
429
|
+
fi
|
|
430
|
+
fi
|
|
431
|
+
fi
|
|
432
|
+
printf '%s\n' "$steps" | while IFS= read -r step; do [ -n "$step" ] && printf 'unknown\t%s\n' "$step"; done
|
|
433
|
+
return 0
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
# The subject mark of one step from the lines `rt_push_subjects` printed; `unknown` when absent.
|
|
437
|
+
rt_push_subject_of() {
|
|
438
|
+
local mark
|
|
439
|
+
mark="$(printf '%s\n' "$1" | awk -F '\t' -v step="$2" '$2 == step { print $1; exit }')"
|
|
440
|
+
printf '%s' "${mark:-unknown}"
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
# The steps `rt_push_select` dropped leave a run line of their own: zero seconds, `not-run`. The
|
|
444
|
+
# report counts them apart from the idle runs — such a step cannot run idle.
|
|
445
|
+
rt_push_note_not_run() {
|
|
446
|
+
local sign="$1" base="$2" subjects="$3" step
|
|
447
|
+
command -v rt_run_note >/dev/null 2>&1 || return 0
|
|
448
|
+
printf '%s\n' "$subjects" | awk -F '\t' '$1 == "not-run" { print $2 }' | while IFS= read -r step; do
|
|
449
|
+
[ -n "$step" ] && rt_run_note "$sign" "$(date +%s 2>/dev/null)" not-run "$step" "$base" not-run
|
|
450
|
+
done
|
|
451
|
+
return 0
|
|
452
|
+
}
|
|
453
|
+
|
|
205
454
|
# The tree runs its heavy steps ahead and the guard only reads their marks. Declared by the
|
|
206
455
|
# profile: in a tree whose heavy steps fit the hook limit a refusal for a missing mark is a new step
|
|
207
456
|
# for nothing, and the package does not know how long another tree's steps take.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# rt-hook: PreToolUse Bash|mcp__webstorm__execute_terminal_command|mcp__webstorm__execute_tool|mcp__terminal__run_in_terminal
|
|
3
3
|
# rt-hook-timeout: 1800
|
|
4
|
-
# Requires: hooks/profile-check.sh, hooks/deny-tail.sh, hooks/push-sign.sh, hooks/push-set.sh, hooks/git-guard-push-marks.sh
|
|
4
|
+
# Requires: checks/decide.mjs, hooks/decide.sh, hooks/facts.sh, hooks/profile-check.sh, hooks/deny-tail.sh, hooks/push-sign.sh, hooks/push-set.sh, hooks/git-guard-push-marks.sh
|
|
5
5
|
# The guard of the checks before a push. PreToolUse on the push call.
|
|
6
6
|
#
|
|
7
7
|
# A push is the entry into the pipeline: a merge into the main branch starts the rollout, and
|
|
@@ -78,19 +78,22 @@ printf '%s\n' "$push_calls" | grep -qx 'opaque' && printf '%s' "$cmd" | grep -q
|
|
|
78
78
|
|
|
79
79
|
# The refusal of this gate. The shared deny tail — the two lawful moves and the lawful form of a
|
|
80
80
|
# bypass — may not be laid out; then there is no tail, and the reason stays as it was.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
${
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
# push_refuse <action> <facts of the set> [params]
|
|
82
|
+
# The decision, the move and the text come from the decision table; the hook names the shape of the
|
|
83
|
+
# call, the state of the set and the words of the outputs.
|
|
84
|
+
shape_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
85
|
+
# shellcheck disable=SC1091
|
|
86
|
+
. "$shape_dir/facts.sh" 2>/dev/null
|
|
87
|
+
push_refuse() {
|
|
88
|
+
local facts params
|
|
89
|
+
facts="$(jq -cn --arg r "$(rt_fact_rule_loaded git-workflow "$(printf '%s' "$input" | jq -r '.session_id // "nosession"' 2>/dev/null)")" \
|
|
90
|
+
--argjson own "${2:-"{}"}" '{rule_loaded:$r} + $own')"
|
|
91
|
+
# The refusals of the shape name a plain push as the fix, and that push is refused next while the
|
|
92
|
+
# heavy steps of the tree have no green mark. So they name the run ahead before it.
|
|
93
|
+
params="$(jq -cn --arg a "bash ${shape_dir#"$PWD"/}/git-guard-push-ahead.sh" --argjson own "${3:-"{}"}" '{ahead_cmd:$a} + $own')"
|
|
94
|
+
# shellcheck disable=SC1091
|
|
95
|
+
. "$shape_dir/decide.sh" 2>/dev/null
|
|
96
|
+
command -v rt_decide >/dev/null 2>&1 && rt_decide git-guard-push-tests.sh "$1" "$facts" "$params"
|
|
94
97
|
exit 0
|
|
95
98
|
}
|
|
96
99
|
|
|
@@ -98,7 +101,7 @@ ${deny_tail_text}"
|
|
|
98
101
|
# commands from the input, `source` of a substitution, function calls that grow without bound. What
|
|
99
102
|
# such a command runs is seen only when it runs, and a silent pass would let a push leave unchecked.
|
|
100
103
|
if [ "$opaque" = true ]; then
|
|
101
|
-
|
|
104
|
+
push_refuse push_opaque
|
|
102
105
|
fi
|
|
103
106
|
|
|
104
107
|
# A branch switch in the same command is refused whole.
|
|
@@ -118,7 +121,7 @@ fi
|
|
|
118
121
|
switched=false
|
|
119
122
|
printf '%s\n' "$push_calls" | awk '$0 == "switch" { s = 1 } / real$/ && s { f = 1 } END { exit !f }' && switched=true
|
|
120
123
|
if [ "$switched" = true ]; then
|
|
121
|
-
|
|
124
|
+
push_refuse push_switch
|
|
122
125
|
fi
|
|
123
126
|
|
|
124
127
|
# Several pushes in one command, or a push inside a loop, are refused whole. The set runs once
|
|
@@ -130,7 +133,7 @@ printf '%s\n' "$push_calls" | grep -q '^loop .* real$' && looped=true
|
|
|
130
133
|
several_refs=false
|
|
131
134
|
printf '%s\n' "$push_calls" | grep -q ' several real$' && several_refs=true
|
|
132
135
|
if [ "${pushes:-0}" -gt 1 ] || [ "$looped" = true ] || [ "$several_refs" = true ]; then
|
|
133
|
-
|
|
136
|
+
push_refuse push_multi
|
|
134
137
|
fi
|
|
135
138
|
|
|
136
139
|
workdir="$(rt_hook_cwd)"
|
|
@@ -160,7 +163,7 @@ if [ -n "$moved" ] && [ -d "$moved" ]; then
|
|
|
160
163
|
here_repo="$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null)"
|
|
161
164
|
[ -n "$moved_repo" ] && [ -n "$here_repo" ] && [ "$moved_repo" != "$here_repo" ] && exit 0
|
|
162
165
|
if [ -n "$moved_root" ] && [ -n "$here_root" ] && [ "$moved_root" != "$here_root" ]; then
|
|
163
|
-
|
|
166
|
+
push_refuse push_second_copy '{}' "$(jq -cn --arg m "$moved_root" --arg h "$here_root" '{moved_root:$m, here_root:$h}')"
|
|
164
167
|
fi
|
|
165
168
|
fi
|
|
166
169
|
|
|
@@ -211,7 +214,9 @@ base="$(rt_push_set_base)"
|
|
|
211
214
|
# branch, or of the head into a branch of another name, sends what the head says nothing about.
|
|
212
215
|
push_sends_head() {
|
|
213
216
|
local branch
|
|
214
|
-
|
|
217
|
+
# shellcheck disable=SC1091
|
|
218
|
+
command -v rt_fact_branch >/dev/null 2>&1 || . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/facts.sh" 2>/dev/null
|
|
219
|
+
branch="$(rt_fact_branch)" || return 1
|
|
215
220
|
printf '%s' "$cmd" | grep -qE '[[:space:]][A-Za-z0-9_./@^~+-]+:[A-Za-z0-9_./-]+([[:space:];&|]|$)' && return 1
|
|
216
221
|
case " $cmd " in *" $branch "* | *" $branch;"* | *" $branch&"* | *" $branch|"*) return 0 ;; esac
|
|
217
222
|
|
|
@@ -221,7 +226,8 @@ push_sends_head() {
|
|
|
221
226
|
# A head that adds nothing to its base is not judged: the set has nothing new to look at.
|
|
222
227
|
if command -v rt_push_adds_nothing >/dev/null 2>&1 && push_sends_head && rt_push_adds_nothing "$base"; then
|
|
223
228
|
rt_push_gate_note nothing-new
|
|
224
|
-
printf 'the push gate: the head adds no commit to %s — the set is not run\n'
|
|
229
|
+
printf 'the push gate: the head adds no commit to %s — the set is not run\n' \
|
|
230
|
+
"$(command -v rt_push_base_label >/dev/null 2>&1 && rt_push_base_label "$base" || printf '%s' "$base")" >&2
|
|
225
231
|
exit 0
|
|
226
232
|
fi
|
|
227
233
|
|
|
@@ -239,6 +245,24 @@ held="$rt_push_set_held"
|
|
|
239
245
|
ahead="$rt_push_set_ahead"
|
|
240
246
|
ran="$rt_push_set_ran"
|
|
241
247
|
|
|
248
|
+
# The node the tree pins is not on the machine, and PATH gives another one: no step ran, and an empty
|
|
249
|
+
# set must not read as a green one. One line names both versions and the install command.
|
|
250
|
+
if [ -n "${rt_push_set_node:-}" ]; then
|
|
251
|
+
rt_push_gate_note node
|
|
252
|
+
said="$(push_refuse push '{"push_node_pinned":"no"}' "$(jq -cn --arg l "$rt_push_set_node" '{node_line:$l}')")"
|
|
253
|
+
# The decider runs on the node of PATH — the very node that may be too old to run it, or absent:
|
|
254
|
+
# then it answers nothing, and the refusal is said here, or the push would pass unjudged.
|
|
255
|
+
if [ -z "$said" ]; then
|
|
256
|
+
# shellcheck disable=SC1091
|
|
257
|
+
command -v rt_deny_tail >/dev/null 2>&1 || . "$rt_hooks_dir/deny-tail.sh" 2>/dev/null
|
|
258
|
+
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
259
|
+
said="$(jq -cn --arg r "BLOCKED: ${rt_push_set_node}. No step of the push set ran. Install the pinned node by that command and push again. $(rt_deny_tail)" \
|
|
260
|
+
'{hookSpecificOutput:{hookEventName:"PreToolUse", permissionDecision:"deny", permissionDecisionReason:$r}}')"
|
|
261
|
+
fi
|
|
262
|
+
printf '%s\n' "$said"
|
|
263
|
+
exit 0
|
|
264
|
+
fi
|
|
265
|
+
|
|
242
266
|
# Heavy steps with no mark are named in one refusal together with the red light ones: the command
|
|
243
267
|
# that runs them ahead goes to the background, where no hook limit cuts it, and the push after it
|
|
244
268
|
# passes from the marks.
|
|
@@ -256,11 +280,16 @@ Red among the light checks:
|
|
|
256
280
|
${failed}
|
|
257
281
|
|
|
258
282
|
$(printf '%s' "$output" | tr -d '\000')"
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
283
|
+
# Both bases are named: a mark is keyed by its base, and a push that chose another base than
|
|
284
|
+
# the run ahead looks the same as one with no run at all.
|
|
285
|
+
last_base=""
|
|
286
|
+
command -v rt_push_base_last >/dev/null 2>&1 && last_base="$(rt_push_base_last)"
|
|
287
|
+
command -v rt_push_base_label >/dev/null 2>&1 || rt_push_base_label() { printf '%s' "${1:-none}"; }
|
|
288
|
+
base_line="
|
|
289
|
+
|
|
290
|
+
The base of this push: $(rt_push_base_label "$base"). The base of the last run ahead of this branch: ${last_base:-none recorded}."
|
|
291
|
+
push_refuse push '{"push_marks_green":"no"}' "$(jq -cn --arg a "$ahead" --arg c "$ahead_cmd" --arg d "$dirty_line" --arg r "$red_line" \
|
|
292
|
+
--arg b "$base_line" '{ahead:$a, ahead_cmd:$c, dirty_line:$d, red_line:$r, base_line:$b}')"
|
|
264
293
|
fi
|
|
265
294
|
|
|
266
295
|
# What was skipped is named aloud even when the set passed: silence about it is exactly the
|
|
@@ -328,30 +357,7 @@ ${held}"
|
|
|
328
357
|
# When a check of the code fails, "fix it and push again" is right. When the check itself is wrong,
|
|
329
358
|
# the same text orders fixing code nobody touched: a refusal once taken apart lay wholly in
|
|
330
359
|
# documents untouched by any commit of the branch. The verifiability law says a broken check does
|
|
331
|
-
# not stop the work,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
Three moves from here: fix what is named and repeat the call; fix the check itself, if it is the one that is wrong — take the refusals apart one by one, show the analysis to the owner and correct the check; or bring the owner the price of a bypass and wait for their word. What is in dispute is not added to the known list: it holds what was accepted, not the results of a broken check.
|
|
337
|
-
|
|
338
|
-
The tail of every red output:
|
|
339
|
-
|
|
340
|
-
${tail_out}"
|
|
341
|
-
|
|
342
|
-
# The shared deny tail: the two lawful moves and the lawful form of bypass, if the refusal has one.
|
|
343
|
-
# The file may not be laid out — then there is no tail, and the reason for the refusal stays as it
|
|
344
|
-
# was.
|
|
345
|
-
# shellcheck disable=SC1090
|
|
346
|
-
[ -f "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" ] \
|
|
347
|
-
&& . "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/deny-tail.sh" 2>/dev/null
|
|
348
|
-
command -v rt_deny_tail >/dev/null 2>&1 || rt_deny_tail() { :; }
|
|
349
|
-
deny_tail_text="$(rt_deny_tail "")"
|
|
350
|
-
[ -n "$deny_tail_text" ] && reason="${reason}
|
|
351
|
-
|
|
352
|
-
${deny_tail_text}"
|
|
353
|
-
|
|
354
|
-
jq -n --arg r "$reason" '{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:$r}}' 2>/dev/null \
|
|
355
|
-
|| printf '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"The checks before the push did not pass."}}\n'
|
|
356
|
-
|
|
357
|
-
exit 0
|
|
360
|
+
# not stop the work, so the text of the table names the third move too.
|
|
361
|
+
push_refuse push '{"push_marks_green":"yes","push_checks_green":"no"}' \
|
|
362
|
+
"$(jq -cn --arg n "$red_count" --arg f "$failed" --arg h "$held_line" --arg t "$tail_out" \
|
|
363
|
+
'{red_count:$n, failed:$f, held_line:$h, tail_out:$t}')"
|