Skip to content

fix: exclude local test modules from the source index (BootUI 2.6.0) - #384

Draft
ffroliva wants to merge 142 commits into
mainfrom
feat/0.11.0-t2.1-test-modules
Draft

ffroliva wants to merge 142 commits into
mainfrom
feat/0.11.0-t2.1-test-modules

Conversation

@ffroliva

@ffroliva ffroliva commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Summary

Task 2.1 of the 0.11.0 plan (#367), row A14 of the BootUI 2.6.0 delta: the source index excludes the application's
own test modules, so architecture rules and every other reader of the index (FastAPI advisor, config scan, security
static rules, import graph, REST API tools) no longer report findings on test code, as BootUI 2.6.0
ArchitectureRuleSupport.isTestOutput excludes test output before any rule runs.

  • src/sharpit/engine/appsource.py: is_test_module(name_parts, filename) matches a path segment or a module file
    named tests, test or testing, and the files conftest.py, test_*.py and *_test.py; it never matches by
    substring (attestation.py, contests.py, backtest.py stay indexed). The index records the dotted names it
    skipped (excluded_tests), and skipped files do not use the file budget.
  • src/sharpit/engine/collectors/architecture/graph.py: imports resolve to the longest known module as before; an
    import of a skipped test module stays a visible edge to an unresolved target, as BootUI keeps production
    dependencies on test targets.
  • src/sharpit/engine/collectors/architecture/report.py: a package with no production module is scanned with zero
    rules evaluated and evidence.usable = false, as BootUI's ArchitectureScanner does for an empty class set.
  • src/sharpit/engine/collectors/architecture/rules.py: ARCH-CODE-013 uses the same predicate.
  • docs/reference/matrix-updates/0.11.0-rules.tsv: row A14 (adapted: Python source modules instead of compiled test
    output; JAR archives and bytecode subtype projection have no counterpart).

Behaviour change for users: findings in modules under tests/, test/ or testing/, or in conftest.py,
test_*.py, *_test.py, tests.py, test.py or testing.py, are no longer reported. A production package named
testing is excluded too.

Review scope

The branch was cut from the 0.11.0 integration line, so against main the diff also shows the earlier 0.11.0 pull
requests. This pull request's changes are the files above and their tests (tests/engine/test_appsource.py,
tests/engine/collectors/architecture/, tests/fastapi/test_error_contract_introspection.py).

Red evidence

Tests were committed before each change; each red is an assertion (scripts/dev/red_check.py).

Finding Test Red
ARCH-CODE-001 reported app.tests.test_x and app.conftest test_test_modules_excluded_from_index, test_recognized_test_modules_do_not_add_findings_or_application_classes assertion
A test-only package counted as usable evidence test_test_only_package_is_complete_empty_but_not_usable_application_evidence assertion
Production cycles through test packages test_test_only_package_back_edges_disappear_but_real_production_cycles_remain, test_real_production_dependencies_on_internal_test_targets_are_not_waived assertion
A function named like a test hid a production cycle (review) test_from_imported_function_resolves_to_longest_known_module assertion
An import of a missing module no longer resolved to its parent (review) test_cycle_is_kept_when_import_target_is_missing assertion
A tests.py module file stayed indexed (review) test_test_module_files_are_excluded_from_index assertion

The BootUI tests ported (# ported:) come from ArchitectureTestOutputIsolationTests.
tests/fastapi/test_error_contract_introspection.py now points its source-index test at a non-test package, because
the module it used is a test module and is excluded by design.

Verification

uv run ruff check, uv run ruff format --check, uv run pyright (0 errors); 18005 passed over the engine, FastAPI,
Flask, parity, docs, CLI, masking and root tests; the three overhead budget tests that failed under parallel load
pass alone. The full suite runs in CI.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
… file

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…e protocol

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
The Origin header is parsed as scheme://host[:port] with an http or https scheme, as BootUI 2.6.0 does: a path (a trailing slash included), query, fragment, userinfo, control character, trailing colon, unsupported scheme or a port above 65535 makes the origin unreadable, and an unreadable origin is cross-site. The value is no longer trimmed.\n\nA port of more than five digits is refused before int() converts it, in the origin and in the request's own Host, so a very long port is a cross-site refusal and no longer an unhandled ValueError. Adds a property test of the origin parser.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…UI 2.6.0)

A write that carries Sec-Fetch-Site must send same-origin or none (ASCII, case-insensitive); same-site, cross-site, an empty value and any unknown value are refused. A present but empty Origin header is an unreadable origin and is cross-site, no longer read as absent. A same-site navigation GET still loads the shell, and an API path still requires the request's own scheme, host and port. A request whose own origin cannot be formed stays cross-site where that comparison applies.\n\nDocuments the rule in SECURITY.md and the BootUI contract note, and records the deviations in the 0.11.0 guard matrix fragment.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Record the two deviations of the inactivity log from BootUI 2.6.0 in a matrix fragment, update the MVP plan text that still described the old log line, extract the inactivity logging of install() into a helper to keep its complexity at the pinned count, and wrap one over-long test assertion.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
An invalid SHARPIT_ENABLED must log exactly one record, the fixed warning, as BootUI does. The count of the remaining configuration warnings stays.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
An invalid SHARPIT_ENABLED is already reported by the fixed inactive warning. Counting its settings warning as well produced a second WARNING record, where BootUI logs one.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
…tests

Port BootUiInactiveStartupDiagnosticTests.deliberateDisablementIsSilentAtInfo, cite the BootUI tests the other inactivity tests port, and keep the expected log texts in one test module. A single Inactivity alias types the inactivity category. The matrix row for the warning count records that it leaves out the invalid SHARPIT_ENABLED warning.

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>

# Conflicts:
#	tests/fuzz/test_trust_boundary_fuzz.py
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
# Conflicts:
#	docs/reference/matrix-updates/0.11.0-rules.tsv
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
… (A14, review)

Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>
Signed-off-by: Flavio Oliva <ffroliva@gmail.com>

This branch has not been deployed

No deployments
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