Commit graph

1732 commits

Author SHA1 Message Date
LLLin000
4dbeb5ae50 fix: address 4 review items — remove dead INTENTS dict, drop unused --limit from paper-navigation, add -> int return types, guard subsection section_path 2026-07-05 14:46:26 +08:00
LLLin000
1e6edad7ba feat: route Layer 4 gateway through body units and structure tree 2026-07-05 14:39:19 +08:00
LLLin000
2ab3aa4219 fix: deduplicate object unit_id and wire units persistence in builder
Fix 1 (units.py): object unit_id now includes the entry's block_id
instead of the node's block_span, fixing PRIMARY KEY collisions when
a section has multiple objects (e.g. two figure_captions).

Fix 2 (builder.py): retrieval units are now persisted during
build_from_index(). Scans each paper's OCR output directory for
structure-tree.json, builds body+object units and manifest, then
upserts into the DB tables and meta. Also clears body_units and
object_units at rebuild start alongside the other tables.
2026-07-05 14:28:43 +08:00
LLLin000
9d332980f0 feat: add body units, manifest, and body-unit FTS 2026-07-05 14:21:27 +08:00
LLLin000
e23f35114c feat: add LanceDB evaluation backend scaffold 2026-07-05 14:19:37 +08:00
LLLin000
9d5a008df1 feat: make paper lookup decomposed and coverage-scored 2026-07-05 14:14:03 +08:00
LLLin000
b9f4d6c4f0 refactor: add vector backend adapter with Chroma compatibility 2026-07-05 14:13:59 +08:00
LLLin000
bc27ac2255 feat: add Layer 4 gateway command surface 2026-07-05 14:12:50 +08:00
LLLin000
12b930c31d feat: add structure tree builder for paper navigation 2026-07-05 14:12:36 +08:00
LLLin000
b02e762ce4 docs: plan Layer 4 retrieval substrate 2026-07-05 02:27:47 +08:00
LLLin000
9bc12bd6a0 docs: tighten Layer 4 retrieval spec 2026-07-05 02:22:17 +08:00
LLLin000
f8d928d6ed docs: design Layer 4 retrieval substrate 2026-07-05 02:05:27 +08:00
LLLin000
7917858e24 feat: PR D — Base view cleanup
- Removed "重做OCR" view from build_base_views() (3 standard views)
- Changed ocr_status displayName to "状态"
- Removed ocr_redo property from _build_base_yaml()
- Removed deprecated ocr_redo insertion from _sanitize_base_file()
- Updated tests (28 passed)
2026-07-05 01:26:34 +08:00
LLLin000
b585e42ab2 fix: 3 micro-patches from 9.4/10 review
1. show_in_base — separate hidden from maintenance vs hidden from both
2. Unified is_degraded check — done_degraded and health yellow/red
   share one entry point
3. Hash error_summary in manifest instead of raw string
4. Fix Promise.withResolvers for ES compat
2026-07-05 01:19:59 +08:00
LLLin000
d00485777f feat: PR C — Plugin maintenance tab UI + cache + action-first display 2026-07-05 01:13:57 +08:00
LLLin000
0647c9be3f feat: PR C — Plugin maintenance tab UI + cache + action-first display
- i18n: 9 new maintenance_* keys (en + zh)
- ocr-maintenance-ui.ts: new types (DisplayAction, MaintenanceCache,
  MaintenanceDisplayRow) + cache read/write + refreshMaintenanceData
- settings.ts: _renderMaintenanceTab rewritten to action-first model
  (cache-first render, background manifest refresh, grouped tables
  with checkboxes, retry/rebuild/upgrade buttons)
- Backward compatible: old categorizeMaintenanceRow untouched
- 57 tests pass (6 files)
2026-07-05 01:13:47 +08:00
LLLin000
0a41335a7c feat: PR B — CLI manifest/keys + keyed redo 2026-07-05 01:03:30 +08:00
LLLin000
63915e98a4 feat: PR B — CLI manifest/keys + keyed redo
- list_parser: added --manifest and --keys args
- redo_parser: added positional keys args
- _run_ocr_list: manifest mode (calls compute_maintenance_manifest)
  and keys filtering
- _run_ocr_redo: keyed redo for specific papers + fallback to old path
- 11 new tests (56 total, 0 failed)
2026-07-05 01:02:55 +08:00
LLLin000
6b408c8770 feat: PR A — backend display contract + manifest 2026-07-05 00:53:35 +08:00
LLLin000
e15edb1161 feat: PR A — backend display contract + manifest
- 7 display fields on OCRMaintenanceRow (display_action, label, label_key,
  reason, reason_key, group, severity, visible_in_maintenance)
