extract: --source-id/--date/--tag — 昇格 runbook 規約の焼き込み(#466 S1, ADR 0017) - #513
Conversation
…he batch #466 S1 (ADR 0017): the promotion rehearsal's most mechanical step — rewriting each emitted batch's source to session:{agent}:{id} and hand-adding date/tags — becomes three flags. --source-id replaces the header source (verbatim for one document, ID/{stem} across several, collisions refused before any model call); --date (YYYY-MM-DD or epoch seconds) and --tag ride the passage line, so --no-passage alongside them is a usage error. All three are manifest computation inputs but deliberately not checkpoint inputs: a metadata change rewrites the batch while reusing every cached chunk answer, since none of them reaches the prompt. Claude-Session: https://claude.ai/code/session_01UPjzCLVuXQmxhGkr6phPb9
The local diff-scoped sweep (119 mutants — over CI's 60 budget, so
this run is the coverage) left 17 missed: boundary values for the tag
byte/count caps and the source-id name cap (exact-cap passes, one-over
fails, including the /{stem}-suffixed check only extract time can
trip), a duplicate --date, an empty --tag, parse_date's
malformed-shape guards, days_from_civil's negative-year era branch,
and the --source-id usage errors distinguishable only by wording.
Claude-Session: https://claude.ai/code/session_01UPjzCLVuXQmxhGkr6phPb9
…ndtrip-equivalent The chained condition's second || survived mutation to && because operator precedence turns the chain into a || (b && c), and every input that distinguishes it is rescued by the round-trip guard — an out-of-range month or day always renders as a different date. Separate early returns leave nothing for an operator mutant to bind to, and read better anyway. Claude-Session: https://claude.ai/code/session_01UPjzCLVuXQmxhGkr6phPb9
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough
Changesextract 実行時メタデータ
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as extract CLI
participant Run as Run
participant Renderer as render_batch
participant Manifest as Manifest
CLI->>Run: source_id、date、tags
Run->>Run: 実効 source ID を生成して衝突を検証
Run->>Renderer: 実効 source ID、date、tags
Renderer-->>Run: メタデータ付き batch
Run->>Manifest: source_id、date、tags を記録
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/extract/args.rs`:
- Around line 519-537: Update parse_date before the days_from_civil call to
validate year against the supported YYYY-MM-DD range, such as 1..=9999, and
return None when it falls outside that range. Preserve the existing month/day
validation and civil-date conversion for valid years.
In `@src/extract/tests.rs`:
- Around line 3814-3840: In the legacy manifest test around Manifest
serialization and deserialization, validate that each of the three replace
operations for source_id, date, and tags actually removed its field before
calling serde_json::from_str. Add assertions on the transformed JSON so the test
fails when any expected legacy-field removal no longer matches, while preserving
the existing reloaded.matches validation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5acbf3b4-1b05-4075-85d6-a66591d85938
📒 Files selected for processing (12)
CHANGELOG.mdadr/0017-runbook-metadata-at-extract-time.mddocs/extract.htmldocs/promotion.htmlsrc/clock.rssrc/extract.rssrc/extract/args.rssrc/extract/manifest.rssrc/extract/render.rssrc/extract/run.rssrc/extract/tests.rstests/http_api/extract.rs
…y-manifest strip An i64-scale year overflowed era * 146097 inside days_from_civil before the round-trip could refuse it — a panic on external input. 1..=9999 is the YYYY-MM-DD contract and keeps the arithmetic in-domain. The legacy-manifest test now asserts its string replaces actually removed the three fields, so a future field-order or serde change cannot silently turn it into a test of nothing. Claude-Session: https://claude.ai/code/session_01UPjzCLVuXQmxhGkr6phPb9
概要
#466 S1(再評価コメントの推奨分割 1)。リハーサルで「純粋に機械的で束ねる価値が最も高い」と記録した作業 — 生成バッチの
sourceをsession:{agent}:{id}へ手で書き換え、date・tagsを手で足す — を 3 つのフラグにする。これで extract は昇格用の import-ready バッチを直接出力し、runbook step 2 の手編集が消える。設計(ADR 0017)
--source-id ID: バッチヘッダの source を差し替え。単一文書は verbatim、複数文書は runbook の/{doc}規約どおりID/{file stem}を自動付与。stem 衝突は 2 件目をモデル呼び出し前にエラー(import の retract-then-apply は source id 単位 — 黙って畳まれる事故を先に止める)--date WHEN:YYYY-MM-DD(UTC 0時)または正の epoch 秒。実在しない日付(2026-02-30)は描画方向との roundtrip 不一致で拒否。--tag TAG(繰り返し・重複畳み込み・バイト/本数 cap は早期 usage error)--no-passageとの併用は usage error(associations-only source はメタデータを持てない — runbook 自身の警告をそのまま強制)serde(default)で旧 manifest は default run に一致し続ける)。ただしプロンプトに届かないので checkpoint には入れない — メタデータ変更時の書き直しは checkpoint 済みチャンク答案を再利用し、モデル呼び出しゼロ--context/--descriptionと同じ姿勢)Pre-PR Mutation Gate
diff スコープ 119 mutants で CI 予算(60)超過。else 分岐の module sweep は新規モジュール想定で、本 diff は既存 6 ファイルへの分散編集のため whole-file sweep は無関係な既存 mutants を大量に含む — 規定の意図(missed をローカルで解決してから PR)に沿い、diff スコープちょうどをローカル実行した:
/{stem}付与時のみ踏める run 側 cap 含む)、--date重複、空--tag、days_from_civilの負年 era 分岐、文言でしか区別できない usage error の統合アサーションparse_dateの第2||→&&は優先順位によりa || (b && c)となり、範囲違反はすべて roundtrip 検査に救済されるため機能的等価と判明 → 範囲チェックを独立 early-return 3 本に分解して変異面を除去(可読性も向上)テスト
parse_dateの両表記と拒否形状、render の passage 行(フラグなしはバイト同一)、manifest の書き換え条件と旧エントリ後方互換、days_from_civil逆変換ID/{stem}・date/tags)、同フラグ skip、date 変更で再抽出、単一文書 verbatim、stem 衝突、suffix 付き name cap 境界、usage error の文言cargo fmt/cargo clippyクリーン、全 3179 テスト通過残り(#466)
promotetool(graph 経路、LLM なし)/ S3(必要なら): CLI text 経路プリセット — issue の再評価コメント参照https://claude.ai/code/session_01UPjzCLVuXQmxhGkr6phPb9
Summary by CodeRabbit
taguru extractに--source-id、--date、繰り返し指定可能な--tagを追加しました。