pointbreak 0.10.0

Durable terminal code review for changes humans and coding agents collaborate on together
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
use std::ffi::OsStr;
#[cfg(unix)]
use std::ffi::OsString;

use super::product_contract::{
    AuthorityStampExpectation, AuthorityStampMutationLocus, AuthorityStampObservablePolicy,
    AuthorityStampScenarioId, BootstrapAvailabilityCase, CounterCeilingContextV1,
    DERIVED_ACCESS_PROFILE_ENV, DERIVED_ACCESS_ROLLOUT_CONTRACT_SHA256_V1,
    DerivedAccessAvailability, DerivedAccessFallback, DerivedAccessProfile,
    PRODUCT_INTEGRATION_CONTRACT_SHA256_V1, PRODUCTION_READINESS_CONTRACT_SHA256_V1,
    ProductIntegrationContractFixtureV1, ProductParityFixtureId, ProductRouteId, ProductWorkClass,
    ProjectionStampComponent, ProjectionVersionDecision, ProtectedInputId, ReadinessCounterId,
    ReadinessGateId, ReadinessGateResultV1, ReadinessOperationId, ReadinessOutcome,
    RevisionCountSource, RevisionPageLimitOverflow, WireProjectionVersion,
    derived_access_rollout_contract_fixture_v1, derived_access_rollout_contract_publication_v1,
    derived_access_rollout_contract_smoke_v1, derived_access_rollout_contract_v1,
    product_integration_contract_fixture_v1, product_integration_contract_publication_v1,
    product_integration_contract_smoke_v1, product_integration_contract_v1,
    production_readiness_contract_fixture_v1, production_readiness_contract_publication_v1,
    production_readiness_contract_smoke_v1, production_readiness_contract_v1,
    verify_product_integration_contract_fixture_v1,
    verify_production_readiness_contract_fixture_v1,
};

#[test]
fn selector_defaults_active_and_accepts_only_the_two_frozen_values() {
    assert_eq!(
        DerivedAccessProfile::parse(None).expect("unset defaults active"),
        DerivedAccessProfile::SqliteWalBodylessV1
    );
    assert_eq!(
        DerivedAccessProfile::parse(Some(OsStr::new("off"))).expect("explicit off"),
        DerivedAccessProfile::Off
    );
    assert_eq!(
        DerivedAccessProfile::parse(Some(OsStr::new("sqlite-wal-bodyless-v1")))
            .expect("frozen experiment"),
        DerivedAccessProfile::SqliteWalBodylessV1
    );
    assert_eq!(
        DerivedAccessProfile::SqliteWalBodylessV1.as_str(),
        "sqlite-wal-bodyless-v1"
    );
    assert_eq!(DERIVED_ACCESS_PROFILE_ENV, "POINTBREAK_DERIVED_ACCESS");

    let error = DerivedAccessProfile::parse(Some(OsStr::new("sqlite")))
        .expect_err("unknown values fail loudly");
    assert!(error.to_string().contains("unsupported"));
}

#[cfg(unix)]
#[test]
fn selector_rejects_non_unicode_values() {
    use std::os::unix::ffi::OsStringExt as _;

    let value = OsString::from_vec(vec![0xff]);
    let error =
        DerivedAccessProfile::parse(Some(&value)).expect_err("non-Unicode selector must fail");
    assert!(error.to_string().contains("Unicode"));
}

#[test]
fn availability_transition_matrix_is_complete_and_fail_closed() {
    let contract = product_integration_contract_v1();
    assert_eq!(
        contract.availability_states.len(),
        DerivedAccessAvailability::ALL.len()
    );
    for state in DerivedAccessAvailability::ALL {
        assert_eq!(
            contract
                .availability_states
                .iter()
                .find(|row| row.state == state)
                .expect("every state is frozen")
                .allowed_successors,
            state.allowed_successors()
        );
    }

    assert!(DerivedAccessAvailability::Absent.allows(DerivedAccessAvailability::Bootstrapping));
    assert!(DerivedAccessAvailability::CatchingUp.allows(DerivedAccessAvailability::Current));
    assert!(
        DerivedAccessAvailability::RebuildRequired.allows(DerivedAccessAvailability::Quarantined)
    );
    assert!(!DerivedAccessAvailability::Current.allows(DerivedAccessAvailability::Absent));
}

#[test]
fn only_body_search_is_an_exhaustive_route() {
    let contract = product_integration_contract_v1();
    assert_eq!(contract.routes.len(), ProductRouteId::ALL.len());

    for route_id in ProductRouteId::ALL {
        let route = contract
            .routes
            .iter()
            .find(|row| row.route == route_id)
            .expect("every route is frozen");
        if route_id == ProductRouteId::HistoryBodySearch {
            assert_eq!(
                route.fallback,
                DerivedAccessFallback::IntentionalExhaustiveBodySearch
            );
            assert_eq!(
                route.fallback_work,
                Some(ProductWorkClass::HistoryProportional)
            );
            assert!(route.emits_request_receipt);
        } else {
            assert_ne!(
                route.fallback_work,
                Some(ProductWorkClass::HistoryProportional),
                "{route_id:?} may not hide a whole-history fallback"
            );
        }
    }
}

#[test]
fn active_wires_use_projection_stamp_without_relabeling_event_set_hash() {
    let contract = product_integration_contract_v1();
    assert_eq!(
        contract.projection_version.decision,
        ProjectionVersionDecision::ProjectionStamp
    );
    assert_eq!(
        contract.projection_version.stamp_components,
        ProjectionStampComponent::ALL
    );
    assert!(
        contract
            .wire_consumers
            .iter()
            .all(|consumer| consumer.active_version == WireProjectionVersion::ProjectionStamp)
    );
    assert!(
        contract
            .wire_consumers
            .iter()
            .all(|consumer| !consumer.active_event_set_hash_required)
    );
    assert!(
        contract
            .wire_consumers
            .iter()
            .any(|consumer| consumer.loose_event_set_hash_required)
    );
}

#[test]
fn parity_fixture_matrix_covers_every_frozen_product_surface() {
    let contract = product_integration_contract_v1();
    assert_eq!(
        contract
            .parity_fixtures
            .iter()
            .map(|row| row.fixture)
            .collect::<Vec<_>>(),
        ProductParityFixtureId::ALL
    );
    assert!(
        contract
            .parity_fixtures
            .iter()
            .all(|row| row.default_off_exact
                && row.active_domain_parity
                && row.active_wire_parity
                && row.request_counter_receipt)
    );
}

#[test]
fn contract_fixture_is_canonical_strict_and_self_verifying() {
    let contract = product_integration_contract_v1();
    contract.validate().expect("frozen contract validates");

    let expected = format!(
        "{}\n",
        serde_json::to_string_pretty(&product_integration_contract_fixture_v1())
            .expect("fixture serializes")
    );
    verify_product_integration_contract_fixture_v1().expect("embedded fixture verifies");
    assert_eq!(
        expected,
        include_str!("../../../tests/fixtures/derived-access/product-integration-v1.json")
    );

    let mut value: serde_json::Value =
        serde_json::from_str(&expected).expect("fixture JSON parses");
    value
        .as_object_mut()
        .expect("fixture object")
        .insert("unexpected".to_owned(), serde_json::Value::Bool(true));
    assert!(
        serde_json::from_value::<ProductIntegrationContractFixtureV1>(value).is_err(),
        "unknown fields must be rejected"
    );
}

#[test]
fn documentation_table_is_generated_from_the_frozen_contract() {
    let docs = include_str!("../../../docs/benchmarking.md");
    assert!(
        docs.contains(&format!(
            "canonical SHA-256\nis `{PRODUCT_INTEGRATION_CONTRACT_SHA256_V1}`."
        )),
        "documented contract hash must match the frozen constant"
    );
    let table = docs
        .split_once("<!-- derived-access-product-integration-contract-v1:start -->\n")
        .expect("docs start marker")
        .1
        .split_once("\n<!-- derived-access-product-integration-contract-v1:end -->")
        .expect("docs end marker")
        .0;
    assert_eq!(
        table,
        product_integration_contract_publication_v1().decision_table_markdown
    );

    let historical_heading = docs
        .find("## Derived-access product-integration contract")
        .expect("historical contract heading");
    let historical_label = docs
        .find("Pointbreak retains this historical contract for the source cut")
        .expect("historical qualification label");
    let marker = docs
        .find("<!-- derived-access-product-integration-contract-v1:start -->")
        .expect("historical contract marker");
    assert!(historical_heading < historical_label && historical_label < marker);
    assert!(
        docs.contains(
            "The authoritative current runtime posture is the derived-access rollout contract below."
        ),
        "the immutable historical table must not be mistaken for the current runtime contract"
    );
    let current_docs = docs
        .split_once("<!-- derived-access-product-integration-contract-v1:end -->")
        .expect("historical contract end marker")
        .1;
    for stale in [
        "The checked-in runtime remains default-off",
        "The checked-in runtime default remains `off`",
        "an unset selector still resolves to `off`",
    ] {
        assert!(
            !current_docs.contains(stale),
            "live-current docs must not repeat historical default-off prose: {stale}"
        );
    }
}

#[test]
fn contract_validation_rejects_route_drift() {
    let mut contract = product_integration_contract_v1();
    contract.routes.pop();
    assert!(contract.validate().is_err());
}

#[test]
fn non_timing_smoke_emits_the_frozen_inert_receipt() {
    let receipt = product_integration_contract_smoke_v1().expect("pure smoke passes");
    assert_eq!(receipt.filesystem_actions, 0);
    assert_eq!(receipt.route_count, ProductRouteId::ALL.len());
    assert_eq!(
        receipt.availability_state_count,
        DerivedAccessAvailability::ALL.len()
    );
    assert_eq!(
        receipt.profiles,
        vec![
            DerivedAccessProfile::Off,
            DerivedAccessProfile::SqliteWalBodylessV1,
        ]
    );
}

#[test]
fn production_readiness_contract_freezes_the_four_residual_gate_families() {
    let contract = production_readiness_contract_v1();
    contract.validate().expect("frozen readiness contract");

    assert_eq!(
        contract.parent_contract_sha256,
        PRODUCT_INTEGRATION_CONTRACT_SHA256_V1
    );
    assert_eq!(
        contract
            .canonical_sha256()
            .expect("canonical readiness hash"),
        PRODUCTION_READINESS_CONTRACT_SHA256_V1
    );
    assert!(contract.authority_stamp.scenarios.len() > 1);
    assert!(!contract.bootstrap.phases.is_empty());
    assert_eq!(contract.revisions_page.default_limit, 100);
    assert_eq!(contract.revisions_page.maximum_limit, 500);
    assert_eq!(
        contract.terminal_outcomes,
        vec![
            ReadinessOutcome::ReadyForDefaultDecision,
            ReadinessOutcome::RemainDefaultOff,
            ReadinessOutcome::Reject,
        ]
    );

    let old = product_integration_contract_v1();
    assert!(
        old.routes
            .iter()
            .all(|route| route.route != ProductRouteId::Revisions
                || route.active_work == Some(ProductWorkClass::OutputProportional)),
        "the parent contract classifies a complete collection but has no page/token contract"
    );
}

