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
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum EventType {
    ReviewInitialized,
    WorkObjectProposed,
    ReviewObservationRecorded,
    ReviewAssessmentRecorded,
    InputRequestOpened,
    InputRequestResponded,
    /// Legacy (retired write path, ADR-0030 second amendment): retained solely
    /// so old stores that recorded this kind still decode; no projection
    /// consumes it.
    ReviewNoteImported,
    RevisionRefAssociated,
    RevisionRefWithdrawn,
    RevisionCommitAssociated,
    RevisionCommitWithdrawn,
    ValidationCheckRecorded,
    TaskCheckpointCaptured,
    TaskObservationRecorded,
    EventSignatureRecorded,
    ArtifactRemoved,
    ChangeDeclared,
    ChangeMembershipAsserted,
    ChangeMembershipWithdrawn,
    ChangeLinkAsserted,
    ChangeRevisionRelationAsserted,
    ChangeRevisionRelationWithdrawn,
    RevisionRelationAttested,
    ReviewFactPorted,
}

impl EventType {
    /// The snake_case wire string for this event type, matching the serde
    /// representation. Used for per-type counts (e.g. `eventsCreatedByType`).
    pub fn as_str(self) -> &'static str {
        match self {
            Self::ReviewInitialized => "review_initialized",
            Self::WorkObjectProposed => "work_object_proposed",
            Self::ReviewObservationRecorded => "review_observation_recorded",
            Self::ReviewAssessmentRecorded => "review_assessment_recorded",
            Self::InputRequestOpened => "input_request_opened",
            Self::InputRequestResponded => "input_request_responded",
            Self::ReviewNoteImported => "review_note_imported",
            Self::RevisionRefAssociated => "revision_ref_associated",
            Self::RevisionRefWithdrawn => "revision_ref_withdrawn",
            Self::RevisionCommitAssociated => "revision_commit_associated",
            Self::RevisionCommitWithdrawn => "revision_commit_withdrawn",
            Self::ValidationCheckRecorded => "validation_check_recorded",
            Self::TaskCheckpointCaptured => "task_checkpoint_captured",
            Self::TaskObservationRecorded => "task_observation_recorded",
            Self::EventSignatureRecorded => "event_signature_recorded",
            Self::ArtifactRemoved => "artifact_removed",
            Self::ChangeDeclared => "change_declared",
            Self::ChangeMembershipAsserted => "change_membership_asserted",
            Self::ChangeMembershipWithdrawn => "change_membership_withdrawn",
            Self::ChangeLinkAsserted => "change_link_asserted",
            Self::ChangeRevisionRelationAsserted => "change_revision_relation_asserted",
            Self::ChangeRevisionRelationWithdrawn => "change_revision_relation_withdrawn",
            Self::RevisionRelationAttested => "revision_relation_attested",
            Self::ReviewFactPorted => "review_fact_ported",
        }
    }

    /// Every `EventType` variant, in declaration order. The canonical list tests
    /// iterate so a variant is enumerated in exactly one place. Kept complete by
    /// `all_is_exhaustive` below. Test-only: the sole consumers are `#[cfg(test)]`
    /// registries/agreement tests, so gating it keeps the lib pass free of a
    /// dead-code warning under `-D warnings`.
    #[cfg(test)]
    pub(crate) const ALL: [EventType; 24] = [
        Self::ReviewInitialized,
        Self::WorkObjectProposed,
        Self::ReviewObservationRecorded,
        Self::ReviewAssessmentRecorded,
        Self::InputRequestOpened,
        Self::InputRequestResponded,
        Self::ReviewNoteImported,
        Self::RevisionRefAssociated,
        Self::RevisionRefWithdrawn,
        Self::RevisionCommitAssociated,
        Self::RevisionCommitWithdrawn,
        Self::ValidationCheckRecorded,
        Self::TaskCheckpointCaptured,
        Self::TaskObservationRecorded,
        Self::EventSignatureRecorded,
        Self::ArtifactRemoved,
        Self::ChangeDeclared,
        Self::ChangeMembershipAsserted,
        Self::ChangeMembershipWithdrawn,
        Self::ChangeLinkAsserted,
        Self::ChangeRevisionRelationAsserted,
        Self::ChangeRevisionRelationWithdrawn,
        Self::RevisionRelationAttested,
        Self::ReviewFactPorted,
    ];
}

