@cbartens/bkit 5.5.0 β†’ 5.5.1

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.
Files changed (56) hide show
  1. package/.bkit/README.md +2 -2
  2. package/.bkit/core/.agents/rules.md +17 -1
  3. package/.bkit/core/.bkit/README.md +1 -1
  4. package/.bkit/core/.bkit/cloud.md +2 -2
  5. package/.bkit/core/.bkit/install.md +3 -4
  6. package/.bkit/core/.bkit/prompts.md +29 -14
  7. package/.bkit/core/.bkit/templates.md +34 -9
  8. package/.bkit/core/.bkit/trackers.md +10 -1
  9. package/.bkit/core/.bkit/workflows.md +10 -9
  10. package/.bkit/core/engine/checks/after/ci-yml.ts +0 -1
  11. package/.bkit/core/engine/checks/after/github.ts +24 -73
  12. package/.bkit/core/engine/checks/after/index.ts +0 -5
  13. package/.bkit/core/engine/checks/after/tools.ts +1 -1
  14. package/.bkit/core/engine/checks/tips/index.ts +5 -2
  15. package/.bkit/core/engine/commands/workflow/issues.ts +26 -47
  16. package/.bkit/core/engine/commands/workflow/repo.ts +2 -0
  17. package/.bkit/core/engine/commands/workflow/worktrees.ts +91 -14
  18. package/.bkit/core/engine/install/modules/core.ts +77 -6
  19. package/.bkit/core/engine/shared/settings.ts +46 -14
  20. package/.bkit/core/prompts/bkit-debug-abort-handover.md +2 -0
  21. package/.bkit/core/prompts/bkit-design-generate.md +2 -0
  22. package/.bkit/core/prompts/bkit-plan-generate.md +5 -3
  23. package/.bkit/core/prompts/bkit-ship-update-docs.md +1 -1
  24. package/.bkit/core/prompts/bkit-utility-update-documentation.md +1 -1
  25. package/.bkit/core/prompts/bkit-utility-update-tracker.md +4 -4
  26. package/.bkit/core/workflows/bkit-build.md +3 -3
  27. package/.bkit/core/workflows/bkit-debug.md +3 -3
  28. package/.bkit/core/workflows/bkit-design.md +3 -3
  29. package/.bkit/core/workflows/bkit-plan.md +3 -3
  30. package/.bkit/core/workflows/bkit-ship.md +3 -3
  31. package/.bkit/shared/docs/deployments.md +5 -17
  32. package/.bkit/shared/docs/testing.md +11 -3
  33. package/.bkit/templates/.github/workflows/bkit-ci.yml +21 -83
  34. package/.bkit/templates/.husky/pre-push +48 -9
  35. package/.bkit/templates/scripts/ci/bkit-local-stack-lock.sh +194 -0
  36. package/.bkit/templates/scripts/ci/check-capstone.mjs +2 -4
  37. package/.bkit/templates/scripts/ci/check-capstone.test.mjs +4 -23
  38. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.mjs +104 -23
  39. package/.bkit/templates/scripts/ci/lanes/resolve-push-base.test.mjs +103 -6
  40. package/.bkit/templates/scripts/graphify/bkit-graph-pre-push.sh +3 -1
  41. package/.bkit/templates/scripts/prettier/bkit-insert-ignore.mjs +49 -29
  42. package/CHANGELOG.md +30 -0
  43. package/README.md +9 -0
  44. package/dist/checks/after/ci-yml.js +0 -1
  45. package/dist/checks/after/github.js +24 -71
  46. package/dist/checks/after/index.js +1 -6
  47. package/dist/checks/after/tools.js +1 -1
  48. package/dist/checks/tips/index.js +4 -2
  49. package/dist/commands/workflow/issues.js +25 -46
  50. package/dist/commands/workflow/repo.js +1 -0
  51. package/dist/commands/workflow/worktrees.js +74 -13
  52. package/dist/install/modules/core.js +81 -6
  53. package/dist/shared/settings.js +23 -10
  54. package/package.json +4 -2
  55. package/.bkit/templates/scripts/ci/lanes/check-tree-cache.mjs +0 -138
  56. package/.bkit/templates/scripts/ci/lanes/check-tree-cache.test.mjs +0 -181
@@ -83,29 +83,7 @@ jobs:
83
83
  echo "πŸ”Š [verbose ci] marker active β€” escalating log detail"
84
84
  echo "DEBUG=vercel:*,supabase:*" >> "$GITHUB_ENV"
85
85
 
86
- # Pull requests only: the suite skips when this PR's files already passed a push run
87
- # (scripts/ci/lanes/check-tree-cache.mjs). A push or dispatch run always runs it, and so
88
- # does [force build] / [force cache] in the PR title.
89
- - name: Check Tree Cache
90
- id: cache
91
- env:
92
- GH_TOKEN: ${{ github.token }}
93
- REPO: ${{ github.repository }}
94
- EVENT_NAME: ${{ github.event_name }}
95
- JOB: ${{ github.job }}
96
- # User-controlled text (PR title) arrives via env: (runtime expansion,
97
- # injection-safe) β€” never inlined into the run: body.
98
- PR_TITLE: ${{ github.event.pull_request.title }}
99
- run: |
100
- if [ -f scripts/ci/lanes/check-tree-cache.mjs ]; then
101
- node scripts/ci/lanes/check-tree-cache.mjs >> "$GITHUB_OUTPUT"
102
- else
103
- echo "skip=false" >> "$GITHUB_OUTPUT"
104
- echo "::notice::scripts/ci/lanes/check-tree-cache.mjs not copied β€” running the suite."
105
- fi
106
-
107
86
  - name: Detect Direct Push
108
- if: steps.cache.outputs.skip != 'true'
109
87
  id: detect
110
88
  env:
111
89
  GH_TOKEN: ${{ github.token }}
