agentfootprint 11.0.0 → 11.1.1

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.
Files changed (152) hide show
  1. package/CAPABILITIES.md +2 -0
  2. package/dist/adapters/observability/cloudwatch.js +101 -110
  3. package/dist/adapters/observability/cloudwatch.js.map +1 -1
  4. package/dist/adapters/observability/file.js +48 -71
  5. package/dist/adapters/observability/file.js.map +1 -1
  6. package/dist/adapters/observability/outbox.js +217 -0
  7. package/dist/adapters/observability/outbox.js.map +1 -0
  8. package/dist/adapters/observability/xray.js +56 -70
  9. package/dist/adapters/observability/xray.js.map +1 -1
  10. package/dist/debug.js +5 -3
  11. package/dist/debug.js.map +1 -1
  12. package/dist/esm/adapters/observability/cloudwatch.d.ts +6 -2
  13. package/dist/esm/adapters/observability/cloudwatch.js +101 -110
  14. package/dist/esm/adapters/observability/cloudwatch.js.map +1 -1
  15. package/dist/esm/adapters/observability/file.d.ts +8 -4
  16. package/dist/esm/adapters/observability/file.js +48 -71
  17. package/dist/esm/adapters/observability/file.js.map +1 -1
  18. package/dist/esm/adapters/observability/outbox.d.ts +104 -0
  19. package/dist/esm/adapters/observability/outbox.js +213 -0
  20. package/dist/esm/adapters/observability/outbox.js.map +1 -0
  21. package/dist/esm/adapters/observability/xray.js +56 -70
  22. package/dist/esm/adapters/observability/xray.js.map +1 -1
  23. package/dist/esm/debug.d.ts +1 -1
  24. package/dist/esm/debug.js +1 -1
  25. package/dist/esm/debug.js.map +1 -1
  26. package/dist/esm/lib/boundedJson.d.ts +1 -1
  27. package/dist/esm/lib/boundedJson.js +4 -2
  28. package/dist/esm/lib/boundedJson.js.map +1 -1
  29. package/dist/esm/trace-toolpack/causeCapture.d.ts +5 -2
  30. package/dist/esm/trace-toolpack/causeCapture.js +32 -18
  31. package/dist/esm/trace-toolpack/causeCapture.js.map +1 -1
  32. package/dist/esm/trace-toolpack/causeContext.d.ts +14 -0
  33. package/dist/esm/trace-toolpack/causeContext.js +14 -0
  34. package/dist/esm/trace-toolpack/causeContext.js.map +1 -0
  35. package/dist/esm/trace-toolpack/causeProjection.d.ts +17 -0
  36. package/dist/esm/trace-toolpack/causeProjection.js +72 -0
  37. package/dist/esm/trace-toolpack/causeProjection.js.map +1 -0
  38. package/dist/esm/trace-toolpack/causeReader.d.ts +2 -3
  39. package/dist/esm/trace-toolpack/causeReader.js +21 -13
  40. package/dist/esm/trace-toolpack/causeReader.js.map +1 -1
  41. package/dist/esm/trace-toolpack/causeResponse.d.ts +5 -2
  42. package/dist/esm/trace-toolpack/causeResponse.js +26 -9
  43. package/dist/esm/trace-toolpack/causeResponse.js.map +1 -1
  44. package/dist/esm/trace-toolpack/causeSnapshot.d.ts +2 -8
  45. package/dist/esm/trace-toolpack/causeSnapshot.js +3 -63
  46. package/dist/esm/trace-toolpack/causeSnapshot.js.map +1 -1
  47. package/dist/esm/trace-toolpack/causeTools.d.ts +8 -1
  48. package/dist/esm/trace-toolpack/causeTools.js +33 -10
  49. package/dist/esm/trace-toolpack/causeTools.js.map +1 -1
  50. package/dist/esm/trace-toolpack/index.d.ts +3 -0
  51. package/dist/esm/trace-toolpack/index.js +2 -0
  52. package/dist/esm/trace-toolpack/index.js.map +1 -1
  53. package/dist/esm/trace-toolpack/storedCause.d.ts +8 -0
  54. package/dist/esm/trace-toolpack/storedCause.js +58 -0
  55. package/dist/esm/trace-toolpack/storedCause.js.map +1 -0
  56. package/dist/esm/trace-toolpack/storedCauseBinding.d.ts +16 -0
  57. package/dist/esm/trace-toolpack/storedCauseBinding.js +50 -0
  58. package/dist/esm/trace-toolpack/storedCauseBinding.js.map +1 -0
  59. package/dist/esm/trace-toolpack/storedCauseOptions.d.ts +5 -0
  60. package/dist/esm/trace-toolpack/storedCauseOptions.js +53 -0
  61. package/dist/esm/trace-toolpack/storedCauseOptions.js.map +1 -0
  62. package/dist/esm/trace-toolpack/storedCauseProjection.d.ts +3 -0
  63. package/dist/esm/trace-toolpack/storedCauseProjection.js +117 -0
  64. package/dist/esm/trace-toolpack/storedCauseProjection.js.map +1 -0
  65. package/dist/esm/trace-toolpack/storedCauseReader.d.ts +3 -0
  66. package/dist/esm/trace-toolpack/storedCauseReader.js +9 -0
  67. package/dist/esm/trace-toolpack/storedCauseReader.js.map +1 -0
  68. package/dist/esm/trace-toolpack/storedCauseSources.d.ts +8 -0
  69. package/dist/esm/trace-toolpack/storedCauseSources.js +28 -0
  70. package/dist/esm/trace-toolpack/storedCauseSources.js.map +1 -0
  71. package/dist/esm/trace-toolpack/storedCauseTypes.d.ts +48 -0
  72. package/dist/esm/trace-toolpack/storedCauseTypes.js +2 -0
  73. package/dist/esm/trace-toolpack/storedCauseTypes.js.map +1 -0
  74. package/dist/esm/trace-toolpack/traceToolpack.js +18 -0
  75. package/dist/esm/trace-toolpack/traceToolpack.js.map +1 -1
  76. package/dist/lib/boundedJson.js +4 -2
  77. package/dist/lib/boundedJson.js.map +1 -1
  78. package/dist/trace-toolpack/causeCapture.js +35 -20
  79. package/dist/trace-toolpack/causeCapture.js.map +1 -1
  80. package/dist/trace-toolpack/causeContext.js +18 -0
  81. package/dist/trace-toolpack/causeContext.js.map +1 -0
  82. package/dist/trace-toolpack/causeProjection.js +76 -0
  83. package/dist/trace-toolpack/causeProjection.js.map +1 -0
  84. package/dist/trace-toolpack/causeReader.js +21 -13
  85. package/dist/trace-toolpack/causeReader.js.map +1 -1
  86. package/dist/trace-toolpack/causeResponse.js +26 -9
  87. package/dist/trace-toolpack/causeResponse.js.map +1 -1
  88. package/dist/trace-toolpack/causeSnapshot.js +3 -63
  89. package/dist/trace-toolpack/causeSnapshot.js.map +1 -1
  90. package/dist/trace-toolpack/causeTools.js +36 -12
  91. package/dist/trace-toolpack/causeTools.js.map +1 -1
  92. package/dist/trace-toolpack/index.js +5 -1
  93. package/dist/trace-toolpack/index.js.map +1 -1
  94. package/dist/trace-toolpack/storedCause.js +85 -0
  95. package/dist/trace-toolpack/storedCause.js.map +1 -0
  96. package/dist/trace-toolpack/storedCauseBinding.js +55 -0
  97. package/dist/trace-toolpack/storedCauseBinding.js.map +1 -0
  98. package/dist/trace-toolpack/storedCauseOptions.js +58 -0
  99. package/dist/trace-toolpack/storedCauseOptions.js.map +1 -0
  100. package/dist/trace-toolpack/storedCauseProjection.js +121 -0
  101. package/dist/trace-toolpack/storedCauseProjection.js.map +1 -0
  102. package/dist/trace-toolpack/storedCauseReader.js +35 -0
  103. package/dist/trace-toolpack/storedCauseReader.js.map +1 -0
  104. package/dist/trace-toolpack/storedCauseSources.js +32 -0
  105. package/dist/trace-toolpack/storedCauseSources.js.map +1 -0
  106. package/dist/trace-toolpack/storedCauseTypes.js +3 -0
  107. package/dist/trace-toolpack/storedCauseTypes.js.map +1 -0
  108. package/dist/trace-toolpack/traceToolpack.js +18 -0
  109. package/dist/trace-toolpack/traceToolpack.js.map +1 -1
  110. package/dist/types/adapters/observability/cloudwatch.d.ts +6 -2
  111. package/dist/types/adapters/observability/cloudwatch.d.ts.map +1 -1
  112. package/dist/types/adapters/observability/file.d.ts +8 -4
  113. package/dist/types/adapters/observability/file.d.ts.map +1 -1
  114. package/dist/types/adapters/observability/outbox.d.ts +105 -0
  115. package/dist/types/adapters/observability/outbox.d.ts.map +1 -0
  116. package/dist/types/adapters/observability/xray.d.ts.map +1 -1
  117. package/dist/types/debug.d.ts +1 -1
  118. package/dist/types/debug.d.ts.map +1 -1
  119. package/dist/types/lib/boundedJson.d.ts +1 -1
  120. package/dist/types/lib/boundedJson.d.ts.map +1 -1
  121. package/dist/types/trace-toolpack/causeCapture.d.ts +5 -2
  122. package/dist/types/trace-toolpack/causeCapture.d.ts.map +1 -1
  123. package/dist/types/trace-toolpack/causeContext.d.ts +15 -0
  124. package/dist/types/trace-toolpack/causeContext.d.ts.map +1 -0
  125. package/dist/types/trace-toolpack/causeProjection.d.ts +18 -0
  126. package/dist/types/trace-toolpack/causeProjection.d.ts.map +1 -0
  127. package/dist/types/trace-toolpack/causeReader.d.ts +2 -3
  128. package/dist/types/trace-toolpack/causeReader.d.ts.map +1 -1
  129. package/dist/types/trace-toolpack/causeResponse.d.ts +5 -2
  130. package/dist/types/trace-toolpack/causeResponse.d.ts.map +1 -1
  131. package/dist/types/trace-toolpack/causeSnapshot.d.ts +2 -8
  132. package/dist/types/trace-toolpack/causeSnapshot.d.ts.map +1 -1
  133. package/dist/types/trace-toolpack/causeTools.d.ts +8 -1
  134. package/dist/types/trace-toolpack/causeTools.d.ts.map +1 -1
  135. package/dist/types/trace-toolpack/index.d.ts +3 -0
  136. package/dist/types/trace-toolpack/index.d.ts.map +1 -1
  137. package/dist/types/trace-toolpack/storedCause.d.ts +9 -0
  138. package/dist/types/trace-toolpack/storedCause.d.ts.map +1 -0
  139. package/dist/types/trace-toolpack/storedCauseBinding.d.ts +17 -0
  140. package/dist/types/trace-toolpack/storedCauseBinding.d.ts.map +1 -0
  141. package/dist/types/trace-toolpack/storedCauseOptions.d.ts +6 -0
  142. package/dist/types/trace-toolpack/storedCauseOptions.d.ts.map +1 -0
  143. package/dist/types/trace-toolpack/storedCauseProjection.d.ts +4 -0
  144. package/dist/types/trace-toolpack/storedCauseProjection.d.ts.map +1 -0
  145. package/dist/types/trace-toolpack/storedCauseReader.d.ts +4 -0
  146. package/dist/types/trace-toolpack/storedCauseReader.d.ts.map +1 -0
  147. package/dist/types/trace-toolpack/storedCauseSources.d.ts +9 -0
  148. package/dist/types/trace-toolpack/storedCauseSources.d.ts.map +1 -0
  149. package/dist/types/trace-toolpack/storedCauseTypes.d.ts +49 -0
  150. package/dist/types/trace-toolpack/storedCauseTypes.d.ts.map +1 -0
  151. package/dist/types/trace-toolpack/traceToolpack.d.ts.map +1 -1
  152. package/package.json +3 -3
