Commit graph

36 commits

Author SHA1 Message Date
LLLin000
b9f4d6c4f0 refactor: add vector backend adapter with Chroma compatibility 2026-07-05 14:13:59 +08:00
LLLin000
916eadb5ff fix: add validated container regions for figure contained text
Add _container_area_ok, _container_has_media_asset, _validated_container_regions
helpers and wire validated _container_bbox regions into tag_figure_contained_text.
Containment-only fix: no ownership mutation, no new matched_figure entries.
2026-07-01 21:50:37 +08:00
Research Assistant
c15227076a backmatter: remove pre-ref disclosure normalization (pre-ref = body flow)
Confirmed with user: pre-ref disclosure headings (CRediT, Ethics) must stay
as subsection_heading in body flow. Removed _normalize_pre_ref_disclosure_runs
and related constants/functions. Updated tests (20 -> 16 cases).

5 audit papers verified:
  25K5KZAQ: body_end=11 ref_start=10 (was None)
  YGH7VEX6: body_end=8 ref_start=8
  NC66N4Q3: body_end=56 ref_start=56 (was None)
  9TW98JH8: body_end=5 ref_start=5
  XD2BPCMG: body_end=26 ref_start=21

318/318 tests pass.
2026-06-28 01:28:53 +08:00
Research Assistant
1a9ad1d147 P1: backmatter boundary redesign — ref-anchored partition replaces second _reconcile_tail_spread
reference_zone is the only hard boundary. Pre-ref disclosure headings (CRediT,
Ethics, Declaration) are normalized as local same-column runs — they never set
global boundaries. Four contracts enforced (Contract A-D in spec).

- 13 new helpers in ocr_document.py: _has_verified_reference_zone, _partition_by_reference_zone,
  _classify_same_page_block, _normalize_reference_roles_from_partition,
  _normalize_pre_ref_disclosure_runs, _build_tail_boundary_from_ref_partition, etc.
- infer_zones() stores effective_end_page for trimmed reference extent
- normalize_document_structure(): ref-partitioned path replaces second _reconcile_tail_spread;
  _promote_tail_body_candidates/_assign_tail_spread_ownership skipped when active
- 20 tests in test_backmatter_boundary.py
- 322/322 tests pass
2026-06-28 01:13:54 +08:00
Research Assistant
b1fdbc30eb feat: P0 fixes (ref sort, caption insert) + P1 figure containment render hygiene
P0:
- Fix 2: _ref_number_sort_key handles [N] bracket format (ocr_render.py:481)
- Fix 4: remove figure_caption from _INSERT_CANDIDATE_ROLES (ocr_document.py:3846)
- Fix 5: filter demoted body_paragraph from figure legends (ocr_figures.py:2950)

P1:
- figure containment render-hygiene pass after table inventory writeback
- 6 helpers: _cluster_bboxes_by_proximity, _is_contained,
  _highly_overlaps_any_matched_region, _figure_region_bbox,
  _matched_asset_keys, tag_figure_contained_text
- Wire call site in postprocess_ocr_result() (ocr.py:1891)

