Skip to content

原資料を保持する台帳と目印を追加し、追加分析を要約の選択から分離 - #35

Merged
ivgtr merged 2 commits into
mainfrom
feat/source-first-analysis
Oct 10, 2026
Merged

ivgtr merged 2 commits into
mainfrom
feat/source-first-analysis

Conversation

@ivgtr

@ivgtr ivgtr commented Oct 10, 2026

Copy link
Copy Markdown
Owner

変更内容

原資料の保持と、要約に載せる項目の選択を分離します。

  • 抽出済みの行・文字セル・表を名前で除外せず保持し、意味分類は追加の目印にする
  • 原資料が宣言する指標・期間・単位の軸を候補入力に追加する。税引前利益などを既知名の一覧へ例外追加しない
  • 追加分析は既存の全文再抽出で台帳を照合し、要約未選択の原文も読めるようにする
  • 照合済み事実、点検済み会社説明、コード計算、意味未点検の原文引用を区別する
  • 短い見出し・結論・理由を先に表示し、根拠と必要な条件は展開する。不要な条件欄を埋めるための推測は求めない
  • 空白を含む複合金額を原文のまま保持し、百分率の行が金額の列単位を引き継ぐ不具合を修正する
  • 入力識別をv122へ更新し、旧入力のキャッシュを再利用しない

確認したこと

  • npm test: 1,621件/57ファイル成功
  • type-check、lint、production build成功
  • CMap168個とLICENSEの同梱・バイト一致を確認
  • 公開安川電機PDFの元文字アイテム6ページを固定fixtureに追加。個人の診断・設定・生成応答は含めていない
  • 人が原資料から選んだ税引前利益25,963/25,204/65,500百万円の候補を照合し、既存の汎用計算で前年同期差759百万円を確認
  • 安川・ファーストブラザーズ・サーラ・ファーストリテイリングの4資料で、抽出済みの全行が分析へ届くことを確認
  • 26ページ資料で原PDF再照合、分析の保存復元、原文引用のHTML表示を確認。台帳込みの表示構成は約2.10MB、代表的な4論点・24引用の分析保存結果は約9.7KB

入力・保存の予算

追加分析の要求は従来どおり1回です。全文を読むため入力トークンと費用は増える可能性があります。

全メッセージ合計25万文字/512KiBを実行上限とし、超過時は原文を黙って削らず停止します。実サイズと上限は診断に残します。26ページ資料は約17.0万文字/235KBでした。各モデルの文脈長に収まることまで保証する上限ではありません。

診断の1記録上限は256KiB、ストア全体は従来の1MiBです。大きい診断の省略を明示します。ブラウザーの保存容量が不足した場合は警告し、現在の表示結果は維持します。

検証の限界

  • 有料APIと実Chromeでの確認は未実施。新しいモデル入力で論点の質が改善することは、固定テストだけでは保証しない
  • 原資料台帳の保持と、モデルが税引前利益を必ず選ぶことは別の保証
  • 抽出済みの全行を保持しても、画像や未検出の行を含むPDF全体の完全性は保証しない
  • 原文の参照IDが合うだけでは意味の検証にならない。未点検の数量は検算済み計算へ自動投入しない
  • 複合金額は完全な原文として保持する。正確なスカラー化は従来どおり未対応
  • 古い応答の再生では、安川は回復した数量に対する点検範囲不足を拒否、ファーストブラザーズは補足点検が部分成功・旧v3分析を拒否、サーラは点検応答不足で停止。ファーストリテイリングは原資料・予算・保存確認のみ。これらを新モデルによる4資料の分析成功とは扱わない

詳しい契約と検証範囲は docs/additional-analysis.md に記載しています。

@ivgtr
ivgtr marked this pull request as ready for review October 10, 2026 07:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T07:47:29.971909Z ba40752 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ca00f0fe15

ℹ️ 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".

Comment thread src/lib/summary-presentation.ts Outdated
Comment on lines +488 to +489
(value.sourceLedger !== undefined &&
canonicalJSON(value.sourceLedger) !== canonicalJSON(expected.sourceLedger))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Ignore extraction selection when revalidating the ledger

When a smart-mode summary successfully omits only blank or administrative pages, its saved ledger records those pages as omitted; handleFollowup then re-extracts the same PDF in full mode, where every page is selected, so this whole-ledger comparison rejects the unchanged PDF before either scoring or additional analysis can run. Selection is an extraction-policy marker rather than source integrity, so it must be normalized or excluded when comparing the smart summary with the full re-extraction. CLAUDE.mdL175-L175

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ba40752 で修正しました。

原資料の比較を共通の sameSourceLedgerContent にまとめ、ページの selection だけを比較対象から外しました。revalidatePresentation と buildAnalysisInput の両方で使っています。保存済み台帳の完全なチェックサムは先に検査し、文字・配置・抽出状態・目印の変更は引き続き拒否します。元の選択状態と結果IDも書き換えません。

空ページだけを省いた smart 要約から full 再抽出後の追加分析・採点へ進む Background 結合テストを追加しました。選択だけ異なる正常例、本文・座標・状態の変更、チェックサム不一致の拒否も確認しています。

Comment thread src/lib/source-ledger.ts Outdated

/** Every source block survives. Recognition adds hints only; it never gates retention. */
export function buildSourceLedger(pages: ExtractedPage[]): SourceLedger {
const hints = new Map(sourceInventory(pages).map((e) => [e.blockId, e]));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass the document type when deriving ledger role hints

For every document type other than other, this call silently uses sourceInventory's default type and stores incorrect role hints in the model input. For example, an earnings heading such as 経営成績 and its rows are marked content instead of performance, while earnings-revision forecast headings can be marked outlook instead of content; these misleading hints can steer the new full-source analysis into the wrong section even though buildPresentation already knows facts.documentType. CLAUDE.mdL175-L175

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ba40752 で修正しました。

buildSourceLedger に documentType を渡し、sourceInventory の分類へ反映しました。表示構成の作成と分析時の再抽出照合の両方で facts.documentType を渡しています。

決算の経営成績が performance になること、業績修正を含む文書種別ごとの分類が sourceInventory と一致することを確認しました。名前による原行の除外や、目印から検証済み事実への昇格は追加していません。

Comment thread src/lib/source-ledger.ts
Comment on lines +346 to +348
rows: rows.map((r) => [r.id, r.text, r.spanIds.map((id) => position(spans.get(id)!))]),
marks: [...marks.values()],
looseSpans: p.spans.filter((s) => !used.has(s.id)).map(position),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include source items that were not converted to spans

For PDFs containing rotated text, extractPageLayout retains the text in page.text and sourceItems but deliberately excludes it from spans; this projection builds both rows and looseSpans only from spans, so that text silently disappears from sourceDocument, has no raw citation ID, and cannot be considered by the promised full-source analysis. Include otherwise-unrepresented source items or the retained page text in the model projection. CLAUDE.mdL175-L175

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ba40752 で修正しました。

spans に十分対応していない元の sourceItems を、原IDと文字の対応で判定して originalItems に残します。rawitem: の引用、保存復元、診断コピーまで接続しました。同文でも別の原IDなら除外せず、部分的な文字対応や結合・分割された文字も検査します。

同じ傾向の問題として、回転文字だけのページが「文字を取得できない空ページ」と表示される点も修正しました。抽出状態と validatePages を揃え、文字は保持したが行・表への対応は未対応という警告に分けています。水平文字の欠落や抽出失敗の拒否は維持しました。

回転のみ/混在/空白、同文の別ID、部分対応、引用・保存復元、診断の余分なフィールド除去をテストしました。安川と26ページ資料では通常文字の重複追加は0です。これらの原文字は意味未点検のままで、検算済み数量としては扱いません。

ivgtr commented Oct 10, 2026

Copy link
Copy Markdown
Owner Author

@codex review

ba40752 の再レビューをお願いします。3件それぞれに対応内容と検査を返信しました。

共通原因を「原資料・処理方針・派生表現の混同」と整理し、選択方針だけを除く同一性比較、文書種別の受渡し、未対応の元文字の保持・引用を修正しました。関連する回転文字のみのページの空判定と警告も修正しています。

全1,636テスト/58ファイル、type-check、lint、build、CMap同梱照合が成功。4資料の固定再生で保持と予算を再確認し、26ページ資料は約17.1万文字/236KBで既存の入力予算内です。リモートtreeは検証したローカルtreeと一致しています。

このheadのCI statusとPR workflow runは取得時点で0件のため、CI成功とは扱っていません。有料API・実モデル品質・実Chromeは未検証です。

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: ba40752f58

ℹ️ 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".

@ivgtr
ivgtr merged commit 06cb39f into main Oct 10, 2026
@ivgtr
ivgtr deleted the feat/source-first-analysis branch October 10, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant