@codyswann/lisa 4.23.29 → 4.23.31

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 (98) hide show
  1. package/all/copy-overwrite/scripts/lisa-run-gates.mjs +96 -13
  2. package/all/copy-overwrite/scripts/lisa-work-item.mjs +186 -16
  3. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  4. package/dist/core/lisa-owned-hash-ledger.js +8 -0
  5. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  6. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  7. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  8. package/dist/core/upstream-evidence-manifest.js +28 -8
  9. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  10. package/package.json +3 -3
  11. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  12. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  13. package/plugins/lisa/.codex-plugin/skills/lisa-implement/SKILL.md +5 -1
  14. package/plugins/lisa/.codex-plugin/skills/lisa-repair-intake/SKILL.md +32 -0
  15. package/plugins/lisa/.codex-plugin/skills/lisa-secrets-access/scripts/envfile.mjs +2 -0
  16. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/assets/materialized-env-authority.mjs +262 -0
  17. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/assets/session-start.sh +21 -10
  18. package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +5 -1
  19. package/plugins/lisa/skills/lisa-implement/SKILL.md +5 -1
  20. package/plugins/lisa/skills/lisa-repair-intake/SKILL.md +32 -0
  21. package/plugins/lisa/skills/lisa-secrets-access/scripts/envfile.mjs +2 -0
  22. package/plugins/lisa/skills/lisa-setup-remote-env/assets/materialized-env-authority.mjs +262 -0
  23. package/plugins/lisa/skills/lisa-setup-remote-env/assets/session-start.sh +21 -10
  24. package/plugins/lisa/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +5 -1
  25. package/plugins/lisa-agy/plugin.json +1 -1
  26. package/plugins/lisa-agy/skills/lisa-implement/SKILL.md +5 -1
  27. package/plugins/lisa-agy/skills/lisa-repair-intake/SKILL.md +32 -0
  28. package/plugins/lisa-agy/skills/lisa-secrets-access/scripts/envfile.mjs +2 -0
  29. package/plugins/lisa-agy/skills/lisa-setup-remote-env/assets/materialized-env-authority.mjs +262 -0
  30. package/plugins/lisa-agy/skills/lisa-setup-remote-env/assets/session-start.sh +21 -10
  31. package/plugins/lisa-agy/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +5 -1
  32. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  33. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  34. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  35. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  37. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  38. package/plugins/lisa-copilot/skills/lisa-implement/SKILL.md +5 -1
  39. package/plugins/lisa-copilot/skills/lisa-repair-intake/SKILL.md +32 -0
  40. package/plugins/lisa-copilot/skills/lisa-secrets-access/scripts/envfile.mjs +2 -0
  41. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/assets/materialized-env-authority.mjs +262 -0
  42. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/assets/session-start.sh +21 -10
  43. package/plugins/lisa-copilot/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +5 -1
  44. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-cursor/skills/lisa-implement/SKILL.md +5 -1
  46. package/plugins/lisa-cursor/skills/lisa-repair-intake/SKILL.md +32 -0
  47. package/plugins/lisa-cursor/skills/lisa-secrets-access/scripts/envfile.mjs +2 -0
  48. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/assets/materialized-env-authority.mjs +262 -0
  49. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/assets/session-start.sh +21 -10
  50. package/plugins/lisa-cursor/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +5 -1
  51. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-expo-agy/plugin.json +1 -1
  54. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  58. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  59. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  62. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  63. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  64. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  65. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  66. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  67. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  68. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  69. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  70. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  71. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  73. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  74. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  75. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  76. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  77. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  78. package/plugins/lisa-rails-agy/plugin.json +1 -1
  79. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  80. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  81. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  82. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  83. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  84. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  86. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  87. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  88. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  89. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  90. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  91. package/plugins/src/base/skills/lisa-implement/SKILL.md +5 -1
  92. package/plugins/src/base/skills/lisa-repair-intake/SKILL.md +32 -0
  93. package/plugins/src/base/skills/lisa-secrets-access/scripts/envfile.mjs +2 -0
  94. package/plugins/src/base/skills/lisa-setup-remote-env/assets/materialized-env-authority.mjs +262 -0
  95. package/plugins/src/base/skills/lisa-setup-remote-env/assets/session-start.sh +21 -10
  96. package/plugins/src/base/skills/lisa-setup-remote-env/scripts/setup-remote-env.mjs +5 -1
  97. package/scripts/lisa-remote-env/materialized-env-authority.mjs +262 -0
  98. package/scripts/lisa-remote-env/session-start.sh +21 -10
