Skip to content

Cockpit D2 — evidence freshness projection - #49

Draft
LogicDuke wants to merge 1 commit into
mainfrom
cockpit/d2-evidence-freshness-projection
Draft

Cockpit D2 — evidence freshness projection#49
LogicDuke wants to merge 1 commit into
mainfrom
cockpit/d2-evidence-freshness-projection

Conversation

@LogicDuke

Copy link
Copy Markdown
Owner

Cockpit D2 — evidence freshness projection

DRAFT. No Ready authority. No merge authority. No reviewer triggers.

Baseline

D2 single responsibility

Project PR 004 evidence-freshness answers for the evidence records contained in one already-validated CockpitSnapshot. Presentation / observability only.

Trust boundary — Option A

The public API consumes a CockpitSnapshot that has already passed D1's readCockpitSnapshot() boundary. D1 owns hostile unknown input; D2 adds no second reader, no invalidFields envelope, no malformed-input pseudo-validation. A zero-result projection means the valid snapshot's evidence list is actually empty.

One-way data flow

validated CockpitSnapshot
  -> snapshot evidence read models
  -> minimal EvidenceRecord reconstruction
  -> EvidenceTarget derived from the enclosing snapshot
  -> PR 004 evaluateEvidenceSet()
  -> immutable Cockpit presentation projection

No reverse arrow.

Freshness kernel reuse (PR 004)

EvidenceRecord / EvidenceKind / EvidenceSource from src/domain/evidence.ts; EvidenceTarget / evaluateEvidenceSet / FreshnessState / FreshnessReason / FRESHNESS from src/domain/evidence-freshness.ts. No SHA comparison in Cockpit; state / reason / invalidFields copied verbatim.

Identity rules

  • repositoryId injection: every reconstructed record takes repositoryId from snapshot.repository.repositoryId (a D1 snapshot describes exactly one repository; the D1 read model is unchanged).
  • observedHeadSha target: the single EvidenceTarget is { repositoryId: snapshot.repository.repositoryId, currentHeadSha: snapshot.repository.observedHeadSha }, read once into locals. No evidence commitSha, advisory echo, finding, PR, reviewer, or metadata value can become HEAD.
  • Finding freshness: OUT OF SCOPE. findings[*].advisoryFreshness is never read.

Public API

projectCockpitEvidenceFreshness(snapshot: CockpitSnapshot): CockpitEvidenceFreshnessProjection
// types: CockpitEvidenceFreshnessItem, CockpitEvidenceFreshnessCounts, CockpitEvidenceFreshnessProjection

Flat, input-ordered results + counts { current, stale, invalid, total }. No buckets. Deeply frozen, detached, JSON-round-trip stable, ambient-realm robust (captured intrinsics, null-proto records, insulated descriptors, list toJSON shadow).

Exact file scope (5 files)

  • ADD docs/architecture/D2-cockpit-evidence-freshness-projection.md
  • ADD src/cockpit/evidence-freshness-projection.ts
  • MODIFY src/cockpit/index.ts
  • ADD tests/cockpit/evidence-freshness-projection.test.ts
  • MODIFY tests/cockpit/architecture-invariants.test.ts (exact single-name exception for projectCockpitEvidenceFreshness; no general project* grant; authority-name checks unchanged)

No D1 read-model modification. No domain kernel modification. No dependency change. No authority expansion. No new bound beyond D1's 1,000 evidence records.

Deterministic verification

  • D2 focused: 24 passed
  • Cockpit: 4 files / 83 passed
  • Domain evidence-freshness: 2 files / 169 passed
  • Full suite: 19 files / 989 passed
  • typecheck: clean · lint: clean · build: clean · git diff --check: clean

Independent checks

  • Fresh independent validator (new claude -p process, no --resume, on the uncommitted candidate): VALIDATION = PASS (7 non-blocking observations; one doc wording note applied before commit)
  • Second-order closure: PASS

Untouched

🤖 Generated with Claude Code

Cockpit D2: project PR 004 evidence-freshness answers for the evidence
records of one already-validated CockpitSnapshot (Option A trust boundary).
Repository identity and target HEAD come only from the enclosing snapshot;
PR 004 remains the sole freshness authority. Presentation only: no
authority, validation duplication, I/O, or new bound beyond D1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ca1e274-06e8-4a9b-b4de-69ea04ec675d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant