ticket: define flat memory extract staging

This commit is contained in:
Keisuke Hirata 2026-07-18 04:34:28 +09:00
parent 7c1fb65947
commit 444e6bee42
No known key found for this signature in database
9 changed files with 309 additions and 81 deletions

View File

@ -2,8 +2,8 @@
title: "効果的な Memory システム設計・検証" title: "効果的な Memory システム設計・検証"
state: "active" state: "active"
created_at: "2026-06-20T15:16:00Z" created_at: "2026-06-20T15:16:00Z"
updated_at: "2026-07-16T17:24:00Z" updated_at: "2026-07-17T18:10:00Z"
linked_tickets: ["00001KSKBPHRG", "00001KT02TCCG", "00001KTGCAFXG", "00001KSKBPTHR", "00001KXMEZNYC", "00001KXMK7YMC", "00001KXNYXNM6", "00001KXMK846H"] linked_tickets: ["00001KSKBPHRG", "00001KT02TCCG", "00001KTGCAFXG", "00001KSKBPTHR", "00001KXMEZNYC", "00001KXMK7YMC", "00001KXNYXNM6", "00001KXRM6G0G", "00001KXMK846H"]
--- ---
## Goal ## Goal
@ -74,7 +74,7 @@ Memory 墓場化の最初の原因は、保存情報が現在の問いに集ま
- Progress message は専用 Tool ではなく通常 Message とし、ユーザーへの進捗報告と extract 用 semantic summary を兼ねる。 - Progress message は専用 Tool ではなく通常 Message とし、ユーザーへの進捗報告と extract 用 semantic summary を兼ねる。
- extract worker には専用の read-only evidence tools を渡し、Overview で重要そうに見えた箇所だけ session range / tool summaries / source anchors を探索させる。 - extract worker には専用の read-only evidence tools を渡し、Overview で重要そうに見えた箇所だけ session range / tool summaries / source anchors を探索させる。
- extract worker は Memory / Knowledge / Skill を直接更新しない。output は必ず staging を挟み、source / provenance を host 側で機械的に保持する。 - extract worker は Memory / Knowledge / Skill を直接更新しない。output は必ず staging を挟み、source / provenance を host 側で機械的に保持する。
- trigger は LLM call 単位ではなく、Overview accumulation、evidence growth、Worker run cycle、task boundary を組み合わせる。mid-run 発火を入れる場合も staging/checkpoint extraction に限定する - trigger は初期実装では現行通り Worker run cycle 完了後の threshold 判定にする。LLM call 単位や Run 中の Overview accumulation trigger は含めない
### 4. Memory を authority にしない ### 4. Memory を authority にしない

View File

