Test coverage baseline and critical-boundary map

Status: informational repository evidence for STAB-2/SEC-5. This is not a release gate, a security certification, or a claim of exhaustive behavior. There is deliberately no percentage threshold.

Coverage measures only the django_asklens package. The configuration enables branch measurement, includes package files that tests do not import, and reports missing lines and partial branches. Coverage is a navigation aid: executing a line or branch does not prove that its authorization, privacy, or semantic invariants were asserted.

0.2.0 technical acceptance audit

Recorded on 2026-09-23 against clean main and origin/main at 0c80aab0bddc22ac0fd47ca2d07d965bf506827c. No tracked files were changed by the audit itself.

Accepted technical paths

  1. Clean SQLite demo setup, migrations, and seed passed.
  2. Anonymous frontend and API denial passed.
  3. The facility-owner path proved North-only scope, offline aggregate execution, typed result metadata, the raw response, and metadata-only audit.
  4. Authenticated catalog, capabilities/help, question, and submitted-plan API paths passed, including rejection of client-controlled tenant and scope input.
  5. The no-report path proved opaque denial and safe account recovery.
  6. Admin help remained distinct from data querying, and the audit UI remained immutable.
  7. Representative-role, cross-scope, and unauthorized-resource checks passed.
  8. MCP transport and tools passed with server-owned identity, execute-time revalidation, and default row omission.
  9. Live-provider validation was intentionally skipped because external provider spending was not authorized. Local dummy/provider boundaries passed.
  10. The PostgreSQL 18 reference workflow passed its Playwright browser/API/MCP smoke and project-scoped teardown.
  11. Schemas, draft specification, and conformance fixtures passed. The specification remains draft and unversioned; one Django implementation is not independent portability proof.
  12. Cleanup passed, and the final worktree was clean.

Exact audit evidence

Evidence Result
Full SQLite suite 1172 passed, 11 skipped
Contract/conformance subset 77 passed, 1 skipped
Ruff lint passed
Ruff formatting 206 files already formatted
compileall passed
Django system check passed
Migration drift no changes detected
Build wheel and sdist passed
Twine both artifacts passed
Locked dependency audit no known vulnerabilities or adverse statuses in 104 packages
Isolated source-wheel installs core, API, and MCP passed
Historical published-0.1.0a1 replacement/migration-preservation smoke passed
Core exact-wheel quickstart smoke passed
Authenticated API exact-wheel quickstart smoke passed
PostgreSQL 18 reference browser/API/MCP smoke passed
Final Git state clean main == origin/main at 0c80aab0bddc22ac0fd47ca2d07d965bf506827c

The first quickstart smoke attempt failed because generated ignored django_asklens.egg-info metadata in the repository root shadowed the temporary virtual-environment distribution during importlib.metadata lookup. After removing only generated build/ and egg-info artifacts and rerunning from the documented clean source state, both core and API quickstart smokes passed. This is recorded as local test-environment contamination, not a product blocker or a documentation/script defect.

Interpretation and release boundary

At the audited commit, package metadata and PyPI both reported 0.1.0a1; that historical audit predates the 0.2.0 release. The 0.2.0 release does not claim a supported upgrade from the 0.1.0a1 testing artifact.

Tagging, the GitHub release, and PyPI upload were separately gated and were not performed by this historical audit.

R5/R6 and independent security review were previously waived as gates for this first 0.2.0 release. That waiver does not create evidence that was not run. No live-provider, external-pilot, independent-security-review, production-certification, second-implementation, or backend-neutral evidence exists. The draft, unversioned specification and one Django implementation are not SemVer permanence, production certification, NDC compliance, or multi-backend conformance.

Reproduce the baseline

From a development checkout with the locked development group installed:

uv sync --locked --group dev
bash scripts/coverage-baseline.sh

The script prints the current Git branch and commit, erases stale .coverage data, runs the complete default SQLite suite, and prints the package report. It passes no --fail-under value. The ignored .coverage data remains available for local follow-up, for example:

uv run --no-sync coverage html

CI runs the same informational command in the Python 3.12 / Django 5.2 full- suite matrix job. Other matrix jobs retain their ordinary test command.

Recorded baseline

