ark-runtime-kernel 1.2.0 → 1.4.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.
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { I as IntentRegistry, a as IntentName, D as DefineIntentOptions, b as In
2
2
  export { X as ArchitectureLayer, Y as ArchitectureLayerConfig, Z as ArchitectureRule, _ as ArkManifestArchitecture, $ as ArkManifestData, a0 as ArkManifestEntityLink, a1 as ArkManifestGraph, a2 as ArkManifestIntent, a3 as ArkManifestPolicy, a4 as ArkManifestProjection, a5 as AuditRecordInput, a6 as AuditRecordType, a7 as CorrelationId, a8 as EntityMeta, a9 as EventContractIssue, aa as EventHandler, ab as EventInterceptionInfo, ac as EventInterceptor, ad as EventInterceptorContext, ae as EventMetadata, af as EventPayloadPatch, ag as EventPayloadSchema, ah as EventPublisher, ai as EventSchemaField, aj as EventSchemaFieldType, ak as FieldMeta, al as GraphNode, am as IntentRelationshipKind, an as ObservabilityFlow, ao as ObservedLayerFlowMode, ap as PolicyEvaluationResult, aq as ProjectionCheckpoint, ar as ProjectionDefinition, as as PublishedEventRecord, at as RetryPolicy, au as SagaStatus, av as SagaStep, aw as TraceSink, ax as Unsubscribe, ay as WorkflowDefinition, az as WorkflowStatus, aA as WorkflowStep } from './types-7K_KQCgS.cjs';
3
3
 
4
4
  /** Ark library version — single source of truth. */
5
- declare const version = "1.2.0";
5
+ declare const version = "1.4.0";
6
6
 
7
7
  /**
8
8
  * defineIntent
@@ -537,6 +537,12 @@ interface AICodeGateOptions<Context = AICodeGateContext> {
537
537
  * for publish misuse without taking a runtime dependency on TypeScript.
538
538
  */
539
539
  typescript?: unknown;
540
+ /**
541
+ * Ambient globals forbidden per layer (layer name → entries such as "fetch" or
542
+ * "Date.now"). Checked only when `typescript` is provided and context.layer resolves
543
+ * to a listed layer — mirrors ark-check's FORBIDDEN_GLOBAL rule.
544
+ */
545
+ forbiddenGlobals?: Record<string, string[]>;
540
546
  }
541
547
  declare function createAICodeGate<Context = AICodeGateContext>(options?: AICodeGateOptions<Context>): AICodeGate<Context>;
542
548
 
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { I as IntentRegistry, a as IntentName, D as DefineIntentOptions, b as In
2
2
  export { X as ArchitectureLayer, Y as ArchitectureLayerConfig, Z as ArchitectureRule, _ as ArkManifestArchitecture, $ as ArkManifestData, a0 as ArkManifestEntityLink, a1 as ArkManifestGraph, a2 as ArkManifestIntent, a3 as ArkManifestPolicy, a4 as ArkManifestProjection, a5 as AuditRecordInput, a6 as AuditRecordType, a7 as CorrelationId, a8 as EntityMeta, a9 as EventContractIssue, aa as EventHandler, ab as EventInterceptionInfo, ac as EventInterceptor, ad as EventInterceptorContext, ae as EventMetadata, af as EventPayloadPatch, ag as EventPayloadSchema, ah as EventPublisher, ai as EventSchemaField, aj as EventSchemaFieldType, ak as FieldMeta, al as GraphNode, am as IntentRelationshipKind, an as ObservabilityFlow, ao as ObservedLayerFlowMode, ap as PolicyEvaluationResult, aq as ProjectionCheckpoint, ar as ProjectionDefinition, as as PublishedEventRecord, at as RetryPolicy, au as SagaStatus, av as SagaStep, aw as TraceSink, ax as Unsubscribe, ay as WorkflowDefinition, az as WorkflowStatus, aA as WorkflowStep } from './types-7K_KQCgS.js';
3
3
 
4
4
  /** Ark library version — single source of truth. */
5
- declare const version = "1.2.0";
5
+ declare const version = "1.4.0";
6
6
 
7
7
  /**
8
8
  * defineIntent
@@ -537,6 +537,12 @@ interface AICodeGateOptions<Context = AICodeGateContext> {
537
537
  * for publish misuse without taking a runtime dependency on TypeScript.
538
538
  */
539
539
  typescript?: unknown;
540
+ /**
541
+ * Ambient globals forbidden per layer (layer name → entries such as "fetch" or
542
+ * "Date.now"). Checked only when `typescript` is provided and context.layer resolves
543
+ * to a listed layer — mirrors ark-check's FORBIDDEN_GLOBAL rule.
544
+ */
545
+ forbiddenGlobals?: Record<string, string[]>;
540
546
  }