/// Adding an `EventType` variant breaks this match until the variant is also
/// appended to [`EventType::ALL`]. It exists only to make that coupling a compile
/// error rather than a silent test-coverage gap; it is invoked from the tests so
/// it carries no runtime cost and trips no dead-code lint.
#[cfg(test)]
fn all_is_exhaustive(event_type: EventType) {
    match event_type {
        EventType::ReviewInitialized
        | EventType::WorkObjectProposed
        | EventType::ReviewObservationRecorded
        | EventType::ReviewAssessmentRecorded
        | EventType::InputRequestOpened
        | EventType::InputRequestResponded
        | EventType::ReviewNoteImported
        | EventType::RevisionRefAssociated
        | EventType::RevisionRefWithdrawn
        | EventType::RevisionCommitAssociated
        | EventType::RevisionCommitWithdrawn
        | EventType::ValidationCheckRecorded
        | EventType::TaskCheckpointCaptured
        | EventType::TaskObservationRecorded
        | EventType::EventSignatureRecorded
        | EventType::ArtifactRemoved
        | EventType::ChangeDeclared
        | EventType::ChangeMembershipAsserted
        | EventType::ChangeMembershipWithdrawn
        | EventType::ChangeLinkAsserted
        | EventType::ChangeRevisionRelationAsserted
        | EventType::ChangeRevisionRelationWithdrawn
        | EventType::RevisionRelationAttested
        | EventType::ReviewFactPorted => {}
    }
}

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

    #[test]
    fn all_lists_every_variant_once() {
        // Every variant appears exactly once, and the count matches the enum arity.
        assert_eq!(EventType::ALL.len(), 24);
        for variant in EventType::ALL {
            let occurrences = EventType::ALL.iter().filter(|&&v| v == variant).count();
            assert_eq!(
                occurrences, 1,
                "{variant:?} must appear exactly once in ALL"
            );
            // Anchor the completeness reminder so a new variant forces an ALL update.
            all_is_exhaustive(variant);
        }
        // ALL agrees with the serde round-trip surface for every listed variant.
        for variant in EventType::ALL {
            let encoded = serde_json::to_string(&variant).unwrap();
            let decoded: EventType = serde_json::from_str(&encoded).unwrap();
            assert_eq!(decoded, variant);
        }
    }

    #[test]
    fn as_str_matches_serde_wire_string_for_every_variant() {
        for variant in [
            EventType::ReviewInitialized,
            EventType::WorkObjectProposed,
            EventType::ReviewObservationRecorded,
            EventType::ReviewAssessmentRecorded,
            EventType::InputRequestOpened,
            EventType::InputRequestResponded,
            EventType::ReviewNoteImported,
            EventType::RevisionRefAssociated,
            EventType::RevisionRefWithdrawn,
            EventType::RevisionCommitAssociated,
            EventType::RevisionCommitWithdrawn,
            EventType::ValidationCheckRecorded,
            EventType::TaskCheckpointCaptured,
            EventType::TaskObservationRecorded,
            EventType::EventSignatureRecorded,
            EventType::ArtifactRemoved,
            EventType::ChangeDeclared,
            EventType::ChangeMembershipAsserted,
            EventType::ChangeMembershipWithdrawn,
            EventType::ChangeLinkAsserted,
            EventType::ChangeRevisionRelationAsserted,
            EventType::ChangeRevisionRelationWithdrawn,
            EventType::RevisionRelationAttested,
            EventType::ReviewFactPorted,
        ] {
            let serde_wire = serde_json::to_value(variant).unwrap();
            assert_eq!(
                serde_wire,
                serde_json::json!(variant.as_str()),
                "as_str() must equal the serde wire string for {variant:?}"
            );
        }
    }

    #[test]
    fn association_family_wire_strings_match() {
        assert_eq!(
            EventType::RevisionRefAssociated.as_str(),
            "revision_ref_associated"
        );
        assert_eq!(
            EventType::RevisionRefWithdrawn.as_str(),
            "revision_ref_withdrawn"
        );
        assert_eq!(
            EventType::RevisionCommitAssociated.as_str(),
            "revision_commit_associated"
        );
        assert_eq!(
            EventType::RevisionCommitWithdrawn.as_str(),
            "revision_commit_withdrawn"
        );
        for variant in [
            EventType::RevisionRefAssociated,
            EventType::RevisionRefWithdrawn,
            EventType::RevisionCommitAssociated,
            EventType::RevisionCommitWithdrawn,
        ] {
            assert_eq!(
                serde_json::to_value(variant).unwrap(),
                serde_json::json!(variant.as_str())
            );
        }
    }

    #[test]
    fn artifact_removed_event_type_serializes_as_snake_case() {
        assert_eq!(
            serde_json::to_string(&EventType::ArtifactRemoved).unwrap(),
            "\"artifact_removed\""
        );
        assert_eq!(EventType::ArtifactRemoved.as_str(), "artifact_removed");
    }

    #[test]
    fn event_signature_event_type_serializes_as_snake_case() {
        assert_eq!(
            serde_json::to_string(&EventType::EventSignatureRecorded).unwrap(),
            "\"event_signature_recorded\""
        );
        assert_eq!(
            EventType::EventSignatureRecorded.as_str(),
            "event_signature_recorded"
        );
    }

    #[test]
    fn task_event_types_serialize_as_snake_case() {
        assert_eq!(
            serde_json::to_string(&EventType::TaskCheckpointCaptured).unwrap(),
            "\"task_checkpoint_captured\""
        );
        assert_eq!(
            serde_json::to_string(&EventType::TaskObservationRecorded).unwrap(),
            "\"task_observation_recorded\""
        );
    }

    #[test]
    fn task_event_types_round_trip_through_serde() {
        for variant in [
            EventType::TaskCheckpointCaptured,
            EventType::TaskObservationRecorded,
        ] {
            let encoded = serde_json::to_string(&variant).unwrap();
            let decoded: EventType = serde_json::from_str(&encoded).unwrap();
            assert_eq!(decoded, variant);
        }
    }

    #[test]
    fn task_event_types_are_distinct_from_review_event_types() {
        let review_domain = [
            EventType::ReviewInitialized,
            EventType::ReviewObservationRecorded,
            EventType::ReviewAssessmentRecorded,
            EventType::InputRequestOpened,
            EventType::InputRequestResponded,
            EventType::ReviewNoteImported,
        ];
        let task_domain = [
            EventType::TaskCheckpointCaptured,
            EventType::TaskObservationRecorded,
        ];

        for review in review_domain {
            let review_encoded = serde_json::to_string(&review).unwrap();
            for task in task_domain {
                let task_encoded = serde_json::to_string(&task).unwrap();
                assert_ne!(
                    review_encoded, task_encoded,
                    "review variant {review:?} and task variant {task:?} collide on the wire"
                );
            }
        }
    }

    #[test]
    fn work_object_proposed_event_type_serializes_as_snake_case() {
        assert_eq!(
            serde_json::to_string(&EventType::WorkObjectProposed).unwrap(),
            "\"work_object_proposed\""
        );
        assert_eq!(
            EventType::WorkObjectProposed.as_str(),
            "work_object_proposed"
        );
    }

    #[test]
    fn collapsed_capture_event_types_no_longer_decode() {
        for legacy in ["review_unit_captured", "task_attempt_captured"] {
            let result: Result<EventType, _> = serde_json::from_str(&format!("\"{legacy}\""));
            assert!(
                result.is_err(),
                "{legacy} must not decode after the generative-move collapse"
            );
        }
    }

    #[test]
    fn deferred_event_types_are_not_present() {
        for candidate in [
            "task_assessment_recorded",
            "source_artifact_imported",
            "review_relation_changed",
            "review_state_change_observed",
            "review_assessment_superseded",
        ] {
            let result: Result<EventType, _> = serde_json::from_str(&format!("\"{candidate}\""));
            assert!(
                result.is_err(),
                "{candidate} must not decode as an event type"
            );
        }
    }

    #[test]
    fn legacy_review_disposition_recorded_event_type_fails_to_decode_after_split() {
        let result: Result<EventType, _> = serde_json::from_str("\"review_disposition_recorded\"");
        assert!(
            result.is_err(),
            "review_disposition_recorded must not decode after the assessment split"
        );
    }

    #[test]
    fn legacy_intervention_event_types_fail_to_decode_after_input_request_rename() {
        for event_type in ["intervention_requested", "intervention_resolved"] {
            let result: Result<EventType, _> = serde_json::from_str(&format!("\"{event_type}\""));
            assert!(
                result.is_err(),
                "{event_type} must not decode after the input request rename"
            );
        }
    }

    #[test]
    fn input_request_event_type_wire_strings_are_stable() {
        assert_eq!(
            serde_json::to_string(&EventType::InputRequestOpened).unwrap(),
            "\"input_request_opened\""
        );
        assert_eq!(
            serde_json::to_string(&EventType::InputRequestResponded).unwrap(),
            "\"input_request_responded\""
        );
    }

    #[test]
    fn validation_event_type_serializes_as_snake_case() {
        assert_eq!(
            serde_json::to_string(&EventType::ValidationCheckRecorded).unwrap(),
            "\"validation_check_recorded\""
        );
        assert_eq!(
            EventType::ValidationCheckRecorded.as_str(),
            "validation_check_recorded"
        );
    }

    #[test]
    fn legacy_association_event_type_wire_strings_no_longer_decode() {
        for legacy in [
            "review_unit_ref_associated",
            "review_unit_ref_withdrawn",
            "review_unit_commit_associated",
            "review_unit_commit_withdrawn",
        ] {
            let result: Result<EventType, _> = serde_json::from_str(&format!("\"{legacy}\""));
            assert!(
                result.is_err(),
                "{legacy} must not decode after the association family renames to revision_*"
            );
        }
    }

    #[test]
    fn retired_lineage_event_types_no_longer_decode() {
        for retired in [
            "review_unit_lineage_declared",
            "review_unit_lineage_round_recorded",
        ] {
            let result: Result<EventType, _> = serde_json::from_str(&format!("\"{retired}\""));
            assert!(
                result.is_err(),
                "{retired} must not decode after lineage is retired for supersession"
            );
        }
    }
}