package/CAPABILITIES.md CHANGED
@@ -99,9 +99,11 @@ not in this table, search `src/index.ts` for the nearest noun before writing cod
99
99
  | asking a debugging model "what did this run contradict itself about, and why?" — the Context Integrity findings, joined to the step that filed them | `find_context_errors` | `src/trace-toolpack/traceToolpack.ts` | 9.61.0 |
100
100
  | reading abnormal nodes, recorded dependency roots and downstream impact with bounded public Foottrace queries, scoped proof IDs and explicit unknown coverage; optional host-authorized storage graph, including inner tool and subflow questions | `attention_list` / `root_cause` / `impact` + `TraceToolpackArtifacts.cause` + `TraceToolpackOptions.cause` | `src/trace-toolpack/causeTools.ts` | 10.7.0 |
101
101
  | admitting a completed native root-log capture for read-only cause tools without a custom graph; partial, legacy, child and resumed coverage stays uncertain with fixed reasons | `assessCapture` | `src/trace-toolpack/causeCapture.ts` | 10.10.0 |
102
+ | loading one authorized, acknowledged saved root history and asking the existing bounded cause questions without a synthetic snapshot; separate native/storage assessments, privately bound graph identity, missing-value observations preserved; unproven source ownership stays unknown | `readStoredCauseArtifacts` + `traceCauseTools` (`/observe`) | `src/trace-toolpack/storedCause.ts` | 11.1.0 |
102
103
  | the model inventing an id or a reading that no tool ever returned — a deterministic fabrication detector on the final answer, with a posture for how hard it pushes back | `.namesAndNumbersFromEvidence()` + `posture` (`'assist'` record+flag, the default / `'guard'` one revision then ship flagged / `'rails'` refuse instead) + `shapes` + `exempt` + `minDigits` (default 4) + `nudge` (default off) | `src/core/agent/evidence/` | 9.35.0 |
