anhedral 0.8.5 → 0.8.6

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 (46) hide show
  1. package/README.md +14 -11
  2. package/assets/anhedral-cli-init-technical.svg +9 -9
  3. package/assets/anhedral-cli-init.svg +9 -9
  4. package/assets/security/LICENSES.txt +63 -0
  5. package/assets/security/audit-deps.mjs +295 -0
  6. package/assets/security/braces-regression.mjs +102 -0
  7. package/assets/security/braces@3.0.3.patch +285 -0
  8. package/assets/security/decode-uri-component@0.2.2.patch +149 -0
  9. package/assets/security/decoder-regression.mjs +37 -0
  10. package/assets/security/forge-regression.mjs +46 -0
  11. package/assets/security/manifest.json +53 -0
  12. package/assets/security/node-forge@1.4.0.patch +26 -0
  13. package/dist/bin.js +39 -2
  14. package/dist/capabilities.d.ts +11 -7
  15. package/dist/capabilities.js +26 -22
  16. package/dist/dependencies.d.ts +3 -2
  17. package/dist/dependencies.js +44 -40
  18. package/dist/evidence-validation.d.ts +2 -0
  19. package/dist/evidence-validation.js +18 -0
  20. package/dist/foundation.d.ts +6 -0
  21. package/dist/foundation.js +49 -0
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +1 -0
  24. package/dist/platforms/desktop.js +3 -3
  25. package/dist/platforms/extension.js +64 -94
  26. package/dist/platforms/mobile.js +1 -1
  27. package/dist/pnpm-policy.d.ts +6 -0
  28. package/dist/pnpm-policy.js +61 -0
  29. package/dist/progress-view.d.ts +57 -0
  30. package/dist/progress-view.js +69 -0
  31. package/dist/progress.d.ts +95 -0
  32. package/dist/progress.js +327 -0
  33. package/dist/project.d.ts +1 -0
  34. package/dist/readiness.d.ts +1 -0
  35. package/dist/readiness.js +7 -2
  36. package/dist/render.d.ts +4 -0
  37. package/dist/render.js +13 -0
  38. package/dist/security-backports.d.ts +3 -0
  39. package/dist/security-backports.js +21 -0
  40. package/dist/standard.d.ts +2 -0
  41. package/dist/standard.js +161 -98
  42. package/dist/transaction.js +34 -5
  43. package/dist/version.d.ts +1 -1
  44. package/dist/version.js +1 -1
  45. package/docs/application-stack-standard.md +85 -669
  46. package/package.json +10 -9
@@ -1,4 +1,4 @@
1
- import { closeSync, cpSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmdirSync, rmSync, unlinkSync, writeFileSync, } from 'node:fs';
1
+ import { closeSync, constants, fstatSync, cpSync, fsyncSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmdirSync, rmSync, unlinkSync, writeFileSync, } from 'node:fs';
2
2
  import { createHash, randomUUID } from 'node:crypto';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
@@ -232,13 +232,42 @@ function removeEntryDurably(target) {
232
232
  if (pathEntryExists(parent))
233
233
  syncDirectory(parent);
234
234
  }
235
+ /** Reserved recovery metadata must never read devices, pipes or unbounded files. */
236
+ function readRecoveryMetadata(filePath, maximumBytes) {
237
+ const stat = lstatSync(filePath);
238
+ if (!stat.isFile() || stat.isSymbolicLink())
239
+ throw new Error(`Recovery metadata must be a regular file: ${filePath}`);
240
+ const descriptor = openSync(filePath, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
241
+ try {
242
+ const opened = fstatSync(descriptor);
243
+ if (!opened.isFile())
244
+ throw new Error(`Recovery metadata must be a regular file: ${filePath}`);
245
+ if (opened.size > maximumBytes)
246
+ throw new Error(`Recovery metadata exceeds size limit: ${filePath}`);
247
+ const chunks = [];
248
+ let total = 0;
249
+ for (;;) {
250
+ const chunk = Buffer.alloc(Math.min(8192, maximumBytes + 1 - total));
251
+ const length = readSync(descriptor, chunk, 0, chunk.length, null);
252
+ if (!length)
253
+ return Buffer.concat(chunks).toString('utf8');
254
+ total += length;
255
+ if (total > maximumBytes)
256
+ throw new Error(`Recovery metadata exceeds size limit: ${filePath}`);
257
+ chunks.push(chunk.subarray(0, length));
258
+ }
259
+ }
260
+ finally {
261
+ closeSync(descriptor);
262
+ }
263
+ }
235
264
  function parseLockOwner(lockPath) {
236
265
  if (lstatSync(lockPath).isSymbolicLink()) {
237
266
  throw new Error(`Refusing symbolic-link transaction lock at ${lockPath}.`);
238
267
  }
239
268
  let value;
240
269
  try {
241
- value = JSON.parse(readFileSync(lockPath, 'utf8'));
270
+ value = JSON.parse(readRecoveryMetadata(lockPath, 16 * 1024));
242
271
  }
243
272
  catch (error) {
244
273
  throw new Error(`Cannot read transaction lock owner at ${lockPath}; remove it only after confirming no Anhedral process is running.`, { cause: error });
@@ -676,7 +705,7 @@ function recoverInterruptedTransactionUnlocked(root) {
676
705
  if (lstatSync(journalPath).isSymbolicLink()) {
677
706
  throw new Error(`Refusing symbolic-link transaction journal at ${journalPath}.`);
678
707
  }
679
- const journal = validateJournal(root, JSON.parse(readFileSync(journalPath, 'utf8')));
708
+ const journal = validateJournal(root, JSON.parse(readRecoveryMetadata(journalPath, 16 * 1024 * 1024)));
680
709
  restoreJournal(root, journal);
681
710
  return true;
682
711
  }
@@ -697,8 +726,8 @@ export class PostCommitError extends Error {
697
726
  committedPaths;
698
727
  constructor(committedPaths, cause) {
699
728
  const causeMessage = cause instanceof Error ? cause.message : String(cause);
700
- super(`Changes were committed successfully, but the post-commit action failed: ${causeMessage}. `
701
- + 'The generated files were kept; resolve the failure and rerun the post-commit command.', { cause });
729
+ super(`Generated files were saved, but the follow-up action failed: ${causeMessage}. `
730
+ + 'The generated files were kept; resolve the failure and rerun the failed command.', { cause });
702
731
  this.name = 'PostCommitError';
703
732
  this.committedPaths = Object.freeze([...committedPaths]);
704
733
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const GENERATOR_VERSION = "0.8.5";
1
+ export declare const GENERATOR_VERSION = "0.8.6";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const GENERATOR_VERSION = '0.8.5';
1
+ export const GENERATOR_VERSION = '0.8.6';