perf(skills): coalesce inventory before run cache locking (#16576)

Share each active company skill-inventory refresh before taking the version-cache lock. Read actor visibility under the lock and keep snapshot publication protected through durable run pinning. Preserve empty-selection behavior and the list API.

Validation: 176 affected cases, full repository typecheck/build, fresh full CI/E2E, security and exact-head Apex 5/5 pass. The local six-reader latency experiment improves from 50.4s to 18.3s; live response latency is a separate acceptance check.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-10-16 10:39:02 -05:00
1 parent 5fbece9dcc
commit 06689c1b34
8 files changed
+173 -45

No files matched your search

+7
View File
@@ -102,6 +102,13 @@ exclusion and immutable version pinning. This changes no agent endpoint or grant
the [configuration tests](../../server/src/__tests__/heartbeat-execution-configuration.test.ts)
cover the held-lock boundary with real PostgreSQL.
Concurrent preparations share only in-flight inventory reconciliation. After
that work, each actor's visible skill rows are read again under the company cache
lock. Snapshot delivery and durable run pins complete before the lock is released.
No permission result is shared or kept between requests. The
[concurrency tests](../../server/src/__tests__/company-skills-runtime-concurrency.test.ts)
cover separate actors and project-access revocation; this adds no agent API.
## `policy`
Review: `baseline`.
+6
View File
@@ -63,6 +63,12 @@ later assignments. Selected skills and the legacy operational skill retain cache
exclusion through version pinning. The [configuration regression](../../server/src/__tests__/heartbeat-execution-configuration.test.ts)
uses a real PostgreSQL lock; live provider latency remains a separate check.
Concurrent selected-skill preparations share one in-flight company inventory
refresh before cache locking. Each run retains its own selection and durable
version pins. The [concurrency regression](../../server/src/__tests__/company-skills-runtime-concurrency.test.ts)
checks shared work and separate actor access; the cache tests check that cleanup
cannot remove a snapshot before the run stores its pins.
## Gotchas
- The release picker requires `enableBetaSkills`. Do not invent an Instructions