Skip to content

fix: quarantine burndown round 2 — empty the test-quarantine ledger (36 → 0)#142

Merged
cryptoxdog merged 1 commit into
mainfrom
fix/quarantine-burndown-2
Jul 23, 2026
Merged

fix: quarantine burndown round 2 — empty the test-quarantine ledger (36 → 0)#142
cryptoxdog merged 1 commit into
mainfrom
fix/quarantine-burndown-2

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

Summary

Quarantine burndown, round 2. This PR fixes all 36 remaining ledgered test failures and empties the quarantine ledger (.l9/baselines/test-quarantine.yml: 36 → 0 entries). Combined with #140 (61 → 36), the repository now has zero known test debt.

Root-cause groups and fixes

Group Ledgered tests Root cause Fix
Transport packet contracts (C06/C07/C08) 4 constellation-node-sdk never installed, packet-protocol contract tests could not import it Added the public SDK as a git dependency in requirements.txt; tests now exercise TransportPacket for real
Engine structure contracts (C16/C18) 2 Contract allowlist predated real engine dirs (arbitration, outcomes, auth, diagnostics, hoprag, models); 15 engine modules lacked L9_META headers Extended the allowlist to match the actual architecture; added conformant L9_META headers to all 15 modules
Gap-1 content_hash drift 4 Builders hashed {entity_type, batch} / {proposed_fields, provenance} while the verifier hashed the full canonical set including tenant_id — every packet failed verification Extracted a shared _compute_content_hash helper in engine/contract_enforcement.py; builders and verifier now hash the identical canonical field set
Chassis bridge (C02 / T5-03) 2 engine/security/P2_9_llm_schemas.py imported chassis.errors directly, violating the single-bridge contract FeatureNotEnabled is now re-exported through engine/handlers.py (the sanctioned bridge); the security module imports it from there
Resilience invariants (T601/T603/T605) 4 Tests targeted module-level globals (_graph_driver, _loader_lock) removed by the W4-01 EngineState refactor Rewrote tests against the EngineState singleton (get_state()), with proper snapshot/restore fixtures
Trust boundary (T103) 3 Same W4-01 drift: tenant allowlist moved into EngineState Rewrote the three tenant-isolation tests against the state singleton
Compliance security 4 Tests used stale APIs: DomainPackLoader(domains_dir=...) and ComplianceEngine.evaluate(...) Rewrote against real APIs: DomainPackLoader(config_path=...), check_match_request(tenant=, query=, match_direction=)
Handlers outcome mock 1 MagicMock chain leaked a non-string outcome_node_label into sanitize_label Pinned feedbackloop mock config to concrete values in the spec factory
Wave6 dormant-feature LLM test 1 Test hit a live LLM backend whenever OPENAI_API_KEY was set in the environment; error message also didn't contain "LLM" Made the test hermetic (clears the key, resets the cached backend); FeatureNotEnabled message is now prefixed with the feature name
Order-dependent asyncio flakes 11 Deprecated asyncio.get_event_loop().run_until_complete() raises RuntimeError once any earlier test closes the loop (Python 3.12) Replaced with asyncio.run() in test_algorithmic_upgrades, test_pareto_wiring, test_chassis_app

Also fixed while in the area: two mypy unreachable false positives in engine/packet_bridge.py defensive payload guards (explicit Any annotation with rationale).

Verification

  • Unit / contract / invariant / security suites: 1607 passed, 0 failed (11 skipped, 56 xfailed — all pre-existing not-implemented skips)
  • Integration + performance suites vs Neo4j 5.18-enterprise: 53 passed, 0 failed
  • The exact 36 ledgered node IDs were run as a batch: 36/36 pass
  • ruff check / ruff format --check: clean on all touched files
  • mypy engine/ (CI invocation): Success: no issues found in 131 source files
  • Terminology guard patterns (print(, Optional[, List[, Dict[, Tuple[, Set[, log., Substrate): no matches in changed files

Ratchet impact

The ledger may only shrink; this PR shrinks it to zero. No entries were removed for tests that still fail — every removed entry was verified passing both individually and in full-suite order.

Size note

909 changed lines across 29 files — under the 1,000-line review gate. The change is one atomic unit: ledger pruning is only valid together with the fixes that make the ledgered tests pass.

…36 -> 0)

Fixes every remaining ledgered failure so the quarantine ledger is now empty:

- Contract 06/07/08 (transport packet): add public constellation-node-sdk
  git dependency to requirements.txt so packet-protocol contract tests run.
- Contract 16/18: allow real engine dirs (arbitration, outcomes, auth,
  diagnostics, hoprag, models) in the top-level dir contract; add L9_META
  headers to 15 engine modules that lacked them.
- Gap-1 content_hash drift: extract shared _compute_content_hash helper in
  engine/contract_enforcement.py so builders and verifier hash the same
  canonical field set (tenant_id included, tenant_context excluded).
- T5-03 / Contract 02 chassis bridge: engine/security/P2_9_llm_schemas.py no
  longer imports chassis directly; FeatureNotEnabled is re-exported through
  engine/handlers.py (the sanctioned chassis bridge).
- T601/T603/T605 resilience + T103 trust boundary: rewrite tests against the
  W4-01 EngineState singleton instead of removed module-level globals.
- Compliance security tests: use real DomainPackLoader(config_path=...) and
  ComplianceEngine.check_match_request API.
- test_outcomes_success: pin feedbackloop mock config so MagicMock chains
  never leak into sanitize_label.
- Wave6 LLM test: hermetic (clears OPENAI_API_KEY, resets backend);
  FeatureNotEnabled message now self-describing (prefixed with feature name).
- Order-dependent asyncio flakes: replace deprecated
  asyncio.get_event_loop().run_until_complete() with asyncio.run() in
  test_algorithmic_upgrades, test_pareto_wiring, test_chassis_app.
- mypy: silence false-positive unreachable warnings in packet_bridge
  defensive payload guards.

Local verification: 1607 passed (unit/contract/invariant/security),
53 passed (integration+performance vs Neo4j 5.18-enterprise), 0 failed.
ruff check/format clean, mypy clean, terminology guard clean.
@github-actions

Copy link
Copy Markdown

⚠️ Large PR Warning
Reviewable lines changed: 909
Warning threshold: 300 lines
Consider splitting for easier review

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Exclude it from reviewable-size accounting

This PR passes the blocking limit but is larger than recommended.

@sonarqubecloud

Copy link
Copy Markdown

Comment thread engine/handlers.py
# T5-03: handlers.py is the sanctioned chassis bridge. Re-export chassis
# error types here so other engine modules can use them without importing
# chassis directly.
from chassis.errors import FeatureNotEnabled # noqa: F401
cryptoxdog added a commit that referenced this pull request Jul 23, 2026
type=sha,prefix={{branch}}- resolved {{branch}} to an empty string on
pull_request events (ref is refs/pull/N/merge, not a branch ref),
producing the invalid tag ":-<sha>" and failing "Build & Push
Container" on every PR (confirmed on #141 and #142 build logs:
"invalid tag ...:-bb7e3af: invalid reference format"). A static
sha- prefix works identically on push and pull_request events.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cryptoxdog
cryptoxdog merged commit 8be58df into main Jul 23, 2026
39 of 46 checks passed
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