Skip to content

fix(sdl): report invalid import declarations, provenance and directory imports as sdl diagnostics - #1484

Closed
doublewhy wants to merge 10 commits into
devfrom
297-import-diagnostics
Closed

doublewhy wants to merge 10 commits into
devfrom
297-import-diagnostics

Conversation

@doublewhy

@doublewhy doublewhy commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Raw exceptions and raes sdl resolve tracebacks from import resolution become value-free SDLParseErrors naming the file or import. Valid lockfiles are byte-identical; dev's #1446 hardening is kept.

Requirement UIDs

Related Issues

Closes #1580

Not stacked (base cf8b4308): only origin/dev merged; #1480's head ebe04761 merges in cleanly. #1552 keeps verify-imports.

ADR Impact

  • No ADR required; follows ADR-053, ADR-073 §5, ADR-076 §5.

Changes

  • Merge 6cc482c2 keeps dev's models.py, locked: loop and admit_import_source, adding directory/unreadable-import checks, typed import validation and the ADR-073 check in _import_admission.py. bb919701: public lock_records.py, tests on dev's messages, docs. 241b9b9a: dead parameter dropped.
Done-when (verbatim) Change Test Lane
resolve_lock_records and raes sdl resolve report invalid root import declarations with the same code, pointer and range as parse_sdl_file, and reject the import sources and versions that parse_sdl_file cannot record as provenance. A valid root still gives a byte-identical lockfile. resolve_lock_records, _import_declarations, _provenance_record test_resolve_reports_*, test_unrecordable_*, test_valid_root_* shard
An invalid locked: record, or a locked: chain that revisits a record, raises SDLParseError naming raes.lock.json. It does not raise ValidationError or RecursionError. Acyclic chains resolve as before. dev's loop test_invalid_lock_record_*, test_locked_import_cycles_*, test_acyclic_* shard
An invalid, malformed, non-UTF-8 or directory raes.lock.json or raes-trust.yaml raises SDLParseError with the file as path and its name in the message, and never renders its values. dev's loaders test_invalid_policy_files_* shard
An import that names a directory gets an SDLParseError naming the import, and an imported unit with a removed scoring section gets the root's ADR-073 message. _local_import_source, admit_import_source test_directory_import_*, test_unreadable_*, test_*_removed_scoring_* shard
expand_sdl_modules called directly reports an invalid declaration as a field diagnostic. expand_sdl_modules test_direct_expansion_* shard
raes sdl resolve exits non-zero and prints no traceback for each of these, naming the failing file. raes_cli/sdl.py:resolve test_raes_sdl_resolve_* shard
Both research captures are republished. capture-861dc862, capture-c2c3a4d6 checkers contracts
Review: "Reconcile #1580's residual diagnostic/parity cases with current dev and the #1446/#1480 changes, preserving bounded workspace reads, YAML token/graph validation and the locked-chain depth budget." 6cc482c2 *-oversized, trust-alias-cycle, chain-over-budget shard
Review: "Merge current dev with real conflict resolution, retain source-anchored value-free errors and unchanged valid lockfile output, and refresh combined-source captures." 6cc482c2, 84a9adcd sentinels, test_valid_root_* shard
Review: "Run the 40 targeted import-boundary cases plus relevant parser/registry/CLI tests and required CI on the resolved head; leave #1552 scoped to verify-imports rendering." verify_imports untouched below all

Test Plan

  • Unit tests pass
  • Integration tests pass if applicable
  • Completion command passes
  • No coverage regression

test_issue_1580_*: 45 passed; on dev's packages 25 fail and 20 (dev's defenses, controls) pass. Removing dev's chain budget or size bound fails chain-over-budget or lockfile-oversized. 32 related modules: 1218 passed, 1 skipped; -m integration: 5 passed, 6 skipped. With #1480 merged: 334 passed. Fast-feedback, lint, policy, docs-local, contracts, checkers: passed. Full completion suite required in CI before merge.

Evidence: collect_research_evidence.py on 241b9b9a (38/42 stages, 4 preregistered; 20/20 formal), then research_capture record; a7a4ca90 captures kept.

Ground Control Checks

  • Repository policy command passes
  • Pre-push code review and test-quality review completed, or not run for this lane

Self-reviewed only.

Traceability

  • IMPLEMENTS: raes/module_registry/, raes/composition/, raes/_model_diagnostics.py, raes/_composition_provenance.py, raes_cli/sdl.py
  • TESTS: tests/test_issue_1580_import_boundary_diagnostics.py

