Commit Graph

461 Commits

Author SHA1 Message Date
Peter Steinberger 2ebd80cc96 fix: speech-only supplements silently complete agent replies (#126925)
* fix: keep supplemental speech from settling agent replies

* fix: tolerate malformed supplemental reply media
2026-08-20 18:48:44 -07:00
Vito Cappello 46ed76e5e2 fix: unblock replies after recovery owner release conflict (#126507)
* fix: unblock replies after recovery owner release conflict

* fix(diagnostics): keep an unreclaimed active run as an observed skip

Removing the noop outcome left recoverStuckDiagnosticSession able to fall off
the end of its try block when an active run neither aborted nor released,
returning undefined from a Promise<StuckSessionRecoveryOutcome> (tsgo TS2366).
Report that residual path as skipped/active_embedded_run so the watchdog never
clears diagnostic state for work that still owns its session.

* fix(sessions): compare persisted row bytes in session-entry replacement CAS

The replacement projection snapshotted entries with the status/store readers
(no participant projection) and revalidated inside the transaction with
readExactSessionEntryRow, which merges session_participants into the entry.
Any row with a participant that is not its owner therefore serialized
differently on the two sides, so the compare-and-swap threw "SQLite session
entry changed before replacement" on every attempt with no concurrent write
at all. Startup orphan marking selects by status, so such a session could
never be repaired: it stayed status=running across restarts, its rotated
session id never persisted, and every later turn failed with "changed while
starting work", retried by the ingress spool for 24h.

Compare the persisted entry_json bytes on both sides, the same raw-bytes CAS
the sibling lifecycle and projection paths already use, so separately mutable
decorations (participants today, owner columns next) cannot invalidate a
logical-session write. Renames the raw reader to readExactSessionEntryJson
now that it is the general CAS reader rather than repair-only, and aligns
shouldRemoveSessionEntry with the participants-excluding equality its own
callers already use.

* fix(sessions): fail closed when a selected replacement row has no persisted bytes

The raw-bytes CAS could not distinguish "row unchanged" from "row gone". If a
selected row was deleted between hydrating the snapshot entry and reading its
persisted bytes, both the snapshot and the transaction read undefined, the
compare agreed, the transaction's source map stayed empty, and the stale
replacement was written back into the deleted key.

A selected key must hold bytes, so treat a missing snapshot read as the
conflict it is. Reported by ClawSweeper on the previous head.

---------

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
2026-08-20 08:02:20 -07:00
Peter Steinberger 465043ca85 fix(acp): prevent lost prompts and preserve conversation bindings (#126657)
* fix(acp): enforce prompt and binding ownership

* test(acp): align execution-start boundary

* perf(startup): avoid broad ACP core import

* fix(acp): order prompt replacement admission
2026-08-20 07:03:11 -07:00
Peter Steinberger c4c9f6d464 fix(logging): report unavailable log tails (#126481)
Only missing-path metadata failures remain empty successes. Operational filesystem errors now reach existing Gateway, UI, CLI, channel, and diagnostics error paths.\n\nCloses #126467
2026-08-19 17:00:06 -07:00
Peter Steinberger 9814b14c90 test: trim residual exact-subset assertions (#126293) 2026-08-19 03:41:20 -07:00
Peter Steinberger 2456c77459 improve(gateway): avoid repeated logging and delivery scans (#126147)
* perf(gateway): remove repeated logging and delivery scans

Exact session-delivery retries no longer scan the full queue. Logging and diagnostics reuse lifecycle-owned settings and listener interest so uninterested projections are skipped, while outbound WebSocket summaries are built only after recipient admission.

* fix(infra): break diagnostic listener import cycle

Keep event-type validation at the diagnostic dispatcher while the process-wide listener presence counter remains a leaf module.

* test(cli): use logging override owner

Exercise late one-shot JSON diagnostics through the canonical logger override setter so lifecycle-cached console settings are invalidated as they are in production.

* test(auth): use logging override owner

Configure the locked-update warning test through the canonical logger override setter so lifecycle-cached console settings are invalidated before assertion.

* test(gateway): normalize redacted media fixture

Compare durable inbound media facts against the public redaction contract so random identifiers that resemble sensitive text do not make the Gateway suite flaky.
2026-08-18 22:13:22 -07:00
Peter Steinberger f59392fdf5 fix(channels): redact logs and reject unknown filters (#125939)
* fix(channels): redact and validate log filters

* fix(logging): preserve filtered redacted channel tails

* fix(channels): match log filters on exact boundaries

* fix(logging): honor redaction off mode
2026-08-18 13:37:17 -07:00
Peter Steinberger 5028ce87b0 fix(code-mode): show the final tool surface in debug logs (#124934)
* fix(code-mode): isolate and harden diagnostics

Amp-Thread-ID: https://ampcode.com/threads/T-01a00b7c-b9f0-73d5-8fb7-e619e8e458e1

* fix(code-mode): share payload diagnostics across wrappers

Amp-Thread-ID: https://ampcode.com/threads/T-01a00b7c-b9f0-73d5-8fb7-e619e8e458e1

* fix(code-mode): preserve transport debug behavior

* refactor(code-mode): simplify tool observer carrier

* refactor(code-mode): keep spread-safe observer metadata

* test(qa-lab): allow elapsed cron wait budget

* docs(code-mode): preserve transport debug contract

---------

Co-authored-by: Amp <amp@ampcode.com>
2026-08-17 17:32:14 -07:00
Peter Steinberger dd707b02b4 fix: scale Gateway RSS diagnostics to runtime limits (#124914)
* fix(logging): scale RSS pressure to runtime limits

Derive Gateway RSS warning and critical thresholds from the smaller of the effective V8 heap and OS process limit. This preserves heap and rapid-growth pressure detection while avoiding routine false alerts on large heaps.

* test(logging): narrow optional heap fixture

* fix(logging): bound process memory sentinels

* test(logging): pin Bun physical memory fixture
2026-08-16 19:11:47 -07:00
Josh Avant c1d3b33aa7 fix: honor provider timeouts during stuck-session recovery (#123877)
* fix(diagnostics): respect active model request timeouts

* chore(diagnostics): keep recovery activity internal

* test(diagnostics): await stream wrapper results

* fix(diagnostics): harden provider timeout recovery

* fix(diagnostics): track compaction model calls

* test: prove provider timeout recovery boundary
2026-08-16 18:18:29 -07:00
Peter Steinberger 568b920b21 feat(lint): enforce import ordering and deduplication (#124730)
* refactor(imports): dedupe and hoist imports

* feat(lint): enforce import/no-duplicates and import/first
2026-08-16 11:44:52 -07:00
Peter Steinberger f4871eb86b refactor(types): remove chained assertions in runtime boundaries (#124082) 2026-08-15 01:03:26 -07:00
Peter Steinberger 34efe370b2 test(core): trim duplicate strict-subset assertions (#124090) 2026-08-15 00:52:34 -07:00
Peter Steinberger d29a25e987 fix(logging): stop double-writing root log records (#123936) 2026-08-14 19:54:39 -07:00
Peter Steinberger d60a98ec87 fix(diagnostics): suppress startup-only heartbeat delay warnings (#123461)
* fix(diagnostics): suppress startup heartbeat delay warning

* chore: leave release changelog generation to release tooling
2026-08-13 21:42:11 -07:00
Peter Steinberger cb8e08f536 fix(logs): report line-limit truncation (#123358) 2026-08-13 16:57:26 -07:00
licheer-zte f24e164f69 fix(recovery): reclaim proven-stale reply-only ownership with zero queued backlog (#122265)
* fix(recovery): reclaim proven-stale reply-only ownership with zero queued backlog

Stuck-session recovery kept reply-only ownership forever when the queued
backlog was empty: isActiveRunProgressStale short-circuits to false at
queueDepth 0, so stale active_reply_work was never reclaimed even after
the durable session became killed. Evaluate staleness for reply-only
ownership without the queue gate (the gate stays for run-handle paths),
so proven-stale reply work expires through the existing abort-and-drain
owner path while global-lane and deferred-maintenance exemptions and
live reply work with recent progress are preserved.

Closes #122227

* fix(recovery): keep maintenance phases out of zero-backlog stale reclaim

The zero-backlog reclaim path (requireQueueBacklog: false) applied to
every reply-only operation, including preflight_compacting and
memory_flushing. Those phases are explicitly recognized as compaction
and may honor a configured timeout above the stale threshold, so a valid
long-running maintenance operation could be force-cleared early.

Restore the queue-backlog guard for the maintenance phases so an
unqueued compaction or memory flush is never reclaimed by this path;
ordinary reply-only ownership keeps the zero-backlog expiry. Adds
regressions for both maintenance phases.
2026-08-12 17:42:48 -07:00
Peter Steinberger dceb2c343c refactor: retire due compat-ledger surfaces (context-engine host params, deactivate alias, logging internals) (#121845)
* refactor(plugins): retire deactivate hook alias

* refactor(plugin-sdk): prune retired facade exports

* test(logging): isolate logger test controls

* refactor(logging): internalize file transport controls

* test(plugin-sdk): preserve retired facade coverage

* test(auto-reply): remove stale diagnostic imports

* refactor(logging): delete dead config-read guard

shouldSkipMutatingLoggingConfigRead had no production caller even on main;
it survived the dead-export scan only via logger's testApi re-export. The
test-isolation commit removed that mask, exposing the fossil. Delete the
guard, its test-only re-export, its mock entry, and its dedicated test file.

* refactor(plugin-sdk): retire due compatibility subpaths

* test(plugin-sdk): type group policy predicates

* refactor(plugin-sdk): split removed subpath records

* refactor(secrets): remove retired collector barrel

* test(plugin-sdk): tighten wildcard surface pin

* refactor(plugin-sdk): retire matrix facade metadata

* style(plugin-sdk): format facade metadata

* fix(ci): load channel setup contracts from source

Repair the main-owned regression from 99d662473c (Peter Steinberger): the new env-contract test could consume stale ignored dist metadata instead of the checked-in plugin declaration.

* test(plugin-sdk): refresh API baseline after rebase
2026-08-12 12:41:27 -07:00
wanyongstar d52a8b3475 fix(logging): parse diagnostics.stability limit/sinceSeq as strict decimal (#120446)
* fix(logging): parse diagnostics.stability limit/sinceSeq as strict decimal

normalizeDiagnosticStabilityQuery is the only input boundary of the
diagnostics.stability gateway method (no protocol schema), and its
string branch used Number(): "0x10", "1e3", " 5 ", "+42" were
silently coerced instead of rejected, so malformed clients could
filter snapshots by unintended seq values. String params now require
strict decimal digits, matching the boundary's fail-closed contract.

* fix(logging): reject unsafe integers for numeric stability query inputs

Replace Number.isInteger with parseStrictNonNegativeInteger for the numeric path so MAX_SAFE_INTEGER + 1 (and larger) is rejected uniformly across string and number inputs. Add test cases for MAX_SAFE_INTEGER (accepted) and MAX_SAFE_INTEGER + 1 (rejected) for both limit and sinceSeq.

* fix(logging): use normalization-core parser import

---------

Co-authored-by: Altay <altay@hey.com>
2026-08-12 20:31:06 +03:00
Peter Steinberger c23d66e3b5 refactor: consolidate coercion ownership (#122692)
* refactor: consolidate coercion ownership

* test: align shard check with weighted planning

* chore: refresh plugin SDK API baseline
2026-08-12 09:25:28 -07:00
Peter Steinberger b080dd1e76 refactor: consolidate coercion contracts (#122458)
* refactor: consolidate coercion contracts

Centralize exact string, record, numeric, date, Boolean, argument, and structured-error coercions while preserving call-site semantics.

Migrate canonical-name collisions and deprecated internal SDK bypasses, deleting 55 net production/tooling lines. Expand declaration ownership enforcement to 101 allowed helpers and add a narrow export-completeness audit.

* fix: preserve standalone script coercions

Keep copied Control UI tooling self-contained and retain the trusted release harness module-relative source seam when the harness runs against an old target cwd.
2026-08-11 23:26:37 -07:00
Peter Steinberger 964c8c84c1 refactor: consolidate coercion ownership (#122299)
* refactor: consolidate coercion ownership

Centralize four canonical coercion helpers, migrate exact core and plugin duplicates through narrow Plugin SDK facades, and enforce declaration and plugin-normalization ownership boundaries.

The sweep adds eight focused SDK exports while deleting more production and tooling code than it adds. User-visible behavior is unchanged except for safer equivalent object and UI parsing at existing boundaries.

* fix: guard integer option ownership

Register resolveIntegerOption with the canonical function owner and extend the declaration-guard fixture so future local duplicates fail validation.

* fix: keep integer helpers on numeric facade

Remove the unshipped duplicate string-coerce exports and route every affected plugin consumer through the existing number-runtime contract.

* fix: point numeric coercion to number runtime

Make boundary and declaration diagnostics recommend the canonical numeric facade, with failing-before coverage for both guidance paths.
2026-08-11 17:14:53 -07:00
wangmiao0668000666 9dc5a9a152 fix(logging): publish diagnostics ZIP through staged atomic overwrite (#122130)
* fix(logging): publish diagnostics ZIP through staged atomic overwrite

A named support export wrote the in-memory ZIP buffer straight to the
final path, so a failed or interrupted overwrite truncated the previous
archive, and an existing file kept its pre-existing (potentially
permissive) mode since writeFile only applies mode on creation.

Route publication through writeExternalFileWithinRoot's sibling staging:
the new archive is written to a private sibling, fsynced, and atomically
renamed over the final path. A failed publication leaves the previous
ZIP untouched with no staging residue, and the rename always installs
the staged file's 0o600 mode. The command now returns the actual
published path.

Fixes #122064

* test(logging): prove failed zip replacement stays atomic

* test(sqlite): create private reliability fixture

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-08-11 14:12:39 -07:00
Peter Steinberger 3d76246792 refactor: eliminate final export name collisions (#122083)
* refactor: resolve final export name collisions

* refactor: update remaining collision rename consumers

* style: format rebased auth helpers

* test: update remaining session entry mocks

* test: update remaining runtime mock exports

* test: update delivery info path mock

* refactor: reconcile combined collision sweeps

* chore: regenerate collision and sdk baselines
2026-08-11 11:18:24 -07:00
Peter Steinberger db73b59c04 refactor: burn wrapper shadowing baseline entries (#122040)
* refactor: burn wrapper shadowing entries

* chore: refresh wrapper shadowing baselines

* test: update secrets runtime state mocks

* fix(ci): absorb Control UI build identity variance
2026-08-11 08:24:03 -07:00
Peter Steinberger fa03d9b913 refactor: consolidate coercion helpers (#121366)
* refactor: consolidate coercion helpers

* fix: remove duplicate coercion imports

* fix: preserve serialized coercion guard

* chore: ratchet coercion helper carve-outs

* fix(test): keep gauntlet subprocess startup lean

* fix: preserve imported session timestamp semantics

* fix: preserve catalog timestamp string semantics

* chore: align plugin SDK surface ratchet

* fix: preserve trajectory and SDK string contracts

* fix(test): preserve QA record assertion semantics

* fix: complete standalone record guard rename

* refactor(cron): use canonical string coercion

* fix(acpx): preserve Pi timestamp parsing

* test(channels): adapt custody test harnesses

* test(telegram): classify media harness as test support

* test(acpx): split timestamp contract coverage

* test(channels): support generated custody contracts

* chore: ban the full coercion helper name set

Extends the declaration guard to all eleven consolidated helper names and
renames the cron schedule-identity readNumber wrapper to readScheduleInteger
so the banned generic name cannot regrow.

* fix(scripts): repair release-validation guard drift and lint cause

Restores the renamed isJsonRecord guard in assertTrustedWorkflowHarness after
main added isRecord call sites in parallel, and attaches the caught YAML error
as the thrown error cause (preserve-caught-error was red on main).

* fix: preserve Claude timestamp string semantics

* fix: preserve persisted timestamp string semantics

* fix: preserve date-first timestamp contracts

* fix(openai): harden delegation failure formatting

* chore: close coercion helper guard gaps

* test(openai): model non-error delegation rejection

* chore: refresh plugin SDK API contract

* fix(tasks): use canonical string field reader

* fix(ai): use canonical provider error field coercion

* fix(browser): migrate native bootstrap coercion

* docs(plugin-sdk): clarify text record export compatibility

* fix(gateway): normalize approval execution identity

* test(outbound): isolate message action poll harness
2026-08-11 00:02:18 -07:00
Peter Steinberger 3b828df2d9 test(logging): trim recovery duplicate coverage (#121864) 2026-08-10 22:10:26 -07:00
Peter Steinberger 11db07ac06 refactor(logging): remove dead console config fallback (#121776)
* refactor(logging): remove dead console config fallback

* test(logging): complete config module mock
2026-08-10 17:52:32 -07:00
Peter Steinberger f09a33ce41 Optimize OpenAI turn latency and simplify reuse (#121687)
Amp-Thread-ID: https://ampcode.com/threads/T-019fe95b-d75c-70fc-82b6-4825ca874826

Co-authored-by: Amp <amp@ampcode.com>
2026-08-10 16:23:06 -07:00
Peter Steinberger 8616c0c374 refactor: finish shared test helper migrations (#120996)
* test: finish shared helper migrations

* test: fix helper migration CI

* style: fix test import ordering

* test(acpx): restore deferred void types

* test: fix helper migrations after rebase
2026-08-09 06:00:06 -07:00
Peter Steinberger eecbfcc960 fix(infra): unify env-truthiness, missing-path, realpath, and abort-sleep semantics (#120359)
* fix(infra): unify environment truthiness

* fix(infra): unify missing path classification

* refactor(infra): unify realpath fallbacks

* fix(infra): unify abortable sleep errors

* docs(infra): clarify path fallback semantics

* fix(infra): route realpaths through policy wrapper

* fix(infra): ratchet plugin SDK wildcard budget

* fix(agents): preserve zero-delay abort precedence

* fix(infra): preserve fallback and media recovery contracts

* fix(plugins): share quarantine path resolution
2026-08-08 10:58:57 -07:00
joshavant 2253328618 fix(agents): centralize abort and progress authority 2026-08-07 18:42:57 -05:00
Josh Avant 8333892384 fix(agents): retain reply owners through cancellation 2026-08-07 18:42:57 -05:00
Josh Avant 8757119c77 fix(diagnostics): protect recovery authority 2026-08-07 18:42:57 -05:00
Josh Avant 90174086b3 fix(diagnostics): keep semantic provenance private 2026-08-07 18:42:57 -05:00
Josh Avant 32ad6834b1 fix(diagnostics): reserve semantic progress for core 2026-08-07 18:42:57 -05:00
Josh Avant b731aea7e1 fix: trust semantic diagnostic progress 2026-08-07 18:42:57 -05:00
Josh Avant 4ea4596617 fix: bind semantic progress to run owner 2026-08-07 18:42:57 -05:00
Josh Avant 474be1700d fix(diagnostics): preserve legacy progress liveness 2026-08-07 18:42:57 -05:00
Josh Avant be8a954032 fix(diagnostics): classify semantic model progress 2026-08-07 18:42:57 -05:00
joshavant 7bcdb5823e test: prove repeated request recovery through gateway 2026-08-07 18:42:57 -05:00
joshavant 517d0b1c2c fix: recover repeated model requests without progress 2026-08-07 18:42:57 -05:00
Peter Steinberger b4a26783f7 refactor(test): consolidate duplicated requireRecord and provider HTTP mock helpers (#119982)
* refactor(test): consolidate duplicated test helpers

* test: remove stale record guard import

* fix(test): remove orphaned record guards

* refactor(test): keep record requirement messages exhaustively typed

* fix(test): keep packages/ai record guard package-local
2026-08-06 14:48:01 -07:00
Vincent Koc c4292bc8b2 fix(diagnostics): report exporter health in doctor and status (#119816)
* fix(diagnostics): report exporter health transitions

* fix(diagnostics): retire exporter health on shutdown

* test(diagnostics): enforce OTLP protobuf content type

* test(diagnostics): satisfy exporter test type contracts

* fix(diagnostics): redact endpoint-like exporter codes

* fix(diagnostics): coordinate exporter route health

* test(diagnostics): satisfy exporter health static gates

* fix(diagnostics): keep exporter health internal
2026-08-06 20:50:18 +08:00
Jason (Json) 40b0b3da39 fix(diagnostics): bound recent phase attribution (#119625) 2026-08-05 10:14:33 -06:00
Vincent Koc 554a6f3bbf feat(sms): add Twilio MMS support (#118664)
* feat(sms): add Twilio MMS support

* fix(sms): harden hosted media bearer handling

* fix(sms): discard staged media before dispatch

* fix(sms): close staged media cleanup races

* fix(sms): finalize MMS metadata and race proof

* fix(media): bind local reads to authorized descriptors

* fix(sms): close MMS review gaps

* fix(media): make inbound root matching type-safe

* fix(media): route bounded reads through fs-safe facade

* test(media): satisfy async lint contracts
2026-08-04 05:46:37 +08:00
Peter Steinberger d347cd1097 refactor: canonicalize cache mechanics (#118262)
* refactor: adopt shared map pruning

* refactor: share config-scoped ttl cache

* refactor: share backup link cache

* refactor: centralize native relay retention cap

* chore: remove obsolete bundled channel lint suppression

* chore: shrink max-lines baseline

* refactor: remove cache pruning wrappers
2026-08-02 19:33:13 -07:00
Peter Steinberger 3f3ceb2def feat(gateway): track event-loop degradation persistence and add concurrency benchmark (#118193)
* feat(gateway): persist event loop degradation metrics

* fix(gateway): bound concurrency benchmark turn waits
2026-08-02 14:21:44 -07:00
Peter Steinberger e92a98c77d fix(agents): stop repeated equivalent terminal exec failures (#118071)
Co-authored-by: Peter Steinberger <steipete@macos.shared>
2026-08-02 11:42:57 -07:00
Peter Steinberger e46b4c34b0 fix(diagnostics): read active assistant context from canonical SQLite sessions (#117945)
* fix(diagnostics): read active assistant context from canonical SQLite sessions

* fix(logging): keep incognito transcript context out of diagnostics
2026-08-02 04:02:34 -07:00