@remnic/core 10.0.135 → 10.0.136

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/dist/access-admin-ops-surface.js +37 -37
  2. package/dist/access-cli.js +37 -37
  3. package/dist/access-extraction-force-flush.js +37 -37
  4. package/dist/access-http-briefing.js +37 -37
  5. package/dist/access-http-query.js +37 -37
  6. package/dist/access-http.js +37 -37
  7. package/dist/access-identity-continuity-surface.js +37 -37
  8. package/dist/access-lcm-surface.js +37 -37
  9. package/dist/access-mcp.js +37 -37
  10. package/dist/access-observe-write-surface.js +37 -37
  11. package/dist/access-operations-batch.js +37 -37
  12. package/dist/access-operations.js +37 -37
  13. package/dist/access-recall-concurrency.js +37 -37
  14. package/dist/access-recall-diagnostics.js +2 -2
  15. package/dist/access-recall-response.js +37 -37
  16. package/dist/access-recall-surface.js +37 -37
  17. package/dist/access-service.js +37 -37
  18. package/dist/active-recall.js +3 -3
  19. package/dist/briefing.js +3 -3
  20. package/dist/causal-consolidation.js +4 -4
  21. package/dist/{chunk-AGDPIO6J.js → chunk-2OIQHXN4.js} +2 -2
  22. package/dist/{chunk-MKXKED3B.js → chunk-37T5ZO5P.js} +2 -2
  23. package/dist/{chunk-7DWLU7GU.js → chunk-3F6COEHZ.js} +1 -1
  24. package/dist/chunk-3F6COEHZ.js.map +1 -0
  25. package/dist/{chunk-PVCGXXQB.js → chunk-3TU6OBI7.js} +2 -2
  26. package/dist/{chunk-6IPTMGLJ.js → chunk-4H7TUVWQ.js} +2 -2
  27. package/dist/{chunk-SS7CPYWD.js → chunk-4VL2H5Q3.js} +2 -2
  28. package/dist/{chunk-XMT27576.js → chunk-5RCXMLI5.js} +2 -2
  29. package/dist/{chunk-MFPPRA4F.js → chunk-5RZ4DAP6.js} +3 -3
  30. package/dist/{chunk-PWTXXSJ5.js → chunk-5ZS73P3U.js} +2 -2
  31. package/dist/{chunk-ZKYWI3N5.js → chunk-6LNWA6IT.js} +3 -3
  32. package/dist/{chunk-KRMAIJMP.js → chunk-6Z7BRM7C.js} +2 -2
  33. package/dist/{chunk-G2LJ6KVK.js → chunk-BL545EH7.js} +2 -2
  34. package/dist/chunk-BL545EH7.js.map +1 -0
  35. package/dist/{chunk-KW3FFIIG.js → chunk-CGEOIR4F.js} +32 -32
  36. package/dist/{chunk-L7V55O3P.js → chunk-EFMAYZOB.js} +2 -2
  37. package/dist/{chunk-VTL2NQED.js → chunk-FEWOSD33.js} +2 -2
  38. package/dist/{chunk-7OX7U2XB.js → chunk-GUI7MLKC.js} +2 -2
  39. package/dist/{chunk-LAUZ3EQU.js → chunk-GW23JXGJ.js} +2 -2
  40. package/dist/{chunk-IDMIRW7C.js → chunk-HKQ3LH34.js} +3 -3
  41. package/dist/{chunk-EVM7JM3U.js → chunk-IXX4SKF5.js} +2 -2
  42. package/dist/{chunk-G5RFNMJ2.js → chunk-KIICCGSV.js} +2 -2
  43. package/dist/{chunk-L2NXX7B7.js → chunk-KN44QS5F.js} +3 -3
  44. package/dist/{chunk-SEQ3PEJ4.js → chunk-LK3LXSJQ.js} +2 -2
  45. package/dist/{chunk-K4BSIADH.js → chunk-LR6QP72R.js} +2 -2
  46. package/dist/{chunk-IE3KZVCC.js → chunk-NEXJ3OOZ.js} +3 -3
  47. package/dist/{chunk-ETDVI7JS.js → chunk-OE35LFBF.js} +2 -2
  48. package/dist/{chunk-FASAQQF7.js → chunk-PA5FI6A5.js} +2 -2
  49. package/dist/{chunk-H37DI6HW.js → chunk-QOI4PNVG.js} +2 -2
  50. package/dist/{chunk-P76WH5JD.js → chunk-S3LWB6K3.js} +2 -2
  51. package/dist/{chunk-P4G6C7XS.js → chunk-SCQO7JOF.js} +2 -2
  52. package/dist/{chunk-PK7IEAQB.js → chunk-STKNZY7A.js} +2 -2
  53. package/dist/{chunk-FEAIHXCI.js → chunk-U5OVNYJX.js} +2 -2
  54. package/dist/{chunk-GQ6MZ43R.js → chunk-WYSCN5TA.js} +2 -2
  55. package/dist/{chunk-5RPRVPZU.js → chunk-XBNGH2FV.js} +2 -2
  56. package/dist/{chunk-45GDXYAW.js → chunk-XCZQ7MID.js} +7 -7
  57. package/dist/{chunk-Z4EIJ6CR.js → chunk-Y3TA66MZ.js} +2 -2
  58. package/dist/{chunk-IP25A6HJ.js → chunk-YNTVQWLX.js} +8 -8
  59. package/dist/{chunk-45BPRD6P.js → chunk-ZGGFGUUF.js} +2 -2
  60. package/dist/{chunk-MWDMUMQ6.js → chunk-ZKHDDEPF.js} +2 -2
  61. package/dist/cli.js +37 -37
  62. package/dist/coding/export-okf-codegraph.js +2 -2
  63. package/dist/compounding/engine.js +4 -4
  64. package/dist/config.d.ts.map +1 -1
  65. package/dist/config.js +3 -3
  66. package/dist/connectors/codex-materialize-runner.js +3 -3
  67. package/dist/connectors/index.js +3 -3
  68. package/dist/convergence-refresh.js +5 -5
  69. package/dist/corpus-watermark.js +5 -5
  70. package/dist/entity-retrieval.js +3 -3
  71. package/dist/explicit-capture.js +37 -37
  72. package/dist/extraction.js +3 -3
  73. package/dist/harmonic-retrieval.js +3 -3
  74. package/dist/index.js +37 -37
  75. package/dist/location/index.js +4 -4
  76. package/dist/maintenance/memory-governance.js +3 -3
  77. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +3 -3
  78. package/dist/maintenance/rebuild-memory-projection-runner.js +5 -5
  79. package/dist/maintenance/rebuild-memory-projection.js +4 -4
  80. package/dist/namespaces/migrate.js +4 -4
  81. package/dist/namespaces/storage.js +3 -3
  82. package/dist/operator-doctor-corpus.js +6 -6
  83. package/dist/operator-toolkit.js +10 -10
  84. package/dist/orchestration/backlog-scheduler.js +38 -38
  85. package/dist/orchestration/buffer-drain-runner.js +38 -38
  86. package/dist/orchestration/maintenance.js +11 -11
  87. package/dist/orchestrator.js +37 -37
  88. package/dist/recall-explain-renderer.js +3 -3
  89. package/dist/recall-navigate-access.js +2 -2
  90. package/dist/recall-navigate-disclosure.js +2 -2
  91. package/dist/recall-navigate.js +2 -2
  92. package/dist/recall-navigation.js +37 -37
  93. package/dist/recall-xray-cli.js +4 -4
  94. package/dist/recall-xray-renderer.js +3 -3
  95. package/dist/recall-xray.js +2 -2
  96. package/dist/resume-bundles.js +4 -4
  97. package/dist/semantic-consolidation.js +4 -4
  98. package/dist/semantic-rule-promotion.js +3 -3
  99. package/dist/semantic-rule-verifier.js +3 -3
  100. package/dist/source-agent-qualifier.js +3 -3
  101. package/dist/standup/build.js +3 -3
  102. package/dist/storage.js +2 -2
  103. package/dist/transfer/export-okf.js +3 -3
  104. package/dist/types.d.ts +4 -7
  105. package/dist/types.d.ts.map +1 -1
  106. package/dist/types.js +1 -1
  107. package/dist/verified-recall.js +3 -3
  108. package/dist/who-knows-cli.js +4 -4
  109. package/dist/who-knows.js +3 -3
  110. package/package.json +2 -2
  111. package/src/access-serve-trust-principal-config.test.ts +270 -0
  112. package/src/access-trust-principal-header.test.ts +6 -4
  113. package/src/config.ts +6 -8
  114. package/src/types.ts +11 -8
  115. package/dist/chunk-7DWLU7GU.js.map +0 -1
  116. package/dist/chunk-G2LJ6KVK.js.map +0 -1
  117. /package/dist/{chunk-AGDPIO6J.js.map → chunk-2OIQHXN4.js.map} +0 -0
  118. /package/dist/{chunk-MKXKED3B.js.map → chunk-37T5ZO5P.js.map} +0 -0
  119. /package/dist/{chunk-PVCGXXQB.js.map → chunk-3TU6OBI7.js.map} +0 -0
  120. /package/dist/{chunk-6IPTMGLJ.js.map → chunk-4H7TUVWQ.js.map} +0 -0
  121. /package/dist/{chunk-SS7CPYWD.js.map → chunk-4VL2H5Q3.js.map} +0 -0
  122. /package/dist/{chunk-XMT27576.js.map → chunk-5RCXMLI5.js.map} +0 -0
  123. /package/dist/{chunk-MFPPRA4F.js.map → chunk-5RZ4DAP6.js.map} +0 -0
  124. /package/dist/{chunk-PWTXXSJ5.js.map → chunk-5ZS73P3U.js.map} +0 -0
  125. /package/dist/{chunk-ZKYWI3N5.js.map → chunk-6LNWA6IT.js.map} +0 -0
  126. /package/dist/{chunk-KRMAIJMP.js.map → chunk-6Z7BRM7C.js.map} +0 -0
  127. /package/dist/{chunk-KW3FFIIG.js.map → chunk-CGEOIR4F.js.map} +0 -0
  128. /package/dist/{chunk-L7V55O3P.js.map → chunk-EFMAYZOB.js.map} +0 -0
  129. /package/dist/{chunk-VTL2NQED.js.map → chunk-FEWOSD33.js.map} +0 -0
  130. /package/dist/{chunk-7OX7U2XB.js.map → chunk-GUI7MLKC.js.map} +0 -0
  131. /package/dist/{chunk-LAUZ3EQU.js.map → chunk-GW23JXGJ.js.map} +0 -0
  132. /package/dist/{chunk-IDMIRW7C.js.map → chunk-HKQ3LH34.js.map} +0 -0
  133. /package/dist/{chunk-EVM7JM3U.js.map → chunk-IXX4SKF5.js.map} +0 -0
  134. /package/dist/{chunk-G5RFNMJ2.js.map → chunk-KIICCGSV.js.map} +0 -0
  135. /package/dist/{chunk-L2NXX7B7.js.map → chunk-KN44QS5F.js.map} +0 -0
  136. /package/dist/{chunk-SEQ3PEJ4.js.map → chunk-LK3LXSJQ.js.map} +0 -0
  137. /package/dist/{chunk-K4BSIADH.js.map → chunk-LR6QP72R.js.map} +0 -0
  138. /package/dist/{chunk-IE3KZVCC.js.map → chunk-NEXJ3OOZ.js.map} +0 -0
  139. /package/dist/{chunk-ETDVI7JS.js.map → chunk-OE35LFBF.js.map} +0 -0
  140. /package/dist/{chunk-FASAQQF7.js.map → chunk-PA5FI6A5.js.map} +0 -0
  141. /package/dist/{chunk-H37DI6HW.js.map → chunk-QOI4PNVG.js.map} +0 -0
  142. /package/dist/{chunk-P76WH5JD.js.map → chunk-S3LWB6K3.js.map} +0 -0
  143. /package/dist/{chunk-P4G6C7XS.js.map → chunk-SCQO7JOF.js.map} +0 -0
  144. /package/dist/{chunk-PK7IEAQB.js.map → chunk-STKNZY7A.js.map} +0 -0
  145. /package/dist/{chunk-FEAIHXCI.js.map → chunk-U5OVNYJX.js.map} +0 -0
  146. /package/dist/{chunk-GQ6MZ43R.js.map → chunk-WYSCN5TA.js.map} +0 -0
  147. /package/dist/{chunk-5RPRVPZU.js.map → chunk-XBNGH2FV.js.map} +0 -0
  148. /package/dist/{chunk-45GDXYAW.js.map → chunk-XCZQ7MID.js.map} +0 -0
  149. /package/dist/{chunk-Z4EIJ6CR.js.map → chunk-Y3TA66MZ.js.map} +0 -0
  150. /package/dist/{chunk-IP25A6HJ.js.map → chunk-YNTVQWLX.js.map} +0 -0
  151. /package/dist/{chunk-45BPRD6P.js.map → chunk-ZGGFGUUF.js.map} +0 -0
  152. /package/dist/{chunk-MWDMUMQ6.js.map → chunk-ZKHDDEPF.js.map} +0 -0
@@ -0,0 +1,270 @@
1
+ /**
2
+ * `agentAccessHttp.trustPrincipalHeader` config path (issue #3462).
3
+ *
4
+ * The per-request principal header (`x-engram-principal`) was only reachable
5
+ * through the `--trust-principal-header` CLI flag; a fleet daemon started
6
+ * without the flag silently ignored pane-sent principals. This drives the
7
+ * registered `engram access http-serve` action (registerCli + recording
8
+ * program mock, as in cli-wearables-fuse.test.ts) against real namespace
9
+ * storage and asserts the precedence contract:
10
+ *
11
+ * - explicit `--trust-principal-header` flag wins,
12
+ * - absent flag falls back to `agentAccessHttp.trustPrincipalHeader` config,
13
+ * - both unset: header ignored (unchanged behavior),
14
+ * - parseConfig coerces bool-like strings and defaults to false.
15
+ */
16
+
17
+ import assert from "node:assert/strict";
18
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
19
+ import os from "node:os";
20
+ import path from "node:path";
21
+ import test from "node:test";
22
+
23
+ import {
24
+ registerCli,
25
+ type CliApi,
26
+ type CliCommand,
27
+ type CliProgram,
28
+ } from "./cli.js";
29
+ import { parseConfig } from "./config.js";
30
+ import { NamespaceStorageRouter } from "./namespaces/storage.js";
31
+ import type { Orchestrator } from "./orchestrator.js";
32
+
33
+ /** Recording commander stand-in (same shape as cli-wearables-fuse.test.ts). */
34
+ class RecCmd implements CliCommand {
35
+ readonly children = new Map<string, RecCmd>();
36
+ readonly options: string[] = [];
37
+ readonly args: string[] = [];
38
+ actionFn?: (...args: unknown[]) => Promise<void> | void;
39
+ constructor(readonly rawName: string) {}
40
+ description(): CliCommand {
41
+ return this;
42
+ }
43
+ option(flags: string): CliCommand {
44
+ this.options.push(flags);
45
+ return this;
46
+ }
47
+ requiredOption(flags: string): CliCommand {
48
+ this.options.push(flags);
49
+ return this;
50
+ }
51
+ argument(name: string): CliCommand {
52
+ this.args.push(name);
53
+ return this;
54
+ }
55
+ action(fn: (...args: unknown[]) => Promise<void> | void): CliCommand {
56
+ this.actionFn = fn;
57
+ return this;
58
+ }
59
+ command(name: string): CliCommand {
60
+ const key = name.split(/\s+/)[0]!;
61
+ const child = new RecCmd(name);
62
+ this.children.set(key, child);
63
+ return child;
64
+ }
65
+ }
66
+
67
+ class RecProgram implements CliProgram {
68
+ readonly root = new RecCmd("__program__");
69
+ command(name: string): CliCommand {
70
+ return this.root.command(name);
71
+ }
72
+ }
73
+
74
+ const SERVE_TOKEN = "synthetic-serve-token";
75
+
76
+ /** CLI options shape commander hands the `engram access http-serve` action (flag values stay strings). */
77
+ interface ServeCliOptions {
78
+ host?: string;
79
+ port?: string;
80
+ token?: string;
81
+ trustPrincipalHeader?: boolean;
82
+ }
83
+
84
+ interface ServeFixture {
85
+ serve: (options: ServeCliOptions) => Promise<{ host: string; port: number }>;
86
+ stop: () => Promise<void>;
87
+ cleanup: () => Promise<void>;
88
+ }
89
+
90
+ interface EntityListBody {
91
+ entities?: Array<{ name?: string }>;
92
+ }
93
+
94
+ /** Config input for the fixture's access server; parseConfig accepts bool-like strings for the flag. */
95
+ interface FixtureAccessHttp {
96
+ principal: string;
97
+ trustPrincipalHeader?: boolean | string;
98
+ }
99
+
100
+ /**
101
+ * Entity reads need only config + real storage routing from the orchestrator
102
+ * (same Pick pattern as access-entity-principal.test.ts). The configured
103
+ * access principal is "reader", who may read `restricted` but NOT `default`;
104
+ * the header-supplied principal "owner" may read both — so a 200 on
105
+ * `namespace=default` proves the header principal was trusted.
106
+ */
107
+ async function createServeFixture(options: { trustPrincipalHeader?: boolean | string } = {}): Promise<ServeFixture> {
108
+ const memoryDir = await mkdtemp(path.join(os.tmpdir(), "remnic-serve-trust-"));
109
+ const agentAccessHttp: FixtureAccessHttp = {
110
+ principal: "reader",
111
+ };
112
+ if (options.trustPrincipalHeader !== undefined) {
113
+ agentAccessHttp.trustPrincipalHeader = options.trustPrincipalHeader;
114
+ }
115
+ const config = parseConfig({
116
+ memoryDir,
117
+ namespacesEnabled: true,
118
+ defaultNamespace: "default",
119
+ namespacePolicies: [
120
+ { name: "default", readPrincipals: ["owner"], writePrincipals: ["owner"] },
121
+ { name: "restricted", readPrincipals: ["owner", "reader"], writePrincipals: ["owner"] },
122
+ ],
123
+ agentAccessHttp,
124
+ });
125
+ const router = new NamespaceStorageRouter(config);
126
+ for (const namespace of ["default", "restricted"]) {
127
+ const storage = await router.storageFor(namespace);
128
+ const entitiesDir = path.join(storage.dir, "entities");
129
+ await mkdir(entitiesDir, { recursive: true });
130
+ await writeFile(path.join(entitiesDir, "project-widget.md"), [
131
+ `# Widget-${namespace}`,
132
+ "",
133
+ "**Type:** project",
134
+ "",
135
+ "## Summary",
136
+ "",
137
+ `Synthetic entity in ${namespace}.`,
138
+ "",
139
+ ].join("\n"));
140
+ }
141
+
142
+ const dependencies: Pick<Orchestrator, "config" | "getStorage" | "initialize"> = {
143
+ config,
144
+ getStorage: (namespace?: string) => router.storageFor(namespace ?? config.defaultNamespace),
145
+ initialize: async () => {},
146
+ };
147
+
148
+ const program = new RecProgram();
149
+ const api: CliApi = {
150
+ registerCli: (handler) => handler({ program }),
151
+ };
152
+ // SAFETY: registerCli and the http-serve action touch only config, getStorage, and
153
+ // initialize on the orchestrator; each member is provided with its real shape.
154
+ registerCli(api, dependencies as Parameters<typeof registerCli>[1]);
155
+ const engram = program.root.children.get("engram");
156
+ const access = engram?.children.get("access");
157
+ const serveCmd = access?.children.get("http-serve");
158
+ const stopCmd = access?.children.get("http-stop");
159
+ assert.ok(serveCmd?.actionFn, "engram access http-serve registered an action");
160
+ assert.ok(stopCmd?.actionFn, "engram access http-stop registered an action");
161
+
162
+ const stop = async () => {
163
+ await stopCmd!.actionFn!({});
164
+ };
165
+
166
+ const serve = async (options: ServeCliOptions) => {
167
+ const logs: string[] = [];
168
+ const originalLog = console.log;
169
+ console.log = (...args: unknown[]) => {
170
+ logs.push(args.map(String).join(" "));
171
+ };
172
+ try {
173
+ await serveCmd!.actionFn!(options);
174
+ } finally {
175
+ console.log = originalLog;
176
+ }
177
+ const statusLine = logs.map((line) => line.trim()).find((line) => line.startsWith("{"));
178
+ assert.ok(statusLine, "http-serve printed its status JSON");
179
+ // SAFETY: http-serve prints the server.start() status JSON ({ running, host, port, ... });
180
+ // only running/host/port are read and each is asserted below.
181
+ const status = JSON.parse(statusLine) as { running?: boolean; host?: string; port?: number };
182
+ assert.equal(status.running, true);
183
+ assert.ok(Number.isInteger(status.port), "http-serve status carries an integer port");
184
+ return { host: status.host ?? "127.0.0.1", port: status.port! };
185
+ };
186
+
187
+ return { serve, stop, cleanup: () => rm(memoryDir, { recursive: true, force: true }) };
188
+ }
189
+
190
+ async function readDefaultNamespaceAsOwner(
191
+ fixture: ServeFixture,
192
+ serveOptions: ServeCliOptions,
193
+ ): Promise<Response> {
194
+ const { host, port } = await fixture.serve(serveOptions);
195
+ try {
196
+ return await fetch(`http://${host}:${port}/engram/v1/entities?namespace=default`, {
197
+ headers: {
198
+ authorization: "Bearer " + SERVE_TOKEN,
199
+ "x-engram-principal": "owner",
200
+ },
201
+ });
202
+ } finally {
203
+ await fixture.stop();
204
+ }
205
+ }
206
+
207
+ test("parseConfig defaults agentAccessHttp.trustPrincipalHeader to false and coerces bool-like strings", () => {
208
+ assert.equal(parseConfig({}).agentAccessHttp.trustPrincipalHeader, false);
209
+ assert.equal(parseConfig({ agentAccessHttp: {} }).agentAccessHttp.trustPrincipalHeader, false);
210
+ assert.equal(parseConfig({ agentAccessHttp: { trustPrincipalHeader: true } }).agentAccessHttp.trustPrincipalHeader, true);
211
+ assert.equal(parseConfig({ agentAccessHttp: { trustPrincipalHeader: false } }).agentAccessHttp.trustPrincipalHeader, false);
212
+ assert.equal(parseConfig({ agentAccessHttp: { trustPrincipalHeader: "true" } }).agentAccessHttp.trustPrincipalHeader, true);
213
+ assert.equal(parseConfig({ agentAccessHttp: { trustPrincipalHeader: "1" } }).agentAccessHttp.trustPrincipalHeader, true);
214
+ assert.equal(parseConfig({ agentAccessHttp: { trustPrincipalHeader: "false" } }).agentAccessHttp.trustPrincipalHeader, false);
215
+ assert.equal(parseConfig({ agentAccessHttp: { trustPrincipalHeader: "0" } }).agentAccessHttp.trustPrincipalHeader, false);
216
+ });
217
+
218
+ test("absent flag falls back to agentAccessHttp.trustPrincipalHeader config (issue #3462)", async () => {
219
+ const fixture = await createServeFixture({ trustPrincipalHeader: true });
220
+ try {
221
+ // NO --trust-principal-header flag: config alone must trust the header.
222
+ // reader cannot read `default`; the header principal "owner" can.
223
+ const response = await readDefaultNamespaceAsOwner(fixture, {
224
+ host: "127.0.0.1",
225
+ port: "0",
226
+ token: "synthetic-serve-token",
227
+ });
228
+ assert.equal(response.status, 200);
229
+ // SAFETY: a 200 from /engram/v1/entities carries the entity-list envelope; only entity names are read.
230
+ const body = (await response.json()) as EntityListBody;
231
+ assert.equal(body.entities?.[0]?.name, "Widget-default");
232
+ } finally {
233
+ await fixture.cleanup();
234
+ }
235
+ });
236
+
237
+ test("explicit --trust-principal-header flag wins over config", async () => {
238
+ const fixture = await createServeFixture();
239
+ try {
240
+ const response = await readDefaultNamespaceAsOwner(fixture, {
241
+ host: "127.0.0.1",
242
+ port: "0",
243
+ token: "synthetic-serve-token",
244
+ trustPrincipalHeader: true,
245
+ });
246
+ assert.equal(response.status, 200);
247
+ // SAFETY: a 200 from /engram/v1/entities carries the entity-list envelope; only entity names are read.
248
+ const body = (await response.json()) as EntityListBody;
249
+ assert.equal(body.entities?.[0]?.name, "Widget-default");
250
+ } finally {
251
+ await fixture.cleanup();
252
+ }
253
+ });
254
+
255
+ test("both unset: x-engram-principal header stays ignored", async () => {
256
+ const fixture = await createServeFixture();
257
+ try {
258
+ const response = await readDefaultNamespaceAsOwner(fixture, {
259
+ host: "127.0.0.1",
260
+ port: "0",
261
+ token: "synthetic-serve-token",
262
+ });
263
+ assert.equal(response.status, 400);
264
+ // SAFETY: an ACL refusal from the access server answers { error }; only the message is read.
265
+ const body = (await response.json()) as { error?: string };
266
+ assert.match(body.error ?? "", /not readable/);
267
+ } finally {
268
+ await fixture.cleanup();
269
+ }
270
+ });
@@ -33,16 +33,18 @@ function makeConfig(memoryDir: string, agentAccessHttp?: AgentAccessHttpRawOverr
33
33
  });
34
34
  }
35
35
 
36
- test("agentAccessHttp.trustPrincipalHeader defaults off and takes only explicit true", () => {
37
- for (const input of [undefined, false, "yes", 1, { trust: true }]) {
36
+ test("agentAccessHttp.trustPrincipalHeader defaults off and accepts bool-like strings", () => {
37
+ for (const input of [undefined, false, 1, { trust: true }, "garbage"]) {
38
38
  const parsed = makeConfig(
39
39
  "/tmp/remnic-tph-default",
40
40
  input === undefined ? {} : { trustPrincipalHeader: input },
41
41
  );
42
42
  assert.equal(parsed.agentAccessHttp.trustPrincipalHeader, false, `input ${String(input)}`);
43
43
  }
44
- const trusted = makeConfig("/tmp/remnic-tph-on", { trustPrincipalHeader: true });
45
- assert.equal(trusted.agentAccessHttp.trustPrincipalHeader, true);
44
+ for (const input of [true, "yes", "1", "on"]) {
45
+ const parsed = makeConfig("/tmp/remnic-tph-on", { trustPrincipalHeader: input });
46
+ assert.equal(parsed.agentAccessHttp.trustPrincipalHeader, true, `input ${String(input)}`);
47
+ }
46
48
  });
47
49
 
48
50
  /** One timings-probe server per flag value; the route 200s for the operator principal and 403s otherwise. */
package/src/config.ts CHANGED
@@ -435,13 +435,11 @@ function isSecretRefShape(value: unknown): value is import("./types.js").SecretR
435
435
  }
436
436
 
437
437
  /**
438
- * Parse the `agentAccessHttp.authToken` field. Accepts:
439
- * - `string` → env-expanded immediately (current behavior preserved)
440
- * - `SecretRef` object (`{source, ...}`) → preserved verbatim for runtime
441
- * resolution by OpenClaw's gateway secret resolver
442
- * - `undefined` / empty string → fall back to env var, then `undefined`
443
- * - Any other shape → throw with a clear, actionable error so operators can
444
- * debug rather than chasing a generic startup failure (issue #757).
438
+ * Parse `agentAccessHttp.authToken`: string → env-expanded immediately (current behavior
439
+ * preserved); SecretRef object (`{source, ...}`) → preserved verbatim for runtime resolution
440
+ * by OpenClaw's gateway secret resolver; undefined/empty string → env var fallback then
441
+ * undefined; any other shape → throw with an actionable error, never a generic startup
442
+ * failure operators must chase down (issue #757).
445
443
  */
446
444
  function parseAgentAccessAuthToken(raw: unknown): import("./types.js").AgentAccessAuthToken | undefined {
447
445
  if (raw === undefined || raw === null) {
@@ -1487,7 +1485,7 @@ export function parseConfig(
1487
1485
  60_000,
1488
1486
  "agentAccessHttp.writeRateLimitWindowMs",
1489
1487
  ),
1490
- trustPrincipalHeader: rawAgentAccessHttp?.trustPrincipalHeader === true,
1488
+ trustPrincipalHeader: coerceBool(rawAgentAccessHttp?.trustPrincipalHeader, "agentAccessHttp.trustPrincipalHeader") ?? false,
1491
1489
  };
1492
1490
 
1493
1491
  let baseUrl: string | undefined;
package/src/types.ts CHANGED
@@ -92,7 +92,13 @@ export type CodexCompactionFlushMode = "signal" | "heuristic" | "auto";
92
92
  export type DreamingNarrativePromptStyle = "reflective" | "diary" | "analytical";
93
93
  export type HeartbeatDetectionMode = "runtime-signal" | "heuristic" | "auto";
94
94
  export type ActiveRecallQueryMode = "message" | "recent" | "full";
95
- export type ActiveRecallPromptStyle = "balanced" | "strict" | "contextual" | "recall-heavy" | "precision-heavy" | "preference-only";
95
+ export type ActiveRecallPromptStyle =
96
+ | "balanced"
97
+ | "strict"
98
+ | "contextual"
99
+ | "recall-heavy"
100
+ | "precision-heavy"
101
+ | "preference-only";
96
102
  export type ActiveRecallThinking = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "adaptive";
97
103
  export type ActiveRecallChatType = "direct" | "group" | "channel";
98
104
  export type ActiveRecallModelFallbackPolicy = "default-remote" | "resolved-only";
@@ -285,11 +291,8 @@ export interface AgentAccessHttpConfig {
285
291
  enabled: boolean;
286
292
  host: string;
287
293
  port: number;
288
- /**
289
- * Bearer token. Either a literal string (env-expanded) or an unresolved
290
- * SecretRef object preserved verbatim from openclaw.json — resolved at
291
- * service-start time via {@link resolveAgentAccessAuthToken}.
292
- */
294
+ /** Literal string (env-expanded) or unresolved SecretRef object, preserved verbatim and
295
+ * resolved at service-start time via {@link resolveAgentAccessAuthToken}. */
293
296
  authToken?: AgentAccessAuthToken;
294
297
  principal?: string;
295
298
  maxBodyBytes: number;
@@ -297,8 +300,8 @@ export interface AgentAccessHttpConfig {
297
300
  writeRateLimitMaxRequests: number;
298
301
  /** Rolling window for the write rate limit, in ms (issue #1937). */
299
302
  writeRateLimitWindowMs: number;
300
- /** Trust the `x-engram-principal` header for per-request principal resolution (default off; trusted proxies only). */
301
- trustPrincipalHeader?: boolean;
303
+ /** Trust the per-request `X-Engram-Principal` header; only behind the bearer-token trust boundary; `--trust-principal-header` overrides (issue #3462). */
304
+ trustPrincipalHeader: boolean;
302
305
  }
303
306
 
304
307
  export interface DreamingConfig {