Skip to content

Commit d2f2e2f

Browse files
Stage-3 REQ-6: review surface — semantic forks + towers (the F-F tripwire) (#348) (#89)
* Stage-3 REQ-6: review surface — semantic forks and definition towers (#348) Add the additive "semantic forks and definition towers" section to `forge audit` / `forge review` (`.design/stage3-bv-reconstruction.md` REQ-6 / AC-7): bv-shadow density per module + every burned lemma's definition-tower depth, carrying the post-ship F-F density tripwire. - new forge/src/forks.rs: SemanticForks { bv_density (per contract-bearing item, denominated by ens clauses), burned_lemma_towers (via the meaning.rs spec-fn tower rooted at the lemma's req∪ens), tripwire }. The F-F tripwire fires when project-wide bv-shadow density reaches 500‰ (majority of the postcondition surface) — a named, informational warning that gates nothing. - meaning.rs: add tower_metrics (depth-only, no src) + factor the shared spec-fn graph helpers; build_tower behavior unchanged. - additive Option<SemanticForks> on AuditManifest + ReviewArtifact (#[serde(skip_serializing_if = Option::is_none)] → v1 goldens byte-identical); cli render_audit/render_review append the human section. - fixtures: bv_density_normal.th (250‰, no trip) + bv_density_spike.th (666‰, trips); 6 forks unit tests + 3 bv_lowering conformance tests. A pure read-only projection: no verdict changes, no exit-code changes; the @bv per-item overlay (program_has_bv_tag) and REQ-3/4/5 locks stay green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(doc-drift): re-pin 6 docs for the #348 semantic-forks section ripple REQ-6 adds forge/src/forks.rs + the additive semantic_forks section across audit.rs/cli.rs/review.rs/meaning.rs/main.rs, drifting the docs governing them. Content-sha refresh (squash-stable). Governed REQs unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 743d8cd commit d2f2e2f

15 files changed

Lines changed: 795 additions & 44 deletions

File tree

.design/basis/09-option-result.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
tier: 3-component
44
status: draft
5-
audited-content-sha256: 0be0416df846c149e4d5b6feaf22596d7ab912906bd992184cb63eec8d0e9723 (migrated from legacy audited-sha commit pin to a squash-stable content digest; doc-drift-tripwire.md REQ-2 — content pin is primary, commit pin is a migration fallback)
5+
audited-content-sha256: 0e9ce0aee57c30c48e74a37c8c492afafe9545ade899c965e842b98bbf72b12e (migrated from legacy audited-sha commit pin to a squash-stable content digest; doc-drift-tripwire.md REQ-2 — content pin is primary, commit pin is a migration fallback)
66
governs: thermite-syntax/src/ast.rs
77
governs: thermite-syntax/src/parser.rs
88
governs: thermite-spec/src/validator.rs

.design/basis/11-ergonomics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
tier: 3-component
44
status: draft
5-
audited-content-sha256: 0be0416df846c149e4d5b6feaf22596d7ab912906bd992184cb63eec8d0e9723 (migrated from legacy audited-sha commit pin to a squash-stable content digest; doc-drift-tripwire.md REQ-2 — content pin is primary, commit pin is a migration fallback)
5+
audited-content-sha256: 0e9ce0aee57c30c48e74a37c8c492afafe9545ade899c965e842b98bbf72b12e (migrated from legacy audited-sha commit pin to a squash-stable content digest; doc-drift-tripwire.md REQ-2 — content pin is primary, commit pin is a migration fallback)
66
governs: thermite-syntax/src/parser.rs
77
governs: thermite-syntax/src/ast.rs
88
governs: thermite-lower/src/lower.rs

.design/forge/audit-manifest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
tier: 3-component
44
status: draft
55
audited-sha: 1cc9d97c6c5d7eab6109561834db77f2ef4b57ab (re-pinned 2026-06-16: forge workflow status rows now render from canonical registry IDs; behavior unchanged; RFC #17) (prior: 488103d4382815b85141d17bc01b60917ba744e7 (#274 — lean_fragment membership report; REQ-7..10 SHIPPED, audit.rs verified-current))
6-
audited-content-sha256: adf1e73cdae4923311fc2bdac210e295850a490f0edacdc1055a810195dc2458
6+
audited-content-sha256: 11d046491b2627236d2a81608698435e965743ef0c746746e13ec1e6c2cba0af
77
governs: forge/src/audit.rs
88
thesis-refs:
99
- thermite-design.md §6

.design/forge/cli.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
tier: 3-component
55
status: shipped
66
audited-sha: 5ae0816c042debb01c70eb9b89c775837f0c0f24 (content-sha256 re-pinned 2026-06-21 for stage-2 REQ-8 / AC-8 (#330), faithfulness + two-phase TV + the trust flip: the change to this doc's governed file (cli.rs) is the additive `forge strat-faithful-tv [--generated N] [--seed <u64>] [--json]` subcommand (`Command::StratFaithfulTv` → `run_strat_faithful_tv`, the two-phase TV sweep reporting the phase split + the gated trust profile); every other subcommand + flag parse is unchanged. The legacy commit pin stays at the 5ae0816c stable-main ancestor; only the active content-sha256 digest moves. prior: 2026-06-20 stage-2 REQ-4 / AC-4 (#326) `forge strat-tv` + `ForgeError::StratDifferential`; 2026-06-18 umbrella REQ-2c / AC-4 rotating-seed `--seed` flag on `forge tv`; §6 metrics dashboard `--metrics` value)
7-
audited-content-sha256: fefedbf24bbda305680c8fb5947123fd1190ce32279fca0fc21b9f6bb8c86b42
7+
audited-content-sha256: fdf790121bf8dc4fa50c43b0b476a3a390d114cac27709240a111b11f126dcab
88
governs: forge/src/cli.rs
99
thesis-refs:
1010
- thermite-design.md §5

.design/forge/spec-review.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
tier: 3-component
44
status: draft
55
audited-sha: 8b4d2580b472d04fca2b14de5b6be52533a2d258 (re-pinned 2026-06-17 for stage-1 increment 3, REQ-9 lemma library: the only change to this doc's governed file (review.rs) is the additive REQ-9 burned_lemmas partition + BurnedLemma projection (a certified lemma surfaces like any certified item); the v1 intent-reviewable / battery-failing partitions are unchanged (REQ-S1-9). prior: 92396428567edc6940a9e2845217f5ff4c2ea3c6)
6-
audited-content-sha256: 835a51237e78d06896155aff194ef58091b658ed34a04ea32f7b9e13f4de1c3c
6+
audited-content-sha256: dadde2fd2a0e6b248e4d843a120be92e1e69537780b0c531bb2aab2864c1f213
77
governs: forge/src/review.rs
88
thesis-refs:
99
- thermite-design.md §7

.design/scaffold/workspace.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
tier: 3-component
44
status: draft
55
audited-sha: 5ae0816c042debb01c70eb9b89c775837f0c0f24 (content-sha256 re-pinned 2026-06-20 for stage-2 REQ-4 / AC-4 (#326), the classifier ops half: the changes to this doc's governed lib roots are additive — `pub mod classifier;` + the classifier re-exports in thermite-spec/src/lib.rs (the new Rust admission classifier), and `mod strat_tv;` in forge/src/main.rs (the differential battery module); the workspace/crate structure is otherwise unchanged. The legacy commit pin stays at the 5ae0816c stable-main ancestor; only the active content-sha256 digest moves. prior: 2026-06-17 umbrella REQ-7 / AC-12 §6 metrics dashboard `mod metrics;`; stage-1 REQ-10/AC-14 G1 gate seven-verdict test module)
6-
audited-content-sha256: 8028435bfe4a6bedcdd68c639756f7097944430a118435134982131b19527154
6+
audited-content-sha256: bb5fae7f5c33ec049c7e9cd730c1038c02e29e9fce73a6a1a93f42c5e8c7164f
77
governs:
88
- Cargo.toml (virtual workspace manifest)
99
- rust-toolchain.toml
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// bv_density_normal.th — a project whose bv-shadow density is BELOW the F-F retreat
2+
// threshold (`.design/stage3-bv-reconstruction.md` REQ-6 / AC-7, the "normal" case).
3+
//
4+
// `forge audit` / `forge review` auto-route this through the bit-vector engine (it carries
5+
// a `@bv` tag), so the "semantic forks and definition towers" section reports the
6+
// per-module bv-shadow density and the project-wide F-F tripwire. Here ONE @bv-tagged ens
7+
// clause sits among FOUR contract-bearing ens clauses: a project density of 1/4 = 250‰,
8+
// well within the 500‰ retreat threshold — the tripwire does NOT fire (the healthy
9+
// baseline: a small, deliberate machine-semantics fork in an otherwise-unbounded codebase).
10+
//
11+
// Per-module known counts (a pure parse-level projection):
12+
// * wrap_add — 1/1 ens machine-semantics (1000‰)
13+
// * plain_add — 0/1 (0‰)
14+
// * plain_inc — 0/1 (0‰)
15+
// * plain_id — 0/1 (0‰)
16+
// project — 1/4 ens machine-semantics (250‰) → WITHIN the 500‰ threshold.
17+
18+
fn wrap_add(a: u64, b: u64) -> u64
19+
req true
20+
ens@bv64 a + b == b + a
21+
fx pure
22+
{ a + b }
23+
24+
fn plain_add(a: u64, b: u64) -> u64
25+
req a < 100 && b < 100
26+
ens result >= a
27+
fx pure
28+
{ a + b }
29+
30+
fn plain_inc(x: u32) -> u32
31+
req x < 100
32+
ens result == x + 1
33+
fx pure
34+
{ x + 1 }
35+
36+
fn plain_id(x: u32) -> u32
37+
req true
38+
ens result == x
39+
fx pure
40+
{ x }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// bv_density_spike.th — a SYNTHETIC density spike that trips the named F-F warning
2+
// (`.design/stage3-bv-reconstruction.md` REQ-6 / AC-7, the "spike" case).
3+
//
4+
// The post-ship F-F tripwire: when machine-semantics forks become the MAJORITY of the
5+
// contract-bearing postcondition surface, the program has drifted far enough toward the
6+
// fork that the @bv retreat ladder (full → nowrap-only → lemma-only → drop) should be
7+
// weighed. Here TWO @bv-tagged ens clauses sit among THREE contract-bearing ens clauses:
8+
// a project density of 2/3 = 666‰, at or above the 500‰ retreat threshold — the F-F
9+
// tripwire FIRES (a loud, informational warning; it gates nothing, changes no verdict).
10+
//
11+
// Per-module known counts (a pure parse-level projection):
12+
// * wrap_comm — 1/1 ens machine-semantics (1000‰)
13+
// * wrap_xor — 1/1 ens machine-semantics (1000‰)
14+
// * plain_add — 0/1 (0‰)
15+
// project — 2/3 ens machine-semantics (666‰) → REACHES the 500‰ threshold (TRIP).
16+
17+
fn wrap_comm(a: u64, b: u64) -> u64
18+
req true
19+
ens@bv64 a + b == b + a
20+
fx pure
21+
{ a + b }
22+
23+
fn wrap_xor(a: u64, b: u64) -> u64
24+
req true
25+
ens@bv64 a ^ b ^ b == a
26+
fx pure
27+
{ a ^ b }
28+
29+
fn plain_add(a: u64, b: u64) -> u64
30+
req a < 100 && b < 100
31+
ens result >= a
32+
fx pure
33+
{ a + b }

forge/src/audit.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ pub struct AuditManifest {
9797
/// discipline). The section gates nothing — informational, like `lean_fragment`.
9898
#[serde(default, skip_serializing_if = "Vec::is_empty")]
9999
pub bv_shadows: Vec<BvShadowRow>,
100+
/// The "semantic forks and definition towers" section
101+
/// (`.design/stage3-bv-reconstruction.md` REQ-6 / AC-7): the AGGREGATE legibility
102+
/// surface over the per-clause `bv_shadows` above + the burned-lemma towers — bv-shadow
103+
/// density per module, every burned lemma's definition-tower depth, and the post-ship
104+
/// **F-F density tripwire**. A pure projection ([`crate::forks::SemanticForks::build`]);
105+
/// `None` (and omitted) for a tag-free, lemma-free project, so the v1 corpus serializes
106+
/// BYTE-IDENTICALLY (the additive `bv_shadows`/`lean_fragment` discipline;
107+
/// `manifest_version` stays `"v1"`). The section gates nothing — informational, like
108+
/// `bv_shadows`.
109+
#[serde(default, skip_serializing_if = "Option::is_none")]
110+
pub semantic_forks: Option<crate::forks::SemanticForks>,
100111
}
101112

102113
/// One `@bv`-tagged clause's shadow-flag row in the audit manifest
@@ -605,13 +616,18 @@ impl AuditManifest {
605616
// Lock 1 (stage-3 REQ-3 / AC-4): the project's `@bv` shadow flags, one row per
606617
// tagged clause — a pure projection of the certs' obligations.
607618
let bv_shadows = BvShadowRow::from_certificates(certs);
619+
// REQ-6 / AC-7: the aggregate "semantic forks and definition towers" section — the
620+
// bv-shadow density per module, the burned-lemma tower depths, and the F-F density
621+
// tripwire. `None` (omitted) for a tag-free, lemma-free project (the v1 corpus).
622+
let semantic_forks = crate::forks::SemanticForks::build(certs, program);
608623
AuditManifest {
609624
manifest_version: MANIFEST_VERSION.to_string(),
610625
functions,
611626
project_assurance,
612627
tcb,
613628
lean_fragment,
614629
bv_shadows,
630+
semantic_forks,
615631
}
616632
}
617633
}

forge/src/cli.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,6 +2761,12 @@ fn render_review(artifact: &ReviewArtifact) -> String {
27612761
));
27622762
}
27632763
}
2764+
// REQ-6 / AC-7: the aggregate "semantic forks and definition towers" section — the
2765+
// bv-shadow density per module + burned-lemma tower depths + the F-F density tripwire.
2766+
if let Some(forks) = &artifact.semantic_forks {
2767+
out.push('\n');
2768+
out.push_str(&forks.render());
2769+
}
27642770
out
27652771
}
27662772

@@ -3007,6 +3013,11 @@ fn render_audit(manifest: &AuditManifest) -> String {
30073013
));
30083014
}
30093015
}
3016+
// REQ-6 / AC-7: the aggregate "semantic forks and definition towers" section — the
3017+
// bv-shadow density per module + burned-lemma tower depths + the F-F density tripwire.
3018+
if let Some(forks) = &manifest.semantic_forks {
3019+
out.push_str(&forks.render());
3020+
}
30103021
out
30113022
}
30123023

0 commit comments

Comments
 (0)