103
104
  | plain decimal readings honestly rounded at the written precision (opt-in; one carried number only, no new unitless arithmetic), and exactly-two numeric range endpoints checked after declared ID shapes; short bare endpoints retain minDigits | `AgentBuilder.namesAndNumbersFromEvidence` + `NamesAndNumbersOptions` + `EvidenceVerdict` + `ComputedFigure` | `src/core/agent/evidence/` | 10.8.0 |
104
105
  | counting a HUMAN-VERIFIED value as ground for the choice-seam check — the person clicked a row, the app verified the cells against the artifact, and the id the model takes from that selection is not fabricated; the source label travels onto the record | `externalGrounds` + `ExternalGround` + `external_ground_used` | `src/integrity/unsupported-argument/check.ts` | 9.72.0 |
106
+ | following exact read versions in an acknowledged saved root history using independently collected native namespace and invocation ownership; missing ownership stays unknown, partial capture keeps gaps, and recorded reads never prove output derivation | `readStoredCauseArtifacts` + `traceCauseTools` (`/observe`) | `src/trace-toolpack/storedCause.ts` | 11.1.0 |
105
107
  | a lookup tool that answers "nothing found" for EVERY id because a filter broke, and an agent reporting that absence as fact — the run itself produced the id, the lookup came back empty, and that PAIR is worth a look | `noticeEmptyLookups` + `readLookupResult` + `EMPTY_LOOKUP_CEILING` (dial default OFF and needs a tool declaring `argumentsFrom` too — two halves; kind `empty-lookup` at seam `write`, always `advisory: true`; empty = a zero-length ARRAY or an `absent()` envelope, every other shape files `not-applicable` and no finding; the ceiling is quoted verbatim into every message) | `src/integrity/empty-lookup/` | 9.77.0 |