Checklist

  • Code follows the project coding standards
  • FM level classified if semantic change
  • Published contract schemas regenerated if models changed
  • PR title is a Conventional Commit (release-please derives the version and CHANGELOG.md from it)
  • Architectural docs updated if applicable

FM0: error reporting only, no schema change; no executable or runtime adoption is claimed.

@doublewhy
doublewhy force-pushed the 297-import-diagnostics branch from c2028d0 to 67f9550 Compare October 11, 2026 00:39
@doublewhy
doublewhy marked this pull request as ready for review October 11, 2026 01:02
@doublewhy
doublewhy force-pushed the 297-import-diagnostics branch from 67f9550 to 942e5e4 Compare October 13, 2026 04:15
@doublewhy doublewhy changed the title fix(sdl): report invalid imported modules and version ranges as sdl diagnostics fix(sdl): report lock, trust-policy and import-provenance failures as sdl diagnostics Oct 13, 2026
@doublewhy
doublewhy marked this pull request as draft October 13, 2026 04:15
@doublewhy
doublewhy force-pushed the 297-import-diagnostics branch from 942e5e4 to 4f59cef Compare October 13, 2026 04:49
@Brad-Edwards

Copy link
Copy Markdown
Collaborator

Recommendation: do not merge as is.

Reviewed head a7a4ca9063c15a0ed4fd8130800615157525ab5f, targeting dev.

  1. Merge conflicts against dev (DIRTY), with stated dependencies on feat!: make reference eligibility explicit per purpose and align the editor with validation #1446 and fix(sdl): fetch oci modules from public registries through the anonymous token flow #1480.
  2. Current integration code already has a bounded workspace-config reader/token-and-graph validation and a locked-import chain-depth limit. The proposed loaders/loop are based on older code; resolving conflicts by replacing those paths with path.read_text/yaml.safe_load or an unbounded acyclic loop would regress current defenses.

Required action:

Coverage and outstanding work: #1580's existing SDLParseError renderer reuse, import-list parity and cycle handling are appropriate. The old-base implementation must be reconciled with landed security hardening before it can be considered complete.

Verification limits: Green head checks validate the old-base tree; resulting current-base code remains unverified.

Resolve the conflicts with the hardening that #1446 landed on dev:

- module_registry/models.py: keep dev's bounded workspace-configuration
  reader, YAML token and graph validation and value-free
  sdl.workspace-config.invalid errors; drop this branch's unbounded
  read_text and yaml.safe_load loaders.
- module_registry/resolution.py: keep dev's locked-import loop with its
  cycle check, composition-depth budget and value-free invalid-record
  error; drop this branch's unbounded loop and value-rendering record
  error. Keep the directory and unreadable local-import checks and the
  imported-unit removed-scoring check.
- composition/_expand.py: keep dev's admit_import_source and
  declaration-source tracking; keep typed import-list validation before
  the first import resolves. The imported-unit removed-scoring check moves
  into composition/_import_admission.py, where dev now loads the unit.
…ardening

- Tests expect dev's value-free lockfile and workspace-configuration
  errors: the lockfile or policy file is the error path, and the message
  and diagnostics never render a value. They also prove that an oversized
  or alias-cyclic policy file and an over-budget locked chain are still
  refused, including through resolve_lock_records, and that a chain at the
  budget still resolves like its local target.
- resolve_lock_records lives in the public module_registry.lock_records
  module, beside models, publishing and resolution.
- docs/explain/sdl/parser.md describes the merged error behavior.
@doublewhy doublewhy changed the title fix(sdl): report lock, trust-policy and import-provenance failures as sdl diagnostics fix(sdl): report invalid import declarations, provenance and directory imports as sdl diagnostics Oct 25, 2026
@doublewhy

Copy link
Copy Markdown
Contributor Author

Updated to 84a9adcd.

@doublewhy
doublewhy marked this pull request as ready for review October 25, 2026 21:52
@doublewhy

Copy link
Copy Markdown
Contributor Author

This branch conflicts with dev again after the Quality refactor merges, in _model_diagnostics.py and the composition modules. #1580 is still open, and this PR depends on #1480's module_registry changes. Your open #1761 also touches the import path. Do you want this as a standalone fix, or folded into the SDL refactor? If it is folded in, I'll close this PR and leave #1580 open.

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.

2 participants