541
547
  declare function createAICodeGate<Context = AICodeGateContext>(options?: AICodeGateOptions<Context>): AICodeGate<Context>;
542
548
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var version = "1.2.0";
2
+ var version = "1.4.0";
3
3
 
4
4
  // src/kernel/intent/IntentRegistry.ts
5
5
  var IntentRegistry = class {
@@ -1831,12 +1831,13 @@ var defaultElevenLayerDirectories = {
1831
1831
  function createElevenLayerArkConfig(options = {}) {
1832
1832
  const rootDir = options.rootDir ?? "src";
1833
1833
  const optional = options.optionalLayers ?? true;
1834
+ const prefix = rootDir === "." ? "" : `${rootDir}/`;
1834
1835
  return {
1835
1836
  include: options.include ?? [rootDir],
1836
1837
  layers: elevenLayerProfile.layers.map((layer) => ({
1837
1838
  name: layer.name,
1838
1839
  patterns: (defaultElevenLayerDirectories[layer.name] ?? [layer.name]).map(
1839
- (directory) => `${rootDir}/${directory}/**`
1840
+ (directory) => `${prefix}${directory}/**`
1840
1841
  ),
1841
1842
  intentPrefixes: layer.prefixes,
1842
1843
  optional
@@ -2098,6 +2099,33 @@ function tsPublishSourceLiteral(ts, node) {
2098
2099
  const rawMetadata = tsObjectPropertyValue(ts, firstArg, "metadata");
2099
2100
  return tsStringLiteralText(ts, tsObjectPropertyValue(ts, rawMetadata, "source")) ?? tsStringLiteralText(ts, tsObjectPropertyValue(ts, secondArg, "source")) ?? tsStringLiteralText(ts, tsObjectPropertyValue(ts, thirdArg, "source"));
2100
2101
  }
2102
+ function analyzeForbiddenGlobals(ts, source, filePath, layer, forbidden) {
2103
+ const entries = new Set(forbidden);
2104
+ if (entries.size === 0) return [];
2105
+ const sourceFile = ts.createSourceFile("generated.ts", source, ts.ScriptTarget.Latest, true);
2106
+ const violations = [];
2107
+ const flag = (name, node) => violations.push(
2108
+ violation("FORBIDDEN_GLOBAL", `${layer} must not use the ambient global "${name}".`, {
2109
+ line: sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1,
2110
+ filePath,
2111
+ target: name,
2112
+ fromLayer: layer,
2113
+ suggestion: "Inject the capability through a port (e.g. a Clock, IdGenerator, or HttpPort) instead of reaching for the ambient global."
2114
+ })
2115
+ );
2116
+ const visit = (node) => {
2117
+ if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {
2118
+ const dotted = `${node.expression.text}.${node.name.text}`;
2119
+ if (entries.has(dotted)) flag(dotted, node);
2120
+ else if (entries.has(node.expression.text)) flag(node.expression.text, node);
2121
+ } else if ((ts.isCallExpression(node) || ts.isNewExpression(node)) && node.expression && ts.isIdentifier(node.expression) && entries.has(node.expression.text)) {
2122
+ flag(node.expression.text, node);
2123
+ }
2124
+ ts.forEachChild(node, visit);
2125
+ };
2126
+ visit(sourceFile);
2127
+ return violations;
2128
+ }
2101
2129
  function analyzePublishAst(ts, source, context, profile) {
2102
2130
  const sourceFile = ts.createSourceFile(
2103
2131
  "generated.ts",
@@ -2296,6 +2324,26 @@ function createAICodeGate(options = {}) {
2296
2324
  }
2297
2325
  }
2298
2326
  }
2327
+ if (options.typescript && contextLayer && options.forbiddenGlobals?.[contextLayer]?.length) {
2328
+ try {
2329
+ violations.push(
2330
+ ...analyzeForbiddenGlobals(
2331
+ options.typescript,
2332
+ source,
2333
+ filePath,
2334
+ contextLayer,
2335
+ options.forbiddenGlobals[contextLayer]
2336
+ )
2337
+ );
2338
+ } catch (err) {
2339
+ violations.push(
2340
+ violation(
2341
+ "AST_ANALYZER_ERROR",
2342
+ `TypeScript AST analyzer failed: ${err instanceof Error ? err.message : String(err)}`
2343
+ )
2344
+ );
2345
+ }
2346
+ }
2299
2347
  if (options.typescript) {
2300
2348
  try {
2301
2349
  violations.push(