vyre-self-substrate 0.6.1

Vyre self-substrate: vyre using its own primitives on its own scheduler problems. The recursion-thesis layer between vyre-primitives and vyre-driver.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
//! Completion audit coverage for `paradigm-shift-100-concrete.md`.

use std::collections::BTreeSet;

use crate::release_validation_matrix::RELEASE_VALIDATION_MATRIX;

/// Validated 100-item plan audit proof.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct ParadigmShiftPlanAuditProof {
    /// Number of numbered plan items found.
    pub item_count: usize,
    /// Number of unique release gates referenced by the item map.
    pub gate_count: usize,
}

/// Plan-audit validation failure.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ParadigmShiftPlanAuditError {
    /// Required release-definition text is missing.
    MissingPlanText {
        /// Missing text class.
        field: &'static str,
    },
    /// A numbered plan item is missing.
    MissingItem {
        /// Missing item number.
        item: u8,
    },
    /// A plan item has no release evidence mapping.
    MissingEvidence {
        /// Item number.
        item: u8,
    },
    /// An item maps to a release gate that is not in the matrix.
    UnknownGate {
        /// Item number.
        item: u8,
        /// Gate id.
        gate: &'static str,
    },
}

impl std::fmt::Display for ParadigmShiftPlanAuditError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::MissingPlanText { field } => write!(
                f,
                "paradigm-shift plan audit missing {field}. Fix: audit the active 100-item plan, not a stale release artifact."
            ),
            Self::MissingItem { item } => write!(
                f,
                "paradigm-shift plan audit missing numbered item {item}. Fix: every item 1..100 must be present and mapped."
            ),
            Self::MissingEvidence { item } => write!(
                f,
                "paradigm-shift plan item {item} has no evidence gates. Fix: map the item to concrete release validation gates."
            ),
            Self::UnknownGate { item, gate } => write!(
                f,
                "paradigm-shift plan item {item} references unknown release gate `{gate}`. Fix: add the gate or correct the item mapping."
            ),
        }
    }
}

impl std::error::Error for ParadigmShiftPlanAuditError {}

/// Validate that the active 100-item plan is fully mapped to current release gates.
pub fn validate_paradigm_shift_plan_audit(
    plan_text: &str,
) -> Result<ParadigmShiftPlanAuditProof, ParadigmShiftPlanAuditError> {
    validate_plan_identity(plan_text)?;
    let items = numbered_items(plan_text);
    for item in 1..=100 {
        if !items.contains(&item) {
            return Err(ParadigmShiftPlanAuditError::MissingItem { item });
        }
    }

    let available_gates = RELEASE_VALIDATION_MATRIX
        .iter()
        .map(|gate| gate.id)
        .collect::<BTreeSet<_>>();
    let mut referenced_gates = BTreeSet::new();
    for item in 1..=100 {
        let evidence = evidence_for_item(item);
        if evidence.is_empty() {
            return Err(ParadigmShiftPlanAuditError::MissingEvidence { item });
        }
        for gate in evidence {
            if !available_gates.contains(gate) {
                return Err(ParadigmShiftPlanAuditError::UnknownGate { item, gate });
            }
            referenced_gates.insert(*gate);
        }
    }

    Ok(ParadigmShiftPlanAuditProof {
        item_count: 100,
        gate_count: referenced_gates.len(),
    })
}

fn validate_plan_identity(plan_text: &str) -> Result<(), ParadigmShiftPlanAuditError> {
    for (field, needle) in [
        (
            "active plan title",
            "# GPU-First Dataflow/Compiler Platform Paradigm-Shift Launch Plan",
        ),
        (
            "vyre/dataflow/vyrec scope",
            "Scope: platform, dataflow, and compiler frontend only.",
        ),
        (
            "completion definition",
            "code, tests, benchmarks, docs, packaging, and public launch path",
        ),
        ("cargo publish final step", "cargo publish"),
        ("git push final step", "git push"),
    ] {
        if !plan_text.contains(needle) {
            return Err(ParadigmShiftPlanAuditError::MissingPlanText { field });
        }
    }
    Ok(())
}