- _compute_display_fields() pure function with 12 mapping rules
- compute_maintenance_manifest() lightweight hash function
- Integration in collect_maintenance_rows()
- 45 tests covering all mapping rules + manifest
2026-07-05 00:53:18 +08:00
LLLin000
44bbad9250 docs: plan v2 — fix all P0/P1 (deps, error status, redo keys, health-bound, i18n) 2026-07-05 00:36:21 +08:00
LLLin000
069c344af7 docs: implementation plan for maintenance tab — 3 PRs (row model, CLI, plugin UI) 2026-07-05 00:28:58 +08:00
LLLin000
b4edea8ee6 docs: spec cleanup — remove duplicate old UI, add row model display fields + mapping contract 2026-07-05 00:27:44 +08:00
LLLin000
ac55a519db docs: maintenance tab design spec v2 — action-first labels, legacy handling, cache strategy 2026-07-05 00:24:08 +08:00
LLLin000
f76396220d docs: mark Layer 2 done, update project docs
- Active queue: Layer 2 added to completed with commit reference
- PROJECT-MANAGEMENT: updated header, test counts, component table,
  Layer 3 replaced health hardening with done status, active queue
  reprioritized, key file map updated, 7 decision log entries added
- Session timeline entry pending (manual update)
2026-07-04 23:41:59 +08:00
LLLin000
96fd9771ef fix(ocr-quality): contract polish — 4 P0/P1 fixes
1. compute_use_cases output uses status/gates/reasons (not recommended/gate_results)
2. write_feedback validates every mark has result_hash and fulltext_hash
3. load_readiness_policy(policy=...) bypasses user override (reproducible)
4. confidence_and_fallbacks yellow for degraded=True or weak span coverage

