@sema-agent/server 7.43.0 → 7.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/USAGE.md +18 -0
- package/dist/adoption/plan.js +31 -192
- package/dist/adoption/quiesce.js +3 -86
- package/dist/adoption/runner.js +3 -140
- package/dist/adoption/sql.js +0 -74
- package/dist/adoption/wire.js +0 -80
- package/dist/approval-ask-machine.js +0 -75
- package/dist/approval-card.js +0 -323
- package/dist/approval-deny-reasons.js +0 -42
- package/dist/approval-hmac.js +0 -35
- package/dist/approval-reconciler.js +8 -166
- package/dist/approval.js +4 -67
- package/dist/audit.js +1 -44
- package/dist/auth-bridge.js +4 -47
- package/dist/auth-keys.js +0 -23
- package/dist/bake-runner/main.js +4 -65
- package/dist/bake-runner/protocol.js +3 -58
- package/dist/bake-runner/runner.js +5 -91
- package/dist/bench/l8/artifact.js +2 -61
- package/dist/bench/l8/escape.js +0 -25
- package/dist/bench/l8/index.js +0 -14
- package/dist/bench/l8/probes.js +0 -60
- package/dist/bench/l8/run-probes.js +2 -45
- package/dist/bench/s1/arms.js +14 -189
- package/dist/bench/s1/live-deps.js +11 -253
- package/dist/bench/s1/oracle.js +1 -36
- package/dist/bench/s1/repair-oracle-adapter.js +0 -30
- package/dist/bench/s1/reviewer.js +0 -34
- package/dist/bench/s1/row.js +0 -62
- package/dist/bench/s1/run-firm.js +4 -70
- package/dist/bench/s1/runner-ctx.js +0 -40
- package/dist/bench/s1/tasks.js +0 -115
- package/dist/boot/adoption.js +0 -20
- package/dist/boot/budget-tracing.js +3 -55
- package/dist/boot/config-center.js +43 -551
- package/dist/boot/coordinators.js +1 -69
- package/dist/boot/crash-last.js +0 -18
- package/dist/boot/deferred-sandbox-path-env.js +3 -119
- package/dist/boot/execution-env.js +5 -171
- package/dist/boot/governance-seams.js +0 -92
- package/dist/boot/leader.js +0 -69
- package/dist/boot/limit-sync.js +0 -2
- package/dist/boot/memory-boundary.js +3 -91
- package/dist/boot/org-memory.js +1 -25
- package/dist/boot/parked-revive-gate.js +0 -150
- package/dist/boot/permission-rules-audit.js +1 -56
- package/dist/boot/reapers.js +15 -273
- package/dist/boot/resolve-spec.js +9 -768
- package/dist/boot/retention-lane.js +4 -87
- package/dist/boot/runner-deps.js +3 -297
- package/dist/boot/runtime-caps.js +0 -40
- package/dist/boot/session-faces.js +2 -133
- package/dist/boot/shutdown.js +9 -83
- package/dist/boot/side-query-lane.js +2 -137
- package/dist/boot/stores.js +15 -215
- package/dist/boot/task-list-lane.js +0 -18
- package/dist/boot/webfetch-summarize-lane.js +0 -47
- package/dist/boot/workflow-orchestration.js +3 -99
- package/dist/boot-reclaim.js +0 -20
- package/dist/bounded-session-map.js +0 -19
- package/dist/brain.js +2 -139
- package/dist/budget.js +9 -244
- package/dist/capabilities/builtin-tools.js +0 -3
- package/dist/capabilities/center-plugins.js +6 -51
- package/dist/capabilities/center-prompts.js +6 -71
- package/dist/capabilities/code-review-council.js +7 -40
- package/dist/capabilities/collab-workflows.js +1 -44
- package/dist/capabilities/hands-lane.js +0 -65
- package/dist/capabilities/memory-notice.js +0 -70
- package/dist/capabilities/prompt.js +0 -14
- package/dist/capabilities/prompts/code-review.js +0 -14
- package/dist/capabilities/prompts/identity.js +0 -6
- package/dist/capabilities/prompts/team.js +0 -4
- package/dist/capabilities/repo-tools.js +0 -34
- package/dist/capabilities/sandbox-file-send.js +3 -92
- package/dist/capabilities/scenarios.d.ts +0 -1
- package/dist/capabilities/scenarios.js +18 -279
- package/dist/capabilities/select-environment-tool.js +0 -32
- package/dist/capabilities/send-user-file-tool.js +2 -66
- package/dist/capabilities/skills.d.ts +1 -2
- package/dist/capabilities/skills.js +3 -21
- package/dist/capabilities/team.d.ts +3 -11
- package/dist/capabilities/team.js +3 -51
- package/dist/capabilities/tool-defer.js +0 -3
- package/dist/config-center/apply-effective.js +15 -330
- package/dist/config-center/apply-ledger.js +5 -38
- package/dist/config-center/facade.js +0 -41
- package/dist/config-center/hot-keys-registry.js +0 -20
- package/dist/config-center/http-client.js +2 -125
- package/dist/config-center/mcp-revocation.js +2 -34
- package/dist/config-center/read-face.js +0 -59
- package/dist/config-center/restart-signal.js +1 -85
- package/dist/config-center/skills-mcp.d.ts +1 -1
- package/dist/config-center/skills-mcp.js +9 -76
- package/dist/config-center/stage-limits.js +8 -35
- package/dist/config-invariants.js +0 -16
- package/dist/config-lkg.js +0 -42
- package/dist/config-provider.js +3 -186
- package/dist/config-types.js +0 -5
- package/dist/config.js +107 -1145
- package/dist/degenerate-instrument.js +3 -67
- package/dist/deployment-governance.js +0 -124
- package/dist/digest-form.js +0 -12
- package/dist/elicitation.js +3 -86
- package/dist/env-facts.js +7 -75
- package/dist/fleet/fleet-bus.js +34 -507
- package/dist/fleet/fleet-reconciler.js +9 -149
- package/dist/fleet/fleet-terminal-window.js +10 -178
- package/dist/fleet/subagent-tail-bus.js +3 -72
- package/dist/fleet-client.js +10 -70
- package/dist/fleet-lease.js +5 -79
- package/dist/git-api-kind.js +0 -3
- package/dist/governance-ask-marks.js +2 -78
- package/dist/hooks/branch-transcript.js +0 -74
- package/dist/hooks/cc-agent-hook-prompt.js +0 -29
- package/dist/hooks/cc-stop-prompt.js +1 -46
- package/dist/hooks/hook-llm.js +1 -53
- package/dist/hooks/hook-runner.js +20 -414
- package/dist/http/active-run-conflict.js +4 -129
- package/dist/http/cursor-fingerprint.d.ts +5 -0
- package/dist/http/cursor-fingerprint.js +5 -0
- package/dist/http/idempotency.js +0 -37
- package/dist/http/principal-gate.js +3 -40
- package/dist/http/route-ctx.js +0 -9
- package/dist/http/routes/a2a-serve.js +7 -319
- package/dist/http/routes/admin-config-refresh.js +0 -4
- package/dist/http/routes/admin-drain.js +0 -10
- package/dist/http/routes/adoption.js +1 -29
- package/dist/http/routes/agents-roster.js +1 -47
- package/dist/http/routes/approvals-assistant.js +32 -395
- package/dist/http/routes/attachments.js +4 -22
- package/dist/http/routes/capabilities.js +3 -420
- package/dist/http/routes/diagnostics.js +1 -81
- package/dist/http/routes/fleet.js +9 -185
- package/dist/http/routes/images.js +14 -239
- package/dist/http/routes/leader.js +0 -13
- package/dist/http/routes/memory-bundle.js +1 -61
- package/dist/http/routes/memory-policy.js +9 -99
- package/dist/http/routes/notify-wake.js +3 -37
- package/dist/http/routes/observability.js +2 -19
- package/dist/http/routes/retention-ops.js +2 -34
- package/dist/http/routes/rules.js +1 -93
- package/dist/http/routes/runs.js +64 -873
- package/dist/http/routes/session-sync.js +19 -258
- package/dist/http/routes/sessions-list.js +17 -43
- package/dist/http/routes/sessions.js +34 -226
- package/dist/http/routes/shared-memory.js +5 -36
- package/dist/http/routes/side-query.js +1 -87
- package/dist/http/routes/tasks.js +52 -722
- package/dist/http/routes/trace-usage.js +32 -195
- package/dist/http/routes/workflows.js +19 -195
- package/dist/http/run-meta.js +0 -6
- package/dist/http/send.js +0 -32
- package/dist/http/server.js +92 -1597
- package/dist/http/sse-lifecycle.js +2 -13
- package/dist/http/sse-log.js +3 -48
- package/dist/http/tar.js +5 -21
- package/dist/http/verify-rounds.js +0 -5
- package/dist/http/wire-gate.js +0 -9
- package/dist/http/workspace-content.js +0 -10
- package/dist/images/bake-validate.js +1 -70
- package/dist/images/manifest.js +1 -6
- package/dist/index.js +0 -21
- package/dist/key-resolver.js +2 -17
- package/dist/leader/diffout.js +1 -20
- package/dist/leader/diffup.js +0 -47
- package/dist/leader/endpoint.js +2 -57
- package/dist/leader/fanout.js +3 -45
- package/dist/leader/grader-env-factory.js +3 -72
- package/dist/leader/leader.js +5 -156
- package/dist/leader/merge.js +8 -115
- package/dist/leader/planner.js +3 -54
- package/dist/leader/repair-oracle.js +1 -60
- package/dist/leader/repair-wire.js +2 -79
- package/dist/leader/wire.js +8 -307
- package/dist/lsp/e2b-bridge.js +4 -64
- package/dist/lsp/e2b-manager.js +6 -94
- package/dist/lsp/lsp-frames.js +0 -12
- package/dist/lsp/manager.js +4 -96
- package/dist/lsp/ws-transport.js +5 -55
- package/dist/lsp-evict.js +1 -15
- package/dist/main.js +57 -765
- package/dist/memory-bundle-engine.js +0 -55
- package/dist/memory-export.js +0 -4
- package/dist/memory-posture.js +1 -15
- package/dist/memory-scope.js +11 -148
- package/dist/memory-sync-client.js +2 -44
- package/dist/memory-sync.js +1 -80
- package/dist/model-select.js +3 -80
- package/dist/observability/cost-quota.js +1 -17
- package/dist/observability/cost-taxonomy.js +0 -34
- package/dist/observability/fail-open.js +7 -86
- package/dist/observability/logger.js +0 -6
- package/dist/observability/metrics.js +0 -94
- package/dist/observability/otel-exporter.js +3 -13
- package/dist/observability/principal-context.js +0 -9
- package/dist/observability/prompt-manifest.js +1 -37
- package/dist/observability/rate-limit.js +0 -4
- package/dist/observability/secret-env-scrub.js +2 -56
- package/dist/observability/tool-trace.js +1 -70
- package/dist/orchestration/hardened-vm-runner.js +4 -118
- package/dist/orchestration/hardened-vm-worker-runner.js +1 -26
- package/dist/orchestration/hardened-vm-worker.js +0 -27
- package/dist/orchestration/subagent-steer.js +1 -45
- package/dist/orchestration/workflow-agent-steer.js +1 -80
- package/dist/orchestration/workflow-completion-inbox.js +32 -285
- package/dist/orchestration/workflow-notify-journal.js +16 -259
- package/dist/org-memory-admission.js +3 -47
- package/dist/parent-watch.js +2 -48
- package/dist/parked-decide.js +1 -109
- package/dist/per-task-image.js +0 -57
- package/dist/plan-cache-probe.js +3 -27
- package/dist/plugins/adoption-log-sql.js +2 -119
- package/dist/plugins/approval-ask-store-memory.js +3 -38
- package/dist/plugins/approval-ask-store-sql.js +6 -188
- package/dist/plugins/approval-exemption-store.js +2 -28
- package/dist/plugins/background-agent-store-sql.js +4 -105
- package/dist/plugins/background-shell-support.js +14 -122
- package/dist/plugins/blob-backend.js +6 -169
- package/dist/plugins/breaker-state-sql.js +8 -46
- package/dist/plugins/caching-session-store.js +4 -106
- package/dist/plugins/checkpoint-store-sql.js +18 -505
- package/dist/plugins/e2b-orphan-reclaim.js +0 -45
- package/dist/plugins/file-outcome-sink.js +0 -9
- package/dist/plugins/file-resume-anchor-store.js +4 -43
- package/dist/plugins/file-run-store.js +26 -364
- package/dist/plugins/file-snapshot-store-sql.js +10 -181
- package/dist/plugins/fork-routing-session-store.js +8 -111
- package/dist/plugins/host-platform.js +2 -91
- package/dist/plugins/image-bake-store-sql.js +7 -250
- package/dist/plugins/image-index-sql.js +4 -123
- package/dist/plugins/k8s-bg-scripts.js +4 -88
- package/dist/plugins/k8s-exec-protocol.js +0 -41
- package/dist/plugins/leader-run-store-sql.js +0 -101
- package/dist/plugins/local-checkpoint-store.js +8 -128
- package/dist/plugins/local-session-store.js +34 -296
- package/dist/plugins/local-task-attachment-store.js +2 -16
- package/dist/plugins/mailbox-store-sql.js +8 -65
- package/dist/plugins/memory-embedder-fingerprint.js +5 -166
- package/dist/plugins/memory-embedder.js +4 -70
- package/dist/plugins/memory-engine-pg.js +6 -170
- package/dist/plugins/memory-engine-tidb.js +7 -155
- package/dist/plugins/memory-engine-vector-util.js +0 -10
- package/dist/plugins/memory-key-guards.js +0 -34
- package/dist/plugins/memory-origin-law.js +0 -187
- package/dist/plugins/memory-resume-anchor-store.js +0 -17
- package/dist/plugins/memory-run-store.js +12 -89
- package/dist/plugins/memory-session-policy-store.js +0 -17
- package/dist/plugins/memory-sync-store-pg.js +4 -49
- package/dist/plugins/memory-sync-store-tidb.js +3 -35
- package/dist/plugins/outcome-ledger-sql.js +3 -97
- package/dist/plugins/permission-rule-store-file.js +5 -133
- package/dist/plugins/permission-rule-store-sql.d.ts +3 -0
- package/dist/plugins/permission-rule-store-sql.js +50 -307
- package/dist/plugins/pg-cost-quota.js +0 -7
- package/dist/plugins/pg-pool.js +0 -92
- package/dist/plugins/pg-rate-limiter.js +2 -13
- package/dist/plugins/pg-safe-json.js +4 -40
- package/dist/plugins/pg-session-storage.js +25 -189
- package/dist/plugins/posix-shell-fs.js +1 -31
- package/dist/plugins/remote-env-adb.js +12 -101
- package/dist/plugins/remote-env-e2b.js +40 -371
- package/dist/plugins/remote-env-file-error.js +0 -37
- package/dist/plugins/remote-env-host.js +63 -483
- package/dist/plugins/remote-env-k8s.js +32 -326
- package/dist/plugins/remote-env-local-docker.js +24 -157
- package/dist/plugins/remote-env-ssh.js +20 -128
- package/dist/plugins/remote-scratchpad.js +2 -32
- package/dist/plugins/remote-shell.js +1 -32
- package/dist/plugins/resume-anchor-store-sql.js +0 -11
- package/dist/plugins/retention-lane-store-sql.js +0 -108
- package/dist/plugins/retention-store-sql.js +4 -383
- package/dist/plugins/roster-store-sql.js +0 -55
- package/dist/plugins/run-store-sql.js +14 -251
- package/dist/plugins/s3-presign.js +2 -49
- package/dist/plugins/scheduler-support.js +3 -80
- package/dist/plugins/send-file-ledger.js +4 -53
- package/dist/plugins/send-user-file.js +4 -94
- package/dist/plugins/session-placement.js +1 -89
- package/dist/plugins/session-policy-store-sql.js +3 -81
- package/dist/plugins/session-store.js +0 -57
- package/dist/plugins/shared-memory-store-sql.js +4 -167
- package/dist/plugins/sql-driver.js +0 -17
- package/dist/plugins/sql-errors.js +0 -7
- package/dist/plugins/sql-escape.js +0 -8
- package/dist/plugins/sql-row-helpers.js +0 -25
- package/dist/plugins/store-backend.js +42 -222
- package/dist/plugins/store-contracts.js +2 -46
- package/dist/plugins/task-attachment-store.js +3 -49
- package/dist/plugins/task-list-store-sql.js +0 -79
- package/dist/plugins/tidb-cost-quota.js +1 -4
- package/dist/plugins/tidb-pool.js +1 -207
- package/dist/plugins/tidb-rate-limiter.js +3 -9
- package/dist/plugins/tidb-session-storage.js +4 -70
- package/dist/plugins/tidb-session-store.js +19 -341
- package/dist/plugins/tool-result-store-sql.js +4 -179
- package/dist/plugins/usage-window-store-sql.js +0 -8
- package/dist/plugins/web-search.js +10 -132
- package/dist/plugins/workflow-journal-store-sql.js +2 -58
- package/dist/plugins/workflow-run-store-sql.js +6 -91
- package/dist/plugins/worktree-isolation.js +6 -126
- package/dist/plugins/write-behind-counter.js +16 -75
- package/dist/principal-jwt.js +5 -60
- package/dist/project-memory.js +15 -146
- package/dist/prompts-domain-validate.js +1 -51
- package/dist/question.js +2 -111
- package/dist/resource-suspend.js +0 -18
- package/dist/router/route-orchestration.js +0 -77
- package/dist/rules-consent.d.ts +44 -5
- package/dist/rules-consent.js +75 -215
- package/dist/run-local.js +14 -381
- package/dist/runs.js +29 -617
- package/dist/runtime-caps-resolver.js +6 -132
- package/dist/runtime-governance.js +1 -232
- package/dist/sandbox-pkg-source.js +0 -37
- package/dist/sealed-key.js +3 -68
- package/dist/security.js +6 -291
- package/dist/session-leaf-bus.js +0 -32
- package/dist/session-sync-content.js +1 -69
- package/dist/session-sync-kernel.js +3 -60
- package/dist/session-sync.js +3 -66
- package/dist/session-titler.js +7 -41
- package/dist/session-watch.js +9 -73
- package/dist/shared-memory-scope-authorizer.js +0 -18
- package/dist/sighup-idle.js +1 -12
- package/dist/spec-fields.js +4 -143
- package/dist/store-live-probe.js +3 -49
- package/dist/task-a2a.js +1 -126
- package/dist/task-cwd.js +1 -103
- package/dist/task-mcp.js +1 -89
- package/dist/task-settings.js +10 -300
- package/dist/task-workflow.js +8 -75
- package/dist/tool-approval.d.ts +28 -1
- package/dist/tool-approval.js +70 -1430
- package/dist/trace/artifacts.js +5 -20
- package/dist/trace/engine-notice-wire.js +6 -138
- package/dist/trace/ledger-sink.js +7 -96
- package/dist/trace/project.js +4 -448
- package/dist/trace/redact.js +9 -77
- package/dist/turn-activity.js +1 -27
- package/dist/usage-analytics.js +4 -34
- package/dist/wall-clock-jump-guard.js +1 -68
- package/package.json +3 -3
- package/dist/capabilities/scenario-alias.d.ts +0 -27
- package/dist/capabilities/scenario-alias.js +0 -61
|
@@ -1,97 +1,30 @@
|
|
|
1
1
|
import { assertPlacementAdmission } from "./session-placement.js";
|
|
2
|
-
/**
|
|
3
|
-
* Warm/sticky cache in front of a durable {@link SessionStore} (Option A).
|
|
4
|
-
*
|
|
5
|
-
* Keeps a woken session in memory and **reuses the same storage instance across turns**, so a hot
|
|
6
|
-
* session is not re-read from TiDB every short turn (treats the cattle like a warm pet while it's
|
|
7
|
-
* active). Idle sessions expire after `ttlSec`; `release` evicts immediately.
|
|
8
|
-
*
|
|
9
|
-
* ⚠️ **Session affinity is REQUIRED** when this cache is enabled (`SESSION_CACHE_TTL_SEC>0`): route a
|
|
10
|
-
* given sessionId to the same instance. Under affinity the cached storage is the sole writer, so its
|
|
11
|
-
* in-memory leaf is always current and consistent with TiDB (write-through; F2 CAS still applies).
|
|
12
|
-
* Without affinity a concurrent write from another instance makes this cache stale; that surfaces as
|
|
13
|
-
* a `SessionError("conflict")` on the next append — the async run driver calls `evict()` on conflict
|
|
14
|
-
* (defense-in-depth) and the entry also expires after `ttlSec`, but those are backstops, not the
|
|
15
|
-
* guarantee. If you cannot guarantee affinity, set `SESSION_CACHE_TTL_SEC=0` to disable the cache.
|
|
16
|
-
*
|
|
17
|
-
* Orthogonal to the F3 branch-floor change: floor bounds the *cold wake* size; this cache removes
|
|
18
|
-
* *repeated* re-reads of an active session.
|
|
19
|
-
*/
|
|
20
2
|
export class CachingSessionStore {
|
|
21
3
|
inner;
|
|
22
4
|
cache = new Map();
|
|
23
5
|
pending = new Map();
|
|
24
6
|
ttlMs;
|
|
25
7
|
timer;
|
|
26
|
-
/** Delegated tenant-ownership ops, present only if the inner store exposes them (the TiDB store does). */
|
|
27
8
|
ownerOf;
|
|
28
9
|
register;
|
|
29
|
-
/** Delegated SessionRepo seam (§0.5) — list/fork/delete operate on the DURABLE tables directly (they bypass the
|
|
30
|
-
* warm cache by design; a fork/delete must read/write durable state, not a possibly-stale cached view). */
|
|
31
10
|
listSessions;
|
|
32
11
|
fork;
|
|
33
12
|
deleteSession;
|
|
34
|
-
/** K-5c (core 1.155 SessionStore.noteTaskRun seam) — core's Runner calls it at runTask START to record the latest
|
|
35
|
-
* run per session (→ listSessions `lastRunId`). MUST be forwarded: the local backend's Runner store is THIS cache
|
|
36
|
-
* wrapper, so without forwarding `noteTaskRun?.()` silently no-ops and lastRunId stays null (review BLOCKER). Pure
|
|
37
|
-
* pass-through to the inner store's in-mem map — no cache interaction. (TiDB/PG don't implement it → not bound.)
|
|
38
|
-
* Return type matches core's `SessionStore.noteTaskRun?(): void | Promise<void>` (review: don't narrow to void). */
|
|
39
13
|
noteTaskRun;
|
|
40
|
-
/** Write-once auto-title (SQL twins + local sidecar carry it; pure pass-through). */
|
|
41
14
|
setTitleIfNull;
|
|
42
15
|
probeTitle;
|
|
43
|
-
/** E18 — delegate the leaf read straight to inner (a cache-bypassing single SELECT; the resume-at turn-capture
|
|
44
|
-
* reads the DURABLE leaf, not a possibly-stale cached view — same discipline as the §0.5 repo ops above). */
|
|
45
16
|
getLeafId;
|
|
46
|
-
/** [1196] 六轮复审:owner+leafId 原子快照透传(cache-bypassing,getLeafId 同姿势)。 */
|
|
47
17
|
getHead;
|
|
48
|
-
/** 2c session-sync — delegated export/import seam, DURABLE (bypasses the warm cache exactly like
|
|
49
|
-
* list/fork: an export reads the full durable log, an import writes durable state). */
|
|
50
18
|
exportEntries;
|
|
51
|
-
/** 2c session-sync P1d-α (PULL streaming) — delegated ids-only projection + keyset-paged entry STREAM, DURABLE
|
|
52
|
-
* (read straight from the durable log, bypassing the warm cache, like exportEntries). The stream's per-batch query
|
|
53
|
-
* discipline (one pooled query per page) lives in the inner store; this wrapper just forwards. */
|
|
54
19
|
listEntryIds;
|
|
55
20
|
exportEntriesStream;
|
|
56
|
-
/** 轴A #1(1.254):core B-17 forget 面(evict 本地 + 转发 inner 可选面)。 */
|
|
57
21
|
forget;
|
|
58
22
|
importEntries;
|
|
59
|
-
/** [2024](cli 取证)2c session-sync P1d-β — delegated STAGED import seam. 此前 staging 族不在本类的逐方法
|
|
60
|
-
* 转发白名单里 ⇒ 默认部署(SESSION_CACHE_TTL_SEC=300 把真店包进本类)PUSH Phase A 恒 501
|
|
61
|
-
* `capability.session_store_required`,而 capabilities().sessionSync 谓词三项(backend/exportEntries/
|
|
62
|
-
* fileSnapshotStore)都被转发了 ⇒ 照报 true(能力面谎)。转发形:handle 的 `commit` 是唯一写真 id 的
|
|
63
|
-
* 时刻,成功后逐出该 id 的暖 handle + S25 指纹(importEntries/replaceEntries 同纪律);`abort` 只丢
|
|
64
|
-
* staging 行、不碰真 id ⇒ 不逐出。 */
|
|
65
23
|
beginImportStaging;
|
|
66
|
-
/** Staging 清扫面(kernel `ImportStagingStore.sweepStagingSessions`)。当下 reaper 走 `backend.session()`
|
|
67
|
-
* 裸店、不经本包装,但 security.ts 的 OwnerAwareSessionStore 契约列了它 —— 经 sessionStorage 消费的
|
|
68
|
-
* 未来调用方不该静默 no-op,与 beginImportStaging 同批补齐(同一类白名单缺口)。 */
|
|
69
24
|
sweepStagingSessions;
|
|
70
|
-
/** 2c session-sync (§7/§8) — delegated IDEMPOTENT replace; like importEntries it writes durable state under
|
|
71
|
-
* `sessionId`, so a stale warm handle for that id is evicted on success (next acquire re-wakes from the new log). */
|
|
72
25
|
replaceEntries;
|
|
73
|
-
/**
|
|
74
|
-
* #270 车1 —— 内层店的 `retention` **声明**(core `RetentionDeclaring`)。
|
|
75
|
-
*
|
|
76
|
-
* 🔴 为什么这一格必须转发,而且方向比别的转发更要命:生产默认 `SESSION_CACHE_TTL_SEC=300` 会把真店
|
|
77
|
-
* 包进本类,于是 boot 递给 `assertRetentionCapability` 的就是**包装层**。core 对缺席是 fail-closed
|
|
78
|
-
* 读 `"none"` —— 不转发 ⇒ 一个真 managed 的 SQL 部署在 locked policy 下**被拒启**,而拒启文案会指着
|
|
79
|
-
* 一只其实完全合格的店(「stores that cannot delete」)。转发是**只读快照**而不是 getter:声明是店的
|
|
80
|
-
* 构造期常量,一个会变的声明本身就是缺陷。缺席则不设(保持 fail-closed 的缺席读法)。
|
|
81
|
-
*/
|
|
82
26
|
retention;
|
|
83
|
-
/**
|
|
84
|
-
* #292 C18 —— 内层店的 **placement 声明**转发。
|
|
85
|
-
*
|
|
86
|
-
* 🔴 这一格与 {@link retention} 是同一条教训的同一族(而且更狠):生产默认 `SESSION_CACHE_TTL_SEC=300`
|
|
87
|
-
* 把真店包进本类,于是 boot 递给 core 的就是**包装层**。core 的铸造门判「row store ∧ **session 店声明**」
|
|
88
|
-
* ⇒ 不转发 = 整条 subagent 转录持久化在默认部署上**静默不生效**(placement 参数被合法忽略、子代转录
|
|
89
|
-
* 退回普通会话、声明的 durable tier 变成一句空话),而且没有任何一处会报错。
|
|
90
|
-
* 只读快照而非 getter:声明是店的构造期常量(会变的声明本身就是缺陷)。
|
|
91
|
-
*/
|
|
92
27
|
placements;
|
|
93
|
-
/** #292:placed 分区的两只读面(reap 分区腿 / 准入探针)——同款转发理由:reaper 与准入判据拿到的
|
|
94
|
-
* 是包装层,不转发 = 分区腿静默不可用、暖命中的 claim 关门静默失效。缺席则不设(诚实降级)。 */
|
|
95
28
|
listPlaced;
|
|
96
29
|
placementOf;
|
|
97
30
|
constructor(inner, opts) {
|
|
@@ -100,7 +33,6 @@ export class CachingSessionStore {
|
|
|
100
33
|
const declared = inner.retention;
|
|
101
34
|
if (declared !== undefined)
|
|
102
35
|
this.retention = declared;
|
|
103
|
-
// #292:声明 + 两只读面逐字转发(理由见各自的字段注)。
|
|
104
36
|
if (inner.placements !== undefined)
|
|
105
37
|
this.placements = inner.placements;
|
|
106
38
|
if (typeof inner.listPlaced === "function")
|
|
@@ -122,7 +54,7 @@ export class CachingSessionStore {
|
|
|
122
54
|
if (ownerAware.fork)
|
|
123
55
|
this.fork = ownerAware.fork.bind(inner);
|
|
124
56
|
if (ownerAware.noteTaskRun)
|
|
125
|
-
this.noteTaskRun = ownerAware.noteTaskRun.bind(inner);
|
|
57
|
+
this.noteTaskRun = ownerAware.noteTaskRun.bind(inner);
|
|
126
58
|
if (ownerAware.getLeafId)
|
|
127
59
|
this.getLeafId = ownerAware.getLeafId.bind(inner);
|
|
128
60
|
if (ownerAware.getHead)
|
|
@@ -133,39 +65,29 @@ export class CachingSessionStore {
|
|
|
133
65
|
this.listEntryIds = ownerAware.listEntryIds.bind(inner);
|
|
134
66
|
if (ownerAware.exportEntriesStream)
|
|
135
67
|
this.exportEntriesStream = ownerAware.exportEntriesStream.bind(inner);
|
|
136
|
-
// 历史复审轴A #1(1.254,core B-17 缝):core prepare-task 在 reconcile 冲突重试/prepare-throw 清理时
|
|
137
|
-
// 调 `sessions.forget?.()`,缺席=无 fallback(B-17 判例:绝不代之以 release)——本店此前无 forget,
|
|
138
|
-
// tidb+cache 形态下运行内冲突自愈失效(暖缓存命中同一 stale 实例→重试预算耗尽→该 run 以 conflict 败;
|
|
139
|
-
// runs.ts evictIfConflict 只兜 run 后)。补齐=evict 本地缓存 + 转发 inner 可选面(fork-routing 店同款)。
|
|
140
68
|
this.forget = (sessionId) => {
|
|
141
69
|
this.evict(sessionId);
|
|
142
70
|
return inner.forget?.(sessionId);
|
|
143
71
|
};
|
|
144
72
|
if (ownerAware.importEntries) {
|
|
145
|
-
// An import writes durable state under `sessionId`; if a stale handle for that id is warm, drop it so the
|
|
146
|
-
// next acquire re-wakes from the freshly-imported durable log (mirrors the deleteSession evict discipline).
|
|
147
73
|
const imp = ownerAware.importEntries.bind(inner);
|
|
148
74
|
this.importEntries = async (sessionId, owner, entries) => {
|
|
149
75
|
await imp(sessionId, owner, entries);
|
|
150
76
|
if (this.cache.has(sessionId))
|
|
151
|
-
opts.onConflictEvict?.(sessionId);
|
|
77
|
+
opts.onConflictEvict?.(sessionId);
|
|
152
78
|
this.evict(sessionId);
|
|
153
79
|
};
|
|
154
80
|
}
|
|
155
81
|
if (ownerAware.replaceEntries) {
|
|
156
|
-
// A replace REWRITES durable state under `sessionId` (purge + re-import); evict any warm handle so the next
|
|
157
|
-
// acquire re-wakes from the replaced log (same discipline as importEntries / deleteSession above).
|
|
158
82
|
const rep = ownerAware.replaceEntries.bind(inner);
|
|
159
83
|
this.replaceEntries = async (sessionId, owner, entries) => {
|
|
160
84
|
await rep(sessionId, owner, entries);
|
|
161
85
|
if (this.cache.has(sessionId))
|
|
162
|
-
opts.onConflictEvict?.(sessionId);
|
|
86
|
+
opts.onConflictEvict?.(sessionId);
|
|
163
87
|
this.evict(sessionId);
|
|
164
88
|
};
|
|
165
89
|
}
|
|
166
90
|
if (ownerAware.beginImportStaging) {
|
|
167
|
-
// [2024] staged import(P1d-β)经包装店贯通:handle 逐字段代理,只有 `commit`(唯一写真 id 的时刻)
|
|
168
|
-
// 加了成功后逐出——与上面 importEntries/replaceEntries 完全同款的纪律;abort 不写真 id,不逐出。
|
|
169
91
|
const begin = ownerAware.beginImportStaging.bind(inner);
|
|
170
92
|
this.beginImportStaging = (realSessionId, token) => {
|
|
171
93
|
const h = begin(realSessionId, token);
|
|
@@ -176,7 +98,7 @@ export class CachingSessionStore {
|
|
|
176
98
|
commit: async (owner, o) => {
|
|
177
99
|
const r = await h.commit(owner, o);
|
|
178
100
|
if (this.cache.has(realSessionId))
|
|
179
|
-
opts.onConflictEvict?.(realSessionId);
|
|
101
|
+
opts.onConflictEvict?.(realSessionId);
|
|
180
102
|
this.evict(realSessionId);
|
|
181
103
|
return r;
|
|
182
104
|
},
|
|
@@ -187,8 +109,6 @@ export class CachingSessionStore {
|
|
|
187
109
|
if (ownerAware.sweepStagingSessions)
|
|
188
110
|
this.sweepStagingSessions = ownerAware.sweepStagingSessions.bind(inner);
|
|
189
111
|
if (ownerAware.deleteSession) {
|
|
190
|
-
// A durable delete must also drop the deleted session from THIS warm cache (else a stale cached handle
|
|
191
|
-
// could keep serving a purged session until its idle TTL). Wrap to evict on success.
|
|
192
112
|
const del = ownerAware.deleteSession.bind(inner);
|
|
193
113
|
this.deleteSession = async (sessionId, owner) => {
|
|
194
114
|
const removed = await del(sessionId, owner);
|
|
@@ -210,28 +130,13 @@ export class CachingSessionStore {
|
|
|
210
130
|
return fresh;
|
|
211
131
|
}
|
|
212
132
|
const hit = this.cache.get(sessionId);
|
|
213
|
-
// 🔴 #292 义务 6(claim 关门)在**暖命中**上的半场:一次 claim 形 acquire 撞上缓存里的 placed 会话,
|
|
214
|
-
// 若按下面的「命中即返回」放行,包装层就成了义务的一个**旁路**——同一条 id 在冷缓存上被拒、在暖
|
|
215
|
-
// 缓存上被接受,而生产默认恰恰是暖的。判据仍吃**持久化元组**(一次 PK 探针,只在声明了分区的内层
|
|
216
|
-
// 店 + 非 requireExisting 的形上付),绝不用缓存里的影子事实当准入依据。
|
|
217
133
|
if (hit && opts?.requireExisting !== true && this.placements !== undefined && this.placementOf !== undefined) {
|
|
218
134
|
assertPlacementAdmission(sessionId, await this.placementOf(sessionId), opts);
|
|
219
135
|
}
|
|
220
136
|
if (hit) {
|
|
221
|
-
// A warm cache hit means the session EXISTS → it satisfies `requireExisting` (no need to re-open the durable
|
|
222
|
-
// log). design/114 Phase3: the fail-loud only ever fires on a genuinely-missing (uncached) session below.
|
|
223
|
-
// 🟡 Affinity caveat (doc-as-intentional, LOW): under the REQUIRED session affinity (see the class header), the
|
|
224
|
-
// cached instance is the sole writer, so a warm handle can't be stale w.r.t. a purge — a same-instance E21
|
|
225
|
-
// delete evicts this entry (deleteSession wrapper). Only an out-of-band / cross-instance purge that VIOLATES
|
|
226
|
-
// affinity could leave a stale hit that satisfies requireExisting until the idle TTL expires. Bypassing the
|
|
227
|
-
// cache for strict acquires would add a DB round-trip to EVERY warm-resume (the hot path) to close an
|
|
228
|
-
// affinity-violation-only window — not worth it; the affinity contract already governs cross-instance writes.
|
|
229
137
|
hit.expiresAt = Date.now() + this.ttlMs;
|
|
230
138
|
return hit.acquired;
|
|
231
139
|
}
|
|
232
|
-
// design/114 Phase3 (F1): a `requireExisting` acquire can REJECT (not_found) and never creates — it MUST bypass
|
|
233
|
-
// the shared create-dedup `pending`, else a concurrent create-capable waiter would inherit the not_found rejection
|
|
234
|
-
// instead of creating-on-miss. Forward the option to the inner (durable) store, which does the fail-loud.
|
|
235
140
|
if (opts?.requireExisting) {
|
|
236
141
|
const a = await this.inner.acquire(sessionId, opts);
|
|
237
142
|
this.store(a);
|
|
@@ -239,12 +144,6 @@ export class CachingSessionStore {
|
|
|
239
144
|
}
|
|
240
145
|
const inflight = this.pending.get(sessionId);
|
|
241
146
|
if (inflight) {
|
|
242
|
-
// 🔴 #292(codex 对抗复审 R1-[high],验真后修):**in-flight 合并也要逐调用者复判**准入。
|
|
243
|
-
// 病:两个并发调用一冷一后到,后到者直接拿走**首个**调用者的 promise —— 于是
|
|
244
|
-
// · 可信 placement 创建先到 + claim 形后到 ⇒ 后者当场附着到一条 placed 转录上(义务 6 被绕过);
|
|
245
|
-
// · 顺序反过来 ⇒ placement 创建方拿到一只**普通**会话(镜像方向的 squat 判本该拒,却被合并吞掉)。
|
|
246
|
-
// 内层 SQL 店自己有逐调用者复判(它的 pending 分支同款),但**默认生产形是本包装层**,而本层在
|
|
247
|
-
// 到达内层之前就把第二个调用者截断了 —— 判据被一层缓存挡在门外,正是本类反复吃过的那一类亏。
|
|
248
147
|
const acquired = await inflight;
|
|
249
148
|
if (this.placements !== undefined && this.placementOf !== undefined) {
|
|
250
149
|
assertPlacementAdmission(sessionId, await this.placementOf(sessionId), opts);
|
|
@@ -271,7 +170,6 @@ export class CachingSessionStore {
|
|
|
271
170
|
this.cache.delete(sessionId);
|
|
272
171
|
await this.inner.release(sessionId);
|
|
273
172
|
}
|
|
274
|
-
/** Drop a session from the warm cache (e.g. after a cross-instance write conflict). */
|
|
275
173
|
evict(sessionId) {
|
|
276
174
|
this.cache.delete(sessionId);
|
|
277
175
|
}
|