Recorded on 2026-08-16 from branch stab2-sec5-coverage-baseline, whose package source was unchanged from base commit 3930798cc54d08cb0a3775dbf29605c58bbe1230. The local environment was Python 3.12.9, Django 6.1, and SQLite; live-provider tests remained disabled.

The complete working-tree suite result was 900 passed, 8 skipped. The package report was:

Scope Statements Missed Branches Partial branches Coverage
django_asklens total 4,450 427 1,316 211 88%

Representative critical modules make the baseline reviewable without implying that one file represents an entire boundary:

Boundary representative Statements Missed Branches Partial branches Coverage
execution/runner.py 145 12 12 1 92%
api/views.py 101 5 22 2 94%
mcp/core.py 112 4 36 5 94%
admin_querying.py 24 7 4 2 68%
catalog/registry.py 35 0 2 0 100%
planning/validation.py 383 35 184 18 90%
compiler/orm.py 130 3 24 3 96%
results/serialization.py 101 8 56 5 89%
execution/audit.py 104 9 24 4 90%

These rounded values are a commit- and environment-bound starting point, not a minimum. Future changes should inspect newly missing branches in the affected boundary rather than optimize the aggregate percentage.

Critical-boundary map

The map identifies primary source and regression surfaces. It does not replace reading adjacent modules, test assertions, PostgreSQL evidence, or the security model.

Boundary Primary package sources Primary focused evidence Review focus
Trusted execution facade execution/runner.py, querying.py test_facade.py, test_context_revalidation.py, test_internal_boundaries.py Current request/catalog/policy validation, context binding, safe execution errors, and no supported bypass.
Optional API adapter api/views.py, api/serializers.py, api/permissions.py test_http_characterization.py, test_error_adapter_regressions.py, test_run_detail_privacy.py Route gates, strict input, safe envelopes, member/run opacity, audit effects, and application-data query rejection.
Optional MCP adapter mcp/core.py, mcp/wrappers.py, mcp/fastmcp.py test_core.py, test_wrappers.py, test_mcp_example.py Server-owned context mapping, facade convergence, compact discovery, and default row omission/denial.
Admin and frontend adapters admin_querying.py, admin.py, frontend/views.py test_admin_access.py, test_admin_view_only.py, test_demo_frontend.py Shared orchestration, view-only audit administration, permission gates, safe denials, and non-mutation.
Fail-closed scope catalog/registry.py, catalog/resources.py, permissions.py test_scope_policy.py, test_multitenant_security.py, test_complex_tenant_permissions.py Explicit global/context policy, trusted QuerySet providers, current identity, cross-scope isolation, and pre-application-SQL failure.
Structural budgets planning/validation.py, planning/schemas.py test_budgets.py, test_untrusted_plan_generative.py Every bounded plan dimension, above-limit safe errors, audit privacy, and zero application-data SQL.
Draft contract schemas and conformance contracts/_generation.py, contracts/_models.py, contracts/schemas/ test_schemas.py, test_containment_schema.py, test_replay.py Generated/packaged schema parity, independent Draft 2020-12 validation, language-neutral fixture shape, and parser/facade rejection consistency; schema validity is never execution authority.
Private bindings and compilation compiler/orm.py, compiler/filters.py, catalog/resources.py test_orm.py, test_registry.py, test_public_errors.py Semantic-to-private binding resolution, cardinality policy, prepared-state use, and non-disclosure of ORM/policy details.
Result serialization results/serialization.py, results/presentation.py test_serialization.py, test_presentation.py, test_ordering_truncation.py Canonical safe values, deterministic metadata, empty results, presentation separation, ordering, and accurate truncation.
Audit privacy and lifecycle execution/audit.py, management/_audit_lifecycle.py test_audit_boundary.py, test_audit_lifecycle_commands.py, test_audit_purge_command.py Metadata-only defaults, server-owned sink/alias policy, failure isolation, safe output, preview defaults, and bounded explicit lifecycle operations.

Issue #82 assertion-gap disposition

