{"record":{"id":"0c710c4d4f1d256f","repo":"ruvnet/ruflo","slug":"trajectory-envelope-not-found-path","errorCode":null,"errorMessage":"trajectory envelope not found: ${path}","messagePattern":"trajectory envelope not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/browser/src/application/signed-trajectory-service.ts","lineNumber":94,"sourceCode":"    },\n    key,\n    { sealedAt: input.sealedAt },\n  );\n\n  return { envelope, publicKeyHex: key.publicKeyHex };\n}\n\n/** Write a signed envelope to disk. */\nexport async function writeSealedTrajectory(\n  envelope: SignedTrajectoryEnvelope,\n  path: string,\n): Promise<void> {\n  await writeFile(resolvePath(path), JSON.stringify(envelope, null, 2), 'utf8');\n}\n\n/** Read a signed envelope from disk. */\nexport async function readSealedTrajectory(path: string): Promise<SignedTrajectoryEnvelope> {\n  if (!existsSync(path)) throw new Error('trajectory envelope not found: ' + path);\n  const raw = await readFile(resolvePath(path), 'utf8');\n  return JSON.parse(raw) as SignedTrajectoryEnvelope;\n}\n\n/** Verify a sealed envelope. Thin wrapper that allows trust-list filtering. */\nexport function verifySealedTrajectory(\n  envelope: unknown,\n  options: { trustedPublicKeys?: string[] } = {},\n): VerificationResult {\n  return verifyTrajectory(envelope, options);\n}\n\n/**\n * Compute the replay plan from a sealed envelope + mutations.\n *\n * Phase 1 deliberately returns a plan rather than executing — the executor\n * needs a live BrowserService and is wired in BrowserService.replayFromEnvelope.\n * This keeps the signing/replay logic browser-engine-independent so it can be","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/browser/src/application/signed-trajectory-service.ts#L76-L112","documentation":"Thrown synchronously by readSealedTrajectory(path) when existsSync(path) reports the file is absent. The function then would readFile + JSON.parse the envelope, but it guards the missing-file case first with this error. Note it uses existsSync (synchronous) then readFile (async) — a TOCTOU gap means the file could disappear between the two calls, surfacing as a different ENOENT.","triggerScenarios":"Calling readSealedTrajectory with a path that was never written by writeSealedTrajectory, a relative path resolved against an unexpected cwd, a path on a different filesystem/container, or a path whose write failed silently upstream.","commonSituations":"Passing a trajectoryId-derived path before sealing; using a relative path that resolves differently in tests vs. runtime; reading from a temp dir cleared between CI steps; mistyping the extension (.json vs none).","solutions":["Confirm the path was produced by a successful writeSealedTrajectory call in the same process.","Use an absolute path (resolvePath is applied internally, but absolute removes cwd ambiguity).","Guard the call with existsSync yourself only when you also control concurrent deletion; otherwise wrap in try/catch and treat absence as 'no trajectory yet'.","If reading across processes/containers, verify the shared volume mount and that the writer flushed before the reader starts."],"exampleFix":"// before\nconst env = await readSealedTrajectory(`./runs/${id}`); // throws 61\n\n// after\nimport { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nconst p = resolve('./runs', `${id}.json`);\nconst env = existsSync(p)\n  ? await readSealedTrajectory(p)\n  : undefined;","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nfunction assertTrajectoryReadable(p) {\n  const abs = resolve(p);\n  if (!existsSync(abs)) throw new Error(`no trajectory at ${abs}`);\n  return abs;\n}","typeGuard":"null","tryCatchPattern":"try {\n  const env = await readSealedTrajectory(path);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('trajectory envelope not found')) {\n    return undefined; // treat absence as 'no trajectory yet'\n  }\n  throw e;\n}","preventionTips":["Always write with writeSealedTrajectory before reading; assert the write resolved.","Use absolute paths to avoid cwd-dependent resolution.","Share a single resolve() helper between writer and reader so paths agree."],"tags":["filesystem","trajectory","missing-file","typescript"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}