106
108
  | an agent answering a NEW question out of an OLD turn's tool results — grounded, four turns stale, and the evidence gate approving it (`Tool calls 0` and "all 7 values were found in what the tools returned"). ALSO the bug half: the gate's two sentences claimed the flagged values "appear in no tool result FROM THIS TURN" while its index walked every `role:'tool'` turn — a boundary asserted and never measured; both now say "no tool result this run read" | `noticePriorTurnEvidence` + `PRIOR_TURN_EVIDENCE_CEILING` + `priorTurnEvidenceOf` + `AnswerGroundingReading` (dial default OFF and needs `.namesAndNumbersFromEvidence()` too — two halves, and the second is structural: the gate owns the extractor that decides which tokens are values; kind `prior-turn-evidence` at seam `claim`, always `advisory: true`; `EvidenceCorpus.values` became a `Map<form, turn>` stamped in the walk that was already happening, a TURN = each `role:'user'` message `isLibraryAuthoredTurn` did NOT write (counting the gate's own correction would file against every revised answer); fires when ≥1 value is grounded and NOT ONE came from the turn being answered — ONE current-turn value files nothing, which is what keeps an honest follow-up quiet and is the design's falsification test; the zero-tool-call turn is the SAME kind with a stronger witness, not a second kind; corpus is the LIVE WINDOW so ordinals are window-relative and the distance is a FLOOR, while the boundary stays exact (`'current-request'` is un-droppable); memory/RAG values are exempt from grounding and invisible — it can under-report, never over-report; the ceiling is quoted verbatim into every message) | `src/integrity/prior-turn-evidence/` | 9.83.0 |
107
109
  | a tool's ROWS quietly disagreeing with what the tool promised — a LUN 0 stored as `""` because it is falsy, a numeric column arriving as quoted strings, a declared column present in no row at all | `Tool.resultColumns` + `checkColumnTypes` + `COLUMN_TYPE_CEILING` + `readRowset` (dial `'off'` (default) / `'warn'` (file findings, model reads the rows unchanged) / `'enforce'` (refuse the rows, `resultCeiling`'s teaching-sentence idiom, delivered status `'invalid'`) — the `toolArgsValidation` trio, this seam's mirror; needs a tool declaring `resultColumns` too — two halves; types `number`/`string`/`boolean`/`date`, bare word or `{type, nullable}`, deliberately NO `'unknown'`; OPEN — unlisted columns allowed and unjudged; TWO kinds at seam `write` — `column-type-mismatch` (there, wrong type) vs `missing-column` (declared, in no row); rowset = an ARRAY OF PLAIN OBJECTS with ≥1 row, everything else incl. the ZERO-ROW result files `not-applicable` (empty is `empty-lookup`'s subject); travels MCP `_meta`; the ceiling is quoted verbatim into every message) | `src/integrity/column-types/` | 9.78.0 |
@@ -44,6 +44,23 @@ exports.cloudwatchObservability = exports._buildCloudWatchObservability = void 0
44
44
  const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
45
45
  const wireJson_js_1 = require("../../lib/wireJson.js");
46
46
  const deliveryErrors_js_1 = require("./deliveryErrors.js");
47
+ const outbox_js_1 = require("./outbox.js");
48
+ /**
49
+ * What ONE `PutLogEvents` request may carry — CloudWatch Logs' documented
50
+ * per-request limits (PutLogEvents API reference): "The maximum number of log
51
+ * events in a batch is 10,000", and "The maximum batch size is 1,048,576
52
+ * bytes. This size is calculated as the sum of all event messages in UTF-8,
53
+ * plus 26 bytes for each log event."
54
+ *
55
+ * These split a delivery into legal requests; they are NOT triggers.
56
+ * `maxBatchEvents` / `maxBatchBytes` still decide when a delivery starts,
57
+ * exactly as before. The split matters because puts now go one at a time
58
+ * (#223): a slow put lets a backlog build behind it, and without the split
59
+ * the next delivery sent the whole backlog as one request CloudWatch refuses.
60
+ */
61
+ const PUT_LOG_EVENTS_MAX_EVENTS = 10_000;
62
+ const PUT_LOG_EVENTS_MAX_BYTES = 1_048_576;
63
+ const PUT_LOG_EVENTS_BYTES_PER_EVENT = 26;
47
64
  // ─── Generic base — also used by agentcoreObservability ──────────────