@ -1,6 +1,6 @@
--- ---
created_at: "2026-07-15T21:33:00Z" created_at: "2026-07-15T21:33:00Z"
updated_at: "2026-07-16T17:18:00Z" updated_at: "2026-07-16T18:20:00Z"
objective: "00001KVJSMQXZ" objective: "00001KVJSMQXZ"
status: "architecture-draft" status: "architecture-draft"
notes: "Memory / Knowledge / Skills を別々の workspace resource として再設計するための draft architecture。この文書は Objective resource であり、実装 authority ではない。" notes: "Memory / Knowledge / Skills を別々の workspace resource として再設計するための draft architecture。この文書は Objective resource であり、実装 authority ではない。"
@ -65,7 +65,7 @@ Memory record に入るもの:
Memory は provisional に書く: Memory は provisional に書く:
- いつ / なぜ learned したかを書く。 - いつ / なぜ learned したかを書く。
- scope と applicability を書く。 - どの前提で learned したかを必要な範囲で書く。
- staleness / supersession を許す。 - staleness / supersession を許す。
- authoritative records を verbatim にコピーしない。 - authoritative records を verbatim にコピーしない。
- 可能なら Tickets / docs / Knowledge notes への pointer を優先する。 - 可能なら Tickets / docs / Knowledge notes への pointer を優先する。
@ -95,17 +95,17 @@ Memory は Knowledge のような note bundle ではない。1〜3 行程度の
## Current focus ## Current focus
- Memory extract redesign is focused on Overview-first extraction and staging resolution. - Memory extract redesign is focused on Overview-first extraction and staging resolution.
Scope: Yoi repo. Source: Objective 00001KVJSMQXZ. Stale when related tickets close. Source: Objective 00001KVJSMQXZ. Stale when related tickets close.
## Preferences ## Preferences
- User prefers implementation Tickets, not design-only Tickets. - User prefers implementation Tickets, not design-only Tickets.
Scope: Yoi dogfooding. Source: 2026-07-16 session. Source: 2026-07-16 session.
## Working assumptions ## Working assumptions
- Knowledge should be OKF-compatible, while volatile Memory and staging should not be OKF. - Knowledge should be OKF-compatible, while volatile Memory and staging should not be OKF.
Scope: Memory architecture redesign. Source: architecture objective. Source: architecture objective.
## Reminders ## Reminders
@ -121,7 +121,7 @@ Recommended H2 sections:
- `## Reminders` - `## Reminders`
- `## Stale or superseded` - `## Stale or superseded`
Each item should stay short. When useful, include `Scope`, `Source`, and `Stale when` inline. Long explanations, evidence-heavy analysis, durable rationale, citations, and cross-linked concepts should be routed to Knowledge rather than expanded inside Memory. Each item should stay short. When useful, include `Source` and `Stale when` inline. Long explanations, evidence-heavy analysis, durable rationale, citations, and cross-linked concepts should be routed to Knowledge rather than expanded inside Memory.
The single-file layout is an initial storage profile, not an API contract. Workers, Web, Runtime, and CLI should use the Workspace Memory API view rather than depending on the exact file layout, so storage can later split or evolve without changing the model-visible contract. The single-file layout is an initial storage profile, not an API contract. Workers, Web, Runtime, and CLI should use the Workspace Memory API view rather than depending on the exact file layout, so storage can later split or evolve without changing the model-visible contract.
@ -129,7 +129,6 @@ The single-file layout is an initial storage profile, not an API contract. Worke
```text ```text
User preference: prefers direct commits only when explicitly requested. User preference: prefers direct commits only when explicitly requested.
Scope: this repository / current dogfooding workflow.
Source: repeated user corrections in sessions around git operations. Source: repeated user corrections in sessions around git operations.
Staleness: revisit if user changes repo workflow. Staleness: revisit if user changes repo workflow.
``` ```
@ -420,50 +419,149 @@ Overview の意図は、extract worker に「何のための探索だったか
### 6.2 Extract: candidate generation ### 6.2 Extract: candidate generation
Extract は candidate generation であり、Memory 化ではない。入力は Overview-first / Evidence-index-second にする Extract は candidate generation であり、Memory 化ではない。runtime 側の extract worker が Overview と session evidence を読んで、後で記憶化を検討すべき **flat candidate records** を staging に出す
Extract の責務: Extract の責務:
- Overview を読んで、重要そうな request / discussion / decision / attempt を見つける。 - Overview を読んで、記憶化を検討すべき candidate を見つける。
- 必要な箇所だけ evidence tools で確認する。 - 必要な箇所だけ evidence tools で確認する。
- source anchors を持つ candidate を staging に出す。 - candidate ごとに bounded evidence snippets / source anchors を選ぶ。
- empty / NOP を正常結果として扱う。 - candidate ごとに `stage_candidate` を呼び、1 candidate = 1 staging record として保存する。
- 最後に `finish_extraction` を呼び、staged count または NOP reason を残す。
Extract がしてはいけないこと: Extract がしてはいけないこと:
- Memory / Knowledge / Skill / Ticket / docs を直接変更しない。 - Memory / Knowledge / Skill / Ticket / docs を直接変更しない。
- batch payload として複数 candidate を 1 staging record にまとめない。
- tool result 全文や reasoning を無制限に取り込まない。 - tool result 全文や reasoning を無制限に取り込まない。
- local slice だけから根拠を推測しない。 - local slice だけから根拠を推測しない。
- tool call chronology、generic progress、current focus update を抽出しない。
- 「進捗報告があった」こと自体を Memory 化しない。 - 「進捗報告があった」こと自体を Memory 化しない。
初期の extract output schema は既存の `decisions` / `discussions` / `attempts` / `requests` を維持してよい。ただし、entry-level evidence refs / source anchors を段階的に追加できる形にする。 Staging candidate は、Consolidation がそれ単体で discard / merge / promote / defer を判断できる最小単位にする。
### 6.3 Extract worker evidence tools `decisions` / `discussions` / `attempts` / `requests` batch schema は維持しなくてよい。互換性よりも、flat candidate records と clear responsibility を優先する。
extract worker には専用の constrained evidence tools を渡す。これは main Worker の tool 数を増やすものではなく、extract 専用 worker の read-only surface である。 #### 6.2.1 Extract candidate taxonomy
必要な tool category: Extract が抽出する対象は activity log ではない。抽出対象は次の candidate kinds に絞る。
- **Evidence search**: session slice / tool summaries / message index から query で候補 range を探す。 | kind | extract で見る観点 | consolidation での扱い |
- **Evidence read**: bounded な session entry range、tool call/result summary、必要なら host が許す bounded content excerpt を読む。 | --- | --- | --- |
- **Source anchor resolver**: `session_id`, entry range, tool call id, file path, Ticket/Objective artifact ref などを staging source に結びつける。 | `preference` | ユーザーまたは workspace の継続的な好み・作法。単発指示ではなく、今後の agent behavior に効くもの。 | Memory に短く merge / replace する候補。既存 preference と重複するなら統合。Ticket/docs の要件そのものなら mirror せず authority link へ。曖昧なら discard / defer。 |
- **write_extracted**: structured payload を 1 回提出する既存 output tool。 | `working_assumption` | 現時点で仮に置いている設計・実装前提。future work に影響し、変更条件や反証条件があり得るもの。 | Memory に入れる場合は short-lived assumption として stale condition 必須。長期設計なら Knowledge candidate。すでに authority record に反映済みなら Memory には pointer だけ、または discard。 |
| `constraint` | 今後守るべき境界・禁止・invariant。実装や review でチェック可能なもの。 | active implementation に効くなら Memory。durable policy なら Ticket decision / Knowledge / docs candidate。破られた既存 Memory があれば mark_stale / replace。 |
| `decision` | alternatives / chosen / rationale がある判断。単なる事実確認や作業進行ではないもの。 | まず authority routing を判断する。Ticket 要件・state・acceptance に関係するなら Ticket decision/comment candidate。長期設計なら Knowledge/Objective candidate。短期実装判断だけ Memory に短く置く。会話中の一時結論なら discard。 |
| `open_question` | 未解決で後続作業に影響する問い。next action が書けるもの。単なる会話中の疑問ではない。 | Memory reminder にするか、Ticket follow-up / planning item に送る。解決済みなら discard。長く残る概念的問いなら Knowledge candidate。TTL / defer reason を持たせる。 |
| `lesson` | 検証・失敗・試行から得た再利用価値のある学び。同じ失敗を避ける、作業方法を改善する、Skill 化できる可能性があるもの。 | Memory に短く残すか、recurring / portable なら Skill candidate。単なる tool execution result は discard。validation evidence として Ticket/report に残すべきものは authority link。 |
抽出しないもの:
- `current_focus` update。これは resident summary surface であり、extract candidate kind ではない。
- tool call chronology。
- file read/write history。
- generic progress updates。
- one-off chit-chat。
- resolved local confusion。
- assistant self-corrections without durable consequence。
- authoritative Ticket/docs/git facts copied verbatim。
- validation results unless they imply a reusable lesson, active blocker, or authority evidence。
- implementation details that belong only in commit diff。
### 6.3 Extract worker tools
extract worker には `session-explore` feature の constrained tools だけを渡す。これは main Worker の tool 数を増やすものではない。
Tool surface:
- `search_evidence`: session snapshot / tool summaries / message index から query で候補 range を探す。
- `read_evidence`: bounded な session entry range、tool call/result summary、host が許す bounded excerpt を読む。
- `stage_candidate`: 1 candidate を staging record として保存する。
- `finish_extraction`: extract run を終了し、staged count または NOP reason を記録する。
`stage_candidate` は direct Memory write ではない。これは staging write だけを行う output tool である。
`stage_candidate` input の概念形:
```json
{
"kind": "decision",
"claim": "Overview is runtime-only extract projection, not staging data.",
"why_useful": "Clarifies extract/consolidate responsibility boundary.",
"staleness": "Revisit if Workspace can directly explore runtime sessions.",
"evidence_ids": ["E001", "E002"]
}
```
Host wrapper は `evidence_ids` を runtime reference environment から解決し、bounded evidence snippets と source anchors を staging record に機械的に付与する。LLM に自由な source anchor を書かせない。
`finish_extraction` の概念形:
```json
{
"staged_count": 0,
"reason": "Only local progress and tool chronology; no durable candidates."
}
```
候補が無い場合は `stage_candidate` を呼ばず、`finish_extraction` で NOP を明示する。tool call なし終了も host 側では NOP fallback として扱ってよいが、基本は `finish_extraction` を要求する。
制約: 制約:
- read-only。file write、Ticket mutation、Memory/Knowledge/Skill direct write は持たせない。 - read-only evidence access。file write、Ticket mutation、Memory/Knowledge/Skill direct write は持たせない。
- bounded output。large tool result は summary / excerpt / pointer に留める。 - bounded output。large tool result は summary / excerpt / pointer に留める。
- provenance first。extract worker が根拠を推測せず、読んだ evidence range を output と結びつけられるようにする。 - provenance first。extract worker が根拠を推測せず、読んだ evidence ids を `stage_candidate` に渡す。
- NOP allowed。Overview を読んで保存価値がなければ empty payload で終わる。
### 6.4 Staging: provenance-backed candidate queue ### 6.4 Staging: flat provenance-backed candidate records
Staging は Memory ではない。Staging は、extract が拾った candidate を provenance 付きで保管し、consolidation が後で審査できるようにする queue / buffer である。 Staging は Memory ではない。Staging は、extract が切り出した candidate を provenance 付きで保管し、consolidation が後で審査できるようにする queue である。
Staging は flat records にする。
```text
1 extract run = 0..N staging records
1 staging record = 1 candidate = 1 consolidation decision unit
```
1 record の概念形:
```json
{
"schema_version": 2,
"id": "stg_...",
"extract_run_id": "er_...",
"source": {
"segment_id": "segment-1",
"range": [120, 180]
},
"kind": "constraint",
"claim": "Extract worker must not direct-write Memory/Knowledge/Skill; it only writes staging.",
"why_useful": "Preserves runtime/embedded responsibility boundary.",
"staleness": "Revisit if extract and consolidation move into the same Workspace execution context.",
"evidence": [
{
"id": "E001",
"kind": "message",
"entry_range": [132, 133],
"excerpt": "extract worker は Memory / Knowledge / Skill を直接更新しない",
"summary": "User and architecture discussion fixed staging-only extract boundary."
}
],
"source_refs": [
{
"evidence_id": "E001",
"evidence_kind": "message",
"entry_range": [132, 133]
}
]
}
```
Staging の責務: Staging の責務:
- candidate kind / claim / hints を保持する。
- extract が選んだ bounded evidence snippets を保持する。
- source anchors を保持する。 - source anchors を保持する。
- candidate と Overview / Evidence の対応を保持する。
- extract と consolidation を decouple する。 - extract と consolidation を decouple する。
- duplicate / defer / discard / consumed の追跡対象になる。 - duplicate / defer / discard / consumed の追跡対象になる。
- crash / cancel / long-running work の途中でも、後から審査できる候補を残す。 - crash / cancel / long-running work の途中でも、後から審査できる候補を残す。
@ -472,7 +570,8 @@ Staging がしてはいけないこと:
- Memory として resident context に直接入らない。 - Memory として resident context に直接入らない。
- Knowledge note の代替にならない。 - Knowledge note の代替にならない。
- raw session log の永久保存場所にならない。 - raw session log や Overview 全体の保存場所にならない。
- extract run 単位の batch file として複数 candidate を抱え込まない。
- staging entry をすべて Memory 化する前提にしない。 - staging entry をすべて Memory 化する前提にしない。
Pirolli & Card 的には、staging は shoebox / evidence file に近い。ただし Yoi の storage taxonomy そのものを shoebox にするのではなく、審査前の evidence-backed candidate queue として扱う。 Pirolli & Card 的には、staging は shoebox / evidence file に近い。ただし Yoi の storage taxonomy そのものを shoebox にするのではなく、審査前の evidence-backed candidate queue として扱う。
@ -515,10 +614,10 @@ Consolidation は precision-oriented pass である。staging を読んで、Mem
Consolidation の責務: Consolidation の責務:
- staging entry を評価する。 - staging entry を candidate kind ごとの扱いに沿って評価する。
- Memory 化するなら usefulness / scope / staleness / source を要求する。 - Memory 化するなら usefulness / staleness / source を要求する。
- 既存 Memory と merge / replace / mark stale / delete する。 - 既存 Memory と merge / replace / mark stale / delete する。
- Knowledge / Skill / Ticket / docs candidate に routing する。 - decision / constraint / lesson などを authority / Knowledge / Skill / Ticket / docs candidate に routing する。
- discard reason / defer reason を残す。 - discard reason / defer reason を残す。
- linter feedback / usage evidence / tidy hints を使う。 - linter feedback / usage evidence / tidy hints を使う。
- Memory bloat と stale records を防ぐ。 - Memory bloat と stale records を防ぐ。
@ -534,7 +633,6 @@ Memory 化に必要な minimum fields / prose:
```text ```text
content: 何を覚えるか content: 何を覚えるか
scope: どこで効くか
why_useful: 今後なぜ役立つか why_useful: 今後なぜ役立つか
source: staging / evidence anchor source: staging / evidence anchor
staleness: 何が起きたら古くなるか staleness: 何が起きたら古くなるか
@ -549,12 +647,13 @@ Consolidation は append worker ではなく garden worker である。新規作
初期方針: 初期方針:
- overview token count または Assistant Progress/final message count が一定量を超えたら extract を予約する。 - 現行通り、Worker run cycle が完了してから threshold を判定し、超えていれば extract を発火する。
- tool evidence growth が大きい場合も extract を予約できる。 - extract 開始時点で immutable snapshot / Overview projection / Evidence index を作る。
- Worker run cycle / task boundary / Ticket phase boundary では extract を試す。 - LLM call ごとには発火しない。
- long-running 中に mid-run 発火する場合も、direct update ではなく staging/checkpoint extraction に限定する。 - Run 中の Overview accumulation trigger / mid-run extract は初期実装に含めない。
- 将来 long-running 中に mid-run 発火を入れる場合も、direct update ではなく staging/checkpoint extraction に限定する。
この trigger は「意味のある overview が溜まったか」と「evidence が失われる前に staging したいか」の両方で判断する。 この trigger は、まず既存の post-run memory job model を保ち、extract の入力品質と staging record 粒度の改善に集中する。
## 7. Sensemaking interpretation ## 7. Sensemaking interpretation
@ -580,7 +679,7 @@ Product
Ticket/doc update, review evidence, discard resolution Ticket/doc update, review evidence, discard resolution
``` ```
重要なのは、Memory 化を evidence から product へ進める審査の一形態として扱うこと。Memory record は「将来の作業に効く」という hypothesis なので、scope、why_useful、staleness、source が必要である。 重要なのは、Memory 化を evidence から product へ進める審査の一形態として扱うこと。Memory record は「将来の作業に効く」という hypothesis なので、why_useful、staleness、source が必要である。
初期 sensemaking support は lightweight でよい: 初期 sensemaking support は lightweight でよい:
@ -713,11 +812,12 @@ Recommended implementation sequence:
- tool calls / tool results は Evidence index として分離する。 - tool calls / tool results は Evidence index として分離する。
- committed history だけから Overview を作り、hidden context injection を避ける。 - committed history だけから Overview を作り、hidden context injection を避ける。
4. **Extract worker 専用 evidence tools を実装する** 4. **Extract worker 専用 evidence tools と staging output tools を実装する**
- extract worker に read-only Evidence search / Evidence read / Source anchor resolver を渡す。 - extract worker に read-only Evidence search / Evidence read を渡す。
- main Worker の tool surface は増やさない。 - main Worker の tool surface は増やさない。
- output tool は `write_extracted` を維持し、structured payload を 1 回提出させる。 - output tools は `stage_candidate` / `finish_extraction` にする。
- source range と output entry を結びつけられる schema / staging format を実装する。 - `stage_candidate` は 1 candidate = 1 flat staging record を書く。
- source range と candidate record を結びつけられる schema / staging format を実装する。
5. **Staging-first extract を維持する** 5. **Staging-first extract を維持する**
- extract worker は direct Memory / Knowledge / Skill write をしない。 - extract worker は direct Memory / Knowledge / Skill write をしない。
@ -772,6 +872,7 @@ Recommended implementation sequence:
- Knowledge notes を Tickets / docs / git history より authoritative にすること。 - Knowledge notes を Tickets / docs / git history より authoritative にすること。
- review なしに Knowledge / Skills / docs を自動 rewrite すること。 - review なしに Knowledge / Skills / docs を自動 rewrite すること。
- extract worker に direct resource mutation authority を持たせること。 - extract worker に direct resource mutation authority を持たせること。
- extract run 単位の batch staging record に複数 candidate を抱え込ませること。
- staging entry をすべて Memory 化すること。 - staging entry をすべて Memory 化すること。
- human-readable artifact model が安定する前に vector database を設計すること。 - human-readable artifact model が安定する前に vector database を設計すること。
- volatile Memory や staging queue を OKF concept document として扱うこと。 - volatile Memory や staging queue を OKF concept document として扱うこと。
@ -791,10 +892,11 @@ Recommended implementation sequence:
- Memory -> Knowledge の promotion UI/tool をどうするか。 - Memory -> Knowledge の promotion UI/tool をどうするか。
- personal Memory と workspace Memory をどう区別するか。 - personal Memory と workspace Memory をどう区別するか。
- Knowledge drafts の auto-generation をどこまで許すか。 - Knowledge drafts の auto-generation をどこまで許すか。
- extract worker 専用 evidence tools の exact API: search/read/resolver の引数、上限、source anchor format。 - extract worker 専用 evidence tools の exact API: search/read の引数、上限、evidence id format。
- `stage_candidate` / `finish_extraction` の exact tool schema。
- flat staging record の exact fields: `claim`, `why_useful`, `staleness`, `evidence`, `source_refs`, `extract_run_id` など。
- Overview trigger を overview token count、Assistant message count、evidence growth、run/task boundary のどれで制御するか。 - Overview trigger を overview token count、Assistant message count、evidence growth、run/task boundary のどれで制御するか。
- mid-run extract をどこまで許すか。初期は staging/checkpoint extraction に限定する方針。 - mid-run extract をどこまで許すか。初期は staging/checkpoint extraction に限定する方針。
- source range と `ExtractedPayload` entries をどう結びつけるか。
- staging resolution log / archive の保持期間と compact policy。 - staging resolution log / archive の保持期間と compact policy。
- どの Memory sidecar writes を direct に許し、どれを staged proposals にするか。extract worker 自体は direct write しない。 - どの Memory sidecar writes を direct に許し、どれを staged proposals にするか。extract worker 自体は direct write しない。
- Skill sidecar output は patches/proposals だけから始めるか、low-risk Skill edits を auto-apply してよいか。 - Skill sidecar output は patches/proposals だけから始めるか、low-risk Skill edits を auto-apply してよいか。

View File

@ -8,6 +8,14 @@
"note": "session-explore extract worker must use the finalized staging source anchor / evidence ref format.", "note": "session-explore extract worker must use the finalized staging source anchor / evidence ref format.",
"author": "yoi ticket", "author": "yoi ticket",
"at": "2026-07-16T17:19:11Z" "at": "2026-07-16T17:19:11Z"
},
{
"ticket_id": "00001KXMK7YMC",
"kind": "depends_on",
"target": "00001KXRM6G0G",
"note": "session-explore extract worker must write flat candidate staging records via stage_candidate.",
"author": "yoi ticket",
"at": "2026-07-17T18:10:00Z"
} }
] ]
} }

View File

@ -2,24 +2,24 @@
title: 'session-explore feature付きextract workerを実装する' title: 'session-explore feature付きextract workerを実装する'
state: 'planning' state: 'planning'
created_at: '2026-07-16T04:34:01Z' created_at: '2026-07-16T04:34:01Z'
updated_at: '2026-07-16T17:19:41Z' updated_at: '2026-07-17T18:10:00Z'
assignee: null assignee: null
--- ---
## 背景 ## 背景
Overview-first extract では、extract worker が開始時点の会話 snapshot と filtered Overview projection を参照し、必要な evidence だけを探索して staging payload を出す。main Worker の tool surface は増やさず、extract worker だけに session exploration 用の read-only tools を与える必要がある。 Overview-first extract では、extract worker が開始時点の会話 snapshot と filtered Overview projection を参照し、必要な evidence だけを探索して staging candidate を出す。main Worker の tool surface は増やさず、extract worker だけに session exploration 用の read-only tools と staging output tools を与える。
このため、`session-explore` feature を新設し、その feature のみが有効な Worker / ToolRegistry として extract worker を作る。extract worker は Memory / Knowledge / Skill / Ticket / docs を直接変更せず、`write_extracted` によって staging payload だけを出す。 新方針では、extract run ごとの batch payload は使わない。extract worker は candidate ごとに `stage_candidate` を呼び、flat staging record を 1 件ずつ作る。出すべき candidate がない場合は `finish_extraction` で NOP reason を残す。
この Ticket は worker 実装を扱う。先に Ticket `00001KXNYXNM6` で staging payload / source anchor 形式を固める。 この Ticket は worker 実装を扱う。先に Ticket `00001KXRM6G0G` で flat candidate staging record schema を実装する。
関連: 関連:
- Objective `00001KVJSMQXZ` - Objective `00001KVJSMQXZ`
- `.yoi/objectives/00001KVJSMQXZ/memory-architecture-overview.md` - `.yoi/objectives/00001KVJSMQXZ/memory-architecture-overview.md`
- Ticket `00001KXMEZNYC` — ターン中のProgress messageを残す指示を追加する - Ticket `00001KXMEZNYC` — ターン中のProgress messageを残す指示を追加する
- Ticket `00001KXNYXNM6` — Extract stagingのsource anchor形式を実装する - Ticket `00001KXRM6G0G` — Flat candidate staging record schemaを実装する
## 実装意図 ## 実装意図
@ -33,7 +33,7 @@ Conversation snapshot at extract start
- message entries - message entries
- tool call summaries - tool call summaries
- tool result summaries / bounded excerpts - tool result summaries / bounded excerpts
- source anchor table - evidence id -> source anchor table
Filtered Overview projection Filtered Overview projection
- User messages - User messages
@ -48,11 +48,11 @@ Extract worker:
Overview を読む Overview を読む
-> important candidate を見つける -> important candidate を見つける
-> session-explore tools で evidence を確認する -> session-explore tools で evidence を確認する
-> host-resolved source anchors を使う -> stage_candidate(kind, claim, why_useful, staleness, evidence_ids) を候補ごとに呼ぶ
-> write_extracted で staging payload を出す -> 最後に finish_extraction(staged_count, reason) を呼ぶ
``` ```
この変更で目指す改善は recall をむやみに増やすことではない。断片的な `attempts` や無用な `discussions` を減らし、source に辿れる候補だけを staging に出す precision 改善を優先する。 この変更で目指す改善は recall をむやみに増やすことではない。断片的な activity log を減らし、Consolidation が単体で解決できる最小 candidate record を staging に出す precision 改善を優先する。
## 対象領域 ## 対象領域
@ -64,16 +64,16 @@ Overview を読む
- Overview-first / Evidence-index-second rendering。 - Overview-first / Evidence-index-second rendering。
- Conversation snapshot / filtered Overview projection の入力作成。 - Conversation snapshot / filtered Overview projection の入力作成。
- `crates/memory/src/extract/tool.rs` または隣接 module - `crates/memory/src/extract/tool.rs` または隣接 module
- `write_extracted` に加えて session exploration tools を実装。 - `search_evidence` / `read_evidence` / `stage_candidate` / `finish_extraction` を実装。
- `crates/memory/src/extract/payload.rs` - `crates/memory/src/extract/payload.rs`
- Ticket `00001KXNYXNM6` の staging source refs を利用。 - Ticket `00001KXRM6G0G` の flat staging record schema を利用。
- `crates/memory/src/extract/staging.rs` - `crates/memory/src/extract/staging.rs`
- staging write。 - candidate ごとの staging write。
- `crates/worker/src/worker.rs` - `crates/worker/src/worker.rs`
- `run_extract_once` / extract worker 起動。 - `run_extract_once` / extract worker 起動。
- extract worker 用 ToolRegistry / enabled feature set の構築。 - extract worker 用 ToolRegistry / enabled feature set の構築。
- `resources/prompts/internal/memory_extract_system.md` - `resources/prompts/internal/memory_extract_system.md`
- Overview-first / evidence-confirmation / staging-only output 前提へ更新。 - candidate taxonomy / evidence-confirmation / `stage_candidate` / `finish_extraction` 前提へ更新。
## 実装方針 ## 実装方針
@ -86,8 +86,7 @@ extract worker は live Worker state を自由に読むのではなく、extract
- source range / segment id。 - source range / segment id。
- Overview projection。 - Overview projection。
- Evidence index。 - Evidence index。
- evidence id -> source anchor table。 - evidence id -> anchor / summary / bounded excerpt table。
- bounded tool result summary / excerpt。
含めないもの: 含めないもの:
@ -108,16 +107,17 @@ Feature の tool surface:
- `read_evidence` - `read_evidence`
- evidence id または entry range を読む。 - evidence id または entry range を読む。
- output は bounded message/tool summary/excerpt と source anchor。 - output は bounded message/tool summary/excerpt と source anchor。
- `resolve_source_anchor` - `stage_candidate`
- evidence id / entry range / tool call id から normalized source anchor を返す。 - 1 candidate を flat staging record として保存する。
- 実装上過剰なら、`search_evidence` / `read_evidence` output に anchor を含める形でもよい。 - input は `kind`, `claim`, `why_useful`, optional `staleness`, `evidence_ids`
- `write_extracted` - host が evidence ids を source anchors / bounded snippets に解決する。
- structured staging payload を 1 回提出する output tool。 - `finish_extraction`
- staged count と completion reason / NOP reason を記録する。
制約: 制約:
- read-only。 - evidence access は read-only。
- file write / Ticket mutation / Memory direct write / Knowledge direct write / Skill direct write を持たせない。 - `stage_candidate` は staging write だけであり、Memory / Knowledge / Skill / Ticket / docs を mutate しない。
- main Worker の通常 tool surface には出さない。 - main Worker の通常 tool surface には出さない。
- extract worker の enabled feature set は `session-explore` のみにする。 - extract worker の enabled feature set は `session-explore` のみにする。
@ -129,15 +129,15 @@ Feature の tool surface:
- foreground Worker history を汚染しない。 - foreground Worker history を汚染しない。
- extract prompt / harness messages は canonical foreground history に混ざらない。 - extract prompt / harness messages は canonical foreground history に混ざらない。
- output は `write_extracted` 経由で host context に戻す。 - output は `stage_candidate` / `finish_extraction` 経由で host context に戻す。
- empty / NOP は正常結果。 - empty / NOP は正常結果。
- worker が evidence tools 以外の通常 workspace tools を見ないことを test する。 - worker が evidence tools と staging output tools 以外の通常 workspace tools を見ないことを test する。
### 4. Trigger は広げすぎない ### 4. Trigger は現行 post-run threshold を維持する
初期実装では既存 post-run trigger を維持してよい。LLM call ごとの extract はしない。 初期実装では既存の post-run trigger を維持する。Worker run cycle が完了してから threshold を判定し、超えていれば extract を発火する。LLM call ごと、または Run 中の途中では発火しない。
この Ticket の中心は scheduler ではなく、extract worker の参照環境と tool surface である。mid-run trigger や Overview accumulation trigger が大きくなる場合は別 Ticket に分ける。 この Ticket の中心は scheduler ではなく、extract worker の参照環境、tool surface、flat staging output である。mid-run trigger や Overview accumulation trigger は別 Ticket に分ける。
## 実装要件 ## 実装要件
@ -145,32 +145,36 @@ Feature の tool surface:
- `builtin:session-explore` feature を追加する。 - `builtin:session-explore` feature を追加する。
- extract worker は `session-explore` feature のみ有効な Worker / ToolRegistry として起動する。 - extract worker は `session-explore` feature のみ有効な Worker / ToolRegistry として起動する。
- `session-explore` feature に bounded read-only evidence tools を実装する。 - `session-explore` feature に bounded read-only evidence tools を実装する。
- `write_extracted` は output tool として維持する。 - `stage_candidate``finish_extraction` を output tools として実装する。
- `stage_candidate` は 1 call = 1 flat staging record を書く。
- `finish_extraction` は 0 件 NOP を正常終了として表現できる。
- `build_extract_input` 相当の入力を Overview-first / Evidence-index-second に変更する。 - `build_extract_input` 相当の入力を Overview-first / Evidence-index-second に変更する。
- extract worker は Ticket `00001KXNYXNM6` で定義された source anchor / evidence ref 形式を使って staging payload を出す。 - extract worker は Ticket `00001KXRM6G0G` の flat staging record schema を使って staging records を出す。
- extract worker は Memory / Knowledge / Skill / Ticket / docs を直接変更しない。 - extract worker は Memory / Knowledge / Skill / Ticket / docs を直接変更しない。
- main Worker の model-visible tool surface は増やさない。 - main Worker の model-visible tool surface は増やさない。
- raw tool result content 全文を無制限に extract prompt / tool output へ流さない。 - raw tool result content 全文を無制限に extract prompt / tool output / staging record へ流さない。
- `memory_extract_system.md`session-explore / evidence-confirmation / staging-only output 前提に更新する。 - `memory_extract_system.md`candidate taxonomy / session-explore / evidence-confirmation / `stage_candidate` 前提に更新する。
## 非目標 ## 非目標
- staging payload / source anchor format の確定はこの Ticket では行わない。Ticket `00001KXNYXNM6` が先行する。 - flat staging record schema の実装はこの Ticket では行わない。Ticket `00001KXRM6G0G` が先行する。
- staging -> Memory disposition / resolution flow はこの Ticket では実装しない。Ticket `00001KXMK846H` の対象。 - staging -> Memory disposition / resolution flow はこの Ticket では実装しない。Ticket `00001KXMK846H` の対象。
- 専用 Progress Tool を main Worker に追加しない。 - 専用 Progress Tool を main Worker に追加しない。
- Knowledge / Skill / docs を extract worker が直接 rewrite しない。 - Knowledge / Skill / docs を extract worker が直接 rewrite しない。
- 大規模な mid-run extraction scheduler はこの Ticket では作らない。 - 大規模な mid-run extraction scheduler はこの Ticket では作らない。
- 旧 batch staging schema との互換性維持を目的にしない。
## 受け入れ条件 ## 受け入れ条件
- extract 開始時点の immutable reference environment が作られる。 - extract 開始時点の immutable reference environment が作られる。
- filtered Overview projection が User messages / Assistant text outputs / committed task context から作られる。 - filtered Overview projection が User messages / Assistant text outputs / committed task context から作られる。
- `builtin:session-explore` feature が存在し、extract worker にだけ有効化される。 - `builtin:session-explore` feature が存在し、extract worker にだけ有効化される。
- extract worker が `session-explore` の read-only evidence tools と `write_extracted` だけを使える。 - extract worker が `session-explore` の read-only evidence tools と `stage_candidate` / `finish_extraction` だけを使える。
- `stage_candidate` 1 call が 1 flat staging record を作る。
- candidate がない場合、`finish_extraction` で staged_count=0 / NOP reason を記録できる。
- main Worker の model-visible tool surface が増えていない。 - main Worker の model-visible tool surface が増えていない。
- extract output は staging にだけ書かれ、Memory / Knowledge / Skill への direct write がない。 - extract output は staging にだけ書かれ、Memory / Knowledge / Skill への direct write がない。
- source / provenance は Ticket `00001KXNYXNM6` の形式で機械的に保持される。 - empty / no-candidate path が正常終了として扱われる。
- empty payload / no-op path が維持されている。 - Overview rendering、reference environment immutability、feature-gated tool registry、evidence tool bounds、stage_candidate output の tests が追加または更新されている。
- Overview rendering、reference environment immutability、feature-gated tool registry、evidence tool bounds の tests が追加または更新されている。
- `cargo test -p memory` と関連 worker tests、または該当 crate の同等テストが通る。 - `cargo test -p memory` と関連 worker tests、または該当 crate の同等テストが通る。
- prompt/resource/code 変更として `nix build .#yoi` が通る。 - prompt/resource/code 変更として `nix build .#yoi` が通る。

View File

@ -48,4 +48,13 @@ Marked ready by `yoi ticket state`.
Rescoped from broad Overview-first extract implementation to the worker implementation slice. This Ticket now implements an extract worker that runs with only the builtin:session-explore feature enabled, connected to an immutable conversation snapshot and filtered Overview projection. It depends on Ticket 00001KXNYXNM6 for the staging source anchor / evidence ref format. Rescoped from broad Overview-first extract implementation to the worker implementation slice. This Ticket now implements an extract worker that runs with only the builtin:session-explore feature enabled, connected to an immutable conversation snapshot and filtered Overview projection. It depends on Ticket 00001KXNYXNM6 for the staging source anchor / evidence ref format.
---
<!-- event: decision author: hare at: 2026-07-17T18:10:00Z -->
## Decision
Design updated: abandon the old batch `write_extracted` / `decisions` / `discussions` / `attempts` / `requests` staging direction. Extract now stages flat candidate records with `stage_candidate` and finishes with `finish_extraction`. The older dependency on 00001KXNYXNM6 is historical; the active schema dependency is 00001KXRM6G0G.
--- ---

View File

@ -0,0 +1,13 @@
{
"version": 1,
"relations": [
{
"ticket_id": "00001KXRM6G0G",
"kind": "related",
"target": "00001KXMK846H",
"note": "flat staging records are the consolidation decision units for later resolution/disposition.",
"author": "yoi ticket",
"at": "2026-07-17T18:10:00Z"
}
]
}

