Skip to content

Commit bc81652

Browse files
committed
Ledger vendor error sequence patches
1 parent 40da15d commit bc81652

9 files changed

Lines changed: 148 additions & 33 deletions

File tree

docs/VENDORING.md

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ points straight at `./src/*.ts` files rather than a `dist/` build.
2222

2323
## What's vendored
2424

25-
| Package | Vendor path | License | Synced from upstream commit | Retrieved | Local patches |
26-
| -------------------------------------------------- | ------------------------------------- | ------------- | ------------------------------------------ | ---------- | -------------------------------------------- |
27-
| `@intx/inference` | `vendor/intx-inference/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Yes — see `vendor/intx-inference/PATCHES.md` |
28-
| `@intx/types` | `vendor/intx-types/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Noneverbatim |
29-
| `@intx/storage-isogit` | `vendor/intx-storage-isogit/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Noneverbatim |
30-
| `@intx/agent` | `vendor/intx-agent/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Noneverbatim |
31-
| `@intx/authz` | `vendor/intx-authz/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
32-
| `@intx/log` | `vendor/intx-log/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
33-
| `@intx/tools-posix` | `vendor/intx-tools-posix/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
34-
| `@intx/mailbox` | `vendor/intx-mailbox/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
35-
| `@intx/harness` | `vendor/intx-harness/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
36-
| `@intx/mime` | `vendor/intx-mime/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
37-
| `@intx/workflow-host` (partial — `adapters/` only) | `vendor/intx-workflow-host/adapters/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
25+
| Package | Vendor path | License | Synced from upstream commit | Retrieved | Local patches |
26+
| -------------------------------------------------- | ------------------------------------- | ------------- | ------------------------------------------ | ---------- | ------------------------------------------------- |
27+
| `@intx/inference` | `vendor/intx-inference/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Yes — see `vendor/intx-inference/PATCHES.md` |
28+
| `@intx/types` | `vendor/intx-types/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Yessee `vendor/intx-types/PATCHES.md` |
29+
| `@intx/storage-isogit` | `vendor/intx-storage-isogit/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Yessee `vendor/intx-storage-isogit/PATCHES.md` |
30+
| `@intx/agent` | `vendor/intx-agent/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | Yessee `vendor/intx-agent/PATCHES.md` |
31+
| `@intx/authz` | `vendor/intx-authz/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
32+
| `@intx/log` | `vendor/intx-log/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
33+
| `@intx/tools-posix` | `vendor/intx-tools-posix/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
34+
| `@intx/mailbox` | `vendor/intx-mailbox/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
35+
| `@intx/harness` | `vendor/intx-harness/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
36+
| `@intx/mime` | `vendor/intx-mime/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
37+
| `@intx/workflow-host` (partial — `adapters/` only) | `vendor/intx-workflow-host/adapters/` | LGPL-2.1-only | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | 2026-09-07 | None — verbatim |
3838

3939
## Provenance, ownership, and kill dates
4040

@@ -48,9 +48,9 @@ package; the date is the deadline even if it is not.
4848
| Vendor path | Upstream repo | Upstream commit | Patched | Why not the published package | Owner | Proposed kill date |
4949
| ------------------------------------- | ----------------------- | ------------------------------------------ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------ |
5050
| `vendor/intx-inference/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | Yes — `PATCHES.md` | Local fixes not yet upstream | runtime | 2027-03-07 or when patches land upstream and publish |
51-
| `vendor/intx-types/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | No | Cross-package coupling with `@intx/inference` | runtime | 2027-03-07 or when the coupled trio publishes past `0.3.0` |
52-
| `vendor/intx-storage-isogit/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | No | Cross-package coupling with `@intx/inference` | runtime | 2027-03-07 or when the coupled trio publishes past `0.3.0` |
53-
| `vendor/intx-agent/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | No | Vendored at Interchange head ahead of npm | runtime | 2027-03-07 or when `@intx/agent@>=0.4.0` publishes |
51+
| `vendor/intx-types/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | Yes — `PATCHES.md` | Cross-package coupling with `@intx/inference` | runtime | 2027-03-07 or when the coupled trio publishes past `0.3.0` |
52+
| `vendor/intx-storage-isogit/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | Yes — `PATCHES.md` | Cross-package coupling with `@intx/inference` | runtime | 2027-03-07 or when the coupled trio publishes past `0.3.0` |
53+
| `vendor/intx-agent/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | Yes — `PATCHES.md` | Vendored at Interchange head ahead of npm | runtime | 2027-03-07 or when `@intx/agent@>=0.4.0` publishes |
5454
| `vendor/intx-authz/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | No | Vendored at Interchange head ahead of npm | runtime | 2027-03-07 or when `@intx/authz@>=0.4.0` publishes |
5555
| `vendor/intx-log/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | No | Vendored at Interchange head ahead of npm | runtime | 2027-03-07 or when `@intx/log@>=0.4.0` publishes |
5656
| `vendor/intx-tools-posix/` | `faremeter/interchange` | `0205b07b64d03f0fec2e4be3593c764070a9ba8a` | No | Vendored at Interchange head ahead of npm | runtime | 2027-03-07 or when `@intx/tools-posix@>=0.4.0` publishes |
@@ -118,9 +118,11 @@ The 2026-09-07 sync also vendored the remaining four consumed packages
118118
(`@intx/agent`, `@intx/authz`, `@intx/log`, `@intx/tools-posix`) at the
119119
same upstream commit, completing the set: every `@intx/*` package this
120120
repo imports now resolves to vendored source. None of the four carried
121-
local patches at vendoring time; their trees are verbatim upstream
122-
copies. `@intx/tools-lsp` remains on published npm (`0.3.0`) — it is a
123-
thin adapter whose transitive `@intx/*` dependencies resolve to the
121+
local patches at vendoring time. `@intx/agent` later gained the error-seq
122+
patches ledgered in `vendor/intx-agent/PATCHES.md`; the other three remain
123+
verbatim upstream copies. `@intx/tools-lsp` remains on published npm
124+
(`0.3.0`) — it is a thin adapter whose transitive `@intx/*` dependencies
125+
resolve to the
124126
vendored workspaces via root `overrides`, so it tracks the vendored set
125127
without being vendored itself. Published transitive dependencies that
126128
stay on npm (`@intx/crypto`, `@intx/inference-discovery`,
@@ -187,13 +189,14 @@ those packages now resolves to the single root instance. As of this sync,
187189

188190
## Patched vs. verbatim
189191

190-
Of the eleven vendored paths, exactly one carries local patches:
191-
`@intx/inference` — every divergence is a real fix not yet upstream, listed
192-
one-per-patch in `vendor/intx-inference/PATCHES.md`. The other ten paths
193-
(nine whole packages plus the partial `vendor/intx-workflow-host/adapters/`
192+
Of the eleven vendored paths, four carry local patches:
193+
`@intx/inference`, `@intx/types`, `@intx/storage-isogit`, and
194+
`@intx/agent` — every divergence is a real fix not yet upstream, listed
195+
one-per-patch in that package's `PATCHES.md`. The other seven paths
196+
(six whole packages plus the partial `vendor/intx-workflow-host/adapters/`
194197
tree) are verbatim copies of upstream — no modifications. A diff against a
195198
pristine upstream checkout at the same commit and paths will show 100%
196-
upstream-authored lines.
199+
upstream-authored lines for those seven.
197200

198201
## Notable upstream shape changes carried by the 2026-08-22 sync
199202

@@ -229,12 +232,12 @@ different reason — the vendored mime sources import `@intx/crypto`, which
229232
stays on published npm, and `Bun.build` cannot resolve that bare specifier
230233
from inside the vendor workspace.
231234

232-
`@intx/inference` carries local patches — real fixes not yet present
233-
upstream, not workarounds for something upstream has since fixed. Every
234-
patched location carries a one-line comment naming its site-specific entry
235-
in `vendor/intx-inference/PATCHES.md` (e.g. `#reactor-ts-correlating-ids-leak`),
236-
so `grep -rn "Locally patched" vendor/intx-inference/src` finds every
237-
divergence. **Markers are navigation; the SHA-diff is proof.** Run
235+
Patched packages carry local fixes not yet present upstream, not
236+
workarounds for something upstream has since fixed. Every patched
237+
location carries a one-line comment naming its site-specific entry in
238+
that package's `PATCHES.md` (e.g. `#reactor-ts-correlating-ids-leak`),
239+
so `grep -rn "Locally patched" vendor/*/src` finds every divergence.
240+
**Markers are navigation; the SHA-diff is proof.** Run
238241
`bin/vendor-patch-diff` against a pristine upstream checkout at the
239242
recorded SHA to print exactly the lines that are ours. A correspondence
240243
test (`tests/unit/vendor-patch-ledger.test.ts`) fails if a marker anchor
@@ -253,7 +256,8 @@ does not resolve to a ledger heading, or if a ledger heading has no marker.
253256
`adapters/substrate-mailbox-store.ts` and
254257
`adapters/substrate-mailbox-store.test.ts`). Run
255258
`bun install`, `bun run typecheck`, `bun run build`, `bun run test`.
256-
3. For a **patched** package (`@intx/inference`): before overwriting
259+
3. For a **patched** package (`@intx/inference`, `@intx/types`,
260+
`@intx/storage-isogit`, `@intx/agent`): before overwriting
257261
anything, run `bin/vendor-patch-diff` (optionally
258262
`--upstream /path/to/interchange`) to re-derive the exact local
259263
divergences against the recorded SHA — do not trust `PATCHES.md`'s

vendor/intx-agent/PATCHES.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Patch ledger — vendor/intx-agent
2+
3+
**The SHA-diff is authoritative; markers are navigation.**
4+
5+
Recorded upstream commit lives in `docs/VENDORING.md`. A pristine checkout
6+
at that SHA, diffed against `vendor/intx-agent/src`, is the only proof of
7+
which lines are ours — run `bin/vendor-patch-diff` to produce it. The
8+
`Locally patched — see …#<anchor>` comments and the entries below are
9+
signposts that point into that diff; they do not define its extent.
10+
11+
## agent-ts-resume-error-seq
12+
13+
`agent.ts``createAgent` resumes `errorSeq` from `auditStore.loadErrors`
14+
so a rebuilt agent does not reuse seq 0 and collide with files the
15+
previous assembly already committed. If `loadErrors` throws, assembly
16+
still succeeds and seq starts at 0; a later colliding flush is dropped
17+
by `agent-ts-duplicate-error-flush` rather than failing the session.
18+
19+
**Disposition:** Promotion candidate. **Removal path:** Upstream PR to
20+
`createAgent` that resumes the durable error sequence; then drop this
21+
entry and its marker.
22+
23+
## agent-ts-duplicate-error-flush
24+
25+
`agent.ts``flushErrors` treats `Duplicate error record:` from
26+
`commitErrors` as already-durable and drops the colliding batch instead
27+
of failing `afterCheckpoint`.
28+
29+
**Disposition:** Promotion candidate. **Removal path:** Upstream PR with
30+
the same duplicate-flush handling; then drop this entry and its marker.
31+
32+
## testing-audit-noop-ts-load-errors
33+
34+
`testing/audit-noop.ts` — No-op `AuditStore` implements `loadErrors` as
35+
an empty array so it satisfies the patched `AuditStore` contract.
36+
37+
**Disposition:** Companion of `runtime-ts-audit-store-load-errors`.
38+
**Removal path:** Ships out with the types patch.

vendor/intx-agent/src/agent.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,14 @@ export async function createAgent<EnvReq extends BaseEnv>(
514514
const accumulatedErrors: ErrorRecord[] = [];
515515
// Resume from durable records so a rebuilt agent does not reuse seq 0
516516
// and collide with files the previous assembly already committed.
517+
// Locally patched — see vendor/intx-agent/PATCHES.md#agent-ts-resume-error-seq
517518
let errorSeq = 0;
518-
for (const record of await auditStore.loadErrors(sessionId)) {
519-
if (record.seq >= errorSeq) errorSeq = record.seq + 1;
519+
try {
520+
for (const record of await auditStore.loadErrors(sessionId)) {
521+
if (record.seq >= errorSeq) errorSeq = record.seq + 1;
522+
}
523+
} catch {
524+
logger.warn`loadErrors failed during assembly; starting error seq at 0`;
520525
}
521526
let flushInProgress: Promise<void> | undefined;
522527
let pendingFollowUp: Promise<void> | undefined;
@@ -557,6 +562,7 @@ export async function createAgent<EnvReq extends BaseEnv>(
557562
await auditStore.commitErrors(batch);
558563
accumulatedErrors.splice(0, count);
559564
} catch (cause) {
565+
// Locally patched — see vendor/intx-agent/PATCHES.md#agent-ts-duplicate-error-flush
560566
if (
561567
cause instanceof Error &&
562568
cause.message.startsWith("Duplicate error record:")

vendor/intx-agent/src/flush-errors.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,4 +676,29 @@ describe("agent error flushing", () => {
676676
expect(duplicateFlushFailures(events)).toEqual([]);
677677
expect(events.some((event) => event.type === "reactor.done")).toBe(true);
678678
});
679+
680+
test("createAgent still assembles when loadErrors throws", async () => {
681+
const audit = makeRecordingAuditStore();
682+
audit.loadErrors = async () => {
683+
throw new Error("simulated loadErrors failure");
684+
};
685+
const directors = credentialFailureDirectors();
686+
const def = forbiddenAgentDef("cred-flush-load-errors");
687+
const env = await buildAgentEnv({ workdir: workDir, audit, directors });
688+
const agent = await createAgent(def, { ...env, deps: FORBIDDEN_DEPS });
689+
const events: Array<{ type: string; data?: unknown }> = [];
690+
const stream = agent.stream();
691+
try {
692+
agent.deliver(inboundConversation());
693+
for await (const event of stream) {
694+
events.push(event);
695+
if (event.type === "reactor.done") break;
696+
}
697+
} finally {
698+
await agent.close();
699+
}
700+
701+
expect(events.some((event) => event.type === "reactor.done")).toBe(true);
702+
expect(audit.getCommittedErrors().flat().length).toBeGreaterThan(0);
703+
});
679704
});

vendor/intx-agent/src/testing/audit-noop.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function noopAuditStore(): AuditStore {
2525
async loadAudit(_sessionId: string): Promise<AuditRecord[]> {
2626
return [];
2727
},
28+
// Locally patched — see vendor/intx-agent/PATCHES.md#testing-audit-noop-ts-load-errors
2829
async loadErrors(_sessionId: string): Promise<ErrorRecord[]> {
2930
return [];
3031
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Patch ledger — vendor/intx-storage-isogit
2+
3+
**The SHA-diff is authoritative; markers are navigation.**
4+
5+
Recorded upstream commit lives in `docs/VENDORING.md`. A pristine checkout
6+
at that SHA, diffed against `vendor/intx-storage-isogit/src`, is the only
7+
proof of which lines are ours — run `bin/vendor-patch-diff` to produce it.
8+
The `Locally patched — see …#<anchor>` comments and the entries below are
9+
signposts that point into that diff; they do not define its extent.
10+
11+
## store-ts-load-errors
12+
13+
`store.ts` — Implements `AuditStore.loadErrors` by reading
14+
`state/errors/<sessionId>/*.json`, validating each file as `ErrorRecord`,
15+
and returning records ordered by seq. Missing session directories return
16+
`[]`. Companion to `runtime-ts-audit-store-load-errors` in `@intx/types`.
17+
18+
**Disposition:** Promotion candidate. **Removal path:** Upstream PR adding
19+
the same loader; then drop this entry and its marker.

0 commit comments

Comments
 (0)