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
50 changes: 50 additions & 0 deletions src/v2/lens/medium_structure_containment.dag
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ import v2.std.algebra {
list_snoc_item
}
import v2.std.collection { List }
import v2.std.diagnostic {
AmbiguousIntent,
Diagnostic,
Textual,
Unavailable,
WholeFile
}
import v2.std.logic { Bool }
import v2.std.text { Char, String }
import v2.std.witness { Holds, Violates, Witness }

type MediumLeakFace
= InlineSyntaxLiteral
Expand Down Expand Up @@ -273,6 +281,48 @@ fn medium_structure_containment_clean_live(
)
}

fn medium_structure_containment_witness_diagnostic() -> Diagnostic {
Diagnostic {
reason: ^medium_structure_containment_leak_detected,
at: Textual { file: ^medium_structure_containment_lens_file, extent: WholeFile },
correction: Unavailable { reason: AmbiguousIntent }
}
}

fn medium_structure_containment_witness(
emit_roots: List<String>,
check_roots: List<String>
) -> Witness<Bool> {
if medium_structure_containment_clean_live(
emit_roots: emit_roots,
check_roots: check_roots
) {
Holds { value: true }
} else {
Violates { diagnostic: medium_structure_containment_witness_diagnostic() }
}
}

fn medium_structure_containment_canonical_witness() -> Witness<Bool> {
medium_structure_containment_witness(
emit_roots: medium_emit_side_scan_roots,
check_roots: medium_check_side_scan_roots
)
}

fn medium_structure_check_roots_with_perturb(perturb_roots: List<String>) -> List<String> {
list_append(left: medium_check_side_scan_roots, right: perturb_roots)
}

fn medium_structure_containment_canonical_with_check_perturb_witness(
perturb_roots: List<String>
) -> Witness<Bool> {
medium_structure_containment_witness(
emit_roots: medium_emit_side_scan_roots,
check_roots: medium_structure_check_roots_with_perturb(perturb_roots: perturb_roots)
)
}

data construction_justification: ConstructionJustification = ConstructionJustification {
class: WallAfterGrounding { dissolves_to: RealizationDispatch }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module v2.test.medium_structure_containment.scanner.perturb_red

import v2.lens.medium_structure_containment {
medium_structure_containment_canonical_witness,
medium_structure_containment_canonical_with_check_perturb_witness,
medium_structure_leak_count_live,
medium_emit_side_scan_roots,
medium_structure_check_roots_with_perturb
}
import v2.std.collection { List }
import v2.std.logic { Bool }
import v2.std.text { String }
import v2.std.witness { Holds, Violates }

data perturb_red_scan_roots: List<String> = [
"src/v2/test/fixture/medium_structure_scan/perturb_red"
]

test fn medium_structure_canonical_read_back_holds() -> Bool {
match medium_structure_containment_canonical_witness() {
Holds { value: _ } => true
Violates { diagnostic: _ } => false
}
}

test fn medium_structure_canonical_perturb_flips_violates() -> Bool {
match medium_structure_containment_canonical_with_check_perturb_witness(
perturb_roots: perturb_red_scan_roots
) {
Holds { value: _ } => false
Violates { diagnostic: _ } => true
}
}

test fn medium_structure_perturb_red_leak_count_positive() -> Bool {
medium_structure_leak_count_live(
emit_roots: medium_emit_side_scan_roots,
check_roots: medium_structure_check_roots_with_perturb(
perturb_roots: perturb_red_scan_roots
)
) > 0
}
12 changes: 12 additions & 0 deletions src/v2/test/fixture/medium_structure_scan/perturb_red/plant.dag
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module v2.test.fixture.medium_structure_scan.perturb_red_plant
import v2.std.logic { Bool }
import v2.std.text { String }

fn expected_ci_yml() -> String {
"runs-on: linux\n"
}

fn perturb_red_check_side_leak() -> Bool {
let yaml = expected_ci_yml()
string_contains(s: yaml, pattern: "runs-on")
}
Loading