@@ -176,7 +154,7 @@ jobs:
176
154
  # pre-planner shape (pull_request only). Once bkit-tests-scope exists, run this on every event
177
155
  # against the planner base. deployments.md Β§ One run. To enable: uncomment and delete this header.
178
156
  # - name: Assert Migrations Immutable
179
- # if: github.event_name == 'pull_request' && steps.cache.outputs.skip != 'true'
157
+ # if: github.event_name == 'pull_request'
180
158
  # run: |
181
159
  # git fetch origin "${{ github.base_ref }}" --depth=50 2>/dev/null || true
182
160
  # CHANGED=$(git diff --name-only "origin/${{ github.base_ref }}..HEAD" -- supabase/migrations/ 2>/dev/null || true)
@@ -190,7 +168,6 @@ jobs:
190
168
  # exit $EXIT
191
169
 
192
170
  - name: Install Dependencies
193
- if: steps.cache.outputs.skip != 'true'
194
171
  run: pnpm install --frozen-lockfile
195
172
 
196
173
  # Static checks first β€” they read the source tree and must scan it CLEAN.
@@ -199,19 +176,16 @@ jobs:
199
176
  # Keep this group (typecheck β†’ lint β†’ prettier β†’ vale β†’ slop β†’ bkit check) ahead of
200
177
  # the test/build group if you reorder.
201
178
  - name: Run Typecheck
202
- if: steps.cache.outputs.skip != 'true'
203
179
  env:
204
180
  TURBO_FORCE: ${{ steps.detect.outputs.turbo_force }}
205
181
  run: pnpm typecheck
206
182
 
207
183
  - name: Run Lint
208
- if: steps.cache.outputs.skip != 'true'
209
184
  env:
210
185
  TURBO_FORCE: ${{ steps.detect.outputs.turbo_force }}
211
186
  run: pnpm lint
212
187
 
213
188
  - name: Run Prettier
214
- if: steps.cache.outputs.skip != 'true'
215
189
  env:
216
190
  TURBO_FORCE: ${{ steps.detect.outputs.turbo_force }}
217
191
  run: pnpm format:check
@@ -220,7 +194,6 @@ jobs:
220
194
  # `pnpm lint:prose` guard-skips (write-good missing) and the prose gate is silently
221
195
  # dead. Pinned tarball + `vale sync` (else E100: write-good missing).
222
196
  - name: Install Vale
223
- if: steps.cache.outputs.skip != 'true'
224
197
  env:
225
198
  # renovate: datasource=github-releases depName=errata-ai/vale
226
199
  VALE_VERSION: "3.9.1"
@@ -240,18 +213,16 @@ jobs:
240
213
  done
241
214
 
242
215
  - name: Run Vale Prose Lint
243
- if: steps.cache.outputs.skip != 'true'
244
216
  run: pnpm lint:prose
245
217
 
246
218
  - name: Run Slop Scan
247
- if: steps.cache.outputs.skip != 'true'
248
219
  run: pnpm lint:slop
249
220
 
250
221
  # The ENFORCING slop gate (lint:slop above is an advisory full-scan that never fails).
251
222
  # PR-only: materialises the PR base as a worktree and fails on findings this PR ADDS or
252
223
  # WORSENS vs base. Needs fetch-depth: 0 (set on checkout) so the base SHA is present.
253
224
  - name: Run Slop Delta
254
- if: steps.cache.outputs.skip != 'true' && github.event_name == 'pull_request'
225
+ if: github.event_name == 'pull_request'
255
226
  env:
256
227
  BASE_SHA: ${{ github.event.pull_request.base.sha }}
257
228
  run: pnpm slop:delta "$BASE_SHA"
@@ -260,7 +231,6 @@ jobs:
260
231
  # (${{ }} expression syntax, shellcheck on run: blocks). A YAML linter accepts
261
232
  # workflows that are valid YAML but invalid GHA; actionlint catches that class.
262
233
  - name: Run actionlint
263
- if: steps.cache.outputs.skip != 'true'
264
234
  run: |
265
235
  # Script pinned to the v1.7.12 commit SHA (the git tag is mutable/forgeable); the binary version
266
236
  # is pinned separately via the 1.7.12 arg passed to the script below.
@@ -275,7 +245,6 @@ jobs:
275
245
  "$RUNNER_TEMP/actionlint" -color
276
246
 
277
247
  - name: Run bkit Check
278
- if: steps.cache.outputs.skip != 'true'
279
248
  run: pnpm bkit check
280
249
 
281
250
  # Dependency-audit gate: fails on a high or critical advisory in the lockfile that
@@ -283,7 +252,7 @@ jobs:
283
252
  # Self-skips when the guard is absent β€” a repo that did not adopt
284
253
  # scripts/ci/check-dependency-audit.mjs is a no-op. deployments.md Β§ Dependency updaters.
285
254
  - name: Check Dependency Audit
286
- if: steps.cache.outputs.skip != 'true' && hashFiles('scripts/ci/check-dependency-audit.mjs') != ''
255
+ if: hashFiles('scripts/ci/check-dependency-audit.mjs') != ''
287
256
  run: node scripts/ci/check-dependency-audit.mjs
288
257
 
289
258
  # Capability-register freshness gate: rebuild the graph with graphify and fail when
@@ -294,13 +263,13 @@ jobs:
294
263
  # Push events only β€” a pull_request checkout is the MERGE ref, whose tree (base + head)
295
264
  # can differ from the head the register was built against: a false red no author can clear.
296
265
  - name: Setup uv
297
- if: steps.cache.outputs.skip != 'true' && github.event_name == 'push' && hashFiles('scripts/graphify/bkit-graphify.sh') != ''
266
+ if: github.event_name == 'push' && hashFiles('scripts/graphify/bkit-graphify.sh') != ''
298
267
  uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
299
268
  with:
300
269
  version: "0.13.0"
301
270
 
302
271
  - name: Check Capability Register
