Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/briefs/bridge-retirement-audit-sourcespan-family.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bridge-Retirement Audit — SourceSpan / File-Identity Family

Status: **audit packet only** (no retirements). Anchors
Status: **audit packet with leaf retirements** (row #19 retired; umbrella row remains open). Anchors
`docs/debt/r3-debt-paydown-ledger-2026-05-02.md` row 76 (`B4 bridge-retirement
queue`), family **A** — **SourceSpan / compilation-unit file string** semantics
in the v3 substrate (`src/v3/compiler/src/{dag,lower,infer,emit,lens_apply,
Expand Down Expand Up @@ -95,7 +95,7 @@ shape · **(d)** sibling / blocker.
| 16 | **`bootstrap_regen_fresh.rs` duplicate `declaration_name_preference_rank`** | `bootstrap_regen_fresh.rs` | Fresh regen symbol merge | Delete when #14/#15 delete; keep one implementation. | #14. |
| 17 | **`lens_testgen` std duplicate pick (`std_preference_rank`, `is_bootstrapped_std_file`, `substrate.dag` skip)** | `lens_testgen.rs` (~520–535, ~777) | Lens testgen output only | Consume unified module identity / `DeclarationRef` picks; delete second rank table. | #14/#15 (same duplicate-authority story). |
| 18 | **`lens_testgen` `verification.dag` special-case** | `lens_testgen.rs` (`decl.span.file == "src/v3/std/verification.dag"`) | 1 predicate arm | Typed “skip harness-only decl” flag or `DeclarationRef` set membership. | #17. |
| 19 | **Diagnostics correction file consistency** | `diagnostics.rs` (`correction.span.file != file`) | Low (fix struct consumers) | Corrections carry authoritative `SourceSpan`; drop cross-file string compare if spans are always normalized to compilation unit. | Minor; independent. |
| 19 | **Diagnostics correction file consistency** ✅ retired (this PR) | `diagnostics.rs` (`apply_correction`) | Low (fix struct consumers) | Retired: correction application is bounded by the correction span's byte offsets and UTF-8 boundaries; it no longer compares `correction.span.file` to a separate caller-provided file string as a participation gate. The caller filename remains only for the reparse/tokenize pass after applying the fix. | Minor; independent. |

**Not counted as separate rows:** integration tests under
`src/v3/compiler/tests/**` that **assert** `span.file == "<fixture>"` (they are
Expand Down
2 changes: 1 addition & 1 deletion docs/briefs/r3-v-bridge-retirement-ledger-zero-audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ remainder **#6** stays explicitly `Open`.

| # | Ledger row | Ledger status | Code state at HEAD | Ratchet / authority | Drift signal |
|---|---|---|---|---|---|
| 1 | `bridge_source_span_file_participation_retired` | `Open` | Open. Audit-packet progress (PR #2150 merged 2026-05-07): row #2 (kernel `Bool` bootstrap patch lookup) **partial** — path-string encapsulated behind `BootstrapAuthorityKey::for_kernel_bool()`, full dissolution awaits row #14 retirement; row #6 (pipeline authority file guard, bootstrap.rs slice) **retired** via typed `BootstrapAuthorityKey::for_pipeline_authority()` + witness-derived spans (`pipeline_authority.rs` stage-binding walk + `compile` arrow lowering remain under separate ownership). Production/lens paths still consult `SourceSpan.file` for participation or filtering: `lens_apply.rs::behavior_source_file`, `reflect_program_dag_nodes_in_file` / `fold_lens_over_reflected_program`, lower's `DIMENSION_STD_AUTHORITY_FILE` gates, and emit `source_filtering.excludes`. | `r3-structure.md` L87; `ROADMAP.md#lens-fold-file-path-semantics`; PR #2150 audit-packet receipt. | None. Ledger `Open` matches code. |
| 1 | `bridge_source_span_file_participation_retired` | `Open` | Open. Audit-packet progress (PR #2150 merged 2026-05-07): row #2 (kernel `Bool` bootstrap patch lookup) **partial** — path-string encapsulated behind `BootstrapAuthorityKey::for_kernel_bool()`, full dissolution awaits row #14 retirement; row #6 (pipeline authority file guard, bootstrap.rs slice) **retired** via typed `BootstrapAuthorityKey::for_pipeline_authority()` + witness-derived spans (`pipeline_authority.rs` stage-binding walk + `compile` arrow lowering remain under separate ownership). Row #19 (diagnostic correction file consistency) **retired**: `apply_correction` no longer compares `correction.span.file` to a separate caller file string before applying a fix. Production/lens paths still consult `SourceSpan.file` for participation or filtering: `lens_apply.rs::behavior_source_file`, `reflect_program_dag_nodes_in_file` / `fold_lens_over_reflected_program`, lower's `DIMENSION_STD_AUTHORITY_FILE` gates, and emit `source_filtering.excludes`. | `r3-structure.md` L87; `ROADMAP.md#lens-fold-file-path-semantics`; PR #2150 audit-packet receipt; row #19 receipt in `docs/briefs/bridge-retirement-audit-sourcespan-family.md`. | None. Ledger `Open` matches code. |
| 2 | `bridge_mark_bootstrap_secret_nominal_opacity_retired` | `Retired` | Retired. `dag.rs::bridge_mark_bootstrap_secret_nominal_opacity_retired` asserts `Secret.nominal_opacity` exists in std, full bootstrap, and without-parse-surface snapshots. No live `mark_bootstrap_secret_nominal_opacity` helper remains. | Rust unit test in `src/v3/compiler/src/dag.rs`; Secret nominal-opacity lineage #1272 / old row authority `PR #937`. | None for status. Authority string is historical but not contradictory. |
| 3a | `bridge_canonical_lens_name_dispatch_pr1183_slice_retired` | `Retired` | Retired in ledger. Narrow PR #1183 dispatch slice; ratchet `canonical_lens_bridge_ratchet_test.rs`. | `src/v3/compiler/tests/integration/canonical_lens_bridge_ratchet_test.rs`; Director #828 c#4358798673. | None. Ledger `Retired` matches substrate row. |
| 3b | `bridge_canonical_lens_name_patching_residual` | `Retired` | Retired in ledger per canonical-lens name-dispatch closure receipt; authority `docs/briefs/r3-pb-bridge-canonical-lens-name-dispatch-closure.md`. PB-Runtime may still carry transitional `include_str!` / name-keyed surfaces in `test_runner.rs` until interpreter-as-data — track via that brief, not a parallel `Open` ledger row. | Closure brief + `canonical_lens_bridge_ratchet_test.rs` pins; gate #33 lineage. | None. Ledger `Retired` matches substrate row (do not narrate this row as `Open` while the ledger says otherwise). |
Expand Down
32 changes: 5 additions & 27 deletions src/v3/compiler/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ pub fn positive_interval_width_unit_count_requires_nonnegative_units_literal_mes

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CorrectionApplyError {
FileMismatch {
expected: String,
actual: String,
},
InvalidSpan {
start: u32,
end: u32,
Expand All @@ -104,16 +100,8 @@ pub enum CorrectionValidationError {

pub fn apply_correction(
source: &str,
file: &str,
correction: &Correction,
) -> Result<String, CorrectionApplyError> {
if correction.span.file != file {
return Err(CorrectionApplyError::FileMismatch {
expected: correction.span.file.clone(),
actual: file.to_string(),
});
}

let start = correction.span.byte_start as usize;
let end = correction.span.byte_end as usize;
if start > end || end > source.len() {
Expand Down Expand Up @@ -146,8 +134,7 @@ pub fn apply_correction_and_reparse(
file: &str,
correction: &Correction,
) -> Result<String, CorrectionValidationError> {
let updated =
apply_correction(source, file, correction).map_err(CorrectionValidationError::Apply)?;
let updated = apply_correction(source, correction).map_err(CorrectionValidationError::Apply)?;
let tokens =
crate::tokenize::tokenize(&updated, file).map_err(CorrectionValidationError::Tokenize)?;
crate::parse::parse(&tokens, file).map_err(CorrectionValidationError::Parse)?;
Expand Down Expand Up @@ -987,7 +974,6 @@ mod tests {
fn apply_correction_replaces_the_requested_span() {
let updated = apply_correction(
"let x: Int = 1\n",
"apply_fix.v3",
&Correction {
description: "replace the literal".to_string(),
span: SourceSpan::new("apply_fix.v3", 13, 14),
Expand All @@ -999,24 +985,17 @@ mod tests {
}

#[test]
fn apply_correction_rejects_file_mismatch() {
let error = apply_correction(
fn apply_correction_uses_span_offsets_not_file_participation() {
let updated = apply_correction(
"let x: Int = 1\n",
"actual.v3",
&Correction {
description: "replace the literal".to_string(),
span: SourceSpan::new("expected.v3", 13, 14),
new_source: "2".to_string(),
},
)
.expect_err("mismatched file should fail closed");
assert_eq!(
error,
CorrectionApplyError::FileMismatch {
expected: "expected.v3".to_string(),
actual: "actual.v3".to_string(),
}
);
.expect("correction application is offset-bounded, not gated by a separate file string");
assert_eq!(updated, "let x: Int = 2\n");
}

#[test]
Expand All @@ -1025,7 +1004,6 @@ mod tests {
let accent = source.find('é').expect("fixture contains accent") as u32;
let error = apply_correction(
source,
"utf8_fix.v3",
&Correction {
description: "split the accent".to_string(),
span: SourceSpan::new("utf8_fix.v3", accent, accent + 1),
Expand Down
Loading