Infra:
- Sync workspace fulltext after rebuild (asset_index.py)
- Fix UnboundLocalError on index-refresh (sync_service.py)
- Add missing frontmatter fields to field registry (field_registry.yaml)
- 283 + 19 = 302 tests passing
2026-06-27 22:56:22 +08:00
Research Assistant
a38e41ba78 test: lock OCR phase2 figure inventory contract 2026-06-05 00:08:30 +08:00
Research Assistant
8cc493967e fix: add ocr_redo to expected frontmatter fields in test 2026-06-01 11:25:24 +08:00
Research Assistant
3d820ad5c9 fix(sync): avoid prune crash when optional deps are missing 2026-05-31 20:55:17 +08:00
Research Assistant
49a8c307c1 test: cover preserved frontmatter tags 2026-05-31 19:52:37 +08:00
Research Assistant
15bf3c6529 test: clean up brittle and low-value tests
- Remove 4 broken Python test files (ld_deep x3, path_normalization)
- Fix 2 vector_db tests to mock get_collection instead of chromadb.PersistentClient
- Remove 2 JS test files (settings-panels, vector-ready — trivial)
- Trim 3 buildRuntimeInstallCommand tests from errors.test.ts
- Narrow CI unit-tests to only run tests/unit/ (gate-level)
2026-05-24 20:00:47 +08:00
Research Assistant
3619fe264f Revert "test: clean up brittle and low-value tests"
This reverts commit 5ad9a54a66.
2026-05-24 19:59:24 +08:00
Research Assistant
5ad9a54a66 test: clean up brittle and low-value tests
- Remove 4 broken Python test files (ld_deep x3, path_normalization)
- Fix 2 vector_db tests to use correct mock target (get_collection)
- Remove 2 JS test files (settings-panels, vector-ready — trivial)
- Trim 3 buildRuntimeInstallCommand tests from errors.test.ts
- Narrow CI unit-tests to only run tests/unit/ (gate-level)
2026-05-24 19:59:14 +08:00
Research Assistant
cc5fa0658f fix: add return type annotation to main() and indent=2 to early-exit json.dump calls 2026-05-19 14:41:06 +08:00
Research Assistant
02ef2d9b52 feat(sync): auto-detect orphan papers after sync, show modal in Obsidian
- prune.py: _enrich_orphan_preview() reads note frontmatter for metadata
- sync_service.py: always run dry-run prune, include in result
- sync.py: write sync-orphan-state.json for plugin consumption
- main.js: add checkOrphanState() + PaperForgeOrphanModal with select/toggle
- styles.css: orphan modal styles (list, tags, dimmed rows)
- cli.py: add --keys to prune command for targeted deletion
2026-05-19 00:31:19 +08:00
Research Assistant
e2068d2172 test(prune): add SyncService prune integration tests 2026-05-18 21:58:57 +08:00
Research Assistant
63705b4103 fix(prune): protect dir iteration, add OSError handling, improve test coverage 2026-05-18 21:53:14 +08:00
Research Assistant
6facabc8aa feat(prune): core orphan paper cleanup module 2026-05-18 21:48:18 +08:00
Research Assistant
a599cd930b Merge branch 'paperforge-stabilization'
# Conflicts:
#	paperforge/memory/vector_db.py
2026-05-18 18:47:07 +08:00
Research Assistant
a50a1510bd fix(test): correct patch target in test_retrieve — must patch embedding.get_embed_status, not status.get_embed_status, because retrieve.py imports from __init__ re-export 2026-05-18 17:38:23 +08:00
Research Assistant
a3e8a6e816 test: update vector_db test imports to embedding package 2026-05-18 17:23:37 +08:00
Research Assistant
2b552be9e6 feat: runtime contract hardening + skill/command truth alignment (Package A+B)
Atomic snapshots, canonical index mutation serialization, sync post-clean truth,
plugin path config-awareness, embed stop signal honesty, full snapshot bootstrap,
pf_ prefix unification, workflow command/lifecycle/path corrections,
mechanical/cognitive route separation with unknown-command guard.
2026-05-16 22:38:43 +08:00
Research Assistant
245d09e383 feat: add runtime-health CLI command 2026-05-15 01:16:16 +08:00
Research Assistant
fe33470303 feat: add layered runtime health computation 2026-05-15 01:15:39 +08:00
Research Assistant
b21c339227 feat: persist embed lifecycle and add stop command 2026-05-15 01:15:07 +08:00
Research Assistant
64ee50a080 feat: add persistent vector build state helpers 2026-05-15 01:13:12 +08:00
Research Assistant
fd7f7f3278 perf: refresh_paper accepts entry dict, skip full index read 2026-05-13 16:58:39 +08:00
Research Assistant
1ae7e074d8 feat(memory): dashboard reads from SQLite + incremental refresh_paper() 2026-05-12 20:08:46 +08:00
Research Assistant
b7530d5dee feat(memory): add agent context query module 2026-05-12 19:55:58 +08:00
Research Assistant
80d76e6ac2 feat(frontmatter): add citation_key field and alias from BBT citationKey 2026-05-12 18:28:53 +08:00
Research Assistant
c100423353 feat(memory): add query module for paper lookup and status check 2026-05-12 17:47:30 +08:00
Research Assistant
1407e2606d feat(memory): add builder module that populates SQLite from formal-library.json 2026-05-12 17:44:03 +08:00
Research Assistant
cf919d1801 feat(memory): add schema module with table definitions and tests 2026-05-12 17:40:10 +08:00
Research Assistant
9b88c441b0 refactor(skills): modular literature-qa skill with router-first architecture
- Replace 6 scattered pf-*.md files with single SKILL.md router + 4 reference files
- Add paper_resolver.py: deterministic key/DOI/field search (4 subcommands)
- Remove pf-sync/ocr/status (CLI-only commands, no skill wrapper needed)
- Move chart-reading/ into references/ for flat structure
- Make ld_deep.py --vault optional (auto-detect from cwd)
- Add 26 unit tests for paper_resolver
- All paths dynamically resolved from paperforge.json, zero hardcoding
2026-05-10 20:56:28 +08:00
Research Assistant
05629bce82 refactor: v2.1 contract hardening — PFResult unification, ErrorCode expansion, adapter cleanup, SyncService orchestration
Core contract:
- ErrorCode: 8→26 with _missing_() graceful degradation for unknown codes
- PFResult: +warnings/next_actions, PFError: +suggestions
- OcrStatus: 4→9 granular states (NONE/QUEUED/BLOCKED/NO_PDF/DONE_INCOMPLETE restored 1:1)
- field_registry.yaml: +owner/deprecated/replacement/enum values/default

Adapter cleanup:
- new core/io.py (read_json/write_json), core/date_utils.py (extract_year)
- new adapters/collections.py (build_collection_lookup)
- adapters/bbt.py: cut worker dependency, _private→public+alias
- worker/_utils.py + _domain.py: re-export from core instead of duplicate defs

Command unification:
- All 6 commands (sync/status/ocr/deep/repair/dashboard) → PFResult
- cli.py --json dest unified to 'json' (was json_output on status/doctor)
- commands/sync.py → SyncService (no more int/dict/PFResult mixing)

Service hardening:
- SyncService.run() orchestrates full sync lifecycle (select→index→clean)
- cleanup loops (orphaned records, flat notes) migrated from worker
- worker/sync.py: freeze line + services→worker one-way dependency
- plugin/main.js: formal-library.json fallback deprecation warning

Verification: 181/181 tests, 0 new lint errors
2026-05-09 22:20:07 +08:00
Research Assistant
b52046d209 fix: skip backslash path test on non-Windows (\\ is valid filename char on Linux) 2026-05-09 18:33:42 +08:00
Research Assistant
bbd39a90d3 v1.4.17rc4
Milestone v2.1: Contract-Driven Architecture & Engineering Hardening

- Stop the Bleeding: version sync checker, PyYAML hardening, install docs unification
- Contract Layer: PFResult/PFError dataclasses, ErrorCode enum, --json wrapping
- Service Extraction: sync.py decomposed into 3 adapters + SyncService
- State Machine: PdfStatus/OcrStatus/Lifecycle enums, transitions, field registry
- Setup Modularization: setup_wizard.py decomposed into 6 classes

173 tests passing, 0 regressions.
2026-05-09 17:05:07 +08:00