@biffo/cli 0.253.7 → 0.253.9

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.
@@ -89,9 +89,21 @@ fi
89
89
  # branches are fine, and noise kills a gate. Measured on a branch that DOES
90
90
  # name one: the added latency is the cost of two `gh` lookups, similar in
91
91
  # order of magnitude to `rewrite-scope-check` above.
92
+ #
93
+ # BIFFO_SKIP_CLAIM_GUARD -- narrow, claim-only escape hatch (#1327). Before
94
+ # this, the only documented way past a false positive here was
95
+ # BIFFO_SKIP_VERIFY at the top of this file, which does not target the claim
96
+ # guard: it skips the WHOLE gate -- ruff, pyright, bandit, gitleaks,
97
+ # rewrite-scope, this guard, everything. An agent reading "skip the claim
98
+ # guard" reasonably reaches for the only hatch documented and gets "skip
99
+ # everything" instead; one did, in the session #1327 was filed from. This
100
+ # variable bypasses exactly the `claim --guard` call below and nothing else --
101
+ # rewrite-scope-check, the pg-test block gate and `verify` all still run.
92
102
  branch=$(git symbolic-ref --quiet --short HEAD) || branch=""
93
103
 
94
- if [ -n "$branch" ]; then
104
+ if [ -n "${BIFFO_SKIP_CLAIM_GUARD:-}" ]; then
105
+ echo "pre-push: claim guard skipped (BIFFO_SKIP_CLAIM_GUARD set) -- the rest of the gate still runs." >&2
106
+ elif [ -n "$branch" ]; then
95
107
  sh scripts/biffo.sh claim --guard "$branch"
96
108
  claim_status=$?
97
109
 
@@ -89,9 +89,21 @@ fi
89
89
  # branches are fine, and noise kills a gate. Measured on a branch that DOES
90
90
  # name one: the added latency is the cost of two `gh` lookups, similar in
91
91
  # order of magnitude to `rewrite-scope-check` above.
92
+ #
93
+ # BIFFO_SKIP_CLAIM_GUARD -- narrow, claim-only escape hatch (#1327). Before
94
+ # this, the only documented way past a false positive here was
95
+ # BIFFO_SKIP_VERIFY at the top of this file, which does not target the claim
96
+ # guard: it skips the WHOLE gate -- ruff, pyright, bandit, gitleaks,
97
+ # rewrite-scope, this guard, everything. An agent reading "skip the claim
98
+ # guard" reasonably reaches for the only hatch documented and gets "skip
99
+ # everything" instead; one did, in the session #1327 was filed from. This
100
+ # variable bypasses exactly the `claim --guard` call below and nothing else --
101
+ # rewrite-scope-check, the pg-test block gate and `verify` all still run.
92
102
  branch=$(git symbolic-ref --quiet --short HEAD) || branch=""
93
103
 
94
- if [ -n "$branch" ]; then
104
+ if [ -n "${BIFFO_SKIP_CLAIM_GUARD:-}" ]; then
105
+ echo "pre-push: claim guard skipped (BIFFO_SKIP_CLAIM_GUARD set) -- the rest of the gate still runs." >&2
106
+ elif [ -n "$branch" ]; then
95
107
  sh scripts/biffo.sh claim --guard "$branch"
96
108
  claim_status=$?
97
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.253.7",
3
+ "version": "0.253.9",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/scripts/verify.sh CHANGED
@@ -681,6 +681,11 @@ fi
681
681
  # shrinking with every test the suite gains. Doubled to 240s, the same
682
682
  # doubling this file already suggests as the retry (below) -- comfortable
683
683
  # headroom today, and re-measure this comment again once it stops being so.
684
+ #
685
+ # Raising the number was the smaller half of that fix and it does not scale: a
686
+ # lane growing 310 -> 946 tests in four days outruns any constant. The other
687
+ # half is below -- the lane now runs CONCURRENTLY where it safely can, which is
688
+ # what actually bends the curve.
684
689
  PG_TEST_BUDGET_SECONDS="${BIFFO_VERIFY_PG_BUDGET:-240}"
685
690
  PG_TEST_DSN="${BIFFO_TEST_PG_DSN:-${TABSII_TEST_PG_DSN:-}}"
686
691
 
