Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/104.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Research retries resume every saved action after interruptions, keep the first plan during overlapping attempts, and reject requests with conflicting identities.
16 changes: 12 additions & 4 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Owns `server/src/matcher.ts`, `server/src/llm.ts`, `server/src/planner.ts`, `ser
- `llm.ts`: `LlmClient` tag, `LlmLive: Layer<LlmClient, ConfigError>`, `fixtureLlm(responses)` for tests; missing keys fail with `Unavailable`.
- `extraction.ts`: `extractCandidates(input: { meeting: Meeting; segments: ReadonlyArray<TranscriptSegment>; snapshot: ReadonlyArray<ContextItem>; known?: ReadonlyArray<Pick<ContextItem, 'kind' | 'text'>>; epochs?: ReadonlyArray<EpochAnchor> }): Effect<ReadonlyArray<ExtractionCandidate>, Unavailable, LlmClient>`; `snapshot` is the caller's relevant items (context's `relevantItems`), fitted to a 4,000-character prompt budget; `known` is every current item's kind and text (context's `meetingItemTexts`), so a repeat of any current item is rejected; fails `Unavailable` when a segment's epoch has no anchor (pass `capture_epochs` anchors).
- `extraction.ts`: `summarizeMeeting(input: Omit<ExtractionInput, 'snapshot'>): Effect<MeetingNotes, Unavailable, LlmClient>`, the one canonical summary for notes, email sections and exports; it summarizes the transcript in windows of 120 lines (3 requests at once) and, for more than one window, writes the title and summary from the window summaries, so output per request stays below `modelRequest.maxOutputTokens` for any meeting length.
- `planner.ts`: `planWork(access, input: { meeting_id; request: string; actions: ReadonlyArray<GetIntegrationActionOutput>; research?: { text: string; sources; planned: ReadonlyArray<RequestActionInput>; job_id: string } }): Effect<{ web_research: boolean; actions: ReadonlyArray<RequestActionInput>; rejected?: string }, Unavailable | Forbidden, LlmClient>`; offers only inspected actions whose missing fields it can fill and never the `app` field; `rejected` names each dropped proposal and why; a plan that asks for web research may leave required content fields for the second pass; with `research`, research may change only content fields of the planned actions, each keeps its planned title and gets an idempotency key from `job_id`, its non-content arguments and its position among planned actions with the same ones, and any other change returns `rejected` with no actions. `runResearch` reports a key conflict on such a key as `already_requested` with the earlier attempt's action ID and state.
- `planner.ts`: `planWork(access, input: { meeting_id; request: string; actions: ReadonlyArray<GetIntegrationActionOutput>; research?: { text: string; sources; planned: ReadonlyArray<RequestActionInput>; job_id: string } }): Effect<{ web_research: boolean; actions: ReadonlyArray<RequestActionInput>; rejected?: string }, Unavailable | Forbidden, LlmClient>`; offers only inspected actions whose missing fields it can fill and never the `app` field; `rejected` names each dropped proposal and why; a plan that asks for web research may leave required content fields for the second pass; with `research`, research may change only content fields of the planned actions, each keeps its planned title and gets an idempotency key from `job_id`, its non-content arguments and its position among planned actions with the same ones, and any other change returns `rejected` with no actions. See [actions](#actions-t18-t19-recovery-t20) for retry and receipt rules.
- `llm.ts`: `research(prompt, admit?, record?)` sends one hosted web-search request (OpenAI Responses `web_search` by default) after `admit(model)` succeeds, never retries it in-process, and passes the provider-reported usage to `record`, also when a billed call then fails.
- `planner.ts`: `respondToRequest(input: { request: string; context: ContextSnapshot }): Stream<string, Unavailable, LlmClient>` for requested speech.
- `matcher.ts`: `rankMatches(access, query: { profile_id; kind: 'needs' | 'offers'; top_k: number }): Effect<ReadonlyArray<{ profile_id: ProfileId; score: number }>, NotFound, R>`.
Expand Down Expand Up @@ -188,12 +188,20 @@ Owns `server/src/actions.ts`, `server/src/executor.ts`, `server/src/research.ts`
- Replies read the requester's context for the listener's open meeting; a device credential without `context:read` gets no reply, never a guess.
- Results over the Pipedream output budget are stored as `action_output` artifacts and referenced by `provider_receipt.artifact_id`.
- `research.run` (`executor.ts` with `research.ts`): finds the requester's granted actions among the `searchIntegrationActions` matches for the request in each granted app (one search per app, so other usable apps cannot crowd them out), inspects each with its grant's account, lets `planWork` decide on web research and fill in actions, researches first, then requests each planned action through `requestAction`, which writes the job ID to `actions.research_job_id` with the action.
A retried job that finds actions with its ID does not plan again; it reports them as `already_requested` with the research it stored.
Before requesting the first action, it saves every planned request, including its idempotency key, in `jobs.payload.planned_requests`.
It saves the offered actions, research references, and reasons for no actions in `jobs.payload.research_result` in the same update, including empty plans.
Retries and overlapping attempts use the first saved plan and its result metadata, request each missing action, and report every planned action.
Retries call the shared `requestAction` gateway to check request identity before reporting an existing action as `already_requested`, without submitting it again.
A reused key with a different request produces an action result with `refused: 'HashConflict'`, not the earlier action.
Recovery reads action records before checking for a saved plan, so a concurrent plan takes precedence over the action-only fallback.
If an older job has action records but no saved plan, the retry reports those records without planning again.
Unstored requests cannot be recovered.
A retried job with stored research but no requested actions uses that research without another paid call, even when its new plan declines web research.
When research is available and actions are planned, `planWork` runs again over only those actions, with cited research in a delimited untrusted block.
Research may fill only content fields (subject, body, notes and the like).
A pass that changes another argument, adds an action or drops one is rejected; no action is requested.
Refused research also requests no action; both cases appear as the `outcome` of a succeeded job.
A pass that changes another argument, adds an action or drops one is rejected.
Rejected passes and refused research produce empty candidate plans, with reasons in `research` or `outcome`.
These candidates cannot replace an earlier saved plan.
Web research reserves one of the workspace's `SANCTUM_PAID_RESEARCH_CALLS_PER_DAY` and the install's `SANCTUM_PAID_RESEARCH_CALLS_PER_DAY_TOTAL` paid calls in `paid_model_calls` before sending, records the provider's token usage (also for a billed call that ends incomplete), stores a `research` artifact once per job, and adds an `external` `research_observation` citing it; a spent allowance is a `refused` result, a rate limit pauses the job, a dropped proposal is reported in `dropped` with its reason, and nothing to do is a reported `outcome`.
- Known ASR timing limit: delayed finals across lane rotation can split a request prematurely or be ignored during an active reply.
Sorting only restores segments collected before turn completion; the authorized follow-up is [#96](https://github.com/i098/sanctum/issues/96).
Expand Down
2 changes: 1 addition & 1 deletion docs/release-evidence.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Model evidence includes the public speech baseline below and small synthetic com
| MySQL schema | Pass | `server/tests/migrations.test.ts`, `db.test.ts` (UTC microseconds, BIGINT, JSON, Unicode, composite ownership keys), `semantic-matching.test.ts`, `jobs.test.ts` (SKIP LOCKED claims, fencing). |
| Isolation | Pass | `server/tests/authorization.test.ts`, `capabilities.test.ts` (notes, exports, matching across workspaces), `mcp.test.ts` (tenants), `context.test.ts` (search, caches after revocation), `playback-access.test.ts`, `pipedream.test.ts` (account selection). |
| Agent writes | Pass | `server/tests/context.test.ts` (one of two same-revision writers wins with 409, idempotent retry), `api-contract.test.ts` and `mcp.test.ts` (shared revisions across SDK and MCP). |
| Actions | Pass | `server/tests/actions.test.ts`, `worker-recovery.test.ts`: expired/revoked/mismatched grants block, ambiguous timeouts become `unknown` and are never replayed, duplicate requests deduplicate, over-budget results stored as artifacts. `server/tests/research.test.ts`: `research.run` offers only inspected, granted actions and submits them through the gateway, searches each granted app on its own so five other usable apps cannot crowd a granted action out, a retried job never resubmits an `unknown` write, a retried job that stored its research does not pay for it again, a retried job whose earlier attempt requested an action reports that action and plans nothing again whatever the planner answers, web research returns cited sources and records usage, a spent per-workspace or install-wide daily allowance refuses the next paid call, an email planned with research is filled from the cited research and carries its fact and source, a research page that asks for another recipient changes no recipient and adds no action, refused research requests no action, a requester who lost write access to the meeting gets no research, a dropped proposal is reported with its reason, and nothing to do is a reported outcome; `llm.test.ts`: an incomplete paid research answer still records its usage; `planner.test.ts`: two research-pass emails to one recipient keep distinct keys. No real external write was sent. |
| Actions | Prior pass; new cases unverified here | `server/tests/actions.test.ts`, `worker-recovery.test.ts`: expired/revoked/mismatched grants block, ambiguous timeouts become `unknown` and are never replayed, duplicate requests deduplicate, over-budget results stored as artifacts. `server/tests/research.test.ts`: `research.run` offers only inspected, granted actions and submits them through the gateway, searches each granted app on its own so five other usable apps cannot crowd a granted action out, a retried job never resubmits an `unknown` write, a retried job that stored its research does not pay for it again, web research returns cited sources and records usage, a spent per-workspace or install-wide daily allowance refuses the next paid call, an email planned with research is filled from the cited research and carries its fact and source, a research page that asks for another recipient changes no recipient and adds no action, refused research requests no action, a requester who lost write access to the meeting gets no research, a dropped proposal is reported with its reason, and nothing to do is a reported outcome; `llm.test.ts`: an incomplete paid research answer still records its usage; `planner.test.ts`: two research-pass emails to one recipient keep distinct keys. Added cases cover the [actions recovery contract](ARCHITECTURE.md#actions-t18-t19-recovery-t20): interruption between action commits, a plan saved during the action-history read, and overlapping attempts. The overlapping cases include different recipients, empty plans, refused research, rejected synthesis, and a saved empty plan. Account-switch cases assert `HashConflict` on new and saved runs. These added cases were not run in this documentation phase. No real external write was sent. |
| UI | Pass | `web-app/e2e/listen-visual.spec.ts` (1280×720 against the reference, narrow laptop), `listen-waveform.spec.ts` (real audio, reduced motion, hidden page, interruption), `listen-rails.spec.ts` (final transcript lines and action receipts arriving in the side rails), `listen-overlays.spec.ts` (focus and keyboard), `review-notes.spec.ts`. Review: `review-tabs.spec.ts` (all six tabs over fixture responses; per-source loading, empty, forbidden and unavailable states; decision or note source to transcript segment to a seek in the signed recording) and `review-server.spec.ts` (the same path against the real API server and a seeded MySQL database over a real browser session, so the recording-access POST needs the CSRF header, playing the assembled cut at the saved-sample offset past a gap); `web-app/tests/review-data.test.ts` (paging, per-source failures, sample-to-playback mapping). First-run welcome: `listen-welcome.spec.ts` (opens for a new signed-in person; Skip and Start listening store it as done and it stays closed after a reload; Settings opens it again; every step by keyboard with focus on each step's heading; rename for owners and admins, none for members; hosted Invite teammates and Set up team; the level meter moves with Chromium's fake microphone), `team-csp.spec.ts` (Skip against the real server with the CSRF header) and `server/tests/onboarding.test.ts` (completion per principal, idempotent; rename only with `workspace:admin`, trimmed, 1–200 characters). |
| Performance | Unrun (parity) | Matched harness: the benchmark-only Rust reference (`benchmarks/rust`) and `scripts/benchmark-compare.ts`. One uncontrolled-host run of all five workloads in both implementations with source and fixture hashes: [benchmarks/README.md](../benchmarks/README.md). Fixture hashes and the MySQL end state matched, no operation failed, `pcm_ingest` saturation was swept, and a 300 s long run stayed within its RSS bound. The host is a shared, loaded VM and the reference hardware is unverified, so parity is neither claimed nor refuted; MySQL concurrency and saturation sweeps are unrun. |
| Effect lifecycle | Pass, one gap | `jobs.test.ts` and `worker-recovery.test.ts` (lease loss interrupts handlers, killed workers recover, accepted work survives the API), `api-contract.test.ts` and `mcp.test.ts` (client abort cancels the server handler), `ingest.test.ts` (sockets). Pool exhaustion is not tested separately. |
Expand Down
Loading
Loading