@deftai/directive-core 0.88.0 → 0.89.0

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 (168) hide show
  1. package/dist/authz/actions.d.ts +55 -0
  2. package/dist/authz/actions.js +125 -0
  3. package/dist/authz/classify.d.ts +23 -0
  4. package/dist/authz/classify.js +217 -0
  5. package/dist/authz/closed-verb.d.ts +42 -0
  6. package/dist/authz/closed-verb.js +279 -0
  7. package/dist/authz/evaluate.d.ts +41 -0
  8. package/dist/authz/evaluate.js +298 -0
  9. package/dist/authz/index.d.ts +15 -0
  10. package/dist/authz/index.js +15 -0
  11. package/dist/authz/origin.d.ts +28 -0
  12. package/dist/authz/origin.js +64 -0
  13. package/dist/authz/paths.d.ts +6 -0
  14. package/dist/authz/paths.js +19 -0
  15. package/dist/authz/store.d.ts +40 -0
  16. package/dist/authz/store.js +317 -0
  17. package/dist/authz/templates.d.ts +139 -0
  18. package/dist/authz/templates.js +241 -0
  19. package/dist/authz/types.d.ts +111 -0
  20. package/dist/authz/types.js +41 -0
  21. package/dist/authz/verb-classification.d.ts +44 -0
  22. package/dist/authz/verb-classification.js +237 -0
  23. package/dist/branch/evaluate.js +6 -1
  24. package/dist/cache/fetch.js +10 -5
  25. package/dist/cache/io.d.ts +9 -2
  26. package/dist/cache/io.js +30 -10
  27. package/dist/cache/task-cache/store.js +11 -7
  28. package/dist/capacity/backfill.js +10 -4
  29. package/dist/category-b-namespace/index.js +10 -4
  30. package/dist/codebase/default-extractor.js +3 -0
  31. package/dist/codebase/map.js +11 -4
  32. package/dist/doctor/doctor-state.js +28 -4
  33. package/dist/doctor/main.d.ts +10 -0
  34. package/dist/doctor/main.js +160 -0
  35. package/dist/doctor/types.d.ts +11 -0
  36. package/dist/escalation/actions.d.ts +63 -0
  37. package/dist/escalation/actions.js +137 -0
  38. package/dist/escalation/index.d.ts +8 -0
  39. package/dist/escalation/index.js +8 -0
  40. package/dist/escalation/paths.d.ts +3 -0
  41. package/dist/escalation/paths.js +10 -0
  42. package/dist/escalation/store.d.ts +17 -0
  43. package/dist/escalation/store.js +172 -0
  44. package/dist/escalation/types.d.ts +73 -0
  45. package/dist/escalation/types.js +43 -0
  46. package/dist/eval/crud-telemetry.js +30 -10
  47. package/dist/eval/health.js +22 -7
  48. package/dist/eval/readback.js +11 -10
  49. package/dist/eval/run.js +32 -16
  50. package/dist/events/attribution-enrichment.js +10 -4
  51. package/dist/finish-loop/directive-finish-loop.d.ts +37 -0
  52. package/dist/finish-loop/directive-finish-loop.js +239 -0
  53. package/dist/finish-loop/grant-gate.d.ts +31 -0
  54. package/dist/finish-loop/grant-gate.js +169 -0
  55. package/dist/finish-loop/index.d.ts +11 -0
  56. package/dist/finish-loop/index.js +11 -0
  57. package/dist/finish-loop/main.d.ts +35 -0
  58. package/dist/finish-loop/main.js +365 -0
  59. package/dist/finish-loop/pr-finish-loop.d.ts +34 -0
  60. package/dist/finish-loop/pr-finish-loop.js +217 -0
  61. package/dist/finish-loop/progress.d.ts +17 -0
  62. package/dist/finish-loop/progress.js +45 -0
  63. package/dist/finish-loop/queue.d.ts +16 -0
  64. package/dist/finish-loop/queue.js +65 -0
  65. package/dist/finish-loop/types.d.ts +52 -0
  66. package/dist/finish-loop/types.js +10 -0
  67. package/dist/fs/contained-write.d.ts +101 -0
  68. package/dist/fs/contained-write.js +281 -0
  69. package/dist/hooks/classify/classify.d.ts +10 -0
  70. package/dist/hooks/classify/classify.js +37 -0
  71. package/dist/hooks/classify/index.d.ts +14 -0
  72. package/dist/hooks/classify/index.js +13 -0
  73. package/dist/hooks/classify/paths.d.ts +22 -0
  74. package/dist/hooks/classify/paths.js +72 -0
  75. package/dist/hooks/classify/payload.d.ts +16 -0
  76. package/dist/hooks/classify/payload.js +45 -0
  77. package/dist/hooks/classify/stdin.d.ts +12 -0
  78. package/dist/hooks/classify/stdin.js +63 -0
  79. package/dist/hooks/classify/tool-name.d.ts +18 -0
  80. package/dist/hooks/classify/tool-name.js +85 -0
  81. package/dist/hooks/classify/types.d.ts +41 -0
  82. package/dist/hooks/classify/types.js +7 -0
  83. package/dist/hooks/dispatcher.d.ts +21 -18
  84. package/dist/hooks/dispatcher.js +212 -163
  85. package/dist/hooks/fixtures/cases.d.ts +44 -0
  86. package/dist/hooks/fixtures/cases.js +595 -0
  87. package/dist/hooks/fixtures/index.d.ts +2 -0
  88. package/dist/hooks/fixtures/index.js +2 -0
  89. package/dist/hooks/index.d.ts +2 -0
  90. package/dist/hooks/index.js +2 -0
  91. package/dist/index.d.ts +4 -0
  92. package/dist/index.js +5 -0
  93. package/dist/init-deposit/agent-hooks.js +27 -8
  94. package/dist/init-deposit/gitignore.js +11 -3
  95. package/dist/init-deposit/headless-manifest.js +12 -4
  96. package/dist/init-deposit/migrate.d.ts +1 -1
  97. package/dist/init-deposit/migrate.js +13 -3
  98. package/dist/init-deposit/prettierignore.js +10 -3
  99. package/dist/init-deposit/scaffold.js +35 -26
  100. package/dist/init-deposit/xbrief-projections.js +11 -4
  101. package/dist/intake/candidates-log.js +46 -35
  102. package/dist/intake/github-body-cli.d.ts +6 -0
  103. package/dist/intake/github-body-cli.js +17 -0
  104. package/dist/intake/github-body.d.ts +46 -3
  105. package/dist/intake/github-body.js +191 -20
  106. package/dist/intake/issue-emit.d.ts +1 -0
  107. package/dist/intake/issue-emit.js +41 -23
  108. package/dist/lifecycle/event-detect.js +12 -4
  109. package/dist/lifecycle/events.js +29 -20
  110. package/dist/lifecycle/lifecycle-hygiene.js +9 -3
  111. package/dist/packs/pack-render.js +19 -6
  112. package/dist/plan-sequence/store.js +11 -4
  113. package/dist/policy/hotfix-criteria.d.ts +79 -0
  114. package/dist/policy/hotfix-criteria.js +197 -0
  115. package/dist/policy/index.d.ts +4 -0
  116. package/dist/policy/index.js +31 -1
  117. package/dist/policy/intent-ceiling.d.ts +79 -0
  118. package/dist/policy/intent-ceiling.js +181 -0
  119. package/dist/policy/no-deft-directive.js +10 -3
  120. package/dist/policy/org-force-on-migration.js +9 -5
  121. package/dist/policy/require-human-merge.d.ts +75 -0
  122. package/dist/policy/require-human-merge.js +324 -0
  123. package/dist/policy/resolve.js +17 -6
  124. package/dist/policy/runtime-authority.d.ts +15 -2
  125. package/dist/policy/runtime-authority.js +23 -3
  126. package/dist/policy/write-fence.d.ts +78 -0
  127. package/dist/policy/write-fence.js +164 -0
  128. package/dist/pr-wait-mergeable/cascade.d.ts +10 -0
  129. package/dist/pr-wait-mergeable/cascade.js +28 -0
  130. package/dist/preflight/evaluate.js +10 -0
  131. package/dist/product-signal/consent.js +21 -5
  132. package/dist/product-signal/submit.js +22 -12
  133. package/dist/release/build-dist-runner.js +5 -2
  134. package/dist/release/build-dist.d.ts +19 -1
  135. package/dist/release/build-dist.js +50 -2
  136. package/dist/release/native-steps.js +7 -2
  137. package/dist/release-publish/pipeline.d.ts +13 -0
  138. package/dist/release-publish/pipeline.js +46 -1
  139. package/dist/scope/audit-log.js +19 -24
  140. package/dist/scope/decompose.js +10 -5
  141. package/dist/scope/decomposed-refs.js +18 -3
  142. package/dist/scope/demote.js +9 -2
  143. package/dist/scope/undo.js +9 -2
  144. package/dist/session/release-availability.js +26 -6
  145. package/dist/session/ritual-sentinel.js +19 -12
  146. package/dist/session/session-start.js +7 -0
  147. package/dist/staleness-tickler/state.js +26 -6
  148. package/dist/swarm/launch.js +13 -3
  149. package/dist/swarm/routing.js +9 -3
  150. package/dist/task-surface/index.js +24 -9
  151. package/dist/triage/bootstrap/gitignore.js +53 -10
  152. package/dist/triage/cache-path.js +10 -3
  153. package/dist/triage/welcome/summary.js +11 -4
  154. package/dist/triage/welcome/writers.js +45 -16
  155. package/dist/validate-content/validate-links.js +5 -0
  156. package/dist/value/readback.js +11 -6
  157. package/dist/vbrief-activate/activate.js +12 -4
  158. package/dist/vbrief-build/project-definition-io.js +14 -6
  159. package/dist/verify-source/contained-writes.d.ts +59 -0
  160. package/dist/verify-source/contained-writes.js +272 -0
  161. package/dist/verify-source/index.d.ts +1 -0
  162. package/dist/verify-source/index.js +1 -0
  163. package/dist/verify-source/openclaw-tier1.js +14 -1
  164. package/dist/verify-source/verify-stubs.js +3 -0
  165. package/dist/xbrief-migrate/migrate-project.js +26 -12
  166. package/dist/xbrief-migrate/transforms.d.ts +4 -2
  167. package/dist/xbrief-migrate/transforms.js +37 -14
  168. package/package.json +15 -3
