@atlaswork/atlascode 0.1.129 → 0.1.131

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "product": "atlascode",
3
- "version": "0.1.129",
4
- "runtimeSha256": "85e9b293d8cc5b9467c9af84000315badcab88bbd5c34eb6bcc0534e38446b7a",
5
- "executionSha256": "921d0ab7c6084b8d023eea288bfe58e09e1353b9a2ab4a25b719068a60793a96"
3
+ "version": "0.1.130",
4
+ "runtimeSha256": "5710d05618ccfc396ca914195625655e81b279041c587a9d7e190a7ff85be80c",
5
+ "executionSha256": "0fd96bfadfdc26128b8852ef1b94a3018a099a223a5f256f5ef47a576e6ffe6b"
6
6
  }
@@ -31,7 +31,7 @@
31
31
  * 才释放,杜绝 close 竞态下槽位早释的限额绕过)。
32
32
  */
33
33
  import type { WebSessionEvent } from './contract.js';
34
- import type { CursorLedger } from './cursorLedger.js';
34
+ import type { CursorLedger, CursorBinding } from './cursorLedger.js';
35
35
  import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
36
36
  import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
37
37
  /** 投影消息源结构面(engine TranscriptMessage 的结构超集镜像,pack 域零引擎导入)。 */
@@ -62,6 +62,16 @@ export interface FollowDeps {
62
62
  limits: FollowLimits;
63
63
  signal?: AbortSignal;
64
64
  ledger: CursorLedger;
65
+ /**
66
+ * W-FC-1 修形 2(工单 docs/2026-11-28-wfc1-ledger-evict-ticket.md §3 格 2):
67
+ * 活跃 cursor 被账本压力淘汰的 sink 注册/注销面(runtime 持注册表,
68
+ * ledger onActiveEvict 分发后即删)。issue 成功后注册、setTerminal 兜底
69
+ * 注销。inline 类型——零新 export(红线:零新 wire 形/export)。
70
+ */
71
+ evictRouter: {
72
+ register: (token: string, sink: (token: string, binding: CursorBinding) => void) => void;
73
+ unregister: (token: string) => void;
74
+ };
65
75
  /** 引擎 loader 全量基线面(显式 filePath;呈批书 §7.3 钉死形,注入缝)。 */
66
76
  loadFull: (filePath: string) => Promise<{
67
77
  messages: Map<string, ProjectionSourceMessage>;
@@ -24,6 +24,7 @@ export declare const DEFAULT_MAX_PARSE_RECORDS = 100000;
24
24
  export declare const HARD_MAX_PARSE_RECORDS = 500000;
25
25
  export declare const DEFAULT_MAX_PROJECTION_BYTES: number;
26
26
  export declare const HARD_MAX_PROJECTION_BYTES: number;
27
+ export declare const DEFAULT_MAX_FOLLOW_PROJECTION_BYTES: number;
27
28
  export declare const TITLE_HEAD_BYTES: number;
28
29
  /** wire 契约 title ≤512 code points(SessionSummarySchema)——钳制上限。 */
29
30
  export declare const TITLE_MAX_CODE_POINTS = 512;
@@ -1160,6 +1160,9 @@ class CursorLedger {
1160
1160
  this.onActiveEvict = onActiveEvict;
1161
1161
  }
1162
1162
  issue(binding, payloadBytes = 0) {
1163
+ if (payloadBytes > this.maxPayloadBytes) {
1164
+ throw new WebSessionError("resourceLimit", `ledger payload exceeds cap (${payloadBytes} > ${this.maxPayloadBytes} bytes)`);
1165
+ }
1163
1166
  this.evictForInsert(payloadBytes);
1164
1167
  const token = randomUUID();
1165
1168
  this.entries.set(token, {
@@ -1252,6 +1255,7 @@ var DEFAULT_MAX_PARSE_RECORDS = 1e5;
1252
1255
  var HARD_MAX_PARSE_RECORDS = 500000;
1253
1256
  var DEFAULT_MAX_PROJECTION_BYTES = 4 * MIB;
1254
1257
  var HARD_MAX_PROJECTION_BYTES = 16 * MIB;
1258
+ var DEFAULT_MAX_FOLLOW_PROJECTION_BYTES = 16 * MIB;
1255
1259
  var TITLE_HEAD_BYTES = 64 * 1024;
1256
1260
  var TITLE_MAX_CODE_POINTS = 512;
1257
1261
  var TITLE_USER_MESSAGE_CODE_POINTS = 120;
@@ -1261,7 +1265,7 @@ var DEFAULT_MAX_CONCURRENT_READS = 4;
1261
1265
  var HARD_MAX_CONCURRENT_READS = 16;
1262
1266
  var DEFAULT_MAX_PENDING_EVENTS = 8;
1263
1267
  var HARD_MAX_PENDING_EVENTS = 32;
1264
- var DEFAULT_MAX_PENDING_BYTES = 8 * MIB;
1268
+ var DEFAULT_MAX_PENDING_BYTES = 16 * MIB;
1265
1269
  var HARD_MAX_PENDING_BYTES = 32 * MIB;
1266
1270
  var DEFAULT_POLLING_INTERVAL_MS = 1000;
1267
1271
  var HARD_MIN_POLLING_INTERVAL_MS = 100;
@@ -1280,7 +1284,7 @@ var HARD_MIN_CLOSE_DEADLINE_MS = 1;
1280
1284
  var HARD_MAX_CLOSE_DEADLINE_MS = 1e4;
1281
1285
  var DEFAULT_LEDGER_CAPACITY = 128;
1282
1286
  var HARD_MAX_LEDGER_CAPACITY = 1024;
1283
- var DEFAULT_LEDGER_PAYLOAD_BYTES = 16 * MIB;
1287
+ var DEFAULT_LEDGER_PAYLOAD_BYTES = 32 * MIB;
1284
1288
  var HARD_MAX_LEDGER_PAYLOAD_BYTES = 64 * MIB;
1285
1289
  var READ_CHUNK_SIZE = 64 * 1024;
1286
1290
  var PARSE_BATCH_SIZE = 256;
@@ -1494,10 +1498,20 @@ function createFollowSubscription(deps) {
1494
1498
  terminalRank = rank;
1495
1499
  running = false;
1496
1500
  disarmLease();
1497
- for (const t of issuedTokens)
1501
+ for (const t of issuedTokens) {
1498
1502
  ledger.unpin(t);
1503
+ deps.evictRouter.unregister(t);
1504
+ }
1499
1505
  notify();
1500
1506
  }
1507
+ function handleActiveEvict(token, binding) {
1508
+ queueData({
1509
+ ...envelope(deps),
1510
+ kind: "resetRequired",
1511
+ generation: binding.generation,
1512
+ reason: "active cursor evicted (ledger pressure)"
1513
+ });
1514
+ }
1501
1515
  function queueData(ev) {
1502
1516
  if (terminalEvent || finished)
1503
1517
  return;
@@ -1599,19 +1613,29 @@ function createFollowSubscription(deps) {
1599
1613
  setTerminal(errorEvent("resourceLimit", `projection exceeds limit (${bytes} bytes)`));
1600
1614
  return false;
1601
1615
  }
1602
- const cursor = ledger.issue({
1603
- v: 1,
1604
- productId: deps.productId,
1605
- scopeId: deps.scopeId,
1606
- sessionId: deps.sessionId,
1607
- baselineId,
1608
- generation,
1609
- revision,
1610
- byteOffset: offset,
1611
- ino: anchorIno
1612
- }, bytes);
1616
+ let cursor;
1617
+ try {
1618
+ cursor = ledger.issue({
1619
+ v: 1,
1620
+ productId: deps.productId,
1621
+ scopeId: deps.scopeId,
1622
+ sessionId: deps.sessionId,
1623
+ baselineId,
1624
+ generation,
1625
+ revision,
1626
+ byteOffset: offset,
1627
+ ino: anchorIno
1628
+ }, bytes);
1629
+ } catch (e) {
1630
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1631
+ setTerminal(errorEvent("resourceLimit", e.message));
1632
+ return false;
1633
+ }
1634
+ throw e;
1635
+ }
1613
1636
  ledger.pin(cursor);
1614
1637
  issuedTokens.push(cursor);
1638
+ deps.evictRouter.register(cursor, handleActiveEvict);
1615
1639
  queueData({
1616
1640
  ...envelope(deps),
1617
1641
  kind: "baseline",
@@ -1714,19 +1738,29 @@ function createFollowSubscription(deps) {
1714
1738
  return;
1715
1739
  }
1716
1740
  revision++;
1717
- const cursor = ledger.issue({
1718
- v: 1,
1719
- productId: deps.productId,
1720
- scopeId: deps.scopeId,
1721
- sessionId: deps.sessionId,
1722
- baselineId,
1723
- generation,
1724
- revision,
1725
- byteOffset: offset,
1726
- ino: anchorIno
1727
- }, bytes);
1741
+ let cursor;
1742
+ try {
1743
+ cursor = ledger.issue({
1744
+ v: 1,
1745
+ productId: deps.productId,
1746
+ scopeId: deps.scopeId,
1747
+ sessionId: deps.sessionId,
1748
+ baselineId,
1749
+ generation,
1750
+ revision,
1751
+ byteOffset: offset,
1752
+ ino: anchorIno
1753
+ }, bytes);
1754
+ } catch (e) {
1755
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1756
+ setTerminal(errorEvent("resourceLimit", e.message));
1757
+ return;
1758
+ }
1759
+ throw e;
1760
+ }
1728
1761
  ledger.pin(cursor);
1729
1762
  issuedTokens.push(cursor);
1763
+ deps.evictRouter.register(cursor, handleActiveEvict);
1730
1764
  queueData({
1731
1765
  ...envelope(deps),
1732
1766
  kind: "replacement",
@@ -2688,7 +2722,12 @@ function createReadonlySessionRuntime(options) {
2688
2722
  let state = "idle";
2689
2723
  const subscriptions = new Set;
2690
2724
  let activeReads = 0;
2691
- const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes);
2725
+ const evictSinks = new Map;
2726
+ const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes, (token, binding) => {
2727
+ const sink = evictSinks.get(token);
2728
+ evictSinks.delete(token);
2729
+ sink?.(token, binding);
2730
+ });
2692
2731
  function assertStarted(operation) {
2693
2732
  if (state === "idle") {
2694
2733
  throw new WebSessionError("closed", "not started");
@@ -2948,12 +2987,20 @@ function createReadonlySessionRuntime(options) {
2948
2987
  idleLeaseMs: L.idleLeaseMs,
2949
2988
  pendingEvents: L.maxPendingEvents,
2950
2989
  pendingBytes: L.maxPendingBytes,
2951
- maxProjectionBytes: L.maxProjectionBytes,
2990
+ maxProjectionBytes: options.limits?.maxProjectionBytes ?? DEFAULT_MAX_FOLLOW_PROJECTION_BYTES,
2952
2991
  maxRecordBytes: L.maxRecordBytes,
2953
2992
  maxTranscriptBytes: L.maxTranscriptBytes
2954
2993
  },
2955
2994
  signal,
2956
2995
  ledger: cursorLedger,
2996
+ evictRouter: {
2997
+ register: (token, sink) => {
2998
+ evictSinks.set(token, sink);
2999
+ },
3000
+ unregister: (token) => {
3001
+ evictSinks.delete(token);
3002
+ }
3003
+ },
2957
3004
  loadFull: options.engine.loadTranscriptFull,
2958
3005
  buildConversationChain: options.engine.buildConversationChain,
2959
3006
  resolvePath,
@@ -31,7 +31,7 @@
31
31
  * 才释放,杜绝 close 竞态下槽位早释的限额绕过)。
32
32
  */
33
33
  import type { WebSessionEvent } from './contract.js';
34
- import type { CursorLedger } from './cursorLedger.js';
34
+ import type { CursorLedger, CursorBinding } from './cursorLedger.js';
35
35
  import type { SessionStoreAdapter } from './sessionStoreAdapter.js';
36
36
  import { type ProjectionEngineDeps, type ProjectionSourceMessage } from './projection.js';
37
37
  /** 投影消息源结构面(engine TranscriptMessage 的结构超集镜像,pack 域零引擎导入)。 */
@@ -62,6 +62,16 @@ export interface FollowDeps {
62
62
  limits: FollowLimits;
63
63
  signal?: AbortSignal;
64
64
  ledger: CursorLedger;
65
+ /**
66
+ * W-FC-1 修形 2(工单 docs/2026-11-28-wfc1-ledger-evict-ticket.md §3 格 2):
67
+ * 活跃 cursor 被账本压力淘汰的 sink 注册/注销面(runtime 持注册表,
68
+ * ledger onActiveEvict 分发后即删)。issue 成功后注册、setTerminal 兜底
69
+ * 注销。inline 类型——零新 export(红线:零新 wire 形/export)。
70
+ */
71
+ evictRouter: {
72
+ register: (token: string, sink: (token: string, binding: CursorBinding) => void) => void;
73
+ unregister: (token: string) => void;
74
+ };
65
75
  /** 引擎 loader 全量基线面(显式 filePath;呈批书 §7.3 钉死形,注入缝)。 */
66
76
  loadFull: (filePath: string) => Promise<{
67
77
  messages: Map<string, ProjectionSourceMessage>;
@@ -24,6 +24,7 @@ export declare const DEFAULT_MAX_PARSE_RECORDS = 100000;
24
24
  export declare const HARD_MAX_PARSE_RECORDS = 500000;
25
25
  export declare const DEFAULT_MAX_PROJECTION_BYTES: number;
26
26
  export declare const HARD_MAX_PROJECTION_BYTES: number;
27
+ export declare const DEFAULT_MAX_FOLLOW_PROJECTION_BYTES: number;
27
28
  export declare const TITLE_HEAD_BYTES: number;
28
29
  /** wire 契约 title ≤512 code points(SessionSummarySchema)——钳制上限。 */
29
30
  export declare const TITLE_MAX_CODE_POINTS = 512;
@@ -1160,6 +1160,9 @@ class CursorLedger {
1160
1160
  this.onActiveEvict = onActiveEvict;
1161
1161
  }
1162
1162
  issue(binding, payloadBytes = 0) {
1163
+ if (payloadBytes > this.maxPayloadBytes) {
1164
+ throw new WebSessionError("resourceLimit", `ledger payload exceeds cap (${payloadBytes} > ${this.maxPayloadBytes} bytes)`);
1165
+ }
1163
1166
  this.evictForInsert(payloadBytes);
1164
1167
  const token = randomUUID();
1165
1168
  this.entries.set(token, {
@@ -1252,6 +1255,7 @@ var DEFAULT_MAX_PARSE_RECORDS = 1e5;
1252
1255
  var HARD_MAX_PARSE_RECORDS = 500000;
1253
1256
  var DEFAULT_MAX_PROJECTION_BYTES = 4 * MIB;
1254
1257
  var HARD_MAX_PROJECTION_BYTES = 16 * MIB;
1258
+ var DEFAULT_MAX_FOLLOW_PROJECTION_BYTES = 16 * MIB;
1255
1259
  var TITLE_HEAD_BYTES = 64 * 1024;
1256
1260
  var TITLE_MAX_CODE_POINTS = 512;
1257
1261
  var TITLE_USER_MESSAGE_CODE_POINTS = 120;
@@ -1261,7 +1265,7 @@ var DEFAULT_MAX_CONCURRENT_READS = 4;
1261
1265
  var HARD_MAX_CONCURRENT_READS = 16;
1262
1266
  var DEFAULT_MAX_PENDING_EVENTS = 8;
1263
1267
  var HARD_MAX_PENDING_EVENTS = 32;
1264
- var DEFAULT_MAX_PENDING_BYTES = 8 * MIB;
1268
+ var DEFAULT_MAX_PENDING_BYTES = 16 * MIB;
1265
1269
  var HARD_MAX_PENDING_BYTES = 32 * MIB;
1266
1270
  var DEFAULT_POLLING_INTERVAL_MS = 1000;
1267
1271
  var HARD_MIN_POLLING_INTERVAL_MS = 100;
@@ -1280,7 +1284,7 @@ var HARD_MIN_CLOSE_DEADLINE_MS = 1;
1280
1284
  var HARD_MAX_CLOSE_DEADLINE_MS = 1e4;
1281
1285
  var DEFAULT_LEDGER_CAPACITY = 128;
1282
1286
  var HARD_MAX_LEDGER_CAPACITY = 1024;
1283
- var DEFAULT_LEDGER_PAYLOAD_BYTES = 16 * MIB;
1287
+ var DEFAULT_LEDGER_PAYLOAD_BYTES = 32 * MIB;
1284
1288
  var HARD_MAX_LEDGER_PAYLOAD_BYTES = 64 * MIB;
1285
1289
  var READ_CHUNK_SIZE = 64 * 1024;
1286
1290
  var PARSE_BATCH_SIZE = 256;
@@ -1494,10 +1498,20 @@ function createFollowSubscription(deps) {
1494
1498
  terminalRank = rank;
1495
1499
  running = false;
1496
1500
  disarmLease();
1497
- for (const t of issuedTokens)
1501
+ for (const t of issuedTokens) {
1498
1502
  ledger.unpin(t);
1503
+ deps.evictRouter.unregister(t);
1504
+ }
1499
1505
  notify();
1500
1506
  }
1507
+ function handleActiveEvict(token, binding) {
1508
+ queueData({
1509
+ ...envelope(deps),
1510
+ kind: "resetRequired",
1511
+ generation: binding.generation,
1512
+ reason: "active cursor evicted (ledger pressure)"
1513
+ });
1514
+ }
1501
1515
  function queueData(ev) {
1502
1516
  if (terminalEvent || finished)
1503
1517
  return;
@@ -1599,19 +1613,29 @@ function createFollowSubscription(deps) {
1599
1613
  setTerminal(errorEvent("resourceLimit", `projection exceeds limit (${bytes} bytes)`));
1600
1614
  return false;
1601
1615
  }
1602
- const cursor = ledger.issue({
1603
- v: 1,
1604
- productId: deps.productId,
1605
- scopeId: deps.scopeId,
1606
- sessionId: deps.sessionId,
1607
- baselineId,
1608
- generation,
1609
- revision,
1610
- byteOffset: offset,
1611
- ino: anchorIno
1612
- }, bytes);
1616
+ let cursor;
1617
+ try {
1618
+ cursor = ledger.issue({
1619
+ v: 1,
1620
+ productId: deps.productId,
1621
+ scopeId: deps.scopeId,
1622
+ sessionId: deps.sessionId,
1623
+ baselineId,
1624
+ generation,
1625
+ revision,
1626
+ byteOffset: offset,
1627
+ ino: anchorIno
1628
+ }, bytes);
1629
+ } catch (e) {
1630
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1631
+ setTerminal(errorEvent("resourceLimit", e.message));
1632
+ return false;
1633
+ }
1634
+ throw e;
1635
+ }
1613
1636
  ledger.pin(cursor);
1614
1637
  issuedTokens.push(cursor);
1638
+ deps.evictRouter.register(cursor, handleActiveEvict);
1615
1639
  queueData({
1616
1640
  ...envelope(deps),
1617
1641
  kind: "baseline",
@@ -1714,19 +1738,29 @@ function createFollowSubscription(deps) {
1714
1738
  return;
1715
1739
  }
1716
1740
  revision++;
1717
- const cursor = ledger.issue({
1718
- v: 1,
1719
- productId: deps.productId,
1720
- scopeId: deps.scopeId,
1721
- sessionId: deps.sessionId,
1722
- baselineId,
1723
- generation,
1724
- revision,
1725
- byteOffset: offset,
1726
- ino: anchorIno
1727
- }, bytes);
1741
+ let cursor;
1742
+ try {
1743
+ cursor = ledger.issue({
1744
+ v: 1,
1745
+ productId: deps.productId,
1746
+ scopeId: deps.scopeId,
1747
+ sessionId: deps.sessionId,
1748
+ baselineId,
1749
+ generation,
1750
+ revision,
1751
+ byteOffset: offset,
1752
+ ino: anchorIno
1753
+ }, bytes);
1754
+ } catch (e) {
1755
+ if (e instanceof WebSessionError && e.code === "resourceLimit") {
1756
+ setTerminal(errorEvent("resourceLimit", e.message));
1757
+ return;
1758
+ }
1759
+ throw e;
1760
+ }
1728
1761
  ledger.pin(cursor);
1729
1762
  issuedTokens.push(cursor);
1763
+ deps.evictRouter.register(cursor, handleActiveEvict);
1730
1764
  queueData({
1731
1765
  ...envelope(deps),
1732
1766
  kind: "replacement",
@@ -2688,7 +2722,12 @@ function createReadonlySessionRuntime(options) {
2688
2722
  let state = "idle";
2689
2723
  const subscriptions = new Set;
2690
2724
  let activeReads = 0;
2691
- const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes);
2725
+ const evictSinks = new Map;
2726
+ const cursorLedger = new CursorLedger(L.ledgerCapacity, L.cursorTtlMs, L.ledgerPayloadBytes, (token, binding) => {
2727
+ const sink = evictSinks.get(token);
2728
+ evictSinks.delete(token);
2729
+ sink?.(token, binding);
2730
+ });
2692
2731
  function assertStarted(operation) {
2693
2732
  if (state === "idle") {
2694
2733
  throw new WebSessionError("closed", "not started");
@@ -2948,12 +2987,20 @@ function createReadonlySessionRuntime(options) {
2948
2987
  idleLeaseMs: L.idleLeaseMs,
2949
2988
  pendingEvents: L.maxPendingEvents,
2950
2989
  pendingBytes: L.maxPendingBytes,
2951
- maxProjectionBytes: L.maxProjectionBytes,
2990
+ maxProjectionBytes: options.limits?.maxProjectionBytes ?? DEFAULT_MAX_FOLLOW_PROJECTION_BYTES,
2952
2991
  maxRecordBytes: L.maxRecordBytes,
2953
2992
  maxTranscriptBytes: L.maxTranscriptBytes
2954
2993
  },
2955
2994
  signal,
2956
2995
  ledger: cursorLedger,
2996
+ evictRouter: {
2997
+ register: (token, sink) => {
2998
+ evictSinks.set(token, sink);
2999
+ },
3000
+ unregister: (token) => {
3001
+ evictSinks.delete(token);
3002
+ }
3003
+ },
2957
3004
  loadFull: options.engine.loadTranscriptFull,
2958
3005
  buildConversationChain: options.engine.buildConversationChain,
2959
3006
  resolvePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaswork/atlascode",
3
- "version": "0.1.129",
3
+ "version": "0.1.131",
4
4
  "description": "AtlasCode — Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "homepage": "https://www.atlaswork.cn/",
6
6
  "bin": {