#[test]
fn authority_stamp_scenarios_freeze_bounded_observation_and_fail_closed_outcomes() {
    let contract = production_readiness_contract_v1();
    assert_eq!(
        contract.authority_stamp.observable_policy,
        AuthorityStampObservablePolicy::SelectedAndFrozenByNativeFalsifierBeforeIntegration
    );
    assert!(contract.authority_stamp.scenarios.iter().all(|scenario| {
        scenario.event_directory_entries_walked_ceiling == 0
            && scenario.event_carrier_opens_ceiling == 0
    }));
    assert_eq!(
        contract
            .authority_stamp
            .scenario(AuthorityStampScenarioId::OutOfBandCreate)
            .expect("out-of-band create"),
        AuthorityStampExpectation::ChangedOrIndeterminate
    );
    let unrelated = contract
        .authority_stamp
        .scenarios
        .iter()
        .find(|row| row.scenario == AuthorityStampScenarioId::UnrelatedFile)
        .expect("unrelated event-directory file");
    assert_eq!(
        unrelated.mutation_locus,
        AuthorityStampMutationLocus::EventDirectoryNonCarrierEntry
    );
    assert_eq!(
        unrelated.expectation,
        AuthorityStampExpectation::StableOrChangedWithoutTruthClaim
    );
    assert!(!unrelated.authoritative_carrier_created);
    assert_eq!(
        contract
            .authority_stamp
            .scenario(AuthorityStampScenarioId::SidecarDeletion)
            .expect("missing authority metadata fails closed"),
        AuthorityStampExpectation::ChangedOrIndeterminate
    );
    assert_eq!(
        contract
            .authority_stamp
            .scenario(AuthorityStampScenarioId::ExperimentOffRollback)
            .expect("profile-off rollback does not observe the stamp"),
        AuthorityStampExpectation::ObservationNotApplicable
    );
    assert_eq!(
        contract
            .authority_stamp
            .scenario(AuthorityStampScenarioId::ExistingCarrierOverwrite)
            .expect("overwrite non-claim"),
        AuthorityStampExpectation::ExplicitNonClaim
    );
    assert!(
        contract
            .authority_stamp
            .changed_or_indeterminate_never_proves_truth
    );
    assert!(
        contract
            .authority_stamp
            .failures
            .iter()
            .all(|failure| !failure.may_report_current)
    );
}

#[test]
fn readiness_counter_ceilings_are_typed_and_do_not_hide_total_history_work() {
    let contract = production_readiness_contract_v1();
    let no_change = contract
        .counter_ceiling(
            ReadinessOperationId::ActiveOrdinaryNoChange,
            ReadinessCounterId::EventDirectoryEntriesWalked,
        )
        .expect("ordinary no-change directory ceiling");
    let context = CounterCeilingContextV1 {
        requested_entries: 100,
        source_carriers: 262_144,
    };
    assert!(no_change.allows(0, context));
    assert!(!no_change.allows(1, context));

    let writer = contract
        .counter_ceiling(
            ReadinessOperationId::FreshWriterAdmissionNoChange,
            ReadinessCounterId::EventDirectoryEntriesWalked,
        )
        .expect("fresh writer directory ceiling");
    assert!(writer.allows(0, context));
    assert!(!writer.allows(1, context));

    let page = contract
        .counter_ceiling(
            ReadinessOperationId::ActiveRevisionsPage,
            ReadinessCounterId::RevisionRowsExamined,
        )
        .expect("active page scan ceiling");
    assert_eq!(page.ceiling(context), 101);
    assert!(page.allows(101, context));
    assert!(!page.allows(102, context));
}

#[test]
fn bootstrap_contract_is_single_population_progressive_and_truthful() {
    let contract = production_readiness_contract_v1();
    assert_eq!(contract.bootstrap.population_carrier_open_ceiling, 1);
    assert_eq!(
        contract
            .bootstrap
            .maximum_overlapping_full_decoded_histories,
        1
    );
    assert!(contract.bootstrap.strict_oracle_is_serial_or_isolated);
    assert!(contract.bootstrap.completion_is_published_last);
    assert_eq!(contract.bootstrap.maximum_automatic_fallbacks, 1);
    assert!(
        contract
            .bootstrap
            .availability
            .iter()
            .find(|row| row.case == BootstrapAvailabilityCase::FirstBootstrap)
            .expect("first bootstrap contract")
            .offers_explicit_fallback_or_wait
    );
    assert!(
        contract
            .bootstrap
            .availability
            .iter()
            .all(|row| !row.may_serve_stale_as_current)
    );
}

#[test]
fn revision_page_contract_has_one_snapshot_bound_wire_shape() {
    let page = &production_readiness_contract_v1().revisions_page;
    assert_eq!(page.schema, "pointbreak.inspect-revisions-page.v1");
    assert_eq!(page.default_limit, 100);
    assert_eq!(page.maximum_limit, 500);
    assert!(page.absent_limit_uses_default);
    assert_eq!(
        page.over_maximum_limit,
        RevisionPageLimitOverflow::InvalidRequest
    );
    assert!(page.requested_entries_are_accepted_limit);
    assert!(page.token_is_opaque);
    assert!(page.token_binds_profile_schema_snapshot_and_order);
    assert!(page.same_wire_shape_for_active_and_default_off);
    assert_eq!(page.active_work, ProductWorkClass::OutputProportional);
    assert_eq!(page.default_off_work, ProductWorkClass::HistoryProportional);
    assert!(page.default_off_exhaustive_comparator_is_explicit);
    assert_eq!(
        page.revision_count_source,
        RevisionCountSource::DerivedIndexedAggregate
    );
    assert!(page.exact_detail_is_entity_primary);
}

#[test]
fn terminal_evaluator_is_fail_closed_and_keeps_the_default_decision_separate() {
    let contract = production_readiness_contract_v1();
    let passing = ReadinessGateId::ALL
        .into_iter()
        .map(ReadinessGateResultV1::passed)
        .collect::<Vec<_>>();
    assert_eq!(
        contract
            .evaluate(&passing)
            .expect("complete passing matrix"),
        ReadinessOutcome::ReadyForDefaultDecision
    );

    let mut operational_residual = passing.clone();
    let bounded = operational_residual
        .iter_mut()
        .find(|result| result.gate == ReadinessGateId::ActiveOrdinaryWorkBounded)
        .expect("bounded-work result");
    *bounded = ReadinessGateResultV1::failed(bounded.gate);
    assert_eq!(
        contract
            .evaluate(&operational_residual)
            .expect("compensable residual"),
        ReadinessOutcome::RemainDefaultOff
    );

    let mut parent_failure = passing.clone();
    let parent = parent_failure
        .iter_mut()
        .find(|result| result.gate == ReadinessGateId::ParentContractSatisfied)
        .expect("parent-contract result");
    *parent = ReadinessGateResultV1::failed(parent.gate);
    assert_eq!(
        contract
            .evaluate(&parent_failure)
            .expect("parent contract remains load-bearing"),
        ReadinessOutcome::RemainDefaultOff
    );

    let mut correctness_failure = passing;
    let exact = correctness_failure
        .iter_mut()
        .find(|result| result.gate == ReadinessGateId::NoFalseCurrentState)
        .expect("false-current result");
    *exact = ReadinessGateResultV1::failed(exact.gate);
    assert_eq!(
        contract
            .evaluate(&correctness_failure)
            .expect("non-compensable failure"),
        ReadinessOutcome::Reject
    );
    assert!(!contract.production_default_change_authorized);
}

#[test]
fn readiness_decision_table_is_derived_from_the_typed_contract() {
    let contract = production_readiness_contract_v1();
    let table = contract.decision_table_markdown();

    let mut changed_counter = contract.clone();
    changed_counter
        .counter_ceilings
        .iter_mut()
        .find(|row| {
            row.operation == ReadinessOperationId::ActiveOrdinaryNoChange
                && row.counter == ReadinessCounterId::EventDirectoryEntriesWalked
        })
        .expect("ordinary counter")
        .additive = 1;
    assert_ne!(table, changed_counter.decision_table_markdown());

    let mut changed_timing = contract.clone();
    changed_timing.numeric_wall_time_thresholds_present = true;
    assert_ne!(table, changed_timing.decision_table_markdown());

    let mut changed_page = contract;
    changed_page.revisions_page.default_limit = 50;
    assert_ne!(table, changed_page.decision_table_markdown());
}

#[test]
fn readiness_fixture_docs_and_non_timing_smoke_share_one_contract_hash() {
    let expected = format!(
        "{}\n",
        serde_json::to_string_pretty(&production_readiness_contract_fixture_v1())
            .expect("readiness fixture serializes")
    );
    verify_production_readiness_contract_fixture_v1().expect("embedded readiness fixture verifies");
    assert_eq!(
        expected,
        include_str!("../../../tests/fixtures/derived-access/production-readiness-v1.json")
    );
    let mut value: serde_json::Value =
        serde_json::from_str(&expected).expect("readiness fixture JSON parses");
    value
        .as_object_mut()
        .expect("readiness fixture object")
        .insert("unexpected".to_owned(), serde_json::Value::Bool(true));
    assert!(
        serde_json::from_value::<super::product_contract::ProductionReadinessContractFixtureV1>(
            value
        )
        .is_err(),
        "unknown readiness fixture fields must be rejected"
    );

    let docs = include_str!("../../../docs/benchmarking.md");
    let table = docs
        .split_once("<!-- derived-access-production-readiness-contract-v1:start -->\n")
        .expect("readiness docs start marker")
        .1
        .split_once("\n<!-- derived-access-production-readiness-contract-v1:end -->")
        .expect("readiness docs end marker")
        .0;
    assert_eq!(
        table,
        production_readiness_contract_publication_v1().decision_table_markdown
    );

    let smoke = production_readiness_contract_smoke_v1().expect("readiness smoke");
    assert_eq!(
        smoke.contract_sha256,
        PRODUCTION_READINESS_CONTRACT_SHA256_V1
    );
    assert_eq!(smoke.filesystem_actions, 0);
    assert_eq!(smoke.store_roots_opened, 0);
    assert!(!smoke.expensive_scale_work_run);

    assert_eq!(
        production_readiness_contract_v1().protected_inputs,
        vec![
            ProtectedInputId::OwnerStore,
            ProtectedInputId::PrivateCorpus,
            ProtectedInputId::PrivateSnapshotBytes,
            ProtectedInputId::QualificationCorpus,
            ProtectedInputId::Credentials,
            ProtectedInputId::InstalledArtifacts,
            ProtectedInputId::InstalledExtensionDogfoodEvidence,
            ProtectedInputId::RemoteMirrorAutomationState,
            ProtectedInputId::ArchivedEvidence,
            ProtectedInputId::ExternalParticipantEvidence,
            ProtectedInputId::ProductionDefault,
            ProtectedInputId::DeferredContentFormatExperiment,
        ]
    );
}

#[test]
fn current_rollout_contract_is_separate_canonical_and_inert() {
    let contract = derived_access_rollout_contract_v1();
    let actual_hash = contract
        .canonical_sha256()
        .expect("rollout contract is canonical");
    let expected_fixture = format!(
        "{}\n",
        serde_json::to_string_pretty(&derived_access_rollout_contract_fixture_v1())
            .expect("rollout fixture serializes")
    );
    assert_eq!(actual_hash, DERIVED_ACCESS_ROLLOUT_CONTRACT_SHA256_V1);
    assert_eq!(
        expected_fixture,
        include_str!("../../../tests/fixtures/derived-access/default-rollout-v1.json")
    );
    assert_eq!(
        contract.parent_product_integration_sha256,
        PRODUCT_INTEGRATION_CONTRACT_SHA256_V1
    );
    assert_eq!(
        contract.parent_production_readiness_sha256,
        PRODUCTION_READINESS_CONTRACT_SHA256_V1
    );
    assert_eq!(
        contract.default_profile,
        DerivedAccessProfile::SqliteWalBodylessV1
    );
    assert_eq!(contract.explicit_off_profile, DerivedAccessProfile::Off);
    assert_eq!(contract.stable_layout[0], "derived");
    assert_eq!(contract.legacy_layout[0], ".pointbreak-derived");
    assert!(!contract.ordinary_synchronous_rebuild_allowed);
    assert!(contract.explicit_off_is_artifact_free);
    assert!(contract.historical_contracts_immutable);
    assert!(!contract.truth_migration_authorized);

    let publication = derived_access_rollout_contract_publication_v1();
    assert_eq!(publication.contract_sha256, actual_hash);
    let docs = include_str!("../../../docs/benchmarking.md");
    let table = docs
        .split_once("<!-- derived-access-rollout-contract-v1:start -->\n")
        .expect("rollout docs start marker")
        .1
        .split_once("\n<!-- derived-access-rollout-contract-v1:end -->")
        .expect("rollout docs end marker")
        .0;
    assert_eq!(table, publication.decision_table_markdown);
    let smoke = derived_access_rollout_contract_smoke_v1().expect("rollout smoke");
    assert_eq!(smoke.filesystem_actions, 0);
    assert_eq!(smoke.store_roots_opened, 0);
    assert!(!smoke.evidence_collected);
}