@@ -1,5 +1,6 @@
1
- import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
2
- import { dirname, join, relative, resolve } from "node:path";
1
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from "node:fs";
2
+ import { join, relative, resolve } from "node:path";
3
+ import { containedWrite } from "../fs/contained-write.js";
3
4
  import { assertWriteTargetSafe, ProjectionContainmentError } from "../fs/projection-containment.js";
4
5
  import { checkGitClean } from "../migrate-preflight/index.js";
5
6
  import { applyAgentsRefresh } from "../platform/agents-md.js";
@@ -48,19 +49,30 @@ function mapRelativePath(relativePath) {
48
49
  : segment)
49
50
  .join("/");
50
51
  }
51
- function writeMigratedFile(srcPath, destPath) {
52
- mkdirSync(dirname(destPath), { recursive: true });
52
+ function writeMigratedFile(projectRoot, srcPath, destPath) {
53
+ // #2980 wave C: product write sink routes through containedWrite.
54
+ const root = resolve(projectRoot);
53
55
  if (srcPath.endsWith(LEGACY_ARTIFACT_SUFFIX)) {
54
56
  const parsed = JSON.parse(readFileSync(srcPath, "utf8"));
55
57
  const result = transformArtifactV06ToV08Transactional(parsed);
56
58
  if (!result.ok) {
57
59
  throw new Error(result.error);
58
60
  }
59
- writeFileSync(destPath, `${JSON.stringify(result.artifact, null, 2)}\n`, "utf8");
61
+ containedWrite({
62
+ root,
63
+ target: destPath,
64
+ data: `${JSON.stringify(result.artifact, null, 2)}\n`,
65
+ mode: "replace",
66
+ });
60
67
  return;
61
68
  }
62
69
  const raw = readFileSync(srcPath, "utf8");
63
- writeFileSync(destPath, rewriteEmbeddedTokens(raw), "utf8");
70
+ containedWrite({
71
+ root,
72
+ target: destPath,
73
+ data: rewriteEmbeddedTokens(raw),
74
+ mode: "replace",
75
+ });
64
76
  }
65
77
  function backupMigrationInputs(projectRoot, legacyDir, migratedDir) {
66
78
  const stamp = new Date().toISOString().replace(/[:.]/g, "-");
@@ -100,7 +112,7 @@ function migrateLegacyTree(projectRoot, legacyDir, options) {
100
112
  if (shouldOmitLegacyMigrationFile(rel))
101
113
  continue;
102
114
  const destPath = join(stagedDir, mapRelativePath(rel));
103
- writeMigratedFile(srcPath, destPath);
115
+ writeMigratedFile(projectRoot, srcPath, destPath);
104
116
  }
105
117
  overlayCanonicalTriageCache(migratedDir, stagedDir);
106
118
  renameOrReplace(stagedDir, migratedDir);
@@ -123,14 +135,16 @@ function migrateLegacyTree(projectRoot, legacyDir, options) {
123
135
  /** Idempotently write the legacy-root deprecation marker (#2270 / #2869). */
124
136
  function writeVbriefDeprecationMarker(projectRoot, legacyDir) {
125
137
  const markerPath = join(legacyDir, VBRIEF_DEPRECATION_MARKER_FILENAME);
126
- // Refuse leaf or parent-dir symlink escapes before mkdir/write (#2869).
127
- assertWriteTargetSafe(projectRoot, legacyDir);
128
- assertWriteTargetSafe(projectRoot, markerPath);
129
- mkdirSync(legacyDir, { recursive: true });
138
+ // Refuse leaf or parent-dir symlink escapes via containedWrite (#2869 / #2980 wave C).
130
139
  if (hasVbriefDeprecationMarker(legacyDir)) {
131
140
  return;
132
141
  }
133
- writeFileSync(markerPath, VBRIEF_DEPRECATION_MARKER_BODY, "utf8");
142
+ containedWrite({
143
+ root: resolve(projectRoot),
144
+ target: markerPath,
145
+ data: VBRIEF_DEPRECATION_MARKER_BODY,
146
+ mode: "replace",
147
+ });
134
148
  }
135
149
  /**
136
150
  * Converge a leftover legacy `vbrief/` root to an unambiguous state (#2270).
@@ -15,8 +15,10 @@ export declare function readDeclaredArtifactVersion(artifact: JsonObject): strin
15
15
  export declare function rewriteEmbeddedTokens(value: string): string;
16
16
  /**
17
17
  * Convert a single v0.6 in-document artifact to v0.8 semantics.
18
- * Idempotent: v0.8 artifacts are returned unchanged (deep-cloned).
19
- * Transactional: on failure the original input object is not mutated.
18
+ * Accepts classic `vBRIEFInfo@0.6` or hybrid `xBRIEFInfo@0.6` (layout renamed,
19
+ * envelope not bumped #2970). Idempotent: v0.8 artifacts are returned
20
+ * unchanged (deep-cloned). Transactional: on failure the original input
21
+ * object is not mutated.
20
22
  */
21
23
  export declare function transformArtifactV06ToV08(input: JsonObject): JsonObject;
22
24
  /**
@@ -74,30 +74,53 @@ function isAlreadyV08Artifact(artifact) {
74
74
  const info = artifact[MIGRATED_INFO_ROOT_KEY];
75
75
  return isPlainObject(info) && info.version === VBRIEF_VERSION;
76
76
  }
77
+ /**
78
+ * Resolve a v0.6 info block from classic `vBRIEFInfo` or hybrid `xBRIEFInfo@0.6`.
79
+ * Prefer the classic key when both are present. Layout rename ≠ envelope bump (#2970).
80
+ */
81
+ function resolveV06InfoBlock(artifact) {
82
+ if (LEGACY_INFO_ROOT_KEY in artifact) {
83
+ const legacyInfo = artifact[LEGACY_INFO_ROOT_KEY];
84
+ if (!isPlainObject(legacyInfo)) {
85
+ throw new TransformError(`'${LEGACY_INFO_ROOT_KEY}' must be an object`);
86
+ }
87
+ const declaredVersion = legacyInfo.version;
88
+ if (declaredVersion !== LEGACY_VBRIEF_VERSION) {
89
+ throw new TransformError(`expected ${LEGACY_INFO_ROOT_KEY}.version ${LEGACY_VBRIEF_VERSION}, got ${String(declaredVersion)}`);
90
+ }
91
+ return legacyInfo;
92
+ }
93
+ if (MIGRATED_INFO_ROOT_KEY in artifact) {
94
+ const hybridInfo = artifact[MIGRATED_INFO_ROOT_KEY];
95
+ if (!isPlainObject(hybridInfo)) {
96
+ throw new TransformError(`'${MIGRATED_INFO_ROOT_KEY}' must be an object`);
97
+ }
98
+ const declaredVersion = hybridInfo.version;
99
+ if (declaredVersion !== LEGACY_VBRIEF_VERSION) {
100
+ throw new TransformError(`expected hybrid ${MIGRATED_INFO_ROOT_KEY}.version ${LEGACY_VBRIEF_VERSION} (or ${VBRIEF_VERSION} for already-migrated), got ${String(declaredVersion)}`);
101
+ }
102
+ return hybridInfo;
103
+ }
104
+ throw new TransformError(`missing required legacy info block '${LEGACY_INFO_ROOT_KEY}' or hybrid '${MIGRATED_INFO_ROOT_KEY}'@${LEGACY_VBRIEF_VERSION} for v0.6 -> v0.8 transform`);
105
+ }
77
106
  /**
78
107
  * Convert a single v0.6 in-document artifact to v0.8 semantics.
79
- * Idempotent: v0.8 artifacts are returned unchanged (deep-cloned).
80
- * Transactional: on failure the original input object is not mutated.
108
+ * Accepts classic `vBRIEFInfo@0.6` or hybrid `xBRIEFInfo@0.6` (layout renamed,
109
+ * envelope not bumped #2970). Idempotent: v0.8 artifacts are returned
110
+ * unchanged (deep-cloned). Transactional: on failure the original input
111
+ * object is not mutated.
81
112
  */
82
113
  export function transformArtifactV06ToV08(input) {
83
114
  const working = structuredClone(input);
84
115
  if (isAlreadyV08Artifact(working)) {
85
116
  return working;
86
117
  }
87
- if (!(LEGACY_INFO_ROOT_KEY in working)) {
88
- throw new TransformError(`missing required legacy info block '${LEGACY_INFO_ROOT_KEY}' for v0.6 -> v0.8 transform`);
89
- }
90
- const legacyInfo = working[LEGACY_INFO_ROOT_KEY];
91
- if (!isPlainObject(legacyInfo)) {
92
- throw new TransformError(`'${LEGACY_INFO_ROOT_KEY}' must be an object`);
93
- }
94
- const declaredVersion = legacyInfo.version;
95
- if (declaredVersion !== LEGACY_VBRIEF_VERSION) {
96
- throw new TransformError(`expected ${LEGACY_INFO_ROOT_KEY}.version ${LEGACY_VBRIEF_VERSION}, got ${String(declaredVersion)}`);
97
- }
118
+ const info = resolveV06InfoBlock(working);
119
+ // Drop both keys so a dual-key hybrid cannot leave a stale vBRIEFInfo behind.
98
120
  delete working[LEGACY_INFO_ROOT_KEY];
121
+ delete working[MIGRATED_INFO_ROOT_KEY];
99
122
  working[MIGRATED_INFO_ROOT_KEY] = {
100
- ...legacyInfo,
123
+ ...info,
101
124
  version: VBRIEF_VERSION,
102
125
  };
103
126
  const rewritten = deepRewriteValues(working);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deftai/directive-core",
3
- "version": "0.88.0",
3
+ "version": "0.89.0",
4
4
  "description": "TypeScript engine core for the Directive framework.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -75,6 +75,14 @@
75
75
  "types": "./dist/hooks/index.d.ts",
76
76
  "default": "./dist/hooks/index.js"
77
77
  },
78
+ "./authz": {
79
+ "types": "./dist/authz/index.d.ts",
80
+ "default": "./dist/authz/index.js"
81
+ },
82
+ "./escalation": {
83
+ "types": "./dist/escalation/index.d.ts",
84
+ "default": "./dist/escalation/index.js"
85
+ },
78
86
  "./plan-sequence": {
79
87
  "types": "./dist/plan-sequence/index.d.ts",
80
88
  "default": "./dist/plan-sequence/index.js"
@@ -179,6 +187,10 @@
179
187
  "types": "./dist/pr-watch/index.d.ts",
180
188
  "default": "./dist/pr-watch/index.js"
181
189
  },
190
+ "./finish-loop": {
191
+ "types": "./dist/finish-loop/index.d.ts",
192
+ "default": "./dist/finish-loop/index.js"
193
+ },
182
194
  "./vbrief-build": {
183
195
  "types": "./dist/vbrief-build/index.d.ts",
184
196
  "default": "./dist/vbrief-build/index.js"
@@ -318,8 +330,8 @@
318
330
  "provenance": true
319
331
  },
320
332
  "dependencies": {
321
- "@deftai/directive-content": "^0.88.0",
322
- "@deftai/directive-types": "^0.88.0",
333
+ "@deftai/directive-content": "^0.89.0",
334
+ "@deftai/directive-types": "^0.89.0",
323
335
  "archiver": "^8.0.0"
324
336
  },
325
337
  "scripts": {