fn numbered_items(plan_text: &str) -> BTreeSet<u8> {
    let mut items = BTreeSet::new();
    for line in plan_text.lines() {
        let trimmed = line.trim_start();
        let Some((number, _)) = trimmed.split_once(". ") else {
            continue;
        };
        if number.chars().all(|ch| ch.is_ascii_digit()) {
            if let Ok(item) = number.parse::<u8>() {
                items.insert(item);
            }
        }
    }
    items
}

fn evidence_for_item(item: u8) -> &'static [&'static str] {
    match item {
        1 => &[
            "vyre-production-cpu-fallback-lint",
            "vyre-core-gpu-boundary",
        ],
        2 => &["vyre-gpu-probe-contract"],
        3 => &["vyre-gpu-probe-contract", "vyre-architecture-boundary-map"],
        4 => &["vyre-memory-ownership-contract"],
        5 => &["vyre-architecture-boundary-map"],
        6 => &[
            "vyre-cuda-pipeline-modularity",
            "vyre-contributor-module-map",
        ],
        7 => &[
            "vyre-contributor-module-map",
            "release-test-taxonomy-coverage",
        ],
        8 => &["vyre-contributor-module-map", "release-scope-docs"],
        9 => &["vyre-public-api-boundary"],
        10 => &[
            "vyre-production-cpu-fallback-lint",
            "vyre-core-gpu-boundary",
        ],
        11 => &[
            "vyre-cuda-resident-dispatch",
            "release-allocation-regression",
        ],
        12 => &[
            "vyre-cuda-resident-dispatch",
            "vyre-memory-ownership-contract",
        ],
        13 => &[
            "vyre-cuda-resident-dispatch",
            "release-allocation-regression",
        ],
        14 => &["vyre-cuda-megakernel-scheduler"],
        15 => &["vyre-cuda-frontier-queue", "resident-fixed-point"],
        16 => &[
            "cross-crate-perf-contracts",
            "structural-benchmark-pass-selection",
            "vyre-cuda-launch-fusion",
        ],
        17 => &["vyre-cuda-megakernel-scheduler", "vyre-cuda-convergence"],
        18 => &[
            "vyre-cuda-megakernel-scheduler",
            "structural-frontier-partitioning",
        ],
        19 => &["vyre-cuda-megakernel-scheduler", "vyre-cuda-frontier-queue"],
        20 => &[
            "vyre-cuda-megakernel-scheduler",
            "structural-benchmark-pass-selection",
        ],
        21 => &["vyre-cuda-megakernel-scheduler", "release-gpu-evidence"],
        22 => &[
            "vyre-cuda-megakernel-speedup",
            "release-benchmark-baselines",
        ],
        23 => &[
            "vyre-cuda-frontier-queue",
            "vyre-cuda-convergence",
            "vyre-cuda-device-work-queue",
        ],
        24 => &[
            "vyre-cuda-frontier-queue",
            "structural-multi-corpus-batching",
            "vyre-cuda-multi-query-execution",
        ],
        25 => &["vyre-cuda-convergence"],
        26 => &[
            "vyre-cuda-module-cache",
            "vyre-cuda-megakernel-scheduler",
            "release-cuda-ptx-pattern-evidence",
        ],
        27 => &[
            "cross-crate-perf-contracts",
            "structural-diagnostic-aggregation",
            "vyre-cuda-result-compaction",
        ],
        28 => &[
            "vyre-cuda-capability-contracts",
            "vyre-cuda-cooperative-launch",
            "vyre-cuda-kernel-failure-diagnostics",
        ],
        29 => &[
            "vyre-cuda-megakernel-speedup",
            "release-benchmark-baselines",
        ],
        30 => &[
            "release-benchmark-baselines",
            "resident-fixed-point-benchmark",
        ],
        31 => &["resident-fixed-point", "release-allocation-regression"],
        32 => &["resident-fixed-point", "property-reaching-escapes"],
        33 => &["resident-fixed-point", "analysis-coverage"],
        34 => &["resident-fixed-point", "property-points-to"],
        35 => &["resident-fixed-point", "property-slice"],
        36 => &["ifds-resident", "property-ifds"],
        37 => &["graph-layout-coverage", "resident-fixed-point"],
        38 => &["graph-layout-coverage"],
        39 => &["resident-fixed-point", "ifds-resident"],
        40 => &["graph-layout-coverage"],
        41 => &["property-points-to", "property-ifds", "property-slice"],
        42 => &["adversarial-oracles", "release-hostile-input-coverage"],
        43 => &["exact-primitive-parity", "fuzz-bitset-oracles"],
        44 => &["resident-fixed-point", "release-allocation-regression"],
        45 => &[
            "resident-fixed-point-benchmark",
            "ifds-direct-resident-benchmark",
        ],
        46 => &["exact-primitive-parity", "analysis-coverage"],
        47 => &["analysis-coverage", "property-points-to"],
        48 => &["analysis-coverage", "structural-benchmark-pass-selection"],
        49 => &["graph-layout-coverage"],
        50 => &["release-scope-docs", "analysis-coverage"],
        51 => &["vyrec-beta-contract", "release-scope-docs"],
        52 => &["vyrec-c-dialect-matrix", "vyrec-clang-parity-dashboard"],
        53 => &[
            "vyrec-c-preprocess-gpu-resident-state",
            "vyrec-gpu-preprocessing-coverage",
        ],
        54 => &["vyrec-diagnostic-comparison", "structural-token-fact-graph"],
        55 => &[
            "vyrec-gpu-preprocessing-coverage",
            "vyrec-c-parser-throughput-evidence",
        ],
        56 => &["vyrec-gpu-preprocessing-coverage"],
        57 => &[
            "vyrec-c-parser-throughput-evidence",
            "structural-multi-corpus-batching",
        ],
        58 => &[
            "vyrec-gpu-preprocessing-coverage",
            "vyrec-c-parser-throughput-evidence",
        ],
        59 => &[
            "vyrec-parser-semantic-safety",
            "vyrec-diagnostic-comparison",
        ],
        60 => &["semantic-parity-coverage", "vyrec-clang-parity-dashboard"],
        61 => &[
            "vyrec-linux-corpus-parity",
            "vyrec-c-parser-throughput-evidence",
        ],
        62 => &["vyrec-linux-corpus-parity", "release-gap-findings"],
        63 => &["vyrec-diagnostic-comparison"],
        64 => &["vyrec-parser-semantic-safety", "semantic-parity-coverage"],
        65 => &[
            "vyrec-c-parser-throughput-evidence",
            "release-benchmark-baselines",
        ],
        66 => &[
            "vyrec-c-parser-throughput-evidence",
            "release-benchmark-baselines",
        ],
        67 => &["release-scope-docs", "vyrec-beta-contract"],
        68 => &["vyrec-clang-parity-dashboard", "release-gap-findings"],
        69 => &[
            "release-hostile-input-coverage",
            "release-test-taxonomy-coverage",
        ],
        70 => &["release-hostile-input-coverage", "scale-oracle-no-oom"],
        71 => &["structural-token-fact-graph"],
        72 => &["structural-incremental-invalidation"],
        73 => &["structural-multi-corpus-batching"],
        74 => &["structural-frontier-typed-ir"],
        75 => &[
            "structural-frontier-typed-ir",
            "vyre-cuda-megakernel-scheduler",
        ],
        76 => &["structural-frontier-partitioning"],
        77 => &[
            "structural-diagnostic-aggregation",
            "vyre-cuda-device-diagnostic-aggregation",
        ],
        78 => &[
            "optimization-control-plane",
            "optimization-release-evidence",
        ],
        79 => &[
            "optimization-control-plane",
            "optimization-release-evidence",
            "cross-crate-perf-contracts",
            "vyre-cuda-self-optimizer-e2e",
            "vyre-cuda-self-optimizer-const-prop",
            "vyre-cuda-self-optimizer-cse",
            "vyre-cuda-self-optimizer-licm",
            "vyre-cuda-self-optimizer-dead-branch",
            "vyre-cuda-self-optimizer-pattern-match",
            "vyre-cuda-self-optimizer-pipeline-resident",
        ],
        80 => &["structural-optimization-composition"],
        81 => &[
            "structural-benchmark-pass-selection",
            "vyre-cuda-benchmark-pass-selection",
        ],
        82 => &[
            "optimization-control-plane",
            "optimization-release-evidence",
        ],
        83 => &["structural-optimization-composition"],
        84 => &[
            "vyre-cuda-megakernel-scheduler",
            "vyre-memory-ownership-contract",
        ],
        85 => &["cross-crate-perf-contracts"],
        86 => &["release-checklist-gate", "release-gpu-evidence"],
        87 => &["release-test-taxonomy-coverage"],
        88 => &["release-gap-findings", "vyrec-clang-parity-dashboard"],
        89 => &["vyre-production-cpu-fallback-lint"],
        90 => &["release-allocation-regression"],
        91 => &["release-benchmark-baselines"],
        92 => &["vyrec-linux-corpus-parity"],
        93 => &["release-hostile-input-coverage"],
        94 => &["release-public-api-doctests"],
        95 => &["vyre-contributor-module-map", "release-scope-docs"],
        96 => &["release-scope-docs", "vyrec-beta-contract"],
        97 => &["release-deep-review-gate"],
        98 => &["release-gpu-evidence"],
        99 => &["release-checklist-gate", "release-completion-audit-honesty"],
        100 => &[
            "release-crate-metadata-readiness",
            "release-launch-sequence",
            "release-completion-audit-honesty",
        ],
        _ => &[],
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn committed_plan_maps_all_100_items_to_release_gates() {
        let proof = validate_paradigm_shift_plan_audit(include_str!(
            "../../../../release/plans/paradigm-shift-100-concrete.md"
        ))
        .expect("Fix: active 100-item plan should map to release validation gates");

        assert_eq!(proof.item_count, 100);
        assert!(
            proof.gate_count >= 50,
            "Fix: the 100-item plan must map to broad concrete release evidence, not a tiny proxy set."
        );
    }

    #[test]
    fn plan_audit_rejects_stale_release_story() {
        let err = validate_paradigm_shift_plan_audit(include_str!(
            "../../../../release/evidence/final/completion-audit.json"
        ))
        .expect_err("stale final audit artifact must not satisfy the active 100-item plan");

        assert_eq!(
            err,
            ParadigmShiftPlanAuditError::MissingPlanText {
                field: "active plan title",
            }
        );
    }

    #[test]
    fn plan_audit_references_cuda_innovation_gates() {
        let referenced = (1..=100)
            .flat_map(evidence_for_item)
            .copied()
            .collect::<BTreeSet<_>>();

        for gate in [
            "vyre-cuda-device-work-queue",
            "vyre-cuda-launch-fusion",
            "vyre-cuda-multi-query-execution",
            "vyre-cuda-result-compaction",
            "vyre-cuda-device-diagnostic-aggregation",
            "vyre-cuda-kernel-failure-diagnostics",
            "vyre-cuda-benchmark-pass-selection",
            "release-cuda-ptx-pattern-evidence",
            "optimization-release-evidence",
            "vyre-cuda-self-optimizer-e2e",
            "vyre-cuda-self-optimizer-const-prop",
            "vyre-cuda-self-optimizer-cse",
            "vyre-cuda-self-optimizer-licm",
            "vyre-cuda-self-optimizer-dead-branch",
            "vyre-cuda-self-optimizer-pattern-match",
            "vyre-cuda-self-optimizer-pipeline-resident",
        ] {
            assert!(
                referenced.contains(gate),
                "Fix: CUDA innovation gate `{gate}` must map back to a numbered paradigm-shift plan item."
            );
        }
    }
}