303
- if: steps.cache.outputs.skip != 'true' && github.event_name == 'push' && hashFiles('scripts/graphify/bkit-graphify.sh') != ''
272
+ if: github.event_name == 'push' && hashFiles('scripts/graphify/bkit-graphify.sh') != ''
304
273
  # graphify release pinned once: GRAPHIFY_SPEC in bkit-graphify.sh. Same release here,
305
274
  # in the pre-push gate and by hand.
306
275
  run: |
@@ -314,10 +283,8 @@ jobs:
314
283
  # and remote db push move out of this job when you adopt the scaffold below.
315
284
  bkit-tests-unit:
316
285
  runs-on: ubuntu-latest
317
- # bkit-tests-check reads both: cache_skip (a tree-cache short-circuit asserts no count)
318
- # and tests_ran (the executed-test count the Run Unit Tests step writes).
286
+ # bkit-tests-check reads tests_ran (the executed-test count the Run Unit Tests step writes).
319
287
  outputs:
320
- cache_skip: ${{ steps.cache.outputs.skip }}
321
288
  tests_ran: ${{ steps.unit.outputs.ran }}
322
289
  # Env vars duplicated from bkit-tests-static's job-level `env:`.
323
290
  # See the comment above that `env:` in bkit-tests-static β€” NODE_OPTIONS is a
@@ -346,29 +313,7 @@ jobs:
346
313
  echo "πŸ”Š [verbose ci] marker active β€” escalating log detail"
347
314
  echo "DEBUG=vercel:*,supabase:*" >> "$GITHUB_ENV"
348
315
 
349
- # Pull requests only: the suite skips when this PR's files already passed a push run
350
- # (scripts/ci/lanes/check-tree-cache.mjs). A push or dispatch run always runs it, and so
351
- # does [force build] / [force cache] in the PR title.
352
- - name: Check Tree Cache
353
- id: cache
354
- env:
355
- GH_TOKEN: ${{ github.token }}
356
- REPO: ${{ github.repository }}
357
- EVENT_NAME: ${{ github.event_name }}
358
- JOB: ${{ github.job }}
359
- # User-controlled text (PR title) arrives via env: (runtime expansion,
360
- # injection-safe) β€” never inlined into the run: body.
361
- PR_TITLE: ${{ github.event.pull_request.title }}
362
- run: |
363
- if [ -f scripts/ci/lanes/check-tree-cache.mjs ]; then
364
- node scripts/ci/lanes/check-tree-cache.mjs >> "$GITHUB_OUTPUT"
365
- else
366
- echo "skip=false" >> "$GITHUB_OUTPUT"
367
- echo "::notice::scripts/ci/lanes/check-tree-cache.mjs not copied β€” running the suite."
368
- fi
369
-
370
316
  - name: Detect Direct Push
371
- if: steps.cache.outputs.skip != 'true'
372
317
  id: detect
373
318
  env:
374
319
  GH_TOKEN: ${{ github.token }}
@@ -395,7 +340,7 @@ jobs:
395
340
 
396
341
  # bkit-stub:auto-force-e2e β€” Auto-trigger the full lane (E2E etc.) for PRs touching sensitive paths. Orthogonal to the [force full] marker (sets needs_e2e, OR'd with should_run_full at the e2e gate). To enable: uncomment the step below and delete this stub header.
397
342
  # - name: Auto Force E2E for Sensitive Paths
398
- # if: github.event_name == 'pull_request' && steps.cache.outputs.skip != 'true'
343
+ # if: github.event_name == 'pull_request'
399
344
  # id: e2e-paths
400
345
  # run: |
401
346
  # git fetch origin "${{ github.base_ref }}" --depth=1 2>/dev/null || true
@@ -408,7 +353,6 @@ jobs:
408
353
  # done
409
354
 
410
355
  - name: Install Dependencies
411
- if: steps.cache.outputs.skip != 'true'
412
356
  run: pnpm install --frozen-lockfile
413
357
 
414
358
  # bkit-stub:supabase-migrate β€” REMOTE `db push` belongs in `bkit-tests-migration`, NOT here
@@ -419,7 +363,7 @@ jobs:
419
363
  # legacy single-job shape only (no migration lane yet): uncomment below, set SUPABASE_*
420
364
  # secrets, delete this stub header β€” then migrate the step into bkit-tests-migration ASAP.
421
365
  # - name: Apply Supabase Migrations to Dev
422
- # if: github.event_name == 'push' && github.ref == 'refs/heads/dev' && steps.cache.outputs.skip != 'true'
366
+ # if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
423
367
  # env:
424
368
  # SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
425
369
  # SUPABASE_DB_PASSWORD: ${{ secrets.SUPABASE_DEV_DB_PASSWORD }}
@@ -438,14 +382,12 @@ jobs:
438
382
  # * @live catalog-RPC (JOB 3) β€” validates the REAL deployed schema in bkit-tests-live-web. Recommended default once you have a deploy + @live tier (RLS/tenancy especially: a passing fixture check is not evidence prod is locked down).
439
383
  # To enable pgTAP: uncomment, add pgTAP files under supabase/tests/, delete this stub header.
440
384
  # - name: Run DB Tests (pgTAP)
441
- # if: steps.cache.outputs.skip != 'true'
442
385
  # run: pnpm dlx supabase db test # spins up the local DB and runs supabase/tests/*.sql via pg_prove
443
386
  # @live route: a SECURITY DEFINER, service_role-only catalog RPC (e.g. public.rls_coverage_gaps()) called over
444
387
  # REST β€” direct port-5432 from CI runners is IPv4-flaky. Home: bkit-tests-live-web. docs/testing.md Β§ Schema-invariant DB checks.
445
388
 
446
389
  # bkit-stub:test-presence β€” Warn on packages with a test script but zero *.test.ts files. To enable: uncomment the step below and delete this stub header.
447
390
  # - name: Check Test Presence
448
- # if: steps.cache.outputs.skip != 'true'
449
391
  # run: |
450
392
  # for pkg in $(jq -r '.workspaces // [] | .[]' package.json 2>/dev/null) $(ls -d packages/*/ apps/*/ 2>/dev/null); do
451
393
  # [ -f "$pkg/package.json" ] || continue
@@ -457,7 +399,6 @@ jobs:
457
399
 
458
400
  - name: Run Unit Tests
459
401
  id: unit
460
- if: steps.cache.outputs.skip != 'true'
461
402
  env:
462
403
  TURBO_FORCE: ${{ steps.detect.outputs.turbo_force }}
463
404
  # Write the executed-test count as the step output `ran` so bkit-tests-check can
@@ -467,7 +408,6 @@ jobs:
467
408
  run: pnpm test
468
409
 
469
410
  - name: Run Integration Tests
470
- if: steps.cache.outputs.skip != 'true'
471
411
  env:
472
412
  TURBO_FORCE: ${{ steps.detect.outputs.turbo_force }}
473
413
  run: |
@@ -510,10 +450,9 @@ jobs:
510
450
  # and rarely drives every branch). For a real integration %, add --coverage.include='src/server/**'
511
451
  # (a CLI flag on the integration run, same idiom as --exclude above) to scope it to the integration
512
452
  # surface THEN set a floor, or ratchet from current β€” never a picked number. See docs/testing.md Β§ Coverage on PRs.
513
- # 4. JOB-LEVEL permissions on bkit-tests-unit. Job-level REPLACES the workflow-level block (not additive), and the
514
- # Check Tree Cache step reads runs and jobs, so you MUST re-include actions: read or the cache step breaks:
453
+ # 4. JOB-LEVEL permissions on bkit-tests-unit. Job-level REPLACES the workflow-level block (not additive), so
454
+ # re-include contents: read or the checkout breaks:
515
455
  # permissions:
516
- # actions: read
517
456
  # contents: read
518
457
  # pull-requests: write # required to post/update the sticky PR coverage comments
519
458
  # SEPARATE LANES: this stub wires both reports into bkit-tests-unit (the combined starter). If you run
@@ -532,7 +471,7 @@ jobs:
532
471
  # # Every event, including a red unit run (reportOnFailure keeps the summary): writes the coverage table, with
533
472
  # # the floor as its target, to the job summary; comments on same-repo PRs only. No floor yet β†’ drop
534
473
  # # vite-config-path (a missing file only warns, on every run).
535
- # if: ${{ !cancelled() && steps.cache.outputs.skip != 'true' && hashFiles('coverage/unit/coverage-summary.json') != '' }}
474
+ # if: ${{ !cancelled() && hashFiles('coverage/unit/coverage-summary.json') != '' }}
536
475
  # uses: davelosert/vitest-coverage-report-action@c4bbc33a89b7ace0e63d35f1f7d4bcee31155a73 # v2.13.0
537
476
  # with:
538
477
  # name: unit
@@ -544,7 +483,7 @@ jobs:
544
483
  # github-token: ${{ secrets.GITHUB_TOKEN }}
545
484
  # - name: Report Integration Coverage on PR
546
485
  # # hashFiles guard: skip cleanly when the repo has no integration tier (no coverage/integration report produced).
547
- # if: steps.cache.outputs.skip != 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('coverage/integration/coverage-summary.json') != ''
486
+ # if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('coverage/integration/coverage-summary.json') != ''
548
487
  # uses: davelosert/vitest-coverage-report-action@c4bbc33a89b7ace0e63d35f1f7d4bcee31155a73 # v2.13.0
549
488
  # with:
550
489
  # name: integration
@@ -557,7 +496,7 @@ jobs:
557
496
  # Once bkit-tests-build-web publishes deployment_url, E2E reads TEST_URL from that output and this stub stays off.
558
497
  # To enable the pre-split shape: uncomment, set the host secrets, delete this header.
559
498
  # - name: Await Vercel Preview
560
- # if: github.event_name == 'pull_request' && steps.cache.outputs.skip != 'true'
499
+ # if: github.event_name == 'pull_request'
561
500
  # id: vercel
562
501
  # env:
563
502
  # VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
@@ -599,7 +538,7 @@ jobs:
599
538
  # surfaces them.
600
539
  # - name: Run E2E Tests
601
540
  # id: e2e
602
- # if: (steps.detect.outputs.should_run_full == 'true' || steps.e2e-paths.outputs.needs_e2e == 'true') && steps.cache.outputs.skip != 'true'
541
+ # if: (steps.detect.outputs.should_run_full == 'true' || steps.e2e-paths.outputs.needs_e2e == 'true')
603
542
  # env:
604
543
  # TARGET_URL: ${{ steps.vercel.outputs.target_url || 'http://localhost:3000' }}
605
544
  # run: |
@@ -630,13 +569,13 @@ jobs:
630
569
  # entryFilter/sourceFilter to the surface E2E is meant to cover, THEN ratchet from current β€” never a picked number.
631
570
  # See docs/testing.md Β§ E2E coverage on PRs.
632
571
  # Permissions/forks/pin: this step runs in the SAME bkit-tests-unit job as bkit-stub:coverage, so it REUSES that
633
- # stub's job-level permissions block (pull-requests: write + actions: read + contents: read) β€” if you enable
572
+ # stub's job-level permissions block (pull-requests: write + contents: read) β€” if you enable
634
573
  # e2e-coverage WITHOUT the unit/integration coverage, add that same job-level block or the comment cannot post.
635
574
  # The head.repo == repo guard skips fork PRs (read-only GITHUB_TOKEN); the action is SHA-pinned to a commit
636
575
  # (# vX.Y.Z comment) per best practice, kept current by your updater (Renovate/Dependabot).
637
576
  # - name: Report E2E Coverage on PR