48
65
  /**
49
66
  * Internal: shared CloudWatch Logs base used by every adapter that
@@ -65,11 +82,8 @@ function _buildCloudWatchObservability(opts, strategyName) {
65
82
  const maxBatchEvents = opts.maxBatchEvents ?? 100;
66
83
  const maxBatchBytes = opts.maxBatchBytes ?? 10_240;
67
84
  const flushIntervalMs = opts.flushIntervalMs ?? 1000;
68
- // Buffered batch — drained by `flush()` / size-trigger / time-trigger.
69
- const buffer = [];
70
- let bufferBytes = 0;
71
- let lastFlushPromise = Promise.resolve();
72
- let timer;
85
+ // Set by `stop()`: no more events accepted. NOT a guard on delivery (8.11.1):
86
+ // stopping does not authorise throwing away what was already accepted.
73
87
  let stopped = false;
74
88
  // What we know about the log stream (8.11.0). This is the per-(group,stream)
75
89
  // create latch — group and stream are fixed for the life of a strategy, so
@@ -94,14 +108,6 @@ function _buildCloudWatchObservability(opts, strategyName) {
94
108
  client = createCloudWatchClient(opts.region, strategyName, opts._sdk);
95
109
  return client;
96
110
  }
97
- function scheduleTimedFlush() {
98
- if (timer || flushIntervalMs <= 0 || stopped)
99
- return;
100
- timer = setTimeout(() => {
101
- timer = undefined;
102
- void doFlush();
103
- }, flushIntervalMs);
104
- }
105
111
  /** Route a delivery failure through whatever `_onError` IS RIGHT NOW.
106
112
  * Reading it at call time (rather than capturing a hook at construction)
107
113
  * is the whole fix: a consumer who assigns `_onError` after building the
@@ -117,90 +123,89 @@ function _buildCloudWatchObservability(opts, strategyName) {
117
123
  logEvents: batch,
118
124
  });
119
125
  }
120
- async function doFlush() {
121
- // `stopped` is deliberately NOT a guard here (8.11.1). `stop()` stops this
122
- // strategy ACCEPTING events and cancels its timer; it does not authorise
123
- // throwing away events already accepted. Guarding here made `flush()`
124
- // after `stop()` unable to make progress while its loop waited for
125
- // progress — an infinite microtask spin that starved the event loop of
126
- // the very process trying to shut down. Same stance as `auditExport`:
127
- // stop observing, never destroy what was collected.
128
- if (buffer.length === 0)
129
- return;
130
- // Snapshot + clear so concurrent emits during the in-flight put
131
- // accumulate into the next batch.
132
- const batch = buffer.splice(0);
133
- bufferBytes = 0;
126
+ /** Ship one batch. Throws when it could not — the outbox drops the batch
127
+ * and reports it once. Runs inside the outbox's queue, so two puts are
128
+ * never in flight at once and CloudWatch's per-stream order holds. */
129
+ async function shipBatch(batch) {
130
+ const client = ensureClient();
134
131
  try {
135
- const client = ensureClient();
136
- try {
137
- await putBatch(client, batch);
138
- streamState = 'created'; // a successful put proves the stream is there
139
- return;
140
- }
141
- catch (err) {
142
- // The one recoverable shape: CloudWatch rejects a put into a stream
143
- // that doesn't exist. Before 8.11.0 this adapter asserted that
144
- // precondition and never established it, so any stream name that
145
- // didn't already exist dropped every event, forever, in silence —
146
- // and the documented `${HOSTNAME}/${Date.now()}` convention can never
147
- // pre-exist, so following the docs guaranteed the bug.
148
- if (!isMissingStreamError(err) || streamState === 'unavailable')
149
- throw err;
150
- if (!client.createLogStream) {
151
- throw new Error(`log stream '${logStreamName}' does not exist in log group ` +
152
- `'${opts.logGroupName}', and the injected \`_client\` has no ` +
153
- `\`createLogStream\` to create it.`);
154
- }
155
- try {
156
- await client.createLogStream({
157
- logGroupName: opts.logGroupName,
158
- logStreamName,
159
- });
160
- }
161
- catch (createErr) {
162
- // Two processes racing to create the same stream is normal and
163
- // expected — whoever lost the race still has a usable stream.
164
- if (!isAlreadyExistsError(createErr)) {
165
- // Anything else (no `logs:CreateLogStream`, or the log GROUP
166
- // itself is missing) will not fix itself. Latch it off so we
167
- // never loop, and say which of the two it probably is.
168
- streamState = 'unavailable';
169
- throw new Error(`could not create log stream '${logStreamName}' in log group ` +
170
- `'${opts.logGroupName}': ${errorMessage(createErr)}. Check that the log ` +
171
- `GROUP exists (this adapter never creates one) and that the role allows ` +
172
- `\`logs:CreateLogStream\`.`);
173
- }
174
- }
175
- streamState = 'created';
176
- // Exactly ONE re-put of the same batch. Not a retry loop: if this
177
- // fails the events are gone, and saying so is better than growing a
178
- // buffer during an outage.
179
- await putBatch(client, batch);
180
- }
132
+ await putBatch(client, batch);
133
+ streamState = 'created'; // a successful put proves the stream is there
181
134
  }
182
135
  catch (err) {
183
- const cause = errorMessage(err);
184
- reportFailure(new Error(`${batch.length} event(s) dropped shipping to log group '${opts.logGroupName}' ` +
185
- `stream '${logStreamName}': ${cause}`));
136
+ // The one recoverable shape: CloudWatch rejects a put into a stream
137
+ // that doesn't exist. Before 8.11.0 this adapter asserted that
138
+ // precondition and never established it, so any stream name that
139
+ // didn't already exist dropped every event, forever, in silence —
140
+ // and the documented `${HOSTNAME}/${Date.now()}` convention can never
141
+ // pre-exist, so following the docs guaranteed the bug.
142
+ if (!isMissingStreamError(err) || streamState === 'unavailable')
143
+ throw err;
144
+ await createStream(client);
145
+ // Exactly ONE re-put of the same batch. Not a retry loop: if this
146
+ // fails the events are gone, and saying so is better than growing a
147
+ // buffer during an outage.
148
+ await putBatch(client, batch);
186
149
  }
187
150
  }
