Commit 2ecd863
refactor(paper): add source-first Paper Flow V1 (#120)
## Summary
- Replaces the model-authored `Paper(TreeKnowledge)` output with a
source-first `PaperFlowResult` containing an immutable exact source
revision, a deterministic page-aware `PaperChunkSet`, and an
independently versioned cited `PaperGlobalSummary`.
- Implements manager-style multi-agent summarization with the OpenAI
Agents SDK: one coordinator retains final-summary ownership, delegates
required chunk ranges through a real `Agent.as_tool()` research
specialist, permits bounded parallel and overlapping follow-up calls,
and rejects incomplete source coverage.
- Enforces shared research call, concurrency, turn, input-token,
worker-output, total-output, final-output, citation, and runtime limits.
Worker reports contain typed
context/contribution/method/result/limitation findings with
code-validated chunk/page coordinates.
- Replaces the open `list[str]` paper search filter with the
Pydantic-validated `PaperArtifactKind` enum. Python callers use
`PaperArtifactKind.GLOBAL_SUMMARY` or `PaperArtifactKind.CHUNK_SET`;
JSON and YAML retain the corresponding string values while unknown kinds
fail validation.
- Adds SQLite schema version 3 with explicit source/blob,
artifact/member, lineage, and search-projection tables; atomic
`put_paper()`; selective embedding reuse; reopen-safe locator
resolution; cross-record integrity checks; and a tested `LegacyPaper`
compatibility boundary for existing databases.
- Moves retrieval-text selection out of canonical knowledge models,
preserves existing non-paper search behavior, and documents the Source →
Artifact → SearchProjection contract across flow, knowledge, RAG,
library, examples, and contributor guidance.
The cross-flow placement and reuse policy for Pydantic input/config
types is intentionally tracked separately in #121 instead of being
decided implicitly by this paper refactor.
## Related Issues
Closes #119
- #121 tracks ownership, reuse, naming, supported-variant, schema, and
migration rules for typed operation inputs and stage configuration.
## Breaking Changes
- `paper_flow()` now returns `PaperFlowResult` and supports PDF-backed
arXiv, HTTP, and local inputs in V1; raw text, non-PDF content, and
unresolved DOI inputs fail explicitly.
- The former primary `Paper` tree is no longer exported or generated.
Existing version-2 databases and the bundled compatibility example load
that shape as `LegacyPaper`.
- `SemanticQuery.artifact_kinds` now validates as
`list[PaperArtifactKind]`; valid serialized string values remain
`paper_summary` and `paper_chunk_set`.
## Verification
- `./scripts/verify.sh` — PASS: ruff format/check, basedpyright with 0
errors and warnings, all 7 import contracts, 335 tests, and 83.69%
coverage.
- `.venv/bin/python scripts/verify_pdf_rag_e2e.py` — live PASS against
exact arXiv revision `1706.03762v7`: manager/research-agent
orchestration, complete coverage of 36 chunks, 15 text pages, 19 source
assets, 42 chunk-to-asset references, cited summary across 7 pages,
summary retrieval, multi-head-attention passages in the top five,
close/reopen, repeated searches, and canonical locator resolution.
- Focused config, flow, library, and live-verifier tests — PASS: 41
tests cover typed artifact parsing, real agent-tool construction, worker
concurrency and budgets, complete-coverage enforcement, persistence,
retrieval, and E2E assertions.
- Commit and pre-push hooks — PASS: file hygiene, YAML validation,
large-file check, ruff, and the deterministic verification harness.
- GitHub Actions — required `ci` PASS; the `paper-flow` job PASS with
its live step explicitly skipped because the repository has no
`OPENAI_API_KEY`; the unrelated `news` job failed on both the initial
run and one retry because PR Newswire returned `404` for its RSS
endpoint while the discovery and ticker-hint checks passed.
## Checklist
- [x] The title uses English Conventional Commit format: `type(scope):
summary`.
- [x] The related issue or design discussion is linked when applicable.
- [x] `./scripts/verify.sh` passes.
- [x] Every applicable live-network component smoke test passes, or this
PR states why none applies.
- [x] Public behavior has focused tests, an example, and documentation
where applicable.
- [x] The PR contains no unrelated changes.
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 4ecb2e5 commit 2ecd863
60 files changed
Lines changed: 5317 additions & 1436 deletions
File tree
- .agents/skills/quantmind-dev/references
- .claude/skills/quantmind-dev/references
- .github/workflows
- contexts
- design
- flow
- knowledge
- library
- operations
- preprocess
- rag
- usage
- docs
- examples
- flows
- library
- data
- quantmind
- configs
- flows
- knowledge
- library
- _internal
- preprocess/fetch
- rag
- scripts
- examples
- tests
- configs
- flows
- knowledge
- library
- preprocess/fetch
- rag
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| |||
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
41 | | - | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
63 | | - | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
| |||
98 | 108 | | |
99 | 109 | | |
100 | 110 | | |
101 | | - | |
| 111 | + | |
102 | 112 | | |
103 | | - | |
| 113 | + | |
104 | 114 | | |
105 | 115 | | |
| 116 | + | |
| 117 | + | |
106 | 118 | | |
107 | 119 | | |
108 | 120 | | |
| |||
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
128 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
129 | 153 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
| 170 | + | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| |||
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
222 | | - | |
223 | | - | |
| 223 | + | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| |||
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
241 | | - | |
| 242 | + | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
| |||
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
269 | 262 | | |
270 | 263 | | |
271 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
0 commit comments