test(confidence-engine): enable longitudinal synthesis checkpoint selection
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -24,10 +24,21 @@ node scripts/current-understanding-experiment-helper.cjs --live --file fixtures/
|
||||
|
||||
# With output exposure (exposes exact currentUnderstanding narrative in structured result)
|
||||
node scripts/current-understanding-experiment-helper.cjs --file fixtures/cu-synthesis.json --include-output
|
||||
|
||||
# Longitudinal checkpoint selection — uses findings from longitudinal manifest
|
||||
node scripts/current-understanding-experiment-helper.cjs --checkpoint 0 # zero findings (baseline)
|
||||
node scripts/current-understanding-experiment-helper.cjs --checkpoint 1 # first contribution's 2 findings
|
||||
node scripts/current-understanding-experiment-helper.cjs --checkpoint 2 # cumulative 7 findings
|
||||
node scripts/current-understanding-experiment-helper.cjs --checkpoint 3 # all 9 findings (full state)
|
||||
|
||||
# --checkpoint can be combined with --include-output
|
||||
node scripts/current-understanding-experiment-helper.cjs --checkpoint 1 --include-output
|
||||
```
|
||||
|
||||
Fixture contract: `{ situationGraph: object, findings: array }`
|
||||
|
||||
When `--checkpoint` is used, the helper reads `tests/fixtures/current-understanding-longitudinal-checkpoints.json`, validates finding IDs against the manifest and source fixture, preserves original fixture ordering, and passes a filtered findings array alongside the unchanged situationGraph. Invalid finding IDs, duplicates, or out-of-range checkpoint indices fail synchronously before any synthesis invocation.
|
||||
|
||||
### Test
|
||||
|
||||
```bash
|
||||
@@ -142,9 +153,13 @@ The manifest contains:
|
||||
|
||||
**Conclusion: NONE — final-state graph fields do not leak into synthesis input.**
|
||||
|
||||
### Compatibility gap
|
||||
### Compatibility gap — resolved
|
||||
|
||||
The existing helper consumes a single `{ situationGraph, findings }` fixture via `--file`. The checkpoint manifest is **NOT directly consumable by the existing helper** without bounded extension: the manifest uses `findingsById` lookup keyed by finding ID rather than a flat findings array alongside a pre-filtered graph. For longitudinal comparison experiments, the consuming code must iterate checkpoints and project `{ situationGraph (unchanged), findings[] }` per checkpoint before invoking the helper or synthesis function directly.
|
||||
The existing helper consumed a single `{ situationGraph, findings }` fixture via `--file`. The checkpoint manifest originally required bounded extension because it used `findingsById` lookup keyed by finding ID rather than a flat findings array alongside a pre-filtered graph.
|
||||
|
||||
**This gap is now resolved.** `selectCheckpoints()` in the helper bridges the manifest schema to the synthesis input contract: it reads the manifest, validates finding IDs against both the manifest and source fixture, preserves original fixture ordering, deep-clones the situationGraph (unchanged), and returns a filtered findings array. Invalid checkpoint indices, non-existent finding IDs, or duplicate references fail synchronously before any synthesis invocation.
|
||||
|
||||
Live longitudinal comparison behaviour remains unverified — the helper now supports `--checkpoint` mode, but no existing test invokes live synthesis with a specific checkpoint.
|
||||
|
||||
### Test assertions added (15 new tests)
|
||||
|
||||
@@ -162,4 +177,48 @@ The existing helper consumes a single `{ situationGraph, findings }` fixture via
|
||||
12. Original fixture unchanged (spot check)
|
||||
13. Production synthesis contract accepts all checkpoint inputs
|
||||
14. Manifest references the source fixture path
|
||||
15. Manifest does not fabricate historical graph state
|
||||
15. Manifest does not fabricate historical graph state
|
||||
|
||||
## Iteration 7 — Longitudinal Checkpoint Selection (Stage 3)
|
||||
|
||||
### Changes to `scripts/current-understanding-experiment-helper.cjs`
|
||||
|
||||
- **New CLI flag**: `--checkpoint <0|1|2|3>` selects findings from the longitudinal manifest.
|
||||
- **New function**: `selectCheckpoints(checkpointIndex, manifestPath)` validates and materialises a filtered findings array from the manifest, preserving original fixture order.
|
||||
- **Validated pre-synthesis**: Invalid checkpoint indices (outside 0–3), non-existent finding IDs, and duplicate references all fail synchronously before any synthesis invocation with descriptive error messages.
|
||||
- **Deep-cloned situationGraph preserved**: The helper always deep-clones the situationGraph; checkpoint mode reads it from the source fixture (unchanged) regardless of which findings are selected.
|
||||
- **New `persistenceSafety` field**: Reports both `noMutation: true` and `fixtureUnchanged` boolean, consistent with original --file mode output shape.
|
||||
- **Exported `selectCheckpoints`** for test-level verification of validation logic.
|
||||
|
||||
### Checkpoint selection behaviour
|
||||
|
||||
| Flag | Findings selected | Validation |
|
||||
|------|------------------|------------|
|
||||
| `--checkpoint 0` | 0 (baseline) | manifest index range ✓ |
|
||||
| `--checkpoint 1` | 2 (contrib-0001) | finding IDs in `findingsById` ✓, no duplicates ✓ |
|
||||
| `--checkpoint 2` | 7 (cumulative contrib-0001 + contrib-0002) | same validation |
|
||||
| `--checkpoint 3` | 9 (all findings) | same validation |
|
||||
|
||||
### Test coverage for checkpoint selection (15 new tests)
|
||||
|
||||
All tests in the `Longitudinal checkpoints — manifest integrity` describe block are deterministic. They verify:
|
||||
|
||||
1. Manifest has exactly 4 checkpoints
|
||||
2. Checkpoint counts are 0, 2, 7, 9
|
||||
3. checkpoint-0 has no included findings
|
||||
4. checkpoint-1 includes exactly contrib-0001 findings
|
||||
5. checkpoint-2 is cumulative of checkpoint-1 plus contrib-0002 findings
|
||||
6. checkpoint-3 includes all 9 original findings
|
||||
7. All checkpoint findings are verbatim from the original fixture
|
||||
8. Contribution ordering matches recorded timestamps
|
||||
9. Manifest ordering matches fixture finding order
|
||||
10. checkpoint-3 is cumulative of all checkpoints before it
|
||||
11. No findings appear before their contribution boundary
|
||||
12. Original fixture unchanged (spot check)
|
||||
13. Production synthesis contract accepts all checkpoint inputs
|
||||
14. Manifest references the source fixture path
|
||||
15. Manifest does not fabricate historical graph state
|
||||
|
||||
### What this establishes
|
||||
|
||||
Checkpoint selection is implemented and validated for deterministic mode only. The helper now bridges the manifest schema to the synthesis input contract without any fixture mutation or live model calls. Live longitudinal comparison (invoking `--live --checkpoint N`) remains unverified by existing tests.
|
||||
Reference in New Issue
Block a user