Skip to content

feat(task): persist task thinking effort on history items (DTE series 2/5) - #39

Closed
easonLiangWorldedtech wants to merge 1 commit into
feat/dte-v2-3-task-runtime-effortfrom
feat/dte-v2-4-effort-persistence
Closed

feat(task): persist task thinking effort on history items (DTE series 2/5)#39
easonLiangWorldedtech wants to merge 1 commit into
feat/dte-v2-3-task-runtime-effortfrom
feat/dte-v2-4-effort-persistence

Conversation

@easonLiangWorldedtech

@easonLiangWorldedtech easonLiangWorldedtech commented Sep 4, 2026

Copy link
Copy Markdown
Owner

≤400-line redo of Zoo-Code-Org#1338 — DTE series 2/5, unit 4/5

Persistence for the task-local thinking effort: the history-item schema
fields, taskMetadata propagation (key-presence contract), the Task
constructor restore, and the abort/dispose snapshot ordering. Also lands the
dispose boundary group split out of PR #38 per plan §2.6 — the task-end
override reset, its DTE JSDoc, and its test block.

Stack

Budget (plan §2: a+d ≤ 400)

5 files changed, 248 insertions(+), 5 deletions(-) = 253 ≤ 400

File a+d
src/core/task/Task.ts 36+/2−
src/core/task/__tests__/Task.runtime-thinking-effort.test.ts 111+/2−
src/core/task-persistence/__tests__/taskMetadata.spec.ts (new) 81+
src/core/task-persistence/taskMetadata.ts 13+/1−
packages/types/src/history.ts 7+/0−

Provenance / fidelity

  • 3-way git merge-file per file — base 90b47b053 (U3 tip, before the U4
    work), ours = U3 head, theirs = 77ec064d3 (U4 tip). Task.ts and
    taskMetadata.ts merged clean (0 conflicts). history.ts had 2 conflicts
    where main's newer pendingTaskAction schema met the DTE import/fields —
    resolved by keeping both (imports alphabetical, DTE block above the
    pendingAction field; result = 7+/0− over U3 head).
  • taskMetadata.spec.ts (new, 81 lines) is the byte-exact 77ec064d3
    version. The runtime-effort test is the byte-exact 77ec064d3 version
    (394 lines) plus the same 3 mutation-killing assertion lines that landed
    with U3 (PR feat(task): task-local runtime thinking effort state with per-request override (DTE series 2/5) #38) plus the 13-line constructor-restore killing test added by
    the mutation-diff fix below — 410 lines total; both carry no U5/U14 content.
  • Task.ts dispose boundary group (task-end reset + DTE JSDoc, 9 lines) and
    the 13-line describe("dispose") test block are the content PR feat(task): task-local runtime thinking effort state with per-request override (DTE series 2/5) #38 split
    out under plan §2.6; they land here with the persistence work, matching the
    plan's U4 scope ("persistence + boundary cases").
  • src/eslint-suppressions.json: untouched (no U4-owned count changes).

Out of scope (next unit)

  • U5 (DTE-2d): the Anthropic output_config.effort adaptive envelope.

Mutation-diff fix (killing test, plan L42 — same PR)

The first CI mutation-diff run (head ac085bbe6, base d0b1a3dcd)
reported 1 Survived ConditionalExpression mutant (replacement: true) on
the constructor restore guard if (historyItem.thinkingEffort)
(Task.ts L594). Mechanism note: Stryker v10's ConditionalExpression
mutator mutates if-tests (the ?: ternary branch is commented out in
the mutator source), so this is the guard's condition → true.

It survived because the redundant restore call it introduces,
setRuntimeThinkingEffort(undefined, undefined), hits the setter's
already-inactive early return and leaves no observable state change — the
existing "leaves the override inactive" it only asserts state. Fix (same
PR): a 13-line it("never calls the restore path when the history item has no persisted effort") with a vi.spyOn(Task.prototype, "setRuntimeThinkingEffort") call-count assertion — fails on the mutant,
passes on the real guard.

Local dev-stage gate on the amended head (§5.1):
node scripts/stryker-diff.mjs ci --base 4075c8a75 --head 111cf40ae
extension 22 changed lines, 10 ranges, exit 0, 0 Survived.

Verification (local)

  • pnpm --dir src exec eslint --prune-suppressions --max-warnings=0 on the four src files → exit 0, no count change
  • pnpm check-types → 11/11 projects
  • pnpm --dir src exec vitest run core/task/__tests__/Task.runtime-thinking-effort.test.ts → 16/16 (3.81 s); core/task-persistence/__tests__/taskMetadata.spec.ts → 3/3 (unchanged by this amend)
  • git diff --shortstat 4075c8a75 HEAD → 248+/5− = 253 ≤ 400 (the 3 shared killing-assertion lines already sit in the U3 base and do not appear in this diff)
  • mutation-diff gate (dev stage, §5.1) on the amended head → exit 0, 0 Survived (see fix above)

@easonLiangWorldedtech
easonLiangWorldedtech force-pushed the feat/dte-v2-3-task-runtime-effort branch from d0b1a3d to 4075c8a Compare September 4, 2026 07:42
… 2/5)

- historyItemSchema: optional thinkingEffort/thinkingEffortSource
- taskMetadata: carries both keys (always present, even while undefined)
  so clearing the override propagates through the TaskHistoryStore merge
- Task: constructor restore via setRuntimeThinkingEffort; saveClineMessages
  writes the active effort; abortTask snapshots the effort before dispose()
  clears it
- dispose: task-end override reset + DTE JSDoc (boundary group split out of
  the DTE 2b PR per plan 2.6)
- spec: taskMetadata key-presence contract + history round-trip / abort
  snapshot cases

Part of #35 (DTE-v2 ship plan, unit 4/5).
@easonLiangWorldedtech

Copy link
Copy Markdown
Owner Author

Superseded — U4 will be opened on upstream (Zoo-Code-Org/Zoo-Code) when its stack slot opens (max 3 open DTE-v2 PRs, ship plan 2.2). Head 111cf40 unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants