From 4fd7891b65e883abad95c3fb1184d025e24b7bbc Mon Sep 17 00:00:00 2001 From: Ambisphaeric <270742616+Ambisphaeric@users.noreply.github.com> Date: Fri, 17 Jul 2026 20:14:32 -0400 Subject: [PATCH] feat(capture): flag-authoritative extraction + time-aware to-dos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two QA defects and the #179 opener. 1. Flag tangle. The workflow executor gated moments/index on BOTH the flag AND the presence of a drain step, so a document without a moments/index step silently disabled the Settings toggle under workflow.enabled — the headline QA case (flags ON, empty Moments/Relevant-now). Make the flags AUTHORITATIVE: a present step may re-bind its gate (documents stay meaningful as data), but its ABSENCE falls back to the flag, exactly as the legacy direct drain does. distill.fields is already immune — it rides the shared distillThrottled seam, gated by its flag directly, not a step. 2. First-person extraction. The extract-moments template defined a commitment as "someone promised to do something"; small models returned [] for "I need to…/I'll…". The commitment kind now explicitly includes first-person intent, keeping the 4 shipped kinds and the strict-JSON invent-nothing rule. 3. Deadlines (#179 opener). Add optional TodoItem.due (validated absolute time) + a dueSource provenance marker. task-extract gets a {{now}} anchor and requests an optional ISO due; the engine validates post-hoc (parseable ISO, within a -60s..+60d horizon; invalid dropped, item kept) and falls back to a deterministic "in N minutes/hours/days" resolver (digits + number words) over the item text so the flagship "in eighteen minutes" works on weak models. todos surface renders due as an honest, unselectable "due 3:29p" decoration. Closes #244 · Refs #179 --- .../surfaces/blocks/selection-hygiene.test.ts | 5 +- apps/client/src/surfaces/blocks/todos.test.ts | 22 +++ apps/client/src/surfaces/blocks/todos.ts | 17 ++- apps/client/src/surfaces/hud/styles.ts | 2 + apps/engine/src/act/defaults.ts | 8 +- apps/engine/src/act/due.test.ts | 71 ++++++++++ apps/engine/src/act/due.ts | 127 ++++++++++++++++++ apps/engine/src/act/todo.test.ts | 50 +++++++ apps/engine/src/act/todo.ts | 31 ++++- apps/engine/src/api/http.test.ts | 78 +++++++++-- apps/engine/src/distill/defaults.ts | 4 +- apps/engine/src/distill/moments.test.ts | 13 ++ apps/engine/src/workflow/executor.test.ts | 42 ++++++ apps/engine/src/workflow/executor.ts | 12 +- .../examples/promptTemplate.extract.json | 2 +- shared/contracts/schemas/TodoItem.json | 17 +++ shared/contracts/schemas/TodoList.json | 17 +++ shared/contracts/schemas/TodoProvenance.json | 12 ++ shared/contracts/src/config/todo.ts | 16 +++ 19 files changed, 528 insertions(+), 18 deletions(-) create mode 100644 apps/engine/src/act/due.test.ts create mode 100644 apps/engine/src/act/due.ts diff --git a/apps/client/src/surfaces/blocks/selection-hygiene.test.ts b/apps/client/src/surfaces/blocks/selection-hygiene.test.ts index 816ce372..068ff5f9 100644 --- a/apps/client/src/surfaces/blocks/selection-hygiene.test.ts +++ b/apps/client/src/surfaces/blocks/selection-hygiene.test.ts @@ -85,7 +85,8 @@ const rel: RelevantEntity = { entity: linkEntity, score: 1, moments: [] } const relNode = render(relBlock, [rel]) const todoBlock: Block = { block: 'todos', show: 'always', query: { source: 'todos', params: { session: 'current' } }, actions: copyAction } -const todo: TodoItem = { id: 't1', text: 'Send Dana the signed MSA', createdAt: '2026-07-16T14:40:00Z', provenance: { sessionId: 'ses', distillateId: 'dst-9' } } +// Carries a due so the deadline decoration ("due 3:29p") is in the row — it must NOT ride into a selection. +const todo: TodoItem = { id: 't1', text: 'Send Dana the signed MSA', due: '2026-07-16T15:29:00Z', createdAt: '2026-07-16T14:40:00Z', provenance: { sessionId: 'ses', distillateId: 'dst-9', dueSource: 'model' } } const todoNode = render(todoBlock, [todo]) const distBlock: Block = { block: 'distillates', show: 'always', query: { source: 'distillates', params: {} }, actions: copyAction } @@ -117,7 +118,7 @@ test('a native selection of a distillates (transcript) row keeps the bare value test('the classes this test relies on are non-selectable in the ACTUAL stylesheet (by-construction guard)', () => { // Derived from styles.ts / panel-styles.ts, not hardcoded — removing any of these rules fails BOTH this // assertion and the equality tests above (the decoration text would leak into selectableText). - for (const cls of ['why', 'ext', 'mk', 'glbl', 'go', 'dot', 't', 'unans', 'in-cites', 'in-who']) { + for (const cls of ['why', 'ext', 'due', 'mk', 'glbl', 'go', 'dot', 't', 'unans', 'in-cites', 'in-who']) { assert.ok(suppressed.has(cls), `.${cls} must be non-selectable`) } }) diff --git a/apps/client/src/surfaces/blocks/todos.test.ts b/apps/client/src/surfaces/blocks/todos.test.ts index dd783ac1..7461fc09 100644 --- a/apps/client/src/surfaces/blocks/todos.test.ts +++ b/apps/client/src/surfaces/blocks/todos.test.ts @@ -4,6 +4,9 @@ import type { QueryResult, Surface, TodoItem } from '@openinfo/contracts' import { renderSurface, renderToHtml, type NowContext } from '../block-renderer/index.js' import { defaultBlockRegistry } from './index.js' +// clockLabel renders viewer-local; pin this process to UTC so the due-time assertion below is host-stable. +process.env.TZ = 'UTC' + const now: NowContext = { live: true, workspace: 'acme', title: 'Renewal — security review' } const result = (items: unknown[]): QueryResult => ({ source: 'todos', items, truncated: false }) @@ -62,6 +65,25 @@ test('the todos block renders STORE-DERIVED items: text, done status and a prove assert.match(html, /