fix: red-team round 3 hardening across desktop, mobile, core and server
Batch of red-team r3 fixes that were in the working tree before the 2026-09-28 design overhaul, committed as one unit with their tests. - desktop main: STT timeouts and sidecar, voice recording store, sync (credentials, audio, knowledge reindex, push gates), runtime provisioner, update policy, AltGr keybindings, voice-command policy, dictionary file codec/limits, meeting transcript condensing and a local recording ledger so interrupted-session recovery only closes meetings this device recorded (a phone's live meeting is left alone). - mobile: login CSRF via implicit token callbacks rejected, account deletion/retention, durable queue retention, knowledge realtime without unfiltered DELETE, meeting re-record failure paths, cloud STT client, preferences store/resync. - core: text chunking splits long unbroken transcripts to fit, template field policy, dictionary limits, meeting markdown inline handling. - server: payple webhook policy and cancellation order scope, meeting document generation quota, team RPC null-role guard, unified LLM quota in-flight accounting, knowledge chunk vector index, meeting re-record failure paths (migrations 20260929*). - ci: portable/runtime feed gates, update-policy schema, Forgejo file delete and alias planning. Four older tests are updated to the new contracts rather than the old behavior: token-pair auth callbacks are rejected, knowledge realtime no longer subscribes to DELETE, long transcript lines are split, and meeting recovery requires the local recording ledger for empty rows.
This commit is contained in:
parent
2428ede03d
commit
ba9ef9741e
161 changed files with 17056 additions and 2379 deletions
|
|
@ -77,6 +77,12 @@ const listeners = new Set<(event: DurableQueueEvent) => void>();
|
|||
const runningControllers = new Map<string, AbortController>();
|
||||
const runningItemPromises = new Map<string, Promise<AudioPipelineResult>>();
|
||||
const discardedItems = new Set<string>();
|
||||
/**
|
||||
* Owners whose session was lost while their items stay parked on the device.
|
||||
* Timer-driven passes skip them so a signed-out owner's retries are not spent
|
||||
* on certain auth failures; resumeQueuedAudioForUser (sign-in) lifts it.
|
||||
*/
|
||||
const suspendedUsers = new Set<string>();
|
||||
|
||||
function emit(event: DurableQueueEvent): void {
|
||||
for (const listener of listeners) listener(event);
|
||||
|
|
@ -458,11 +464,13 @@ export async function processQueuedAudioNow(
|
|||
* overwritten from a stale snapshot.
|
||||
*/
|
||||
async function runResumePass(userId: string): Promise<void> {
|
||||
if (suspendedUsers.has(userId)) return;
|
||||
const order = (await readQueue())
|
||||
.filter(item => item.userId === userId)
|
||||
.sort((left, right) => left.createdAtMs - right.createdAtMs)
|
||||
.map(item => item.id);
|
||||
for (const itemId of order) {
|
||||
if (suspendedUsers.has(userId)) return;
|
||||
const item = await repository.get(itemId);
|
||||
if (item === undefined || item.userId !== userId) continue;
|
||||
if (item.status === 'terminal') continue;
|
||||
|
|
@ -493,6 +501,7 @@ async function runResumePass(userId: string): Promise<void> {
|
|||
* pass after it, and the returned promise settles when that pass is done.
|
||||
*/
|
||||
export function resumeQueuedAudioForUser(userId: string): Promise<void> {
|
||||
suspendedUsers.delete(userId);
|
||||
return scheduler.requestRun(userId);
|
||||
}
|
||||
|
||||
|
|
@ -545,6 +554,28 @@ export async function clearQueuedAudioForUser(userId: string): Promise<void> {
|
|||
if (firstRemovalError !== null) throw firstRemovalError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Involuntary session loss: keeps every item of `ownerUserId` (files and
|
||||
* entries, whatever their status) and suspends its retries until that owner
|
||||
* signs back in; items of any other account are discarded as usual.
|
||||
*/
|
||||
export async function retainQueuedAudioOnlyForUser(ownerUserId: string): Promise<void> {
|
||||
suspendedUsers.add(ownerUserId);
|
||||
scheduler.cancel(ownerUserId);
|
||||
const otherUserIds = [...new Set((await readQueue())
|
||||
.map(item => item.userId)
|
||||
.filter(userId => userId !== ownerUserId))];
|
||||
let firstError: unknown = null;
|
||||
for (const userId of otherUserIds) {
|
||||
try {
|
||||
await clearQueuedAudioForUser(userId);
|
||||
} catch (error) {
|
||||
firstError ??= error;
|
||||
}
|
||||
}
|
||||
if (firstError !== null) throw firstError;
|
||||
}
|
||||
|
||||
export async function clearAllQueuedAudio(): Promise<void> {
|
||||
const userIds = [...new Set((await readQueue()).map(item => item.userId))];
|
||||
let firstError: unknown = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue