Skip to content

chore(ci): run the slow-marked backend guardrails — they have never run, and #12701 slipped past the LLM inventory pin because of it - #12727

Merged
Git-on-my-level merged 1 commit into
mainfrom
chore/backend-guardrail-lane
Sep 4, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
chore/backend-guardrail-lane

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

The repository's codebase guardrails have never run in CI

backend/scripts/run-unit-ci.sh is the only backend unit lane, and it runs
not integration and not slow. No workflow anywhere overrides that mark
expression. So every test marked @pytest.mark.slow — 22 files, 126
assertions, including coverage ratchets, hermeticity contracts, the
direct-provider boundary guardrail and the LLM-endpoint inventory pin —
executes nowhere.

This is not one author's slip. backend/tests/README.md instructs that
codebase-wide greps be marked slow "rather than being allowlisted", and the
duration-allowlist header repeats it. The rule assumes slow means runs in
some other lane
. There was no other lane.

It is already costing us. #12701 (belief model) added two managed get_llm
call sites:

utils/memory/belief_backfill.py::feature:<dynamic>
utils/memory/belief_evidence.py::feature:memory_conflict

test_managed_call_sites_absent_from_the_inventory_fail_ci rejects both. It
merged anyway, within an hour of the pin landing, because nothing ran the pin.
That is the exact failure the pin was written to prevent, on its first
opportunity.

The cost premise does not survive measurement either. These are greps, not
stress tests:

LLM-inventory pin alone 2.6s
All 19 manifest files, one session 31s, 126 passed

What this adds

  • backend/scripts/run-slow-guardrails-ci.sh — runs slow and not integration over the files named in a manifest. It fails loudly if the
    manifest is missing, names a file that does not exist, or selects nothing: a
    lane that runs zero tests must not pass.

  • backend/tests/slow_guardrail_manifest.txt — the 19 files that are green
    today, and, named in the header rather than silently omitted, the three that
    are not:

    tests/unit/test_subscription_restructure.py        32 failed, 2 passed
    tests/unit/test_firestore_query_coverage_ratchet.py     1 failed, 1 passed
    tests/unit/test_sys_modules_hermeticity.py              1 failed, 1 passed
    

    Each needs its own fix and its own PR. Listing them keeps the gap countable
    instead of invisible — which is the whole failure being repaired here.

  • One step in backend-unit-tests.yml, unselected and unconditional. A
    guardrail whose job is to notice a change nobody anticipated cannot be gated
    on the change set that triggered the run — that is the second half of why
    feat(memory): belief model — weights, not deletion (flag-gated) #12701 slipped through, since the file it changed does not select the test
    that pins it.

  • The two missing inventory rows, so the pin is green the moment it starts
    running. Both belong to langchain_feature_routing: they are internal
    memory-formation calls reached through canonical_memory_adapter, not a new
    user-triggerable entrypoint.

  • tests/README.md — the rule that produced this is now qualified, so the
    next guardrail author lands in the lane instead of outside it.

Automatic-or-dead check

The lane is its own check, and it is not vacuous by construction: delete the
manifest, empty it, or list a path that does not exist and
run-slow-guardrails-ci.sh exits non-zero rather than reporting success over
nothing. Revert either inventory row and
test_managed_call_sites_absent_from_the_inventory_fail_ci fails in CI —
which is the thing that was not true before this PR.

Proof

  • PYTHON=.venv/bin/python bash scripts/run-slow-guardrails-ci.sh →
    126 passed, 516 deselected, 31.03s.
  • Red-proof on the real inventory file: with the two rows removed,
    pytest -m slow tests/unit/test_llm_gateway_coverage_guardrails.py →
    AssertionError: managed call sites absent from the inventory: utils/memory/belief_backfill.py::feature:<dynamic>; utils/memory/belief_evidence.py::feature:memory_conflict. Restored by
    putting the lines back, not by git checkout.
  • Every slow-marked unit file measured individually to build the manifest; the
    three exclusions are the measured failures, not guesses.

Cut list

  • Fixing the three red files. Each is someone's owned surface and deserves its
    own diagnosis; bundling them here would make this PR unreviewable and would
    couple a CI-plumbing change to three unrelated product judgements.
  • Extending the lane to tests/services/ or tests/integration/.
  • Any change to what run-unit-ci.sh selects. The PR lane keeps its latency
    budget exactly as it is; this is a second, additive lane.

Product invariants

none — no locked invariant path glob matched.

Failure class

No fix: commits in this range.

Failure-Class: none

🤖 Generated with Claude Code

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Confidence score: 3/5

  • backend/scripts/run-slow-guardrails-ci.sh can pass when the manifest contains existing files even if the selected slow-test set is empty or incomplete, allowing newly added @pytest.mark.slow tests to be omitted from CI coverage; strengthen the guard to verify the selected set is non-empty and complete.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/scripts/run-slow-guardrails-ci.sh">

<violation number="1" location="backend/scripts/run-slow-guardrails-ci.sh:43">
P2: The lane's non-vacuity guard only checks that the manifest lists existing files, not that the slow test set it selects is non-empty or complete. A newly added @pytest.mark.slow test file is still selected by select_backend_unit_tests.py --all (so check_unit_test_discovery.py will not flag it), but it is excluded from the fast lane by `not slow` and, unless the author manually adds it to the manifest, never runs in this lane either — the exact "slow guardrail runs nowhere" failure #12701 slipped past. The manifest comment documents manual enrollment ("Files are added, never silently dropped"), but nothing enforces it. Consider a check that every slow-marked file under tests/unit/ is present in the manifest (or that pytest collection with the -m expression is non-empty), so a slow test can't silently drop out of both lanes.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

fi

echo "Running slow-marked guardrails across ${#files[@]} file(s)."
exec "$PYTHON_BIN" -m pytest -q -p no:cacheprovider -m "slow and not integration" "${files[@]}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The lane's non-vacuity guard only checks that the manifest lists existing files, not that the slow test set it selects is non-empty or complete. A newly added @pytest.mark.slow test file is still selected by select_backend_unit_tests.py --all (so check_unit_test_discovery.py will not flag it), but it is excluded from the fast lane by not slow and, unless the author manually adds it to the manifest, never runs in this lane either — the exact "slow guardrail runs nowhere" failure #12701 slipped past. The manifest comment documents manual enrollment ("Files are added, never silently dropped"), but nothing enforces it. Consider a check that every slow-marked file under tests/unit/ is present in the manifest (or that pytest collection with the -m expression is non-empty), so a slow test can't silently drop out of both lanes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At backend/scripts/run-slow-guardrails-ci.sh, line 43:

<comment>The lane's non-vacuity guard only checks that the manifest lists existing files, not that the slow test set it selects is non-empty or complete. A newly added @pytest.mark.slow test file is still selected by select_backend_unit_tests.py --all (so check_unit_test_discovery.py will not flag it), but it is excluded from the fast lane by `not slow` and, unless the author manually adds it to the manifest, never runs in this lane either — the exact "slow guardrail runs nowhere" failure #12701 slipped past. The manifest comment documents manual enrollment ("Files are added, never silently dropped"), but nothing enforces it. Consider a check that every slow-marked file under tests/unit/ is present in the manifest (or that pytest collection with the -m expression is non-empty), so a slow test can't silently drop out of both lanes.</comment>

<file context>
@@ -0,0 +1,43 @@
+fi
+
+echo "Running slow-marked guardrails across ${#files[@]} file(s)."
+exec "$PYTHON_BIN" -m pytest -q -p no:cacheprovider -m "slow and not integration" "${files[@]}"
</file context>

… hour

`run-unit-ci.sh` is the only backend unit lane and it runs `not integration and
not slow`. Nothing overrides that mark expression anywhere, so 22 files and 126
assertions — coverage ratchets, hermeticity contracts, the direct-provider
boundary, the LLM-endpoint inventory pin — have been executing nowhere.

The README told authors to mark codebase greps `slow` rather than allowlist
them, which is a sound rule if `slow` means "runs in the other lane". There was
no other lane, and an exact-set pin that fails nothing is a comment.

It is not hypothetical. #12701 added two managed `get_llm` call sites that
`test_managed_call_sites_absent_from_the_inventory_fail_ci` rejects, and merged
anyway, within an hour of that pin landing, because nothing ran it. The file it
changed also does not select the test that pins it, which is why the new lane is
unconditional: a check whose job is to notice a change nobody anticipated cannot
be gated on the change set that triggered the run.

The cost premise does not survive measurement. The pin runs in 2.6 seconds; all
19 currently-green files run in 31.

The three files that are red today are named in the manifest header rather than
omitted from it, so the gap stays countable. Each needs its own fix.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level force-pushed the chore/backend-guardrail-lane branch from aeccfc3 to c094859 Compare September 4, 2026 08:31
@Git-on-my-level
Git-on-my-level merged commit 84ec103 into main Sep 4, 2026
38 checks passed
@Git-on-my-level
Git-on-my-level deleted the chore/backend-guardrail-lane branch September 4, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant