archgraph-argo-beta 0.27.0-beta.15 → 0.27.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -43,6 +43,13 @@ ArchGraph deploys the ARGO toolchain to all major coding-agent environments:
43
43
  A single `argo-deploy` registers the `argo` MCP server and installs all artifacts into each harness
44
44
  automatically.
45
45
 
46
+ For **Codex** (OpenAI Codex CLI / desktop), `argo-deploy` places the artifacts where Codex looks:
47
+ the rules go to `~/.codex/AGENTS.md` (Codex injects the global `AGENTS.md` into every session, so the
48
+ wakeup gate is always active), the `argo-init` and `ea-human-reconcile` skills go to
49
+ `~/.codex/skills/`, and the `argo` and `graph-mcp` MCP servers are registered in
50
+ `~/.codex/config.toml` (`[mcp_servers.*]`) — the `argo` server follows the workspace you open in
51
+ Codex.
52
+
46
53
  ## Install
47
54
 
48
55
  ```powershell
package/argo/.env.example CHANGED
@@ -168,3 +168,14 @@ ARGO_W31_LIVE_MUTATION_VECTOR_E2E=
168
168
  # ARGO_MCP_SEMANTIC_DEDUP_THRESHOLD=
169
169
  # Alias of ARGO_MCP_SEMANTIC_DEDUP_THRESHOLD (takes precedence when set).
170
170
  # ARGO_SEMANTIC_DEDUP_THRESHOLD=
171
+ # Cross-project WRITE guard. Default ON: a write tool may only target the
172
+ # server's own (home) workspace, so a foreign per-call workspaceRoot is
173
+ # rejected fail-closed while cross-project READS stay open. "0" disables it
174
+ # (all-or-nothing) for a trusted multi-workspace host that legitimately writes
175
+ # several workspaces through one server.
176
+ # ARGO_WORKSPACE_WRITE_GUARD=
177
+ # Set to "1" by a trusted host broker (e.g. the DSH workspace bridge) to assert
178
+ # it controls the per-call `sessionWorkspaceRoot` field; the argo server then
179
+ # allows WRITES to that host-designated session workspace as well as its home
180
+ # workspace. A model cannot set a process env var, so the trust is unforgeable.
181
+ # ARGO_WORKSPACE_ROOT_TRUSTED=
@@ -19,6 +19,11 @@ const {
19
19
  externalQueryRequested,
20
20
  queryExternalRead,
21
21
  } = require('./external-graph-query.js');
22
+ const {
23
+ authorizeWorkspaceWrite,
24
+ isWriteTool,
25
+ stripTrustedSessionField,
26
+ } = require('./workspace-write-guard.js');
22
27
  const {
23
28
  getWorkspaceRoot,
24
29
  hasStaticWorkspace,
@@ -411,6 +416,33 @@ function resolveWorkspaceRoot(args) {
411
416
  }
412
417
 
413
418
  async function callTool(name, args = {}, progressToken = null, dependencies = undefined) {
419
+ // Cross-project WRITE guard (single choke point for every tool): a write tool
420
+ // may only target this server's HOME workspace, or a host-designated trusted
421
+ // session workspace when the process was launched by a trusted broker
422
+ // (ARGO_WORKSPACE_ROOT_TRUSTED=1). A foreign `workspaceRoot` is rejected
423
+ // fail-closed before any side effect; READ tools stay ungated so cross-project
424
+ // reading still works. See workspace-write-guard.js.
425
+ if (isWriteTool(name, args)) {
426
+ const decision = authorizeWorkspaceWrite({ tool: name, args, homeRoot: getWorkspaceRoot() });
427
+ if (!decision.allowed) {
428
+ return toolResult({
429
+ status: 'failed',
430
+ error: {
431
+ category: decision.category,
432
+ message: decision.message,
433
+ tool: decision.tool,
434
+ homeWorkspaceRoot: decision.homeWorkspaceRoot,
435
+ requestedWorkspaceRoot: decision.requestedWorkspaceRoot,
436
+ ...(decision.trustedSessionWorkspaceRoot
437
+ ? { trustedSessionWorkspaceRoot: decision.trustedSessionWorkspaceRoot }
438
+ : {}),
439
+ },
440
+ });
441
+ }
442
+ }
443
+ // The broker-only field is not part of any tool's schema: honor it above, then
444
+ // drop it before dispatch so schema validation never sees it.
445
+ args = stripTrustedSessionField(args);
414
446
  loadRepositoryArgoEnvironment(resolveWorkspaceRoot(args));
415
447
  try {
416
448
  const crash = require('./graph-rag/mcpCrashDiagnostics.js');
@@ -99,6 +99,8 @@ const HOST_ONLY_ENV_KEYS = Object.freeze([
99
99
  'ARGO_MCP_SEMANTIC_DEDUP',
100
100
  'ARGO_MCP_SEMANTIC_DEDUP_THRESHOLD',
101
101
  'ARGO_SEMANTIC_DEDUP_THRESHOLD',
102
+ 'ARGO_WORKSPACE_WRITE_GUARD',
103
+ 'ARGO_WORKSPACE_ROOT_TRUSTED',
102
104
  'ARGO_COST_PROFILER',
103
105
  'ARGO_COST_TRACE_MAX_BYTES',
104
106
  'ARGO_CONTEXT_MAX_BYTES',
@@ -0,0 +1,144 @@
1
+ 'use strict';
2
+
3
+ // Cross-project workspace WRITE guard.
4
+ //
5
+ // The per-call `workspaceRoot` override is a wanted capability: it lets a caller
6
+ // READ another local project's intent graph. It must NOT let the caller WRITE an
7
+ // arbitrary other project's graph. This guard bounds writes to the server's HOME
8
+ // workspace PLUS a host-designated session workspace that only a trusted broker
9
+ // may name.
10
+ //
11
+ // Two channels, deliberately distinct:
12
+ // - `workspaceRoot` : the generic per-call override. A model may set it.
13
+ // Reads honor it; a WRITE to a foreign path is denied.
14
+ // - `sessionWorkspaceRoot`: the host broker's (e.g. the DSH workspace bridge)
15
+ // designation of the current session's workspace. It
16
+ // is trusted for writes ONLY when the process was
17
+ // launched with ARGO_WORKSPACE_ROOT_TRUSTED=1 (set by
18
+ // the broker at spawn, which the model cannot forge).
19
+ // A model-supplied sessionWorkspaceRoot on a plain
20
+ // (unflagged) server is ignored.
21
+ //
22
+ // So: cross-project reading keeps working everywhere; cross-project WRITING is
23
+ // blocked unless the trusted host broker explicitly designates that workspace.
24
+ // The whole guard is OFF (all-or-nothing) with ARGO_WORKSPACE_WRITE_GUARD=0.
25
+
26
+ const path = require('node:path');
27
+
28
+ // Host-designated trusted session workspace (broker channel, not advertised to
29
+ // the model).
30
+ const TRUSTED_SESSION_FIELD = 'sessionWorkspaceRoot';
31
+ // Spawn-time flag the broker sets to assert it controls TRUSTED_SESSION_FIELD.
32
+ const TRUSTED_ENV = 'ARGO_WORKSPACE_ROOT_TRUSTED';
33
+
34
+ // Tools whose invocation mutates the target workspace. `preview*` and the read
35
+ // tools are intentionally absent.
36
+ const WRITE_TOOLS = Object.freeze(new Set([
37
+ 'initializeWorkspace',
38
+ 'runArchitectureTests',
39
+ 'applySystemArchitectureMutation',
40
+ 'addArchitectureElement',
41
+ 'updateArchitectureElement',
42
+ 'removeArchitectureElement',
43
+ 'addArchitectureRelationship',
44
+ 'updateArchitectureRelationship',
45
+ 'removeArchitectureRelationship',
46
+ 'addArchitectureView',
47
+ 'updateArchitectureView',
48
+ 'removeArchitectureView',
49
+ ]));
50
+
51
+ function guardDisabled(env = process.env) {
52
+ const value = env && env.ARGO_WORKSPACE_WRITE_GUARD;
53
+ return value !== undefined && String(value).trim() === '0';
54
+ }
55
+
56
+ // A focused mutation with dryRun:true validates only and never writes, so it is
57
+ // not a write for this guard. initializeWorkspace has no dry-run.
58
+ function isWriteTool(name, args = {}) {
59
+ if (!WRITE_TOOLS.has(name)) {
60
+ return false;
61
+ }
62
+ if (name !== 'initializeWorkspace' && args && args.dryRun === true) {
63
+ return false;
64
+ }
65
+ return true;
66
+ }
67
+
68
+ function sameWorkspace(a, b) {
69
+ const na = path.resolve(String(a));
70
+ const nb = path.resolve(String(b));
71
+ return process.platform === 'win32' ? na.toLowerCase() === nb.toLowerCase() : na === nb;
72
+ }
73
+
74
+ // The host-broker-designated session workspace, honored only behind the
75
+ // spawn-time trust flag. Returns an absolute path or null.
76
+ function trustedSessionWorkspace(args, env = process.env) {
77
+ if (!env || String(env[TRUSTED_ENV]).trim() !== '1') {
78
+ return null;
79
+ }
80
+ const raw = args && typeof args[TRUSTED_SESSION_FIELD] === 'string'
81
+ ? args[TRUSTED_SESSION_FIELD].trim()
82
+ : '';
83
+ return raw !== '' ? path.resolve(raw) : null;
84
+ }
85
+
86
+ /**
87
+ * Authorize one write against the home workspace and the trusted session workspace.
88
+ *
89
+ * @param {object} options
90
+ * @param {string} options.tool
91
+ * @param {object} [options.args]
92
+ * @param {string} options.homeRoot - the server's own workspace root.
93
+ * @param {object} [options.env] - injectable environment (tests).
94
+ * @returns {{allowed:boolean, category?:string, message?:string, tool:string, homeWorkspaceRoot:string, requestedWorkspaceRoot:string, trustedSessionWorkspaceRoot:(string|null)}}
95
+ */
96
+ function authorizeWorkspaceWrite({ tool, args = {}, homeRoot, env = process.env }) {
97
+ const requestedRaw = args && typeof args.workspaceRoot === 'string' ? args.workspaceRoot.trim() : '';
98
+ const requested = requestedRaw !== '' ? path.resolve(requestedRaw) : path.resolve(homeRoot);
99
+ const trusted = trustedSessionWorkspace(args, env);
100
+ const base = {
101
+ tool,
102
+ homeWorkspaceRoot: path.resolve(homeRoot),
103
+ requestedWorkspaceRoot: requested,
104
+ trustedSessionWorkspaceRoot: trusted,
105
+ };
106
+ if (guardDisabled(env) || sameWorkspace(requested, homeRoot)) {
107
+ return { ...base, allowed: true };
108
+ }
109
+ if (trusted && sameWorkspace(requested, trusted)) {
110
+ return { ...base, allowed: true };
111
+ }
112
+ return {
113
+ ...base,
114
+ allowed: false,
115
+ category: 'WORKSPACE_WRITE_DENIED',
116
+ message:
117
+ `Write tool '${tool}' targets workspace '${requested}' but this server is only allowed to write its home workspace ` +
118
+ `'${base.homeWorkspaceRoot}' (plus a trusted host-designated session workspace). Cross-project access is read-only: ` +
119
+ 'pass workspaceRoot only to read tools (getSystemArchitecture, getIntentElementContext, getArchitectureViewContext, ' +
120
+ 'queryNeo4jGraph, memory_search).',
121
+ };
122
+ }
123
+
124
+ // Remove the broker-only field so it never reaches tool schema validation.
125
+ function stripTrustedSessionField(args) {
126
+ if (!args || !Object.prototype.hasOwnProperty.call(args, TRUSTED_SESSION_FIELD)) {
127
+ return args;
128
+ }
129
+ const next = { ...args };
130
+ delete next[TRUSTED_SESSION_FIELD];
131
+ return next;
132
+ }
133
+
134
+ module.exports = {
135
+ WRITE_TOOLS,
136
+ TRUSTED_SESSION_FIELD,
137
+ TRUSTED_ENV,
138
+ guardDisabled,
139
+ isWriteTool,
140
+ sameWorkspace,
141
+ trustedSessionWorkspace,
142
+ authorizeWorkspaceWrite,
143
+ stripTrustedSessionField,
144
+ };
@@ -50,6 +50,14 @@ function normalizeServerSpecs(config) {
50
50
  if (spec.injectWorkspaceRoot && topWorkspaces.length > 0) {
51
51
  env.ARGO_WORKSPACE_ROOTS = topWorkspaces.join(';')
52
52
  }
53
+ // Assert the broker-controlled workspace channel: the argo server will only
54
+ // trust the per-call sessionWorkspaceRoot (which this bridge sets from the
55
+ // durable SessionHeader.cwd, overwriting any model value) when this flag is
56
+ // present. The model cannot set a server process env var, so the trust is
57
+ // unforgeable.
58
+ if (spec.injectWorkspaceRoot) {
59
+ env.ARGO_WORKSPACE_ROOT_TRUSTED = '1'
60
+ }
53
61
  return { ...spec, env, cwd: spec.cwd ?? (spec.injectWorkspaceRoot ? config.cwd : undefined) }
54
62
  }
55
63
 
@@ -173,6 +181,13 @@ async function mountServer(ctx, spec, registered) {
173
181
  : undefined
174
182
  if (typeof sessionCwd === 'string' && sessionCwd !== '') {
175
183
  injected.workspaceRoot = sessionCwd
184
+ // Broker-only trusted channel: the server allows WRITES to this
185
+ // workspace (see workspace-write-guard.js). Set AFTER the spread so
186
+ // a model-supplied value can never win.
187
+ injected.sessionWorkspaceRoot = sessionCwd
188
+ } else {
189
+ // No session workspace: never forward a model-supplied trusted field.
190
+ delete injected.sessionWorkspaceRoot
176
191
  }
177
192
  }
178
193
  if (exec && exec.signal && exec.signal.aborted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archgraph-argo-beta",
3
- "version": "0.27.0-beta.15",
3
+ "version": "0.27.0-beta.16",
4
4
  "description": "Deploy the ArchGraph ARGO toolchain, skills, and rules (schema, scripts, argo-init skill, global rule) with one command.",
5
5
  "license": "MIT",
6
6
  "bin": {