638
577
  # # Same gate as Run E2E Tests (coverage exists only if E2E ran); hashFiles skips repos that produced no E2E report.
639
- # if: (steps.detect.outputs.should_run_full == 'true' || steps.e2e-paths.outputs.needs_e2e == 'true') && steps.cache.outputs.skip != 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('coverage/e2e/coverage-summary.json') != ''
578
+ # if: (steps.detect.outputs.should_run_full == 'true' || steps.e2e-paths.outputs.needs_e2e == 'true') && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('coverage/e2e/coverage-summary.json') != ''
640
579
  # uses: davelosert/vitest-coverage-report-action@c4bbc33a89b7ace0e63d35f1f7d4bcee31155a73 # v2.13.0
641
580
  # with:
642
581
  # name: e2e
@@ -687,17 +626,16 @@ jobs:
687
626
  - name: Assert Lanes Passed
688
627
  # The verdict is scripts/ci/check-capstone.mjs (copy it with this file from
689
628
  # .bkit/templates/scripts/ci/; check-capstone.test.mjs tests it). Every lane in LANES
690
- # must succeed; a lane with a *_RAN variable must have run more than 0 tests unless
691
- # cache_skip=true. EMPTY_COUNT=warn: a lane that writes no count yet warns instead of
692
- # failing; delete it once every counted lane writes one. Add each lane you adopt to
693
- # LANES and to its *_RESULT / *_RAN / *_CACHE_SKIP variables.
629
+ # must succeed; a lane with a *_RAN variable must have run more than 0 tests.
630
+ # EMPTY_COUNT=warn: a lane that writes no count yet warns instead of failing; delete it
631
+ # once every counted lane writes one. Add each lane you adopt to LANES and to its
632
+ # *_RESULT / *_RAN variables.
694
633
  env:
695
634
  LANES: static,unit
696
635
  EMPTY_COUNT: warn
697
636
  STATIC_RESULT: ${{ needs.bkit-tests-static.result }}
698
637
  UNIT_RESULT: ${{ needs.bkit-tests-unit.result }}
699
638
  UNIT_RAN: ${{ needs.bkit-tests-unit.outputs.tests_ran }}
700
- UNIT_CACHE_SKIP: ${{ needs.bkit-tests-unit.outputs.cache_skip }}
701
639
  run: |
702
640
  if [ ! -f scripts/ci/check-capstone.mjs ]; then
703
641
  echo "::error::scripts/ci/check-capstone.mjs is missing. Copy it from .bkit/templates/scripts/ci/ into scripts/ci/; without it bkit-tests-check cannot tell a green lane from a lane that ran no tests."
@@ -887,7 +825,7 @@ jobs:
887
825
  # (own checkout/setup/install); gate heavy steps on web_affected; emit integration_ran; the
888
826
  # bkit-stub:coverage integration report (report-only, name: integration) posts from HERE, not bkit-tests-unit.
889
827
  # bkit-tests-integration: needs:[bkit-tests-scope]; if: run_level != 'none'; timeout-minutes: 20
890
- # # own job-level permissions: { actions: read, contents: read, pull-requests: write } for the coverage comment.
828
+ # # own job-level permissions: { contents: read, pull-requests: write } for the coverage comment.
891
829
  # steps: Checkout / Setup pnpm+Node / Install β†’ Build (if needed) β†’ Run Integration Tests
892
830
  # (id: vitest; --continue so one failure doesn't mask the rest; --reporter=json β†’ integration_ran) β†’
893
831
  # Report Integration Coverage on PR (davelosert, name: integration). Step detail: JOB 2 catalogue above.
@@ -118,6 +118,51 @@ for push_sha in $PUSH_SHARED_SHAS; do
118
118
  fi
119
119
  done
120
120
 
121
+ # Fast blocking checks run BEFORE the gates: each reads only git and the tree, so a failure
122
+ # stops the push in seconds instead of after the full gate. Paste fast repo extras that can
123
+ # block (seconds to ~30s, needing nothing the gates build) here too. Slow extras go below
124
+ # the gates.
125
+ #
126
+ # bkit mirror-drift gate β€” fails if `.agents/*` was edited without `bkit install`
127
+ # regenerating the `.claude/*`/`.cursor/*` mirrors (same check CI runs).
128
+ # Outside the gate scripts: it validates the bkit install, not your source.
129
+ # Fix: `pnpm bkit install`, stage the regenerated files, commit, push.
130
+ pnpm bkit check < /dev/null
131
+
132
+ # Slop base on a dev push β€” the commit CI's slop scan compares against: the head of the last
133
+ # green CI push run on dev, else origin/dev (scripts/ci/lanes/resolve-push-base.mjs, the
134
+ # script CI's planner runs, in local mode). Exported as SLOP_BASE_REF, which `bkit ci slop`
135
+ # reads, so a finding a red push already landed on dev fails here as it does in CI. Other
136
+ # branches keep the merge-base default. Skipped until scripts/ci/lanes/ holds the script.
137
+ if [ -n "$PUSH_DEV_SHA" ] && [ -f scripts/ci/lanes/resolve-push-base.mjs ]; then
138
+ PUSH_BASE_SOURCE_FILE=$(mktemp)
139
+ CI_PUSH_BASE=$(SOURCE_FILE="$PUSH_BASE_SOURCE_FILE" node scripts/ci/lanes/resolve-push-base.mjs \
140
+ --local --branch=dev --head="$PUSH_DEV_SHA" < /dev/null || echo "")
141
+ CI_PUSH_BASE_SOURCE=$(cat "$PUSH_BASE_SOURCE_FILE" 2>/dev/null || echo "unknown")
142
+ rm -f "$PUSH_BASE_SOURCE_FILE"
143
+ case "$CI_PUSH_BASE_SOURCE" in
144
+ *failed*)
145
+ echo "[pre-push] WARNING: could not read CI's last green run on dev (reason above)." >&2
146
+ echo "[pre-push] Slop compares against origin/dev, not CI's base: a finding an earlier red" >&2
147
+ echo "[pre-push] push landed passes here and still reds CI. Fix gh (gh auth status), push again." >&2
148
+ ;;
149
+ esac
150
+ if [ -n "$CI_PUSH_BASE" ]; then
151
+ export SLOP_BASE_REF="$CI_PUSH_BASE"
152
+ echo "[pre-push] slop base: $CI_PUSH_BASE ($CI_PUSH_BASE_SOURCE) β€” the base CI uses" >&2
153
+ else
154
+ echo "[pre-push] WARNING: no slop base resolved ($CI_PUSH_BASE_SOURCE) β€” slop uses its merge-base default" >&2
155
+ fi
156
+ fi
157
+
158
+ # Capability register (graphify, .bkit/templates.md Β§ graphify) β€” blocks a push to dev when
159
+ # docs/capabilities.md is not what the pushed commit builds (~30s); warn-only on other
160
+ # branches. Skipped until scripts/graphify/ holds the script, and on a min push: it changes
161
+ # no source the register is built from.
162
+ if [ "$MIN_PUSH" != "1" ] && [ -f scripts/graphify/bkit-graph-pre-push.sh ]; then
163
+ PUSH_DEV_SHA="$PUSH_DEV_SHA" IS_REVERT="$IS_REVERT" bash scripts/graphify/bkit-graph-pre-push.sh < /dev/null
164
+ fi
165
+
121
166
  # tmp/ prune β€” deletes files under tmp/ untouched for 7+ days. Not a gate: a failed