#[test]
fn live_documentation_tracks_the_default_on_rollout() {
    let cli = include_str!("../../../docs/cli-reference.md");
    let installation = include_str!("../../../docs/installation.md");
    let benchmarking = include_str!("../../../docs/benchmarking.md");
    let normalized_cli = cli.split_whitespace().collect::<Vec<_>>().join(" ");

    for docs in [cli, installation, benchmarking] {
        assert!(
            docs.contains("POINTBREAK_DERIVED_ACCESS=off"),
            "every operator-facing surface must retain the explicit-off rollback"
        );
        assert!(
            docs.contains("pointbreak store derived status"),
            "every operator-facing surface must name the read-only diagnostic command"
        );
    }

    assert!(cli.contains("exact resolved authoritative store root"));
    assert!(cli.contains("A first bounded CLI read"));
    assert!(cli.contains("A first write"));
    assert!(cli.contains("macOS/APFS and Windows/NTFS"));
    assert!(normalized_cli.contains(
        "Linux remains compile/CI qualified; that support surface does not substitute for retained-scale \
         Linux measurements"
    ));
    assert!(cli.contains("both the stable `derived/` namespace"));
    assert!(normalized_cli.contains("retain one disposable copy and move the other aside"));
    assert!(cli.contains("Pointbreak never guesses, merges, or deletes either"));

    assert!(installation.contains("## Derived access after upgrade"));
    assert!(installation.contains("legacy `.pointbreak-derived/`"));
    assert!(installation.contains("retain one disposable copy and move the other aside"));
    assert!(installation.contains("may scan the complete"));
    assert!(installation.contains("event history"));

    assert!(benchmarking.contains("## Derived-access default rollout contract"));
    assert!(benchmarking.contains("authoritative current runtime posture"));
    assert!(benchmarking.contains("Platform scope | native `macOS APFS`, `Windows NTFS`"));
}

#[test]
fn coupled_storage_adrs_record_the_as_built_default_on_follow_through() {
    let adrs = [
        include_str!("../../../docs/adr/adr-0020-durable-storage-backend-seam.md"),
        include_str!("../../../docs/adr/adr-0023-secondary-read-index-shape.md"),
        include_str!("../../../docs/adr/adr-0024-secondary-read-index-substrate.md"),
        include_str!("../../../docs/adr/adr-0041-bodyless-sqlite-derived-access.md"),
    ];

    for adr in adrs {
        let amendment = adr
            .rsplit_once("## Amendment: Default-On Derived-Access Rollout (2026-08-03)")
            .expect("as-built rollout amendment")
            .1;
        assert!(amendment.contains("`pointbreak store derived status|build|rebuild`"));
        assert!(amendment.contains("POINTBREAK_DERIVED_ACCESS=off"));
        assert!(amendment.contains("rollback"));
        assert!(amendment.contains("No authoritative truth migration"));
    }
}