@@ -0,0 +1,262 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Fail-closed authority for Lisa's materialized remote environment.
4
+ *
5
+ * SessionStart sources secret-bearing shell text, so it must first prove that
6
+ * the path still has the exact type, mode, owner, and writer format Lisa owns.
7
+ * This asset is self-contained because a freshly cloned remote host has no
8
+ * plugin module graph yet.
9
+ * @module materialized-env-authority
10
+ */
11
+ import { lstatSync, readFileSync, realpathSync } from "node:fs";
12
+ import { dirname, isAbsolute, join, resolve } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const HEADER = [
16
+ "# Generated by lisa-secrets-access. Contains secret values.",
17
+ "# Do not print, inspect, summarize, commit, or copy this file.",
18
+ ];
19
+ const SAFE_NAMESPACE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
20
+ const EXPORT_LINE = /^export ([A-Za-z_]\w*)='(.*)'$/u;
21
+ const AUTHORITY_REFUSAL = 77;
22
+
23
+ /**
24
+ * Decide whether both materialized filesystem objects belong to this user.
25
+ * @param {{directoryUid: number, expectedUid: number, fileUid: number}} facts
26
+ * Immutable owner identities.
27
+ * @returns {boolean} Whether both objects have the expected owner.
28
+ */
29
+ export function materializedOwnersMatch(facts) {
30
+ return (
31
+ facts.directoryUid === facts.expectedUid &&
32
+ facts.fileUid === facts.expectedUid
33
+ );
34
+ }
35
+
36
+ /**
37
+ * Create the pure filesystem authority decision around one owner predicate.
38
+ * @param {(facts: object) => boolean} ownersMatch Owner authority.
39
+ * @returns {(facts: object) => {accepted: boolean, reason?: string}} Verdict.
40
+ */
41
+ export function createMaterializedEnvAuthority(ownersMatch) {
42
+ return facts => {
43
+ if (facts.directoryType === "symlink" || facts.fileType === "symlink") {
44
+ return { accepted: false, reason: "materialized environment symlink" };
45
+ }
46
+ if (facts.directoryType !== "directory") {
47
+ return {
48
+ accepted: false,
49
+ reason: "materialized environment directory type mismatch",
50
+ };
51
+ }
52
+ if (facts.fileType !== "file") {
53
+ return {
54
+ accepted: false,
55
+ reason: "materialized environment regular file type mismatch",
56
+ };
57
+ }
58
+ if (facts.directoryMode !== 0o700) {
59
+ return {
60
+ accepted: false,
61
+ reason: "materialized environment directory mode is not 0700",
62
+ };
63
+ }
64
+ if (facts.fileMode !== 0o600) {
65
+ return {
66
+ accepted: false,
67
+ reason: "materialized environment file mode is not 0600",
68
+ };
69
+ }
70
+ if (!ownersMatch(facts.ownership)) {
71
+ return {
72
+ accepted: false,
73
+ reason: "materialized environment file ownership mismatch",
74
+ };
75
+ }
76
+ return { accepted: true };
77
+ };
78
+ }
79
+
80
+ export const validateMaterializedEnvAuthority = createMaterializedEnvAuthority(
81
+ materializedOwnersMatch
82
+ );
83
+
84
+ /**
85
+ * Identify one lstat result without following a symbolic link.
86
+ * @param {import("node:fs").Stats} stat Immutable lstat observation.
87
+ * @returns {"symlink" | "directory" | "file" | "other"} Object kind.
88
+ */
89
+ function statType(stat) {
90
+ if (stat.isSymbolicLink()) return "symlink";
91
+ if (stat.isDirectory()) return "directory";
92
+ if (stat.isFile()) return "file";
93
+ return "other";
94
+ }
95
+
96
+ /**
97
+ * Capture the complete immutable authority decision before reading bytes.
98
+ * @param {string} valuesFile Absolute materialized artifact path.
99
+ * @param {object} dependencies Injected filesystem and identity boundary.
100
+ * @returns {Readonly<object>} Frozen authority facts.
101
+ */
102
+ function authorityFacts(valuesFile, dependencies) {
103
+ const expectedUid = dependencies.getuid();
104
+ const directory = dependencies.lstat(dirname(valuesFile));
105
+ const file = dependencies.lstat(valuesFile);
106
+ const ownership = Object.freeze({
107
+ directoryUid: directory.uid,
108
+ expectedUid,
109
+ fileUid: file.uid,
110
+ });
111
+ return Object.freeze({
112
+ directoryMode: directory.mode & 0o777,
113
+ directoryType: statType(directory),
114
+ directoryUid: directory.uid,
115
+ expectedUid,
116
+ fileMode: file.mode & 0o777,
117
+ fileType: statType(file),
118
+ fileUid: file.uid,
119
+ ownership,
120
+ });
121
+ }
122
+
123
+ /**
124
+ * Prove text is exactly the sorted, newline-terminated Lisa writer format.
125
+ * @param {string} text Candidate shell artifact content.
126
+ * @returns {boolean} Whether the complete artifact matches the writer format.
127
+ */
128
+ function materializedFormatValid(text) {
129
+ if (typeof text !== "string" || !text.endsWith("\n")) return false;
130
+ const lines = text.split("\n");
131
+ lines.pop();
132
+ if (lines[0] !== HEADER[0] || lines[1] !== HEADER[1]) return false;
133
+ const names = [];
134
+ for (const line of lines.slice(2)) {
135
+ const match = EXPORT_LINE.exec(line);
136
+ if (!match || match[2].replaceAll("'\\''", "").includes("'")) {
137
+ return false;
138
+ }
139
+ names.push(match[1]);
140
+ }
141
+ return names.every((name, index) => index === 0 || names[index - 1] < name);
142
+ }
143
+
144
+ /**
145
+ * Read the configured safe namespace and resolve its exact values artifact.
146
+ * @param {string} configFile Absolute project configuration path.
147
+ * @param {string} configRoot Absolute per-user configuration root.
148
+ * @param {object} dependencies Injected filesystem boundary.
149
+ * @returns {string} Absolute materialized values path.
150
+ */
151
+ function valuesFileFromConfig(configFile, configRoot, dependencies) {
152
+ let config = {};
153
+ try {
154
+ config = JSON.parse(dependencies.readFile(configFile, "utf8"));
155
+ } catch (error) {
156
+ if (error?.code !== "ENOENT") throw new Error("configuration is invalid");
157
+ }
158
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
159
+ throw new Error("configuration is invalid");
160
+ }
161
+ const secrets = config.secrets ?? {};
162
+ if (!secrets || typeof secrets !== "object" || Array.isArray(secrets)) {
163
+ throw new Error("configuration secrets are invalid");
164
+ }
165
+ const namespace = secrets.namespace ?? "lisa";
166
+ if (
167
+ typeof namespace !== "string" ||
168
+ namespace === ".." ||
169
+ !SAFE_NAMESPACE.test(namespace)
170
+ ) {
171
+ throw new Error("unsafe materialized environment namespace");
172
+ }
173
+ if (!isAbsolute(configRoot)) {
174
+ throw new Error("materialized environment config root is not absolute");
175
+ }
176
+ return join(configRoot, namespace, "secrets.env");
177
+ }
178
+
179
+ /**
180
+ * Convert a caught failure into a bounded, value-free reason.
181
+ * @param {unknown} error Refusal caught at the CLI boundary.
182
+ * @returns {string} Public diagnostic reason without artifact content.
183
+ */
184
+ function refusalReason(error) {
185
+ if (error?.code === "ENOENT") return "file is missing";
186
+ if (error?.code === "EACCES") return "file is unreadable";
187
+ if (error instanceof Error && error.message.startsWith("materialized ")) {
188
+ return error.message;
189
+ }
190
+ if (error instanceof Error && error.message.startsWith("unsafe ")) {
191
+ return error.message;
192
+ }
193
+ if (error instanceof Error && error.message.startsWith("configuration ")) {
194
+ return error.message;
195
+ }
196
+ return "authority check failed";
197
+ }
198
+
199
+ /** Default synchronous boundary; injection is reserved for executable tests. */
200
+ const DEFAULT_DEPENDENCIES = Object.freeze({
201
+ getuid: () => (typeof process.getuid === "function" ? process.getuid() : -1),
202
+ lstat: lstatSync,
203
+ readFile: readFileSync,
204
+ writeError: diagnostic => process.stderr.write(diagnostic),
205
+ writeOutput: output => process.stdout.write(output),
206
+ });
207
+
208
+ /**
209
+ * Validate one materialized file, or resolve it from the project config.
210
+ * @param {readonly string[]} argv Direct file or `--resolve` arguments.
211
+ * @param {object} [injected] Test-owned filesystem and diagnostic boundary.
212
+ * @returns {number} Zero only after complete authority and format validation.
213
+ */
214
+ export function runMaterializedEnvAuthorityCli(argv, injected = {}) {
215
+ const dependencies = { ...DEFAULT_DEPENDENCIES, ...injected };
216
+ try {
217
+ const resolving = argv[0] === "--resolve";
218
+ if ((!resolving && argv.length !== 1) || (resolving && argv.length !== 3)) {
219
+ throw new Error("materialized environment arguments are invalid");
220
+ }
221
+ const valuesFile = resolving
222
+ ? valuesFileFromConfig(argv[1], argv[2], dependencies)
223
+ : argv[0];
224
+ if (!isAbsolute(valuesFile)) {
225
+ throw new Error("materialized environment path is not absolute");
226
+ }
227
+ const facts = authorityFacts(valuesFile, dependencies);
228
+ const decision = validateMaterializedEnvAuthority(facts);
229
+ if (!decision.accepted) throw new Error(decision.reason);
230
+ const text = dependencies.readFile(valuesFile, "utf8");
231
+ if (!materializedFormatValid(text)) {
232
+ throw new Error("materialized environment format is invalid");
233
+ }
234
+ if (resolving) dependencies.writeOutput(`${valuesFile}\n`);
235
+ return 0;
236
+ } catch (error) {
237
+ const reason = refusalReason(error);
238
+ dependencies.writeError(`Lisa materialized environment ${reason}\n`);
239
+ return AUTHORITY_REFUSAL;
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Decide whether this module is the process entrypoint.
245
+ * @param {string} moduleUrl Current module URL.
246
+ * @param {string | undefined} argv1 Invoked script path, when present.
247
+ * @returns {boolean} Whether the CLI driver must run.
248
+ */
249
+ function invokedAsScript(moduleUrl, argv1 = process.argv[1]) {
250
+ if (!argv1) return false;
251
+ try {
252
+ return (
253
+ realpathSync(resolve(argv1)) === realpathSync(fileURLToPath(moduleUrl))
254
+ );
255
+ } catch {
256
+ return false;
257
+ }
258
+ }
259
+
260
+ if (invokedAsScript(import.meta.url)) {
261
+ process.exitCode = runMaterializedEnvAuthorityCli(process.argv.slice(2));
262
+ }
@@ -57,15 +57,26 @@ esac
57
57
 
58
58
  bash "${here}/setup.sh" --phase=secrets "$@"
59
59
 
60
- # Materialization writes a Lisa-owned block into .profile that sources the
61
- # generated environment and removes ambient AWS credential poison. The project
62
- # hook is another non-login child, so load that block here and let the child
63
- # inherit the exact environment materialization just produced.
64
- if [ -r "$HOME/.profile" ]; then
65
- # The materializer owns this runtime path.
66
- # shellcheck disable=SC1090
67
- . "$HOME/.profile"
68
- fi
60
+ # Validate the exact Lisa-owned secrets.env before sourcing any bytes. The
61
+ # profile is unrelated host startup code and may return before Lisa's managed
62
+ # block, mutate the environment, or run arbitrary user commands. The authority
63
+ # process resolves the same configured namespace as the materializer and emits
64
+ # only the fully validated absolute artifact path.
65
+ project_root="$(CDPATH='' cd -- "${here}/../.." && pwd)"
66
+ config_root="${XDG_CONFIG_HOME:-$HOME/.config}"
67
+ values_file="$(
68
+ node "${here}/materialized-env-authority.mjs" \
69
+ --resolve "${project_root}/.lisa.config.json" "${config_root}"
70
+ )"
71
+
72
+ # Match the managed block's AWS poison removal, then export the artifact's
73
+ # values only for this session-start process and its project-hook child.
74
+ unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
75
+ set -a
76
+ # The authority process proved this exact path and its complete writer format.
77
+ # shellcheck disable=SC1090
78
+ . "${values_file}"
79
+ set +a
69
80
 
70
81
  # A project hook is part of the remote toolchain contract too. It covers tools
71
82
  # that cannot be expressed by the pinned manifest, so skipping it on a cached
@@ -73,4 +84,4 @@ fi
73
84
  # Run it last, matching the full setup order, and exec so its failure becomes
74
85
  # the SessionStart result the host can surface. SessionStart remains fail-open;
75
86
  # this reports an incomplete bootstrap but does not block the agent session.
76
- exec bash "${here}/setup.sh" --phase=hook "$@"
87
+ exec /bin/bash "${here}/setup.sh" --phase=hook "$@"
@@ -538,7 +538,11 @@ const PHASES = ["toolchain", "secrets", "hook"];
538
538
  export const INSTALL_DIR = join("scripts", "lisa-remote-env");
539
539
 
540
540
  /** Assets a host project needs on disk before any remote session can start. */
541
- const INSTALLABLE = ["setup.sh", "session-start.sh"];
541
+ const INSTALLABLE = [
542
+ "setup.sh",
543
+ "session-start.sh",
544
+ "materialized-env-authority.mjs",
545
+ ];
542
546
 
543
547
  /**
544
548
  * Copy this skill's assets into the host project that will run them.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "4.23.29",
3
+ "version": "4.23.31",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -86,7 +86,11 @@ INCLUDE|EXCLUDE - <agent type> - <one-sentence reason>
86
86
 
87
87
  Review all available agent types listed in the current runtime's delegation options. In Claude, this includes the Task tool's `subagent_type` options: built-in agents such as `Explore` and `general-purpose`, custom agents from `.claude/agents/`, and plugin agents from enabled plugins. In Codex, Cursor, Copilot, agy, OpenCode, or another runtime, use that runtime's tool-discovery and delegation surfaces to enumerate the equivalent available specialists. If the runtime exposes no specialist list, record that explicitly in the Roster Decision and justify the fallback agent type you will use.
88
88
 
89
- Persist the Roster Decision where the flow can be audited later. Prefer task-list metadata `metadata.roster` when a task list exists; otherwise write `${LISA_PROJECT_DIR:-${CLAUDE_PROJECT_DIR:-.}}/.lisa/roster.md` or post the Roster Decision in the plan/tracker artifact the flow is already updating. The later verification/evidence step must reference the recorded artifact; absence of the artifact is a workflow failure.
89
+ Persist the Roster Decision where the flow can be audited later. Prefer task-list metadata `metadata.roster` when a task list exists; otherwise write `${LISA_PROJECT_DIR:-${CLAUDE_PROJECT_DIR:-.}}/.lisa/roster/<work-item-slug>.md` or post the Roster Decision in the plan/tracker artifact the flow is already updating. The later verification/evidence step must reference the recorded artifact; absence of the artifact is a workflow failure.
90
+
91
+ `<work-item-slug>` is this flow's work-item reference with every character outside `[A-Za-z0-9._-]` replaced by `-` — `SE-490` stays `SE-490`, `CodySwannGT/lisa#3395` becomes `CodySwannGT-lisa-3395`. **One file per work item, never a shared one.** The path used to be the single `.lisa/roster.md`, and two flows running concurrently in one repository both wrote it: the first time each created it, the merge was add/add, which has no common ancestor for git to three-way, so resolution was a coin flip that silently discarded the other flow's roster. Because the file reads as scratch, that discard looked harmless and got done without thought — while the surviving roster belonged to a different flow than the one being audited. A per-work-item path cannot collide, and it matches the per-flow `.lisa/plan-<id>.md` artifacts already written alongside it.
92
+
93
+ Rosters stay **trackable** — they are the auditable record of who was on a flow, not runtime scratch, which is why `.lisa/` ignores specific runtime filenames rather than the whole directory (CodySwannGT/lisa#1607). Do not add `.lisa/roster/` to `.gitignore`. A repository that already carries a committed `.lisa/roster.md` from before this change keeps it; leave it alone rather than migrating or deleting it, and write this flow's roster to the per-work-item path.
90
94
 
91
95
  Inclusion is the default. You MUST justify excluding an agent. Every team must include the Explore agent, or the runtime's nearest read-only search/research equivalent; if no equivalent exists, record that gap in the Roster Decision.
92
96
 
@@ -999,6 +999,38 @@ running the needed research (`lisa-codebase-research` / `lisa-product-walkthroug
999
999
  human comment/edit newer than the last `[lisa-repair-intake]` note. Resolved → proceed to
1000
1000
  re-dispatch; else stay blocked.
1001
1001
 
1002
+ **`human_needed` hard-stops this path. Do not enter Class C at all.** Before classifying a block as
1003
+ Class C, check the marker: if the item carries `human_needed`, skip it, leave it `blocked`, and
1004
+ record the skip reason in the run record (`skipped: human_needed`). This is a **refusal to
1005
+ re-evaluate**, not a preserve-and-proceed — preserving the marker while overriding what it guards is
1006
+ not a guard. The marker means a human must decide; no amount of research substitutes for a decision
1007
+ that has not been made.
1008
+
1009
+ Match the marker **robustly**: the configured label resolves to `human-needed` (hyphen) while the
1010
+ contract term is `human_needed` (underscore), and it can also appear in the block note's prose. Treat
1011
+ hyphen and underscore as the same marker, case-insensitively, in both the label set and the note. A
1012
+ literal single-spelling match silently defeats this guard.
1013
+
1014
+ **"No blocker found" is inconclusive, never clearance.** Research that finds nothing does **not**
1015
+ satisfy the resolution condition. Absence of a tracked blocker is not evidence that the blocker is
1016
+ gone — it is frequently evidence that the blocker was never the kind of thing a dependency link
1017
+ records. An item whose research terminates in "nothing found" stays `blocked`. Only a positive
1018
+ finding — the research answered the open question, or a human comment/edit newer than the last
1019
+ `[lisa-repair-intake]` note supplied the answer — clears it.
1020
+
1021
+ **Distinguish a decision-block from an ambiguity-block.** Class C applies only where a *discoverable
1022
+ fact* would settle the question. A block awaiting a **choice between valid alternatives** is not a
1023
+ researchable ambiguity at any confidence level, and research against it is structurally incapable of
1024
+ reaching the right answer: there is nothing to find, so it terminates in "no blocker found" — which,
1025
+ before this guard, the next step read as clearance. If the blocker names two or more technically
1026
+ valid options and asks which to take, it is a decision-block: leave it `blocked`, ensure the
1027
+ `human_needed` marker is present, and do not research it.
1028
+
1029
+ > Two conditions make a decision-block look exactly like a Class-C candidate: **no dependency links**
1030
+ > (the blocker is a question, not a tracked ticket) and **no failed validation gate** (it is prose, not
1031
+ > a red check). Together they read as "no blockers tracked, ambiguity present, go research it" —
1032
+ > precisely the Class-C trigger, and precisely when the guard above must fire instead.
1033
+
1002
1034
  ### Class D — deployed / runtime verification failure
1003
1035
 
1004
1036
  A block set by a *deployed* or *runtime* check that failed against a live environment — a
@@ -10,6 +10,8 @@
10
10
  * @module envfile
11
11
  */
12
12
 
13
+ export { materializedOwnersMatch } from "../../lisa-setup-remote-env/assets/materialized-env-authority.mjs";
14
+
13
15
  /**
14
16
  * POSIX single-quote a value so a shell reproduces it byte for byte.
15
17
  *
@@ -0,0 +1,262 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Fail-closed authority for Lisa's materialized remote environment.
4
+ *
5
+ * SessionStart sources secret-bearing shell text, so it must first prove that
6
+ * the path still has the exact type, mode, owner, and writer format Lisa owns.
7
+ * This asset is self-contained because a freshly cloned remote host has no
8
+ * plugin module graph yet.
9
+ * @module materialized-env-authority
10
+ */
11
+ import { lstatSync, readFileSync, realpathSync } from "node:fs";
12
+ import { dirname, isAbsolute, join, resolve } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const HEADER = [
16
+ "# Generated by lisa-secrets-access. Contains secret values.",
17
+ "# Do not print, inspect, summarize, commit, or copy this file.",
18
+ ];
19
+ const SAFE_NAMESPACE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
20
+ const EXPORT_LINE = /^export ([A-Za-z_]\w*)='(.*)'$/u;
21
+ const AUTHORITY_REFUSAL = 77;
22
+
23
+ /**
24
+ * Decide whether both materialized filesystem objects belong to this user.
25
+ * @param {{directoryUid: number, expectedUid: number, fileUid: number}} facts
26
+ * Immutable owner identities.
27
+ * @returns {boolean} Whether both objects have the expected owner.
28
+ */
29
+ export function materializedOwnersMatch(facts) {
30
+ return (
31
+ facts.directoryUid === facts.expectedUid &&
32
+ facts.fileUid === facts.expectedUid
33
+ );
34
+ }
35
+
36
+ /**
37
+ * Create the pure filesystem authority decision around one owner predicate.
38
+ * @param {(facts: object) => boolean} ownersMatch Owner authority.
39
+ * @returns {(facts: object) => {accepted: boolean, reason?: string}} Verdict.
40
+ */
41
+ export function createMaterializedEnvAuthority(ownersMatch) {
42
+ return facts => {
43
+ if (facts.directoryType === "symlink" || facts.fileType === "symlink") {
44
+ return { accepted: false, reason: "materialized environment symlink" };
45
+ }
46
+ if (facts.directoryType !== "directory") {
47
+ return {
48
+ accepted: false,
49
+ reason: "materialized environment directory type mismatch",
50
+ };
51
+ }
52
+ if (facts.fileType !== "file") {
53
+ return {
54
+ accepted: false,
55
+ reason: "materialized environment regular file type mismatch",
56
+ };
57
+ }
58
+ if (facts.directoryMode !== 0o700) {
59
+ return {
60
+ accepted: false,
61
+ reason: "materialized environment directory mode is not 0700",
62
+ };
63
+ }
64
+ if (facts.fileMode !== 0o600) {
65
+ return {
66
+ accepted: false,
67
+ reason: "materialized environment file mode is not 0600",
68
+ };
69
+ }
70
+ if (!ownersMatch(facts.ownership)) {
71
+ return {
72
+ accepted: false,
73
+ reason: "materialized environment file ownership mismatch",
74
+ };
75
+ }
76
+ return { accepted: true };
77
+ };
78
+ }
79
+
80
+ export const validateMaterializedEnvAuthority = createMaterializedEnvAuthority(
81
+ materializedOwnersMatch
82
+ );
83
+
84
+ /**
85
+ * Identify one lstat result without following a symbolic link.
86
+ * @param {import("node:fs").Stats} stat Immutable lstat observation.
87
+ * @returns {"symlink" | "directory" | "file" | "other"} Object kind.
88
+ */
89
+ function statType(stat) {
90
+ if (stat.isSymbolicLink()) return "symlink";
91
+ if (stat.isDirectory()) return "directory";
92
+ if (stat.isFile()) return "file";
93
+ return "other";
94
+ }
95
+
96
+ /**
97
+ * Capture the complete immutable authority decision before reading bytes.
98
+ * @param {string} valuesFile Absolute materialized artifact path.
99
+ * @param {object} dependencies Injected filesystem and identity boundary.
100
+ * @returns {Readonly<object>} Frozen authority facts.
101
+ */
102
+ function authorityFacts(valuesFile, dependencies) {
103
+ const expectedUid = dependencies.getuid();
104
+ const directory = dependencies.lstat(dirname(valuesFile));
105
+ const file = dependencies.lstat(valuesFile);
106
+ const ownership = Object.freeze({
107
+ directoryUid: directory.uid,
108
+ expectedUid,
109
+ fileUid: file.uid,
110
+ });
111
+ return Object.freeze({
112
+ directoryMode: directory.mode & 0o777,
113
+ directoryType: statType(directory),
114
+ directoryUid: directory.uid,
115
+ expectedUid,
116
+ fileMode: file.mode & 0o777,
117
+ fileType: statType(file),
118
+ fileUid: file.uid,
119
+ ownership,
120
+ });
121
+ }
122
+
123
+ /**
124
+ * Prove text is exactly the sorted, newline-terminated Lisa writer format.
125
+ * @param {string} text Candidate shell artifact content.
126
+ * @returns {boolean} Whether the complete artifact matches the writer format.
127
+ */
128
+ function materializedFormatValid(text) {
129
+ if (typeof text !== "string" || !text.endsWith("\n")) return false;
130
+ const lines = text.split("\n");
131
+ lines.pop();
132
+ if (lines[0] !== HEADER[0] || lines[1] !== HEADER[1]) return false;
133
+ const names = [];
134
+ for (const line of lines.slice(2)) {
135
+ const match = EXPORT_LINE.exec(line);
136
+ if (!match || match[2].replaceAll("'\\''", "").includes("'")) {
137
+ return false;
138
+ }
139
+ names.push(match[1]);
140
+ }
141
+ return names.every((name, index) => index === 0 || names[index - 1] < name);
142
+ }
143
+
144
+ /**
145
+ * Read the configured safe namespace and resolve its exact values artifact.
146
+ * @param {string} configFile Absolute project configuration path.
147
+ * @param {string} configRoot Absolute per-user configuration root.
148
+ * @param {object} dependencies Injected filesystem boundary.
149
+ * @returns {string} Absolute materialized values path.
150
+ */
151
+ function valuesFileFromConfig(configFile, configRoot, dependencies) {
152
+ let config = {};
153
+ try {
154
+ config = JSON.parse(dependencies.readFile(configFile, "utf8"));
155
+ } catch (error) {
156
+ if (error?.code !== "ENOENT") throw new Error("configuration is invalid");
157
+ }
158
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
159
+ throw new Error("configuration is invalid");
160
+ }
161
+ const secrets = config.secrets ?? {};
162
+ if (!secrets || typeof secrets !== "object" || Array.isArray(secrets)) {
163
+ throw new Error("configuration secrets are invalid");
164
+ }
165
+ const namespace = secrets.namespace ?? "lisa";
166
+ if (
167
+ typeof namespace !== "string" ||
168
+ namespace === ".." ||
169
+ !SAFE_NAMESPACE.test(namespace)
170
+ ) {
171
+ throw new Error("unsafe materialized environment namespace");
172
+ }
173
+ if (!isAbsolute(configRoot)) {
174
+ throw new Error("materialized environment config root is not absolute");
175
+ }
176
+ return join(configRoot, namespace, "secrets.env");
177
+ }
178
+
179
+ /**
180
+ * Convert a caught failure into a bounded, value-free reason.
181
+ * @param {unknown} error Refusal caught at the CLI boundary.
182
+ * @returns {string} Public diagnostic reason without artifact content.
183
+ */
184
+ function refusalReason(error) {
185
+ if (error?.code === "ENOENT") return "file is missing";
186
+ if (error?.code === "EACCES") return "file is unreadable";
187
+ if (error instanceof Error && error.message.startsWith("materialized ")) {
188
+ return error.message;
189
+ }
190
+ if (error instanceof Error && error.message.startsWith("unsafe ")) {
191
+ return error.message;
192
+ }
193
+ if (error instanceof Error && error.message.startsWith("configuration ")) {
194
+ return error.message;
195
+ }
196
+ return "authority check failed";
197
+ }
198
+
199
+ /** Default synchronous boundary; injection is reserved for executable tests. */
200
+ const DEFAULT_DEPENDENCIES = Object.freeze({
201
+ getuid: () => (typeof process.getuid === "function" ? process.getuid() : -1),
202
+ lstat: lstatSync,
203
+ readFile: readFileSync,
204
+ writeError: diagnostic => process.stderr.write(diagnostic),
205
+ writeOutput: output => process.stdout.write(output),
206
+ });
207
+
208
+ /**
209
+ * Validate one materialized file, or resolve it from the project config.
210
+ * @param {readonly string[]} argv Direct file or `--resolve` arguments.
211
+ * @param {object} [injected] Test-owned filesystem and diagnostic boundary.
212
+ * @returns {number} Zero only after complete authority and format validation.
213
+ */
214
+ export function runMaterializedEnvAuthorityCli(argv, injected = {}) {
215
+ const dependencies = { ...DEFAULT_DEPENDENCIES, ...injected };
216
+ try {
217
+ const resolving = argv[0] === "--resolve";
218
+ if ((!resolving && argv.length !== 1) || (resolving && argv.length !== 3)) {
219
+ throw new Error("materialized environment arguments are invalid");
220
+ }
221
+ const valuesFile = resolving
222
+ ? valuesFileFromConfig(argv[1], argv[2], dependencies)
223
+ : argv[0];
224
+ if (!isAbsolute(valuesFile)) {
225
+ throw new Error("materialized environment path is not absolute");
226
+ }
227
+ const facts = authorityFacts(valuesFile, dependencies);
228
+ const decision = validateMaterializedEnvAuthority(facts);
229
+ if (!decision.accepted) throw new Error(decision.reason);
230
+ const text = dependencies.readFile(valuesFile, "utf8");
231
+ if (!materializedFormatValid(text)) {
232
+ throw new Error("materialized environment format is invalid");
233
+ }
234
+ if (resolving) dependencies.writeOutput(`${valuesFile}\n`);
235
+ return 0;
236
+ } catch (error) {
237
+ const reason = refusalReason(error);
238
+ dependencies.writeError(`Lisa materialized environment ${reason}\n`);
239
+ return AUTHORITY_REFUSAL;
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Decide whether this module is the process entrypoint.
245
+ * @param {string} moduleUrl Current module URL.
246
+ * @param {string | undefined} argv1 Invoked script path, when present.
247
+ * @returns {boolean} Whether the CLI driver must run.
248
+ */
249
+ function invokedAsScript(moduleUrl, argv1 = process.argv[1]) {
250
+ if (!argv1) return false;
251
+ try {
252
+ return (
253
+ realpathSync(resolve(argv1)) === realpathSync(fileURLToPath(moduleUrl))
254
+ );
255
+ } catch {
256
+ return false;
257
+ }
258
+ }
259
+
260
+ if (invokedAsScript(import.meta.url)) {
261
+ process.exitCode = runMaterializedEnvAuthorityCli(process.argv.slice(2));
262
+ }