Skip to content

D1-44-F1 — reject unreadable optional fields - #45

Merged
LogicDuke merged 1 commit into
cockpit/d1-read-model-contractfrom
repair/d1-44-optional-getter
Aug 21, 2026
Merged

D1-44-F1 — reject unreadable optional fields#45
LogicDuke merged 1 commit into
cockpit/d1-read-model-contractfrom
repair/d1-44-optional-getter

Conversation

@LogicDuke

@LogicDuke LogicDuke commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Purpose

This stacked validation PR repairs exactly one verified finding from parent PR #44.

Finding:

D1-44-F1

Classification on parent HEAD:

CURRENT

Severity:

P2

Repair candidate status:

FIXED

Protected parent

Parent PR:

#44

Parent branch:

cockpit/d1-read-model-contract

Exact affected parent HEAD:

04f751e5488b6ce8cf4f140f82a1f3dd740c8ed2

This child must not mutate the parent directly.

Repair identity

Repair commit:

72ee36e43371211a382f286557c974398b1fd0dc

Repair tree SHA:

a8b385e49bc715721f3a4bd4d5646be3e9b98d07

Validated repair patch SHA-256:

FC373FF37C5F345E6471976F127656079064E641F1480C506680DC439D85614E

Patch size:

7,964 bytes

Verified defect

D1 optional-field handling collapsed:

  • genuinely ABSENT property
  • PRESENT-BUT-UNREADABLE property

into the same value.

That allowed throwing own getters on these optional fields to be accepted as valid null:

  • repository.defaultBranchRef
  • pullRequests[].baseRef
  • pullRequests[].title
  • findings[].filePath

Protected invariant

A genuinely absent optional property may be accepted as absence.

A PRESENT-BUT-UNREADABLE optional property must fail closed.

Exact repair scope

Exactly 2 changed files:

  • src/cockpit/read-model.ts
  • tests/cockpit/read-model-invariants.test.ts

No other files.

No package changes.

No dependency changes.

No public API changes.

No shared readOwnProperty change.

No Autoflow changes.

No transport changes.

No adapter changes.

No PR #9 changes.

Repair shape

The repair adds only a D1-local private distinction between:

  • ABSENT
  • VALUE
  • UNREADABLE

Semantics:

ABSENT
→ accepted as legitimate optional absence

VALUE
→ existing validation behavior

UNREADABLE
→ invalid / snapshot rejected

The shared domain reader remains untouched.

Independent validation

Fresh independent validation:

PASS

Finding status on candidate:

FIXED

Reproducer closure:

  • defaultBranchRef throwing getter: PASS
  • baseRef throwing getter: PASS
  • title throwing getter: PASS
  • filePath throwing getter: PASS
  • true absence preserved: PASS
  • malformed value rejection preserved: PASS

Tests

Focused invariant:

16 passed

Cockpit:

43 passed / 3 files

Full suite:

928 passed / 18 files

Typecheck:

PASS

Lint:

PASS

Build:

PASS

git diff --check:

PASS

Authority boundary

This PR is intentionally DRAFT.

It is a quarantined validation child.

Do not merge it directly to main.

If validated, human integration must merge it upward into:

cockpit/d1-read-model-contract

using CREATE A MERGE COMMIT.

Parent PR #44 remains protected and untouched until that gate.

No Ready authority is granted by this PR creation.

Human merge authority is preserved.

Summary by CodeRabbit

  • Bug Fixes

    • Improved snapshot handling when optional data cannot be safely read.
    • Invalid pull-request titles, base branches, file paths, or repository default branches are now rejected instead of being treated as missing.
    • Genuinely absent optional fields continue to be accepted and normalized appropriately.
  • Tests

    • Added coverage for unreadable optional properties and valid absent properties.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 295d97e2-900f-4fc4-a6f9-c01dfb9ea9b7

📥 Commits

Reviewing files that changed from the base of the PR and between 04f751e and 72ee36e.

📒 Files selected for processing (2)
  • src/cockpit/read-model.ts
  • tests/cockpit/read-model-invariants.test.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The read model now distinguishes absent optional properties from present properties that fail during presence checks or getter access. Pull-request, finding, and repository fields reject unreadable values. Tests cover rejection and null normalization.

Changes

Fail-closed optional property reads

Layer / File(s) Summary
Guarded optional reader and field wiring
src/cockpit/read-model.ts
The read model reads own optional properties once, marks presence-check and getter failures as unreadable, rejects those failures, and applies the behavior to baseRef, title, filePath, and defaultBranchRef.
Unreadable and absent property coverage
tests/cockpit/read-model-invariants.test.ts
Tests verify that throwing getters reject ingestion and that absent optional properties normalize to null.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 72ee3

The PR narrowly changes optional-field validation so present-but-unreadable values are rejected while genuinely absent fields remain accepted; reported validation checks pass, and no actionable merge-blocking risk remains after normal review.

Poem

I checked each field with careful care,
A missing leaf is still called bare.
But if a getter hides its view,
The snapshot fails as it should do.
Hop, hop—null stays true when absent!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting unreadable optional fields.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch repair/d1-44-optional-getter

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.

@LogicDuke

Copy link
Copy Markdown
Owner Author

@codex review

Review ONLY PR #45 at exact CURRENT HEAD:

72ee36e

This child repairs exactly one verified defect:

D1-44-F1

Scope is exactly:

  • src/cockpit/read-model.ts
  • tests/cockpit/read-model-invariants.test.ts

Review mandate:

Verify only whether this repair correctly enforces:

  • genuine absence remains accepted
  • present-but-unreadable optional fields fail closed
  • valid values remain accepted
  • malformed values remain rejected
  • no public API change
  • no unrelated behavior change

Do NOT search for unrelated defects.

Do NOT report:

  • style
  • naming
  • speculative refactors
  • future-layer issues
  • unrelated hardening
  • documentation wording
  • issues outside this 2-file repair

For any claimed defect provide:

  • exact changed line/path
  • concrete reachable failure
  • minimal reproducer
  • why existing tests do not already prevent it

Reviewer output is evidence, not authority.

@LogicDuke

Copy link
Copy Markdown
Owner Author

@coderabbitai review

Review ONLY PR #45 at exact CURRENT HEAD:

72ee36e

This is a bounded two-file repair for:

D1-44-F1

Review only:

  • correctness of ABSENT / VALUE / UNREADABLE handling
  • regression risk introduced by this exact diff
  • scope leakage in these two files

Do NOT search for:

  • unrelated issues
  • style
  • naming preference
  • refactors
  • future architecture
  • adjacent hardening
  • documentation concerns

Reviewer output is evidence, not authority.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected='72ee36e43371211a382f286557c974398b1fd0dc'
parent='04f751e5488b6ce8cf4f140f82a1f3dd740c8ed2'

echo '== HEAD =='
git rev-parse HEAD
echo '== expected commit exists =='
git rev-parse "$expected"
echo '== changed paths =='
git diff-tree --no-commit-id --name-only -r "$expected"
echo '== repair diff =='
git diff --no-ext-diff --unified=80 "$parent" "$expected" -- \
  src/cockpit/read-model.ts \
  tests/cockpit/read-model-invariants.test.ts

echo '== implementation outline =='
ast-grep outline src/cockpit/read-model.ts --items all
echo '== test outline =='
ast-grep outline tests/cockpit/read-model-invariants.test.ts --items all

Length of output: 29540


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== read-model helpers and affected readers =='
sed -n '80,115p;430,590p;630,760p' src/cockpit/read-model.ts

echo '== optional-field test references and surrounding assertions =='
rg -n -C 5 --glob 'read-model-*.test.ts' \
  'defaultBranchRef|baseRef|filePath|pullRequests.*title|title.*pullRequests' \
  tests/cockpit

echo '== changed test file remaining content =='
sed -n '1,360p' tests/cockpit/read-model-invariants.test.ts

echo '== exact diff statistics and whitespace check =='
git diff --check 04f751e5488b6ce8cf4f140f82a1f3dd740c8ed2 72ee36e43371211a382f286557c974398b1fd0dc
git diff --stat 04f751e5488b6ce8cf4f140f82a1f3dd740c8ed2 72ee36e43371211a382f286557c974398b1fd0dc

Length of output: 30958


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== shared reader import and declaration =='
sed -n '45,82p' src/cockpit/read-model.ts
rg -n -C 8 --glob '*.{ts,tsx}' \
  'function readOwnProperty\b|const readOwnProperty\b|export .*readOwnProperty\b' \
  src

echo '== focused cockpit read-model test files =='
fd -t f -e ts . tests/cockpit | sort | grep 'read-model'

echo '== malformed optional-value cases =='
rg -n -C 6 --glob '*read-model*.test.ts' \
  'defaultBranchRef|baseRef|filePath' \
  tests/cockpit

echo '== public exports that expose the snapshot reader =='
rg -n -C 3 --glob '*.ts' 'readCockpitSnapshot|from .*/read-model' src/cockpit

Length of output: 18278


@LogicDuke No findings in the requested scope.

Static review of commit 72ee36e43371211a382f286557c974398b1fd0dc confirms:

  • src/cockpit/read-model.ts Lines 453-467 distinguish absent properties from unreadable properties.
  • src/cockpit/read-model.ts Lines 474-486 accepts undefined and null as optional absence, but rejects the private UNREADABLE_PROPERTY marker.
  • The four affected fields use this distinction: repository.defaultBranchRef, pullRequests[].baseRef, pullRequests[].title, and findings[].filePath.
  • Non-null values continue through the existing branch-reference and text validators. Existing malformed-value rejection remains unchanged.
  • The new invariant tests cover a throwing own getter for each affected field and genuine absence for all fields.
  • The marker is module-private. No public export or public API changed.
  • The commit changes exactly the two allowed files. git diff --check passed.

I did not execute repository tests because the review sandbox does not permit execution of repository code.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 72ee36e433

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LogicDuke
LogicDuke marked this pull request as ready for review August 21, 2026 16:21
@LogicDuke
LogicDuke merged commit bdb16a4 into cockpit/d1-read-model-contract Aug 21, 2026
2 checks passed
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