Minor: append_mark doesn't mutate caller dict; has_figure_evidence includes
unmatched_legend_count and held_count.
2026-07-04 23:38:03 +08:00
LLLin000
b07ac7a177 docs: add Layer 2 spec and implementation plan 2026-07-04 23:32:55 +08:00
LLLin000
8aba7feb48 Merge branch 'feat/ocr-quality-feedback' 2026-07-04 23:28:29 +08:00
LLLin000
c76f1569aa feat(ocr-quality): add evaluate_readiness() with YAML policy evaluator
Adds readiness policy evaluator layer:
- load_readiness_policy() with deep-merge, importlib.resources, user override
- _resolve_field() dotted path resolver, _apply_op() operator matcher
- _check_hard_red() for hard-red rule evaluation
- evaluate_readiness() with weighted scoring + status determination
- compute_use_cases() for all 4 use cases (reading, qa, figure_table, chunking)
- Default YAML policy with weights, hard_red rules, use_case gates
- pyproject.toml: policies/*.yaml added to package-data
- 7 tests (B1-B7) covering all paths

17/17 tests pass (A10 + B7).
2026-07-04 23:28:06 +08:00
LLLin000
3299c606d7 feat(ocr-quality): add human feedback sidecar
Standalone module (ocr_quality_feedback.py) with:
- read_feedback / write_feedback (atomic via temp+rename)
- append_mark (auto-injects hashes, preserves old marks)
- resolve_human_validation (unreviewed/confirmed/disputed/stale)
- Hashes stored per-mark, stale detection via latest_mark hash comparison

5 unit tests covering roundtrip, hash validation, append, stale, and
resolve without UI dependency.
2026-07-04 23:24:06 +08:00
LLLin000
51e16066c9 feat(ocr-quality): add build_quality_indicators() with 5 normalizers
Creates new ocr_quality.py module as pure function layer between
build_ocr_health() and evaluate_readiness(). All 5 indicators:
- rendered_text_integrity
- body_reference_structure
- figure_table_integrity
- metadata_frontmatter_quality
- confidence_and_fallbacks

10 unit tests covering shape, thresholds, applicability,
health_profile spelling, inventory precedence, and run_integrity.
2026-07-04 23:23:51 +08:00
LLLin000
01bacab4d8 feat(pr3): add column-aware same-page reference boundary 2026-07-04 22:40:30 +08:00
LLLin000
2216ac7d87 fix(pr3): remove same-column guard from body_blocks, fix _page_width_for_zone_block arg 2026-07-04 22:36:46 +08:00
LLLin000
53a5336b6a feat(pr3): add column-aware same-page reference boundary 2026-07-04 22:36:46 +08:00
LLLin000
59b303dd66 feat(pr4): add column compatibility check for figure caption-asset pairing 2026-07-04 22:35:57 +08:00
LLLin000
2375f3c984 feat(pr2): tighten figure caption heuristic with inline mention escape 2026-07-04 22:35:50 +08:00
LLLin000
3453026b20 feat(pr1): frontmatter render fallback for empty metadata 2026-07-04 22:35:45 +08:00
LLLin000
17b02b8abf fix(pr4): handle column_band=0 falsy correctly in score_legend_to_group 2026-07-04 22:35:28 +08:00
LLLin000
5cac8d1e08 fix(pr4): remove unused _column_compatible_for_caption_asset helper 2026-07-04 22:29:09 +08:00
LLLin000
08a52dcb48 feat(pr4): add column compatibility check for figure caption-asset pairing 2026-07-04 22:28:43 +08:00
LLLin000
f97365b5b4 fix(pr2): return body_paragraph for inline figure mentions regardless of zone 2026-07-04 22:28:23 +08:00
LLLin000
30cc7c3f7b feat(pr2): tighten figure caption heuristic with inline mention escape 2026-07-04 22:28:17 +08:00
LLLin000
a138100398 fix(pr1): remove has_any_author gate from affiliation/email fallback 2026-07-04 22:17:43 +08:00
LLLin000
57bb73556b feat(pr1): add frontmatter render fallback for empty metadata 2026-07-04 21:57:04 +08:00
LLLin000
3222ac42fa docs: apply 5 corrections to implementation plan
Corrections from review:
1. Move CONSUMED_FRONTMATTER_ROLES to module-level constant
2. Frontmatter fallback reads text/block_content, dedupes, no render_default gate
3. PR 2 body escape defaults to body_paragraph; only display_zone+legend_like bypasses
4. PR 3 page_width helper with 1200 as final fallback only
5. PR 4 enrich column_band after _candidate_group_entry() (Scheme B, no signature change)
Also: fixed PR 2 2HJSWV3V acceptance wording, PR 3 'FALSE POSITIVE' wording
2026-07-04 21:45:08 +08:00
LLLin000
fc968f550a docs: update spec with 8 corrections, add implementation plan
8 spec corrections from review:
1. PR 1: field-based return, not lines; insertion before title
2. PR 2: explicit body_paragraph escape in assign_block_role
3. PR 2: caption syntax supports delimiter + title patterns
4. PR 3: use existing ref_heading_block, no new scan
5. PR 3: same_page_tail_blocks + column check, test body rendering
6. PR 4: split None into full_width vs ambiguous_center
7. PR 4: column check before safe_auto_match, no sidecar exception
8. PR 2: fixture verification criteria per-fixture, not blanket
2026-07-04 21:39:50 +08:00
LLLin000
bdf96af6fd docs: four-PR architecture hardening spec
Based on layout truth audit findings (6 bug patterns), designs 4
independent PRs with precise code locations, helper contracts,
column-aware zone inference, caption formalness tightening,
and render frontmatter fallback. Includes before/after Mermaid
diagrams, test specs, and execution order.
2026-07-04 21:34:02 +08:00
LLLin000
26715a9d7e feat: layout-category truth audit complete
Workstream X: 11 papers audited across 6 layout classes,
5 verified via vision subagents. 6 real bug patterns identified
with code locations and root cause analysis.

Bug patterns:
A - _is_obviously_formal_figure_caption heuristic too aggressive
    (ocr_roles.py:193)
B - Cross-column figure asset mis-assignment ignores boundaries
    (ocr_figures.py:704)
C - Render frontmatter skip silently drops authors/affiliations
    (ocr_render.py)
D - Two-column same-page boundary body→backmatter zone pollution
    (ocr_document.py)
E - Frontmatter headings misclassified (ocr_roles.py)
F - Supplementary-only PDFs not handled

Full report: docs/superpowers/analysis/2026-07-05-layout-truth-audit-findings.md

Also: codebase-memory-mcp 0.8.1 installed and repo indexed.
2026-07-04 21:26:15 +08:00
LLLin000
914acd6aa5 feat: enable OCR_PIPELINE_V3 by default
The V3 pipeline has been tested against the full 555-paper vault vs legacy:

  No diff: 547 (98.6%)
  Diff:     5 (0.9%) — all in v3's favor: 3 papers find 1 more figure
                        (v3 softens role before matching), 2 papers shift
                        1 block boundary (body_paragraph vs frontmatter_noise)
  Error:    3 (0.5%) — 2 missing raw data, 1 pre-existing v3 pipeline edge case

The 5 diffs are marginal improvements, not regressions. V3's shadow-normalize
approach defers role commit until after figure/table matching, so captions
that legacy normalize prematurely hardened to 'body_paragraph' are correctly
found as figure captions.

Changes:
- _ocr_pipeline_v3_enabled() defaults to True now; set OCR_PIPELINE_V3=0 to
  revert to legacy normalize-then-match order
- Test updated to assert default=True
- Full vault corpus diff script + result report archived
2026-07-04 20:04:39 +08:00
LLLin000
c42da204bb fix: expand crop bbox to include figure_inner_text (figures show their own labels)
figure_inner_text role means the text IS part of the figure content
(forest plot y-axis labels, nomogram variable names, panel markers).
The earlier fix listed the text as a separate below the image — that
was wrong: the text already lives inside the cropped image when the
crop bbox covers it.

Now extract_and_write_objects expands the crop bbox to include all
figure_inner_text blocks owned by the figure (via _object_owner_id,
same page). The cropped jpg contains the labels; render only emits
image + Legend.

Verified: M84CTEM9 figure_a001 (forest plot) now crops to 787x363
(previously 444x358 — missed the y-axis labels); figure_a002
(nomogram) still includes its variable labels. 105 focused tests pass.
2026-07-04 19:54:40 +08:00