151
+ /** Create the missing stream, or latch it off for good when retrying cannot
152
+ * help. Losing a create race to another process is success. */
153
+ async function createStream(client) {
154
+ if (!client.createLogStream) {
155
+ throw new Error(`log stream '${logStreamName}' does not exist in log group ` +
156
+ `'${opts.logGroupName}', and the injected \`_client\` has no ` +
157
+ `\`createLogStream\` to create it.`);
158
+ }
159
+ try {
160
+ await client.createLogStream({ logGroupName: opts.logGroupName, logStreamName });
161
+ }
162
+ catch (createErr) {
163
+ // Two processes racing to create the same stream is normal and
164
+ // expected — whoever lost the race still has a usable stream.
165
+ if (!isAlreadyExistsError(createErr)) {
166
+ // Anything else (no `logs:CreateLogStream`, or the log GROUP itself is
167
+ // missing) will not fix itself. Latch it off so we never loop, and say
168
+ // which of the two it probably is.
169
+ streamState = 'unavailable';
170
+ throw new Error(`could not create log stream '${logStreamName}' in log group ` +
171
+ `'${opts.logGroupName}': ${errorMessage(createErr)}. Check that the log ` +
172
+ `GROUP exists (this adapter never creates one) and that the role allows ` +
173
+ `\`logs:CreateLogStream\`.`);
174
+ }
175
+ }
176
+ streamState = 'created';
177
+ }
178
+ // Buffered log events, and the one queue every put goes through — size
179
+ // trigger, timer, `flush()`, shutdown (outbox.ts; #223).
180
+ const outbox = (0, outbox_js_1.createOutbox)({
181
+ name: strategyName,
182
+ // When a delivery starts — compared as given, as before.
183
+ maxItems: maxBatchEvents,
184
+ maxBytes: maxBatchBytes,
185
+ // What one put may carry: the oldest events that fit; the rest ship in
186
+ // the next put, right after, in order. The byte measure is the one `add`
187
+ // records (UTF-8 message bytes) plus CloudWatch's 26 per event. An event
188
+ // too large for any request is still sent — alone — as it was before;
189
+ // CloudWatch refuses it and that one event is reported dropped, without
190
+ // taking its neighbours with it.
191
+ maxItemsPerDelivery: PUT_LOG_EVENTS_MAX_EVENTS,
192
+ maxBytesPerDelivery: PUT_LOG_EVENTS_MAX_BYTES,
193
+ overheadBytesPerItem: PUT_LOG_EVENTS_BYTES_PER_EVENT,
194
+ flushIntervalMs,
195
+ // An un-stopped strategy lingers up to `flushIntervalMs` so the timer can
196
+ // still ship the tail (see `stop()`).
197
+ timerHoldsProcess: true,
198
+ deliver: shipBatch,
199
+ dropped: (batch, cause) => new Error(`${batch.length} event(s) dropped shipping to log group '${opts.logGroupName}' ` +
200
+ `stream '${logStreamName}': ${errorMessage(cause)}`),
201
+ report: reportFailure,
202
+ });
188
203
  function enqueue(event) {
189
204
  if (stopped)
190
205
  return;
191
206
  // The wire rule (`lib/wireJson.ts`) — an Error's custom properties never ship.
192
207
  const message = (0, wireJson_js_1.toWireJson)(event);
193
- const bytes = Buffer.byteLength(message, 'utf8');
194
- buffer.push({ timestamp: Date.now(), message });
195
- bufferBytes += bytes;
196
- if (buffer.length >= maxBatchEvents || bufferBytes >= maxBatchBytes) {
197
- // Size trigger — flush immediately. Chain onto last to preserve
198
- // CloudWatch's per-stream ordering requirement.
199
- lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
200
- }
201
- else {
202
- scheduleTimedFlush();
203
- }
208
+ outbox.add({ timestamp: Date.now(), message }, Buffer.byteLength(message, 'utf8'));
204
209
  }
205
210
  const strategy = {
206
211
  name: strategyName,
@@ -221,25 +226,14 @@ function _buildCloudWatchObservability(opts, strategyName) {
221
226
  * since 8.11.1: a flush after a stop still ships what was already
222
227
  * accepted.
223
228
  */
224
- async flush() {
225
- // BOUNDED BY CONSTRUCTION. Every pass must remove at least one buffered
226
- // event; a pass that removes none ends the drain instead of trying
227
- // again. The previous shape looped `while (buffer.length > 0)` and
228
- // trusted `doFlush()` to make progress — which it stopped doing once
229
- // `stop()` had been called, turning shutdown into an infinite microtask
230
- // spin (no timer could fire, no deadline could expire, 100% of a core).
231
- // A drain that cannot finish must return, never retry forever.
232
- for (;;) {
233
- const pending = buffer.length;
234
- // Chain, never replace: CloudWatch requires per-stream ordering, so a
235
- // drain waits for the in-flight put rather than racing it.
236
- lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
237
- await lastFlushPromise;
238
- if (buffer.length === 0)
239
- return;
240
- if (buffer.length >= pending)
241
- return;
242
- }
229
+ flush() {
230
+ // Resolves once every event accepted before the call is shipped (or
231
+ // dropped and reported) — one a timed put already had in flight
232
+ // included — after one more sweep of what arrived while it waited; it
233
+ // does not chase a producer that keeps emitting. A put that never
234
+ // settles holds it. Since 8.11.1 delivery ignores `stop()`, so a flush
235
+ // after a stop still ships and never spins.
236
+ return outbox.drain();
243
237
  },
244
238
  /** Stop the flush timer and stop accepting events. **The framework does
245
239
  * not call this for you** — an un-stopped strategy keeps a `setTimeout`
@@ -251,10 +245,7 @@ function _buildCloudWatchObservability(opts, strategyName) {
251
245
  * `stop()` still ships it (8.11.1). */
252
246
  stop() {
253
247
  stopped = true;
254
- if (timer) {
255
- clearTimeout(timer);
256
- timer = undefined;
257
- }
248
+ outbox.stop();
258
249
  },
259
250
  /**
260
251
  * Where errors go. Two callers: the dispatch layer (when `exportEvent`
@@ -1 +1 @@
1
- {"version":3,"file":"cloudwatch.js","sourceRoot":"","sources":["../../../src/adapters/observability/cloudwatch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IAEF,MAAM,sBAAsB,GAAG,GAAG,CAAC,sBAAsB,CAAC;IAE1D,OAAO;QACL,KAAK,CAAC,YAAY,CAAC,KAAK;YACtB,6DAA6D;YAC7D,kEAAkE;YAClE,MAAM,GAAG,GAAG,IAAK,GAAG,CAAC,mBAAmD,CAAC,KAAK,CAAC,CAAC;YAChF,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5B,CAAC;QACD,oEAAoE;QACpE,sEAAsE;QACtE,yDAAyD;QACzD,GAAG,CAAC,sBAAsB,IAAI;YAC5B,KAAK,CAAC,eAAe,CAAC,KAAsD;gBAC1E,MAAM,GAAG,GAAG,IAAK,sBAAsD,CAAC,KAAK,CAAC,CAAC;gBAC/E,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;SACF,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -37,10 +37,14 @@
37
37
  * `exportEvent` is sync and never touches the disk: it serializes, buffers, and
38
38
  * returns. Batches are appended asynchronously on a size trigger
39
39
  * (`maxBufferEvents` / `maxBufferBytes`), on a timer (`flushIntervalMs`), and on
40
- * `flush()`. A hard kill therefore loses at most the buffer — the price of not
41
- * making telemetry a term in agent-loop latency. Call `flush()` (or
42
- * `agent.shutdown()`, which does) at process end; see the 8.12.0 lifecycle laws
43
- * on {@link BaseStrategy.flush}.
40
+ * `flush()` — all through ONE queue (`outbox.ts`), so one append is in flight
41
+ * at a time: this sink's appends never interleave, and lines land in dispatch
42
+ * order (#223). That is not atomicity — a disk that fails partway through an
43
+ * append (ENOSPC) can still leave part of a line behind, and that batch is
44
+ * reported dropped. A hard kill loses the buffer and can interrupt the append
45
+ * in flight — the price of not making telemetry a term in agent-loop latency.
46
+ * Call `flush()` (or `agent.shutdown()`, which does) at process end; see the
47
+ * 8.12.0 lifecycle laws on {@link BaseStrategy.flush}.
44
48
  *
45
49
  * ## Rotation is ONE generation, and that is deliberate
46
50
  *
@@ -75,6 +79,7 @@ exports.fileObservability = void 0;
75
79
  const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
76
80
  const wireJson_js_1 = require("../../lib/wireJson.js");
77
81
  const deliveryErrors_js_1 = require("./deliveryErrors.js");
82
+ const outbox_js_1 = require("./outbox.js");
78
83
  // ─── Public factory ──────────────────────────────────────────────────
79
84
  /**
80
85
  * NDJSON-to-a-local-file observability strategy. See
@@ -120,27 +125,13 @@ function fileObservability(opts) {
120
125
  `Fix the path or the permission — this sink refuses to start rather than ` +
121
126
  `silently drop every event.`);
122
127
  }
123
- // Buffered lines — drained by `flush()` / size trigger / timer.
124
- const buffer = [];
125
- let bufferBytes = 0;
126
- let lastFlushPromise = Promise.resolve();
127
- let timer;
128
+ // Set by `stop()`: this sink accepts no more events. It is NOT a guard on
129
+ // writing — `stop()` does not authorise throwing away what was already
130
+ // accepted, and `flush()` after it still writes (the 8.11.1 stance).
128
131
  let stopped = false;
129
132
  // The fallback when the consumer wires nothing. Rate-limited; a
130
133
  // consumer-supplied sink is not.
131
134
  const consoleSink = (0, deliveryErrors_js_1.rateLimitedConsoleSink)(strategyName);
132
- function scheduleTimedFlush() {
133
- if (timer || flushIntervalMs <= 0 || stopped)
134
- return;
135
- timer = setTimeout(() => {
136
- timer = undefined;
137
- void doFlush();
138
- }, flushIntervalMs);
139
- // Never hold the process open for telemetry. `unref` exists on Node's
140
- // Timeout and not on the browser's number — feature-detected, so a
141
- // non-Node runtime with an injected `_fs` still works.
142
- timer.unref?.();
143
- }
144
135
  /** Route a delivery failure through whatever `_onError` IS RIGHT NOW —
145
136
  * reading it at call time, so a consumer who assigns `_onError` after
146
137
  * construction still receives them (the 8.11.0 fix). */
@@ -162,28 +153,29 @@ function fileObservability(opts) {
162
153
  await fs.rename(path, rotatedPath);
163
154
  bytesOnDisk = 0;
164
155
  }
165
- async function doFlush() {
166
- // `stopped` is deliberately NOT a guard here — same stance as the AWS
167
- // adapters since 8.11.1. `stop()` stops this strategy ACCEPTING events; it
168
- // does not authorise throwing away events already accepted, and a `flush()`
169
- // that cannot make progress after a `stop()` is how shutdown spins forever.
170
- if (buffer.length === 0)
171
- return;
172
- // Snapshot + clear so events emitted during the in-flight write accumulate
173
- // into the next batch.
174
- const batch = buffer.splice(0);
175
- const batchBytes = bufferBytes;
176
- bufferBytes = 0;
177
- const data = `${batch.join('\n')}\n`;
178
- try {
179
- await rotateIfNeeded(batchBytes);
180
- await fs.appendFile(path, data);
181
- bytesOnDisk += byteLength(data);
182
- }
183
- catch (err) {
184
- reportFailure(new Error(`${batch.length} event(s) dropped writing to '${path}': ${errorMessage(err)}`));
185
- }
156
+ /** One batch: rotate if it would cross the ceiling, then append. Runs
157
+ * inside the outbox's queue, so no other batch — and no other rotation —
158
+ * can start until this one settles. */
159
+ async function writeBatch(lines) {
160
+ const data = `${lines.join('\n')}\n`;
161
+ const bytes = byteLength(data);
162
+ await rotateIfNeeded(bytes);
163
+ await fs.appendFile(path, data);
164
+ bytesOnDisk += bytes;
186
165
  }
166
+ // Buffered lines, and the one queue every write goes through — size
167
+ // trigger, timer, `flush()`, shutdown (outbox.ts; #223).
168
+ const outbox = (0, outbox_js_1.createOutbox)({
169
+ name: strategyName,
170
+ maxItems: maxBufferEvents,
171
+ maxBytes: maxBufferBytes,
172
+ flushIntervalMs,
173
+ // Never hold the process open for a local write.
174
+ timerHoldsProcess: false,
175
+ deliver: writeBatch,
176
+ dropped: (lines, cause) => new Error(`${lines.length} event(s) dropped writing to '${path}': ${errorMessage(cause)}`),
177
+ report: reportFailure,
178
+ });
187
179
  function enqueue(event) {
188
180
  if (stopped)
189
181
  return;
@@ -205,17 +197,11 @@ function fileObservability(opts) {
205
197
  // write, and a bare "undefined" line would corrupt the NDJSON stream.
206
198
  if (line === undefined)
207
199
  return;
208
- buffer.push(line);
209
- bufferBytes += byteLength(line) + 1; // + the newline this line will carry
210
- if (buffer.length >= maxBufferEvents || bufferBytes >= maxBufferBytes) {
211
- // Size trigger. Chain onto the last write rather than racing it — the
212
- // file's line order IS the dispatch order, and that is the only thing an
213
- // offline reader can rely on.
214
- lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
215
- }
216
- else {
217
- scheduleTimedFlush();
218
- }
200
+ // + the newline this line will carry. The outbox decides when it is
201
+ // written, and writes it after every line accepted before it — the file's
202
+ // line order IS the dispatch order, the one thing an offline reader can
203
+ // rely on.
204
+ outbox.add(line, byteLength(line) + 1);
219
205
  }
220
206
  const strategy = {
221
207
  name: strategyName,
@@ -226,31 +212,22 @@ function fileObservability(opts) {
226
212
  * Write what is buffered. Called for you on shutdown (8.12.0) — by the
227
213
  * handle `enable.observability()` returns, by `agent.shutdown()`, and by a
228
214
  * `standingAgent` closing. Safe at any time, including after `stop()`.
215
+ *
216
+ * Resolves once every event accepted before the call is written (or
217
+ * dropped and reported) — one a timed write already had in flight
218
+ * included — after one more sweep of what arrived while it waited. It
219
+ * does not chase a producer that keeps emitting. A write that never
220
+ * settles holds it: nothing can cancel an in-flight write.
229
221
  */
230
- async flush() {
231
- // BOUNDED BY CONSTRUCTION — every pass must remove at least one buffered
232
- // line; a pass that removes none ends the drain instead of retrying. The
233
- // shape the CloudWatch adapter arrived at in 8.11.1, for the same reason:
234
- // a drain that cannot finish must return, never spin.
235
- for (;;) {
236
- const pending = buffer.length;
237
- lastFlushPromise = lastFlushPromise.then(doFlush, doFlush);
238
- await lastFlushPromise;
239
- if (buffer.length === 0)
240
- return;
241
- if (buffer.length >= pending)
242
- return;
243
- }
222
+ flush() {
223
+ return outbox.drain();
244
224
  },
245
225
  /** Clear the timer and stop accepting events. Terminal: there is no
246
226
  * restart. What it does NOT do is discard the buffer — `flush()` after
247
227
  * `stop()` still writes it. */
248
228
  stop() {
249
229
  stopped = true;
250
- if (timer) {
251
- clearTimeout(timer);
252
- timer = undefined;
253
- }
230
+ outbox.stop();
254
231
  },
255
232
  /** Where failures go. Two callers: the dispatch layer (when `exportEvent`
256
233
  * itself throws) and this adapter's own write path. */
@@ -1 +1 @@
1
- {"version":3,"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