View File

@ -0,0 +1,76 @@
---
title: 'Flat candidate staging record schemaを実装する'
state: 'ready'
created_at: '2026-07-17T18:07:40Z'
updated_at: '2026-07-17T18:10:00Z'
assignee: null
---
## 背景
旧 staging は extract run ごとの batch payload (`decisions` / `discussions` / `attempts` / `requests`) と entry-level source refs を前提にしていた。しかし、consolidation から見ると batch は session に紐いた不必要な集団になり、record ごとの discard / merge / promote / defer が曖昧になる。
新方針では、extract は記憶化を検討すべき candidate を kind taxonomy に基づいて切り出し、candidate ごとに flat staging record を作る。
```text
1 extract run = 0..N staging records
1 staging record = 1 candidate = 1 consolidation decision unit
```
旧 batch schema との互換性は不要。clear responsibility と flat records を優先する。
関連:
- Objective `00001KVJSMQXZ`
- `.yoi/objectives/00001KVJSMQXZ/memory-architecture-overview.md`
- Ticket `00001KXMK7YMC` — session-explore feature付きextract workerを実装する
- Ticket `00001KXMK846H` — StagingからMemory化する審査・剪定フローを実装する
## 実装要件
- flat staging record schema を実装する。
- 1 file / record は 1 candidate のみを表す。
- candidate kind は次に限定する。
- `preference`
- `working_assumption`
- `constraint`
- `decision`
- `open_question`
- `lesson`
- record は少なくとも次を表現できる。
- `schema_version`
- `id`
- `extract_run_id`
- record-level `source`
- `kind`
- `claim`
- `why_useful`
- `staleness` / invalidation hint
- bounded `evidence[]`
- `source_refs[]`
- evidence は extract が選んだ bounded snippets のみを保持する。
- raw session log 全体や Overview 全体は保存しない。
- raw tool result 全文は保存しない。
- `source_refs` は evidence id / evidence kind / entry range など host-resolved anchor を保持する。
- extract run ごとの batch payload を staging record として保存しない。
- consolidation input は flat records を record ごとに列挙する。
- 旧 batch schema の読み込み互換は不要。
## 非目標
- `session-explore` feature / tools はこの Ticket では実装しない。
- `stage_candidate` / `finish_extraction` tool はこの Ticket では実装しない。
- staging resolution / disposition はこの Ticket では実装しない。
- Overview projection を staging に保存しない。
## 受け入れ条件
- flat candidate staging record を serialize / deserialize できる。
- 1 staging file が 1 candidate だけを表す。
- candidate kind が上記 taxonomy に制限されている。
- bounded evidence snippets と source refs を保持できる。
- raw session log / Overview 全体 / raw tool result 全文を schema が要求しない。
- consolidation input が flat records を candidate 単位で表示できる。
- relevant tests が追加または更新されている。
- `cargo test -p memory` または該当 crate の同等テストが通る。
- code 変更として `nix build .#yoi` が通る。

View File

@ -0,0 +1,16 @@
<!-- event: create author: "yoi ticket" at: 2026-07-17T18:07:40Z -->
## 作成
LocalTicketBackend によって作成されました。
---
<!-- event: decision author: hare at: 2026-07-17T18:10:00Z -->
## Decision
Created to replace the previous batch staging direction. This Ticket owns the new flat staging record schema: one candidate per staging record, with kinds `preference`, `working_assumption`, `constraint`, `decision`, `open_question`, and `lesson`.
---