Skip to content

feat: name leftover-map reconstruction on leftover pairs (v2.12.31) - #588

Open
seonghobae wants to merge 12 commits into
mainfrom
feat/leftover-map-reconstruction-v21231
Open

feat: name leftover-map reconstruction on leftover pairs (v2.12.31)#588
seonghobae wants to merge 12 commits into
mainfrom
feat/leftover-map-reconstruction-v21231

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Persist leftover-map reconstruction R̂ = ξ_{1:2} · ζ_{1:2} on period leftover pairs so landed unexplained leftover U = R − R̂ stays auditable as U + R̂ = R (ADR 0183).

Why this is not #564

#564 persists a centered leftover-map reconstruction that recovers (ADR 0186 / v2.12.30). Landed ADR 0182 already defines U = R − R̂ against the uncentered residual R = Y − E and the same two-axis inner product used for distance. Substituting centered would break U + R̂ = R.

This PR keeps that internal and names it on the pair row. Do not mix with leftover stacks #485, #521, #537, #539, #563, #564, or #579. Coverage #518 already landed as ADR 0168.

Buyer-visible change

After make seed, closest and farthest leftover pairs sit above the member list with signed next to leftover-map distance d; click opens that post. Missing or non-finite reconstruction omits the badge rather than inventing a leftover score. Signed reconstruction is stored, never clamped.

Contract


Open in Devin Review

Summary by CodeRabbit

  • 새로운 기능

    • 잔여 쌍에 2축 재구성값 을 저장하고 API와 보고서 화면에 표시합니다.
    • 재구성값이 있는 경우 해당 값과 잔차 거리, 설명되지 않은 잔여를 함께 확인할 수 있습니다.
    • 잔여 쌍을 선택하면 관련 게시물을 열 수 있습니다.
    • 재구성값과 설명되지 않은 잔여의 합이 전체 잔차와 일치하는지 감사할 수 있습니다.
  • 개선 사항

    • 재구성값이 없거나 유효하지 않은 경우 기존 안내를 유지합니다.
    • 영어, 한국어, 중국어, 일본어, 베트남어 안내 문구를 지원합니다.

Persist two-axis Gabriel reconstruction R̂ = ξ_{1:2} · ζ_{1:2} on
period leftover pairs so landed unexplained leftover U = R − R̂ stays
auditable as U + R̂ = R (ADR 0183). Reconstruction is the same internal
two-axis inner product already used for U; do not substitute the
centered R̃ reconstruction claimed by leftover stack #564.

After make seed, closest and farthest leftover pairs sit above the
member list with signed R̂ next to leftover-map distance d; click opens
that post. Missing or non-finite reconstruction omits the badge rather
than inventing a leftover score. Signed reconstruction is stored, never
clamped. Complete-case coverage (ADR 0168) stays independent.

Independent of leftover stacks #485, #518 (landed), #521, #537, #539,
#563, #564, and #579.
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 42 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f7ae3e29-8083-4d0f-9620-6deecb787f1c

📥 Commits

Reviewing files that changed from the base of the PR and between e4234bc and 6185f2a.

📒 Files selected for processing (21)
  • AGENTS.md
  • ARCHITECTURE.md
  • CHANGELOG.d/2.12.31-leftover-map-reconstruction.md
  • backend/app/report_ingestion.py
  • backend/tests/test_api.py
  • docs/adr/0003-fast-mlsirm-report-integration.md
  • docs/adr/0048-persist-lsirm-leftover-pairs.md
  • docs/adr/0049-leftover-pair-report-ui.md
  • docs/adr/0201-leftover-map-reconstruction.md
  • frontend/src/App.test.tsx
  • frontend/src/api.ts
  • frontend/src/components/LeftoverPairList.tsx
  • frontend/src/i18n.test.ts
  • frontend/src/i18n.ts
  • lineageweave/leftover_pairs.py
  • migrations/0206_report_leftover_map_reconstruction.sql
  • migrations/rollback/0206_report_leftover_map_reconstruction.sql
  • scripts/seed_demo_data.py
  • tests/test_leftover_pairs.py
  • tests/test_period_report.py
  • tests/test_schema.py
📝 Walkthrough

Walkthrough

기간 보고서 leftover pair가 두 축 재구성값 을 저장하고 API와 UI에 노출합니다. 유한한 값은 표시하며, 누락되거나 비유한 값은 기존 U 동작을 사용합니다. U + R̂ = R 검증과 스키마 마이그레이션이 추가되었습니다.

Changes

Leftover map reconstruction