@@ -703,12 +708,71 @@ pg_test_modules() {
703
708
  # success. A green gate that ran nothing is the exact shape this whole lane
704
709
  # exists to end, so the summary line is asserted rather than trusted -- the same
705
710
  # assertions its CI workflow makes, for the same reason.
711
+
712
+ # Run the lane concurrently where that is safe, serially where it is not.
713
+ #
714
+ # ## Why the lane can be shared at all
715
+ #
716
+ # It runs against ONE database. Most modules tolerate that because each owns a
717
+ # distinct tenant UUID namespace and its own Postgres role -- which is the same
718
+ # property that makes them safe to run beside each other. A minority are not:
719
+ # they perform DDL with fixed object names, or they sweep `pg_class` /
720
+ # `information_schema` and assert over every table, so they see rows another
721
+ # module created. Those declare `pytest.mark.serial` and run in a second pass.
722
+ #
723
+ # `--dist loadfile` is load-bearing, not a tuning knob: it keeps every test in
724
+ # a file on ONE worker, so a module's fixtures and its tenant namespace stay
725
+ # within a single process. Splitting by test would break exactly the isolation
726
+ # this relies on.
727
+ #
728
+ # ## Why it degrades rather than fails when xdist is absent
729
+ #
730
+ # `pytest-xdist` is declared beside pytest, so a synced repo has it. A repo
731
+ # that has not re-synced does not, and `-n` would then abort the whole lane
732
+ # with a usage error -- a gate failing over its own dependency rather than over
733
+ # the code, which is the fail-closed nuisance that teaches people to reach for
734
+ # BIFFO_SKIP_VERIFY. It falls back to one undivided pass and says so, which is
735
+ # correct and merely slower.
736
+ pg_xdist_ready() {
737
+ uv run --directory "$1" python -c "import xdist" >/dev/null 2>&1
738
+ }
739
+
706
740
  pg_test_run() {
707
741
  _out="/tmp/biffo-verify-pg.$$"
708
742
  _pg_started=$(date +%s)
709
- TABSII_TEST_PG_DSN="$PG_TEST_DSN" BIFFO_TEST_PG_DSN="$PG_TEST_DSN" \
710
- timeout "$PG_TEST_BUDGET_SECONDS" uv run --directory "$1" pytest -q $2 >"$_out" 2>&1
711
- _pg_rc=$?
743
+
744
+ if pg_xdist_ready "$1"; then
745
+ TABSII_TEST_PG_DSN="$PG_TEST_DSN" BIFFO_TEST_PG_DSN="$PG_TEST_DSN" \
746
+ timeout "$PG_TEST_BUDGET_SECONDS" uv run --directory "$1" \
747
+ pytest -q -m 'not serial' -n auto --dist loadfile $2 >"$_out" 2>&1
748
+ _pg_rc=$?
749
+
750
+ # Only if the parallel pass actually passed. A failure there is the answer
751
+ # already, and running the serial pass on top would append a second summary
752
+ # line that the "did it exercise anything" grep below would happily match.
753
+ if [ "$_pg_rc" -eq 0 ]; then
754
+ _pg_left=$((PG_TEST_BUDGET_SECONDS - ($(date +%s) - _pg_started)))
755
+ [ "$_pg_left" -lt 10 ] && _pg_left=10
756
+ TABSII_TEST_PG_DSN="$PG_TEST_DSN" BIFFO_TEST_PG_DSN="$PG_TEST_DSN" \
757
+ timeout "$_pg_left" uv run --directory "$1" \
758
+ pytest -q -m serial $2 >>"$_out" 2>&1
759
+ _pg_rc=$?
760
+ # pytest exits 5 for "no tests collected", which is the CORRECT outcome
761
+ # in a repo where nothing is marked serial yet. Treating it as a failure
762
+ # would make this change break every such repo on adoption.
763
+ [ "$_pg_rc" -eq 5 ] && _pg_rc=0
764
+ fi
765
+ else
766
+ # A FLAG rather than a printf, because this function's whole output is
767
+ # redirected to a temp file the call site prints only when the lane FAILS.
768
+ # Printing here would make the one case that most needs saying -- the lane
769
+ # passed, but slowly and un-split -- the one case nobody ever sees.
770
+ PG_XDIST_MISSING=1
771
+ TABSII_TEST_PG_DSN="$PG_TEST_DSN" BIFFO_TEST_PG_DSN="$PG_TEST_DSN" \
772
+ timeout "$PG_TEST_BUDGET_SECONDS" uv run --directory "$1" pytest -q $2 >"$_out" 2>&1
773
+ _pg_rc=$?
774
+ fi
775
+
712
776
  _pg_elapsed=$(($(date +%s) - _pg_started))
713
777
 
714
778
  # `timeout` exits 124 when it kills the command (137 if SIGKILL was needed).
@@ -908,6 +972,12 @@ else
908
972
  sed 's/^/ /' "/tmp/biffo-verify-pg-check.$$" | tail -25
909
973
  ;;
910
974
  esac
975
+ if [ -n "${PG_XDIST_MISSING:-}" ]; then
976
+ printf ' \033[33m%s\033[0m\n' \
977
+ "pytest-xdist is not installed, so the lane ran in one undivided pass"
978
+ printf ' \033[90m%s\033[0m\n' \
979
+ "re-run 'uv sync' to get the parallel pass back (biffo-template#703)"
980
+ fi
911
981
  rm -f "/tmp/biffo-verify-pg-check.$$"
912
982
  fi
913
983
  fi