122
167
  # prune warns and the push goes on. Skipped until scripts/cleanup/ holds the script.
123
168
  if [ -f scripts/cleanup/bkit-tmp-prune.mjs ]; then
@@ -127,7 +172,7 @@ fi
127
172
 
128
173
  # WHAT each gate runs lives in package.json, not here β€” the same `bkit:gate*` scripts
129
174
  # the bkit agent workflows and prompts dispatch through. Edit the scripts, not this
130
- # hook. Repo-specific extras go BELOW this block.
175
+ # hook. Fast repo extras go ABOVE, with `bkit check`; slow ones BELOW.
131
176
  # Min push: `bkit:gate:min` only. Revert path drops the suite only: prose
132
177
  # and slop:delta still run. Otherwise the deepest push gate package.json declares.
133
178
  if [ "$MIN_PUSH" = "1" ]; then
@@ -142,14 +187,8 @@ else
142
187
  pnpm bkit:gate:static-unit < /dev/null
143
188
  fi
144
189
 
145
- # bkit mirror-drift gate β€” fails fast if `.agents/*` was edited without `bkit install`
146
- # regenerating the `.claude/*`/`.cursor/*` mirrors (same check CI runs).
147
- # Outside the gate scripts: it validates the bkit install, not your source.
148
- # Fix: `pnpm bkit install`, stage the regenerated files, commit, push.
149
- pnpm bkit check < /dev/null
150
-
151
- # Repo extras go here, above the disk prune. Slow ones (Docker, database, build) skip a
152
- # min push:
190
+ # Slow repo extras go here, above the disk prune. Ones that need Docker, a database or a
191
+ # build skip a min push:
153
192
  # if [ "$MIN_PUSH" != "1" ]; then pnpm <slow-script> < /dev/null; fi
154
193
 
155
194
  # disk prune β€” keep this block last, so it runs only once every gate above passed. Starts