Layer / File(s) Summary
스키마와 재구성 계약
docs/adr/*, ARCHITECTURE.md, AGENTS.md, CLAUDE.md, migrations/*, CHANGELOG*
ADR 0201과 nullable leftover_map_reconstruction 컬럼을 추가했습니다. 재구성값 처리 규칙과 U + R̂ = R 관계를 문서화했습니다.
Pair 재구성 계산
lineageweave/leftover_pairs.py, tests/test_leftover_pairs.py
두 축 Gabriel 재구성값을 계산하고 유한한 값만 LeftoverPair에 저장합니다. 테스트는 재구성값과 잔차 합계를 검증합니다.
보고서 저장과 API 노출
backend/app/report_ingestion.py, scripts/seed_demo_data.py, backend/tests/test_api.py, tests/test_period_report.py
기간 보고서 저장 및 조회 경로에 새 필드를 연결했습니다. API 검증은 U + R̂ = R을 확인합니다.
Leftover pair UI 표시
frontend/src/api.ts, frontend/src/leftoverMapReconstruction.ts, frontend/src/components/*, frontend/src/i18n*, frontend/src/App.test.tsx
유한한 을 부호 형식으로 표시하고 reconstruction 안내를 우선합니다. 값이 없으면 기존 unexplained 안내를 표시합니다.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: 🔵 Low · up to e4234

The change adds and displays leftover-map reconstruction values, while rollback requires the application to be downgraded before removing the new database column to avoid report-fetch failures. The PR is mergeable with explicit owner awareness and documented rollback sequencing.

Sequence Diagram(s)

sequenceDiagram
  participant ReportIngestion
  participant ReportLeftoverPair
  participant API
  participant LeftoverPairList
  ReportIngestion->>ReportLeftoverPair: store leftover_map_reconstruction
  API->>ReportLeftoverPair: read reconstruction
  ReportLeftoverPair-->>API: return nullable reconstruction
  API-->>LeftoverPairList: provide leftover pair data
  LeftoverPairList->>LeftoverPairList: format and display R̂
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 leftover pair에 leftover-map reconstruction을 명명하고 추가하는 주요 변경을 정확히 요약합니다. 구체적이고 간결하며 변경 내용과 직접 관련됩니다.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 16 files. (12 skipped: …
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 16 files. (12 skipped: 12 unsupported.)

✨ Finishing Touches 💡 1
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch feat/leftover-map-reconstruction-v21231
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/leftover-map-reconstruction-v21231

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.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting independent Copilot review. Author will not self-approve. Exact-head APPROVE required before squash-merge.

devin-ai-integration[bot]

This comment was marked as resolved.

@seonghobae
seonghobae enabled auto-merge August 24, 2026 22:57
@github-actions
github-actions Bot disabled auto-merge August 24, 2026 23:08
@seonghobae
seonghobae enabled auto-merge (squash) August 25, 2026 00:31
devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions
github-actions Bot disabled auto-merge August 25, 2026 00:37
@seonghobae
seonghobae enabled auto-merge (squash) August 25, 2026 00:50
@github-actions
github-actions Bot disabled auto-merge August 25, 2026 01:01
@seonghobae
seonghobae enabled auto-merge (squash) August 25, 2026 01:07
# Conflicts:
#	AGENTS.md
#	ARCHITECTURE.md
#	CLAUDE.md
#	docs/adr/0049-leftover-pair-report-ui.md
devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions
github-actions Bot disabled auto-merge August 25, 2026 02:19
@seonghobae
seonghobae enabled auto-merge August 25, 2026 02:27
@opencode-agent
opencode-agent Bot disabled auto-merge August 25, 2026 02:28
The prior merge of origin/main into this branch (91d8e4f) resolved the
AGENTS.md/ARCHITECTURE.md/CLAUDE.md conflicts by dropping this PR's own
leftover-map reconstruction documentation:

- AGENTS.md reverted to "Two-axis reconstruction R̂ is not persisted",
  contradicting the shipped migration/ADR 0201 that persists it, and
  dropped ADR 0201 from the governing-ADR list.
- ARCHITECTURE.md kept a redundant "0183 / 0201" pair (0183 is this
  repo's real, unrelated ADR 0183 "GNB four Korean chrome"; the stale
  0183 leftover-map reference should have been renumbered to 0201, not
  kept alongside it).
- CLAUDE.md's "Where the rest lives" pointer never got the ADR 0201
  cross-reference added.

Also finishes the ADR-number renumbering the PR's own history had
started (docs/adr/0201-leftover-map-reconstruction.md is the actual
ADR; ADR 0183 already belongs to a different, already-landed decision
on main): fixes remaining stale "ADR 0183" citations in
docs/adr/0003, the 2.12.31 CHANGELOG.d fragment, and the migration
0183 SQL header comment, all of which should cite ADR 0201.

docs/adr/0049's own conflict resolution (0158 + 0201 amendments) was
already correct and is unchanged.
@seonghobae
seonghobae enabled auto-merge August 25, 2026 02:33
devin-ai-integration[bot]

This comment was marked as resolved.

@opencode-agent
opencode-agent Bot disabled auto-merge August 25, 2026 03:18
@seonghobae

Copy link
Copy Markdown
Contributor Author

Exact head e4234bce reconciles ADR 0182 context with its accepted ADR 0201 amendment: reconstruction was discarded at initial acceptance and is now retained so U + R̂ = R is auditable. Documentation hygiene: 5 passed; diff check passed. The five implementation-consistency notes are informational and resolved. Latest main still conflicts across the later leftover-map ladder, so no merge-ready or approval claim is made; the next loop must compose those accepted semantics without dropping protected-main work.

coderabbitai[bot]

This comment was marked as resolved.

@seonghobae
seonghobae enabled auto-merge August 25, 2026 04:56
@opencode-agent
opencode-agent Bot disabled auto-merge August 25, 2026 05:00
@seonghobae
seonghobae enabled auto-merge August 25, 2026 05:00

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +79 to 88
} else if (reconstruction !== null) {
const signedReconstruction =
formatSignedLeftoverValue(pair.leftover_map_reconstruction ?? Number.NaN) ?? "—";
nextAction = tf(LEFTOVER_MAP_RECONSTRUCTION_ACTION, {
value: signedReconstruction,
criterion,
});
} else if (unexplained !== null) {
const signedUnexplained =
formatSignedLeftoverValue(pair.leftover_map_unexplained ?? Number.NaN) ?? "—";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Reconstruction outranks unexplained in next-action order

The next-action fallback in LeftoverPairList inserts reconstruction above unexplained leftover (cross share → reconstruction → unexplained). New rows with both U and R̂ finite and no cross share now show the reconstruction message instead of the unexplained one. Matches ADR 0049's stated order.

(Refers to this code)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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