fix(deepwork): implement todaysAccum stub + tests#7
Merged
Conversation
todaysAccum は公開 export なのに throw する潜在欠陥だった(TODO v0.2)。当日(now のローカル日付)の span を startedAt 基準で絞り、min を合計して返す実装に。ymd を work_state.ts から export して重複を回避。テスト4件追加(除外/空/丸め/跨ぎ)。 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
todaysAccum()は公開 export なのにthrow new Error("not implemented")で、呼ぶと必ずクラッシュする潜在欠陥だった(TODO v0.2で実装意図は明記済み)。published npm CLI の公開 API に「呼ぶと落ちる」関数が残っている状態を解消する。何を
src/infer/deepwork.ts:todaysAccum(now, spans)を実装。nowのローカル日付に属す span(startedAt基準)だけを絞り、minを合計してMath.round、{date, totalMin, spans}を返す。src/infer/work_state.ts: privateymd()をexport化(重複実装を避け deepwork.ts から import)。tests/todays-accum.test.ts: 4 ケース新規(前日/翌日除外・空入力・端数丸め・真夜中跨ぎ)。設計判断
startedAtで判定: 開始日でその日に属すとみなす(跨ぎ span は開始日に全量計上)。シンプルで予測可能。按分は v0.3 のアクティブ入力モニタ導入時に再検討。ymdは work_state から共有: 日付整形を2箇所に複製せず単一実装に。循環依存なし(work_state は import を持たない一方向辺)。Math.round」でDeepWorkAccumulatorの慣習に合わせた。スコープ外
todaysAccumの呼び出し元への配線は未実施(現状この関数はライブラリとして未使用。実装+テストのみ)。利用箇所が必要になった時に別 PR で wiring。shouldWarnDailyCap(既存・未使用)は変更なし。検証方法
npm test: 33 pass / 0 fail(既存29+新規4)。tsc --noEmit: exit 0。依存
🤖 Generated with Claude Code