@@ -0,0 +1,194 @@
1
+ #!/bin/bash
2
+ # Example. Copy into scripts/ci/ and own it.
3
+ # bkit install does not write this file and does not overwrite a copy.
4
+ #
5
+ # bkit-local-stack-lock.sh β€” one run at a time on a local stack every checkout shares.
6
+ #
7
+ # . scripts/ci/bkit-local-stack-lock.sh
8
+ # take_local_stack_lock "<who>" || exit 1 # waits while another run holds it
9
+ # try_local_stack_lock "<who>" # returns 1 at once while another run holds it
10
+ # release_local_stack_lock # optional: the lock frees itself when the caller exits
11
+ #
12
+ # bash scripts/ci/bkit-local-stack-lock.sh run "<who>" -- <command> [args…] # package.json
13
+ #
14
+ # WHY. Agents work in several worktrees of one repo at once, and every worktree talks to the
15
+ # SAME local services: a Docker database, an emulator, anything whose container names and ports
16
+ # come from the repo's config. Nothing stops two worktrees using them at once, so a database
17
+ # reset from one wipes the data under a test run in another, and a dev server that stops "its"
18
+ # stack on exit stops it under someone else's run. Both show up as test failures nobody caused.
19
+ # A run that starts, resets or stops the stack, or tests against it, takes this lock first; a
20
+ # second run waits and says who it is waiting for.
21
+ #
22
+ # Wiring:
23
+ # - package.json: wrap each script that starts, resets or stops the stack, e.g.
24
+ # "db:reset": "bash scripts/ci/bkit-local-stack-lock.sh run db:reset -- <your reset command>"
25
+ # - local runners that test against the stack: source this file and call take_local_stack_lock
26
+ # before the first command that touches the stack.
27
+ # - fix hints and docs name those scripts, never the raw command, which skips the lock.
28
+ #
29
+ # The lock is named after the stack: BKIT_LOCAL_STACK when set, otherwise the folder name of the
30
+ # repo's main checkout, so every worktree of one repo finds the same lock. A throwaway stack with
31
+ # names and ports of its own sets BKIT_LOCAL_STACK to its own name and never waits on the shared
32
+ # one. The lock file sits outside the checkout: ~/.cache/bkit/local-stack-lock/<name>.lock
33
+ # ($XDG_CACHE_HOME when set). A small perl process holds it (flock) and exits within a second of
34
+ # the caller exiting, however the caller ends (its parent changes), so a killed run cannot leave
35
+ # a stale lock behind. perl by its full path, so a PATH shim cannot stand in for it.
36
+ #
37
+ # A runner started by a runner that holds the lock (LOCAL_STACK_LOCK_OWNER, exported on success)
38
+ # does not wait on its own parent. Safe under a caller's `set -e`. CI (CI=true or CI=1): no-op,
39
+ # as a CI runner has one job and its own Docker. LOCAL_STACK_LOCK_WAIT_S (default 3600) caps
40
+ # the wait. Needs bash and /usr/bin/perl (macOS and Linux ship both).
41
+
42
+ _LOCAL_STACK_LOCK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
43
+ _LOCAL_STACK_LOCK_ROOT="$(git -C "$_LOCAL_STACK_LOCK_DIR" rev-parse --show-toplevel 2>/dev/null || echo "$_LOCAL_STACK_LOCK_DIR")"
44
+ LOCAL_STACK_LOCK_PID=""
45
+
46
+ # The stack's name: BKIT_LOCAL_STACK, else the main checkout's folder name, the same from every
47
+ # worktree. Characters outside A-Z a-z 0-9 . _ - become _.
48
+ local_stack_lock_name() {
49
+ _lsl_name="${BKIT_LOCAL_STACK:-}"
50
+ if [ -z "$_lsl_name" ]; then
51
+ _lsl_common="$(git -C "$_LOCAL_STACK_LOCK_DIR" rev-parse --path-format=absolute --git-common-dir 2>/dev/null)" || return 1
52
+ [ -n "$_lsl_common" ] || return 1
53
+ case "$(basename "$_lsl_common")" in
54
+ .git) _lsl_name="$(basename "$(dirname "$_lsl_common")")" ;;
55
+ *) _lsl_name="$(basename "$_lsl_common" .git)" ;;
56
+ esac
57
+ fi
58
+ printf '%s\n' "$_lsl_name" | LC_ALL=C tr -c 'A-Za-z0-9._\n-' '_'
59
+ }
60
+
61
+ # The lock file for the stack this checkout uses.
62
+ local_stack_lock_file() {
63
+ _lsl_stack="$(local_stack_lock_name)" || return 1
64
+ echo "${XDG_CACHE_HOME:-$HOME/.cache}/bkit/local-stack-lock/${_lsl_stack}.lock"
65
+ }
66
+
67
+ # "<who> β€” <checkout> (pid N, since HH:MM:SS)" for the run holding the lock, or nothing.
68
+ local_stack_lock_holder() {
69
+ _lsl_held="$(local_stack_lock_file)" || return 0
70
+ cat "${_lsl_held}.holder" 2>/dev/null
71
+ return 0
72
+ }
73
+
74
+ _local_stack_lock() {
75
+ _lsl_mode="$1"
76
+ _lsl_who="$2"
77
+ if [ "${CI:-}" = "true" ] || [ "${CI:-}" = "1" ]; then return 0; fi
78
+ if [ -n "${LOCAL_STACK_LOCK_OWNER:-}" ] && kill -0 "$LOCAL_STACK_LOCK_OWNER" 2>/dev/null; then return 0; fi
79
+ if [ -n "$LOCAL_STACK_LOCK_PID" ] && kill -0 "$LOCAL_STACK_LOCK_PID" 2>/dev/null; then return 0; fi
80
+
81
+ if ! _lsl_file="$(local_stack_lock_file)"; then
82
+ echo "[local-stack-lock] ❌ cannot name the local stack: run inside a git checkout, or set BKIT_LOCAL_STACK" >&2
83
+ return 1
84
+ fi
85
+ _lsl_label="$(basename "$_lsl_file" .lock)"
86
+ if [ ! -x /usr/bin/perl ]; then
87
+ echo "[local-stack-lock] ❌ could not take the lock for the local stack $_lsl_label: /usr/bin/perl not found" >&2
88
+ return 1
89
+ fi
90
+ mkdir -p "$(dirname "$_lsl_file")" || return 1
91
+ _lsl_fifo="$(mktemp -u "${TMPDIR:-/tmp}/local-stack-lock.XXXXXX")"
92
+ mkfifo "$_lsl_fifo" || return 1
93
+
94
+ # The holder answers on the fifo once: ok, busy <holder>, timeout <holder> or error <why>.
95
+ /usr/bin/perl -e '
96
+ use strict;
97
+ use Fcntl qw(:flock);
98
+ use POSIX qw(strftime);
99
+ my ($file, $owner, $who, $checkout, $fifo, $wait_s, $mode, $label) = @ARGV;
100
+ # The caller is the parent of this process. When it exits, this process goes to init (or a
101
+ # subreaper) at once, while `kill 0` would still find it until whoever started it reaps it.
102
+ my $parent = getppid();
103
+ my $caller_alive = sub { getppid() == $parent };
104
+ open(my $out, ">", $fifo) or exit 1;
105
+ $out->autoflush(1);
106
+ my $holder = sub { open(my $h, "<", "$file.holder") or return "another run"; my $l = <$h>; chomp $l; $l };
107
+ my $lock;
108
+ open($lock, ">>", $file) or do { print $out "error cannot open $file: $!\n"; exit 1 };
109
+ my $start = time;
110
+ my $next_note = 0;
111
+ until (flock($lock, LOCK_EX | LOCK_NB)) {
112
+ exit 0 unless $caller_alive->();
113
+ if ($mode eq "try") { print $out "busy " . $holder->() . "\n"; exit 0 }
114
+ if (time - $start >= $wait_s) { print $out "timeout " . $holder->() . "\n"; exit 0 }
115
+ if (time >= $next_note) {
116
+ my $m = int((time - $start) / 60);
117
+ my $so_far = $m ? " (still, $m min so far)" : "";
118
+ print STDERR "[local-stack-lock] ⏳ $who is waiting for the local stack $label$so_far: in use by " . $holder->() . "\n";
119
+ $next_note = time + 60;
120
+ }
121
+ sleep 1;
122
+ }
123
+ $SIG{TERM} = $SIG{INT} = $SIG{HUP} = sub { unlink "$file.holder"; exit 0 };
124
+ if (open(my $h, ">", "$file.holder")) {
125
+ print $h "$who β€” $checkout (pid $owner, since " . strftime("%H:%M:%S", localtime) . ")\n";
126
+ close $h;
127
+ }
128
+ print $out "ok\n";
129
+ close $out;
130
+ sleep 1 while $caller_alive->();
131
+ unlink "$file.holder";
132
+ ' "$_lsl_file" "$$" "$_lsl_who" "$_LOCAL_STACK_LOCK_ROOT" "$_lsl_fifo" "${LOCAL_STACK_LOCK_WAIT_S:-3600}" "$_lsl_mode" "$_lsl_label" </dev/null >/dev/null &
133
+ _lsl_pid=$!
134
+ # The fifo is opened read-write, so the read never blocks on a holder that died before it
135
+ # answered (a failed fork under load, a killed perl): the loop stops once it is gone.
136
+ _lsl_reply="$(
137
+ exec 3<>"$_lsl_fifo"
138
+ while :; do
139
+ if IFS= read -r -t 1 _lsl_line <&3; then
140
+ printf '%s' "$_lsl_line"
141
+ break
142
+ fi
143
+ kill -0 "$_lsl_pid" 2>/dev/null || break
144
+ done
145
+ )" || true
146
+ rm -f "$_lsl_fifo"
147
+
148
+ case "$_lsl_reply" in
149
+ ok)
150
+ LOCAL_STACK_LOCK_PID="$_lsl_pid"
151
+ export LOCAL_STACK_LOCK_OWNER="$$"
152
+ return 0
153
+ ;;
154
+ busy\ *)
155
+ echo "[local-stack-lock] the local stack $_lsl_label is in use by ${_lsl_reply#busy }" >&2
156
+ ;;
157
+ timeout\ *)
158
+ echo "[local-stack-lock] ❌ $_lsl_who gave up after ${LOCAL_STACK_LOCK_WAIT_S:-3600}s waiting for the local stack $_lsl_label, in use by ${_lsl_reply#timeout }" >&2
159
+ echo "[local-stack-lock] Let that run finish, or stop it. LOCAL_STACK_LOCK_WAIT_S sets how long to wait." >&2
160
+ ;;
161
+ "")
162
+ echo "[local-stack-lock] ❌ could not take the lock for the local stack $_lsl_label: the perl process holding it stopped before it answered" >&2
163
+ ;;
164
+ *)
165
+ echo "[local-stack-lock] ❌ could not take the lock for the local stack $_lsl_label: ${_lsl_reply#error }" >&2
166
+ ;;
167
+ esac
168
+ wait "$_lsl_pid" 2>/dev/null || true
169
+ return 1
170
+ }
171
+
172
+ take_local_stack_lock() { _local_stack_lock wait "$1"; }
173
+ try_local_stack_lock() { _local_stack_lock try "$1"; }
174
+
175
+ release_local_stack_lock() {
176
+ [ -n "$LOCAL_STACK_LOCK_PID" ] || return 0
177
+ kill "$LOCAL_STACK_LOCK_PID" 2>/dev/null || true
178
+ wait "$LOCAL_STACK_LOCK_PID" 2>/dev/null || true
179
+ LOCAL_STACK_LOCK_PID=""
180
+ unset LOCAL_STACK_LOCK_OWNER
181
+ return 0
182
+ }
183
+
184
+ if [ "${BASH_SOURCE[0]}" = "$0" ]; then
185
+ if [ "${1:-}" != "run" ] || [ -z "${2:-}" ]; then
186
+ echo "usage: bash scripts/ci/bkit-local-stack-lock.sh run \"<who>\" -- <command> [args…]" >&2
187
+ exit 2
188
+ fi
189
+ _lsl_run_who="$2"
190
+ shift 2
191
+ [ "${1:-}" = "--" ] && shift
192
+ take_local_stack_lock "$_lsl_run_who" || exit 1
193
+ "$@"
194
+ fi
@@ -12,8 +12,7 @@
12
12
  * - the plan does not parse (not JSON, not an object, or no `run_level`),