Reviewed against clean main at 12ba7eb1522e09154ffcfd27cdf31987498b9ee2, after the tests-only CSRF/denial correction in PR #90. Rerunning bash scripts/coverage-baseline.sh produced 935 passed, 8 skipped and the same package totals as the historical baseline: 4,450 statements, 427 missed, 1,316 branches, 211 partial branches, 88%. This refresh does not replace the historical environment-bound measurements or establish an assertion-completeness threshold.

The following table and ranking record that preflight; completed follow-ups below supersede their remaining-gap labels where explicitly stated. This is a focused source/assertion inspection of the nine boundaries above, not an exhaustive branch audit. A gap means evidence is missing or weaker than the named invariant; it does not mean a runtime vulnerability was found.

Boundary Existing asserted evidence retained Disposition / remaining gap
Trusted execution facade test_context_revalidation.py rejects reuse of previews across permissions/catalogs with zero SQL; test_internal_boundaries.py checks context identity, lazy compilation, and non-serialization. Selected: permission revocation during provider planning in the same adapter operation, rather than only between separately constructed requests. Permission-resolver exception/invalid-return branches remain a separate negative-evidence candidate.
Optional API adapter test_hostile_query_payloads.py distinguishes transport rejection from trusted rejection, checks zero application-table SQL, exact error envelopes, allowed audit INSERTs, and private sentinels. Selected: real API execution of a stale provider plan with current-request identity checks. The existing successful convergence spy alone asserts a call count, not this negative case. Do not duplicate the seeded hostile corpus.
Optional MCP adapter test_core.py covers scope rejection, unknown/hidden member opacity, current scoped results, row omission/denial, host-plus-request row opt-in, and output caps. Selected: provider-time revocation with row return explicitly enabled, so omission cannot hide an execution defect. Compound over-budget execution while rows are omitted remains a smaller composition gap; core budget coverage is already present.
Admin and frontend adapters test_views.py checks successful admin facade convergence; test_admin_view_only.py blocks direct and bulk audit mutation; test_demo_frontend.py now validates the excluded CSRF token and rejects leaks elsewhere. Selected: stale-provider rejection through the real admin execution helper. Existing frontend-backed HTTP and browser paths remain separate evidence; this is not another browser/logout test.
Fail-closed scope test_scope_policy.py rejects missing policy/provider, invalid project defaults, wrong-model/non-QuerySet/evaluated scope results, and provider exceptions; none() is a valid zero-row scope. API/MCP and tenant suites add execution/isolation evidence. No duplicate registration/scope corpus selected. Current core coverage is substantially stronger than the stale pre-R2 scope summaries. Cross-adapter failure composition is not proven exhaustively.
Structural budgets test_budgets.py tests below/at/above dimensions and above-budget zero-total-SQL rejection; generated core tests add safe custom audit events and private-value sentinels. Retain these tests. Do not equate row omission with budget enforcement, percentage coverage with cost bounds, or SQLite tests with production statement-timeout evidence.
Private bindings and compilation Registry/planner tests omit private bindings/policy from metadata; test_orm.py changes bindings independently of public keys; public-error tests hide compilation/execution diagnostics. No new binding-policy semantics selected. runner.py's specialized FieldError/KeyError conversion branches were unmeasured in this baseline and merit focused error/audit assertions, not an API redesign.
Result serialization test_serialization.py rejects unsupported/non-finite values, missing keys, nullability violations, and unknown enum results. test_facade.py::test_unregistered_enum_result_fails_inside_trusted_execution proves rejection after one real data read. The core guard is already tested. A remaining composition gap is serialization failure through adapters with metadata-only failed auditing and no successful result/audit. This is a post-read failure: do not assert zero SQL or misclassify it as pre-execution rejection.
Audit privacy and lifecycle test_audit_boundary.py covers metadata-only success/rejection, disabled/custom modes, and sink failure before/after successful execution; lifecycle/routing tests cover the built-in database policy. Selected: exactly one safe database audit INSERT after adapter revocation, no successful audit and no protected content. Invalid audit configuration/imports and resolver failures remain operational negative-evidence candidates, coordinated with #84 rather than silently changing policy.

Risk-ranked follow-up

These priorities rank the consequences of an undetected regression, not the severity of a discovered vulnerability:

  1. High disclosure impact — selected: provider-time permission revocation across API/admin/MCP. Preserve the same current request and revalidate the returned ordinary plan, stop before scope/compilation/data SQL, and audit only safe rejection metadata. Retained-permission controls must actually retrieve the synthetic protected row.
  2. High failure-boundary impact — remaining: current permission-resolver exceptions/invalid returns and invalid audit configuration or sink imports. Inspect facade and adapter outcomes separately; current context construction and orchestration have different exception boundaries. Any revealed runtime defect needs its own failing regression and separately bounded fix (#84 coordination); no blanket fallback or broadened access is acceptable.
  3. High disclosure/correctness impact — remaining: specialized binding errors and post-read serialization rejection composed with adapter/audit behavior. Reuse existing core error/value tests rather than claiming these guards are currently absent.
  4. Medium composition gap — remaining: explicit MCP row omission combined with above-budget execution and audit assertions. Core budgets and MCP row policy each have tests; their conjunction is the missing assertion.
  5. Lower incremental value here — retain/defer: defensive serializer/type permutations already largely covered by schema/value tests, additional generator cases without a named invariant, and aggregate percentage increases. Semantic/schema decisions belong with #83; operational load evidence with #84/#85. No new percentage gate or dependency is proposed.

Selected adapter regression matrix

test_adapter_revalidation.py adds twelve deterministic cases: three executing adapters (DRF API, admin helper, MCP question helper), two real orchestration branches (dummy planner and unified provider response), and revoked/retained field permission. Only provider I/O is substituted with an in-process double; parsing, planner validation, facade, compiler, ORM reads, response shaping, and database auditing are real. The provider changes a server-owned permission set after receiving authorized metadata and before returning its plan. This is not a concurrent database transaction/policy-change timing guarantee.

Assertions cover exact current request identity and plan at the facade, current permission reads, one provider call, metadata-only provider inputs without sample rows/private bindings/policy tokens, no scope or compilation after denial, exact safe adapter errors, and SQL/audit effects. Success controls retrieve the synthetic row with one data SELECT and one audit INSERT. Denials perform only one metadata audit INSERT. Caller-supplied questions remain intentionally echoed by the existing admin/MCP orchestration; the privacy checks distinguish that existing behavior from private filter values, database rows, and stored audit content rather than silently imposing a new response contract.

A local, test-only fault injection that substitutes the original permission set for the facade's current resolver made all six revoked cases fail; the unmodified implementation passes all twelve cases. Runtime source was not edited for that probe. This demonstrates sensitivity to one specific stale-policy regression, not exhaustive mutation testing. The new module carries the existing postgresql marker for representative PostgreSQL CI, while provider network I/O remains disabled. Real MCP transport, browser behavior, production permission backends, and independent security review remain separate evidence.

This assertion-gap disposition plus the selected tests does not authorize a release or certify production security.

Completed failure-boundary follow-ups

The subsequent context-failure inspection found actual error-boundary defects. Separately authorized runtime fixes in PRs #93/#94 normalized audit configuration and sink-import failures, preserved original safe rejections when auditing could not resolve, and normalized initial permission-resolver errors across executing adapters. Failed permission resolution cannot authorize help with absent or stale permissions; fresh facade revalidation remains. Dedicated audit configuration tests and permission resolution tests cover those cases and audit-mode effects. Both fixes passed exact PR and post-merge CI; the original fifteen regression cases from draft #92 also replayed unchanged with fifteen passes. This is bounded correction, not completion of

84's wider operational/lifecycle work.

The next tests-only slice inspects runtime at 7d89a4b and adds test_failure_audit_composition.py. It composes injected compiler FieldError/KeyError and a real stored unregistered enum after a valid row with core Python, DRF API, admin execution helper and MCP execution helper responses. Database, disabled, custom and failing custom audit modes are covered. A valid two-row control confirms the same fixture can return real results. No runtime defect was found in these selected cases.

The forty-eight negative cases assert exact error categories and opaque output, no partial result, one failed execution-audit attempt and no successful audit, metadata-only content, and no duplicate audit after sink failure. Binding errors perform zero application-data SQL; serialization rejection performs one SELECT before failure. Database mode adds exactly one failed audit INSERT; other modes add no SQL. A spy on the existing execution-audit boundary detects moving result validation after successful auditing even where a later adapter serialization would still reject the result. This does not promise that serialization failures are detectable before reading data.

Local test-only fault injections produced thirty-two failing binding cases when the specialized exception classification was bypassed, and sixteen failing serialization cases when the runner's serialization guard was removed. The unchanged runtime passes all forty-nine cases. Those probes did not edit runtime source and demonstrate sensitivity to two named regressions, not exhaustive mutation/fuzz testing. Tests use synthetic fixtures and deterministic in-process dummy planning for the admin helper; no live provider or real MCP transport is involved. The existing PostgreSQL marker selects representative backend CI.

The complete working-tree coverage run for this tests-only slice (package source unchanged from 7d89a4b) passed 1,057 tests, with 8 skips: 4,459 statements, 403 missed, 1,316 branches, 203 partial branches, 89%. This includes the preceding runtime corrections and their regression tests; the difference from the older 88% baseline is not attributable solely to this slice and is not a new threshold.

MCP omission and budget composition

The final named #82 tests-only composition slice, based on runtime 7a3d727, adds test_omission_budgets.py. It reuses the existing MCP fixtures and core budget tests rather than rebuilding the exhaustive per-dimension corpus. Forty deterministic cases exercise MAX_ROWS and MAX_FILTERS with default omission, host-allowed/caller-omitted rows, caller-requested/host-denied rows, and host-plus-caller row return capped at zero.

Thirty-two rejection cases cross these policies with database, disabled, custom and failing-custom audit modes. They assert the real facade call, no preparation (and therefore no scope/compilation), zero application-data SQL, exact opaque budget errors, no result or output-policy pseudo-success, and metadata-only failed audit effects without duplicate attempts. Supplied plans cannot invoke provider planning. Eight at-boundary controls use the same plans and real grouped query: one SELECT plus one successful metadata audit INSERT, two result groups, and an empty MCP data array. Core truncation remains false, while a zero MCP output cap correctly reports its separate output truncation. Omitting or capping response rows is not an execution budget or statement-timeout control.

The unchanged runtime passes all forty cases. A test-only replacement that ignored both host budgets made all thirty-two rejection cases fail even though the MCP output would still be empty. Runtime source was not edited; this is one named sensitivity probe, not exhaustive mutation testing. Successful MCP payloads still echo the supplied plan under the existing contract; private-filter checks apply to rejection payloads and stored audit content, not an invented prohibition on successful caller-plan echo. Tests carry the existing PostgreSQL marker but do not claim real-wire MCP, browser, provider-network, production-load, or application-specific scope evidence.

The named #82 technical follow-ups are now covered by the selected tests and the separately authorized fixes above. Maintainer prerelease review of this disposition remains deferred and is not completed. This is not independent review, issue/milestone approval, exhaustive boundary coverage, or production security certification. Broader semantic/schema and operational work stays in its separately scoped issues; no next milestone or runtime change is unlocked.

Interpretation and limitations

  • The recorded percentage is one local Python/Django/SQLite baseline. CI reruns the command on Python 3.12 / Django 5.2, but this report does not combine coverage from the complete compatibility matrix.
  • The default run does not measure the PostgreSQL-marked execution paths as a PostgreSQL baseline. Existing PostgreSQL 15/18 jobs remain the evidence for database-sensitive semantics.
  • Skipped live provider tests, the Compose/browser path, and installed-wheel smokes are separate opt-in or CI evidence. This run does not claim live provider, browser, transport, package-install, or installed-wheel coverage.
  • Import-time execution can raise a module percentage without testing its public contract. Conversely, defensive or environment-specific code can remain unexecuted without being dead or unsafe.
  • Aggregate coverage cannot prove zero-query rejection, cross-tenant isolation, fail-closed scope, privacy-safe audit, deterministic semantics, or adapter convergence; the focused assertions in the map carry those claims.
  • This maintainer-operated synthetic evidence is not an independent security audit, production wire acceptance, external adoption evidence, or production- readiness certification.
  • Choosing a threshold, expanding runtime behavior, or changing security policy requires separate authorization. This baseline has no percentage threshold.