13
13
  * - the planner job (`SCOPE_RESULT`) did not succeed,
14
14
  * - no lane is named, or a lane's result was never wired in.
15
- * It asserts nothing for a lane that `<LANE>_CACHE_SKIP=true` marks as proven on a cached
16
- * SHA, and nothing about a skipped lane when `run_level` is `none`.
15
+ * It asserts nothing about a skipped lane when `run_level` is `none`.
17
16
  *
18
17
  * Environment:
19
18
  * LANES comma-separated lane names, e.g. `static,unit`. The job named
@@ -23,7 +22,6 @@
23
22
  * <LANE>_RAN `needs.<job>.outputs.tests_ran`. Setting the variable (even empty)
24
23
  * makes the lane counted: it must report a number above 0. A lane
25
24
  * with no such variable is not count-checked.
26
- * <LANE>_CACHE_SKIP `needs.<job>.outputs.cache_skip`; `true` skips the count check.
27
25
  * PLAN optional planner JSON (`needs.bkit-tests-scope.outputs.plan`). Unset
28
26
  * means every listed lane is expected to run. Set, it must parse and
29
27
  * carry a `run_level`; `none` expects every lane to be skipped.
@@ -128,7 +126,7 @@ export function checkCapstone(env) {
128
126
 
129
127
  const ranKey = `${prefix}_RAN`;
130
128
  const counted = Object.hasOwn(env, ranKey);
131
- if (!counted || env[`${prefix}_CACHE_SKIP`] === "true") {
129
+ if (!counted) {
132
130
  parts.push(`${lane}=${result}`);
133
131
  continue;
134
132
  }