@fjall/generator 12.0.0 → 12.1.1

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 (30) hide show
  1. package/dist/.build-source-hash +19 -18
  2. package/dist/.minified +1 -1
  3. package/dist/src/ast/astTestHelpers.d.ts +3 -3
  4. package/dist/src/codemod/index.d.ts +1 -1
  5. package/dist/src/codemod/index.js +1 -1
  6. package/dist/src/codemod/llmFallback/claudeTier.js +1 -1
  7. package/dist/src/codemod/llmFallback/egressGate.d.ts +2 -2
  8. package/dist/src/codemod/llmFallback/egressGate.js +1 -1
  9. package/dist/src/codemod/llmFallback/egressGate.types.d.ts +3 -2
  10. package/dist/src/codemod/llmFallback/gateFallbackOutput.d.ts +32 -0
  11. package/dist/src/codemod/llmFallback/gateFallbackOutput.js +1 -0
  12. package/dist/src/codemod/llmFallback/index.d.ts +3 -2
  13. package/dist/src/codemod/llmFallback/index.js +1 -1
  14. package/dist/src/codemod/llmFallback/morphTier.js +2 -2
  15. package/dist/src/codemod/llmFallback/runFallback.d.ts +12 -1
  16. package/dist/src/codemod/llmFallback/runFallback.js +1 -1
  17. package/dist/src/codemod/llmFallback/telemetryEvents.d.ts +10 -1
  18. package/dist/src/codemod/llmFallback/telemetryEvents.js +1 -1
  19. package/dist/src/codemod/llmFallback/types.d.ts +9 -1
  20. package/dist/src/codemod/types.d.ts +9 -1
  21. package/dist/src/codemod/validationGate/index.d.ts +1 -1
  22. package/dist/src/codemod/validationGate/index.js +1 -1
  23. package/dist/src/dns/domainFileGenerator.js +1 -1
  24. package/dist/src/schemas/alarmSchemas.d.ts +3 -3
  25. package/dist/src/schemas/alarmSchemas.js +1 -1
  26. package/dist/src/schemas/applicationSchemas.d.ts +3 -3
  27. package/dist/src/schemas/computeSchemas.d.ts +9 -9
  28. package/dist/src/version.d.ts +1 -1
  29. package/dist/src/version.js +1 -1
  30. package/package.json +2 -2
@@ -9,7 +9,7 @@
9
9
  "package.json",
10
10
  "tsconfig.json"
11
11
  ],
12
- "hash": "527bdd3f25bc65dac4ca977217fb57faccd44dec3b1de06ea9c38f726abd7d63",
12
+ "hash": "53203d5b524831113b90b9a87aff8b37bc1aecf83f13bf90974afec0d9d4819f",
13
13
  "files": {
14
14
  "src/ast/astTestHelpers.ts": "026cac849eb88bdb",
15
15
  "src/ast/domain/astDomainParser.ts": "940ce5742507477d",
@@ -74,21 +74,22 @@
74
74
  "src/codemod/fileRewriter/parse.ts": "b12026c31562a13c",
75
75
  "src/codemod/fileRewriter/print.ts": "f5ff7afb5b7786bf",
76
76
  "src/codemod/historyPaths.ts": "ef8084013146db57",
77
- "src/codemod/index.ts": "db90315eab333aab",
77
+ "src/codemod/index.ts": "b90c77ffc82e09df",
78
78
  "src/codemod/listResources.ts": "97f206a50edbea20",
79
79
  "src/codemod/llmFallback/apply.ts": "2e656a6e55b3b4e3",
80
- "src/codemod/llmFallback/claudeTier.ts": "0a37fe782c85f75b",
81
- "src/codemod/llmFallback/egressGate.ts": "2573dcf5b7a126a0",
82
- "src/codemod/llmFallback/egressGate.types.ts": "15531dd497ae6135",
83
- "src/codemod/llmFallback/index.ts": "b6c6cc8ef78d7887",
84
- "src/codemod/llmFallback/morphTier.ts": "9551b6b63a1af561",
80
+ "src/codemod/llmFallback/claudeTier.ts": "ace3e3baa51383c9",
81
+ "src/codemod/llmFallback/egressGate.ts": "1b9076a5c51508fc",
82
+ "src/codemod/llmFallback/egressGate.types.ts": "e30947f12ee546ff",
83
+ "src/codemod/llmFallback/gateFallbackOutput.ts": "d61dc46527c566b8",
84
+ "src/codemod/llmFallback/index.ts": "d32779fa95df6b94",
85
+ "src/codemod/llmFallback/morphTier.ts": "adcc1cf280f9a65d",
85
86
  "src/codemod/llmFallback/prompt.ts": "60e8f4ab434bf9ec",
86
- "src/codemod/llmFallback/runFallback.ts": "d3f1d1915aa56a23",
87
+ "src/codemod/llmFallback/runFallback.ts": "03880734d6c456af",
87
88
  "src/codemod/llmFallback/shouldTryFallback.ts": "df6038f97612b8ee",
88
89
  "src/codemod/llmFallback/signals.ts": "298bae6465b5f173",
89
- "src/codemod/llmFallback/telemetryEvents.ts": "33a85939739693ab",
90
+ "src/codemod/llmFallback/telemetryEvents.ts": "827282cb185eea6c",
90
91
  "src/codemod/llmFallback/tierRunner.ts": "a26094accd78cf15",
91
- "src/codemod/llmFallback/types.ts": "14af8d2bd9afae12",
92
+ "src/codemod/llmFallback/types.ts": "0b528ccbab7d48b8",
92
93
  "src/codemod/registry.ts": "fca9df965dd2d7ed",
93
94
  "src/codemod/semanticIndex/classifyControlFlow.ts": "ed96215d91a3cae3",
94
95
  "src/codemod/semanticIndex/findReferences.ts": "96aea37418d1e91a",
@@ -98,18 +99,18 @@
98
99
  "src/codemod/semanticIndex/projectCache.ts": "dfd9b265c9d233c9",
99
100
  "src/codemod/semanticIndex/resolveConstructByLiteralProperty.ts": "2d013a330af15c5c",
100
101
  "src/codemod/telemetry/errorKinds.ts": "66c736abfa8b3a67",
101
- "src/codemod/types.ts": "0cd929df5bb46696",
102
+ "src/codemod/types.ts": "41a3d0a462f5fc86",
102
103
  "src/codemod/validationGate/gates/classify.ts": "3cba0ee8fe6d94d9",
103
104
  "src/codemod/validationGate/gates/drift.ts": "bd603a216fbb91a9",
104
105
  "src/codemod/validationGate/gates/locate.ts": "2c186c32edbb97ce",
105
106
  "src/codemod/validationGate/gates/parse.ts": "5433c5c8ffa35324",
106
107
  "src/codemod/validationGate/gates/schema.ts": "7ed5acaec0620a46",
107
- "src/codemod/validationGate/index.ts": "df5754bea9070410",
108
+ "src/codemod/validationGate/index.ts": "47b475a621f5038a",
108
109
  "src/codemod/validationGate/types.ts": "af466ee5f3433042",
109
110
  "src/detection/index.ts": "b4ad9a935564cb3e",
110
111
  "src/dns/bindParser.ts": "376d274bf9e4bf9f",
111
112
  "src/dns/bindWriter.ts": "c296911ce5aef77c",
112
- "src/dns/domainFileGenerator.ts": "83451c031d3ed79c",
113
+ "src/dns/domainFileGenerator.ts": "29ece83900ecc829",
113
114
  "src/dns/domainRecords.ts": "ab917006b92ae916",
114
115
  "src/dns/index.ts": "b476ef3d7b381dc8",
115
116
  "src/dns/types.ts": "82d6db9d7d26dbc2",
@@ -145,7 +146,7 @@
145
146
  "src/projection/project.ts": "2104026f10a27264",
146
147
  "src/projection/tables.ts": "00904da382c06cf5",
147
148
  "src/projection/types.ts": "da0845cb34bfd12b",
148
- "src/schemas/alarmSchemas.ts": "9016095d8031f006",
149
+ "src/schemas/alarmSchemas.ts": "a6f6ac07b2a102de",
149
150
  "src/schemas/applicationSchemas.ts": "d85771a4607cf2da",
150
151
  "src/schemas/baseSchemas.ts": "93d9bd1c0adfcaa0",
151
152
  "src/schemas/buildkiteSchemas.ts": "a28ec3b40f7851ec",
@@ -169,11 +170,11 @@
169
170
  "src/validation/patterns.ts": "f9629eafdad7ac3e",
170
171
  "src/validation/validationMessages.ts": "c727ade4690274f4",
171
172
  "src/validation/validationPatterns.ts": "865f3d688975b7c8",
172
- "src/version.ts": "baf03706b61ef01c",
173
+ "src/version.ts": "342a42667dafc82e",
173
174
  "../scripts/minify-dist.mjs": "6b2e4b0df8aec601",
174
- "package.json": "ef20e5fe2c62e6ea",
175
+ "package.json": "64759ec8031b63be",
175
176
  "tsconfig.json": "1929cf3f99fe9b1e"
176
177
  },
177
- "outputHash": "48f82f9317e6271be251c0adc1e48bb8cfe6216fdb8e767c6326db4dd275f5d0",
178
- "outputFileCount": 319
178
+ "outputHash": "0fe5c0bd63e8fef719fa9e80e5358c25c250ebdcec6c17bd04f0b4df18b65355",
179
+ "outputFileCount": 321
179
180
  }
package/dist/.minified CHANGED
@@ -1 +1 @@
1
- 159 files minified at 2026-08-13T06:26:53.273Z
1
+ 160 files minified at 2026-08-15T09:46:48.150Z
@@ -247,10 +247,10 @@ export declare function parseAndConvert(code: string): {
247
247
  sourceText: string;
248
248
  }[] | undefined;
249
249
  alarms?: false | {
250
- cpuThreshold?: number | undefined;
251
- memoryThreshold?: number | undefined;
250
+ cpuThreshold?: number | false | undefined;
251
+ memoryThreshold?: number | false | undefined;
252
252
  runningTasksMinimum?: number | undefined;
253
- http5xxThreshold?: number | undefined;
253
+ http5xxThreshold?: number | false | undefined;
254
254
  } | undefined;
255
255
  }[] | undefined;
256
256
  docker?: {
@@ -21,5 +21,5 @@ export { evaluateEmitGuard, UNRESOLVED, type EmitGuardProperties, type EmitGuard
21
21
  export { CODEMOD_ERROR_KINDS } from "./telemetry/errorKinds.js";
22
22
  export type { CodemodErrorKind } from "./telemetry/errorKinds.js";
23
23
  export type { GateId } from "./validationGate/index.js";
24
- export { buildEgressBlockedEvent, buildFiredEvent, buildGateFailedEvent, buildGatePassedEvent, buildRejectedEvent, buildSucceededEvent, buildTimeoutEvent, estimateCostUsd, FALLBACK_EVENTS, GATE_EVENTS, PARSE_GATE, RUNTIME_GATE, runFallback, shouldTryFallback, type AnthropicClientProvider, type FallbackClients, type FallbackDecision, type FallbackEgressBlockedEvent, type FallbackGuardConfig, type FallbackInput, type FallbackIntent, type FallbackOp, type FallbackOutput, type FallbackTelemetry, type FallbackTelemetryEvent, type MorphClientProvider, type RunFallbackInput, type TelemetrySource, type TriggerReason, } from "./llmFallback/index.js";
24
+ export { buildEgressBlockedEvent, buildFiredEvent, buildGateFailedEvent, buildGatePassedEvent, buildRejectedEvent, buildSucceededEvent, buildTimeoutEvent, estimateCostUsd, FALLBACK_EVENTS, GATE_EVENTS, gateFallbackOutput, PARSE_GATE, RUNTIME_GATE, runFallback, shouldTryFallback, UNATTRIBUTED_ORGANISATION, type AnthropicClientProvider, type AnthropicContentBlock, type AnthropicResponse, type EgressStage, type FallbackClients, type FallbackDecision, type FallbackEgressBlockedEvent, type FallbackGuardConfig, type FallbackInput, type FallbackIntent, type FallbackOp, type FallbackOutput, type FallbackTelemetry, type FallbackTelemetryEvent, type GateEventAction, type GateFallbackParams, type MorphClientProvider, type RunFallbackInput, type TelemetrySource, type TriggerReason, } from "./llmFallback/index.js";
25
25
  export type { AddOptions, CodemodError, CodemodSuccess, ControlFlowClassifierError, DriftConflictError, DriftUnmergeableError, DuplicateResourceError, EditOrchestratorSuccess, InvalidPropertyError, LinesChanged, LlmFallbackRejectedError, LlmFallbackTimeoutError, LlmFallbackTier, LlmFallbackUnsafeInputError, MissingAppInitError, ModifyOptions, NodeLocation, ParseError, PermissionError, ReferenceLocation, ReferencesRemainError, RemoveOptions, ResourceListing, ResourceListingEntry, ResourceName, ResourceNotFoundError, SemanticQueryError, StatementType, TemplateLiteralNameError, } from "./types.js";
@@ -1 +1 @@
1
- import{addResource as o}from"./edits/addResource.js";import{removeResource as c}from"./edits/removeResource.js";import{modifyResource as m}from"./edits/modifyResource.js";import{appendAccountToStage as a}from"./edits/appendAccountToStage.js";import{setContainerSecrets as d}from"./edits/setContainerSecrets.js";import{connectResourceToCompute as i}from"./edits/connectResourceToCompute.js";import{addVpcPeer as f,modifyVpcPeer as u,removeVpcPeer as P}from"./edits/vpcPeer.js";import{addVpcPeerAccepter as R,modifyVpcPeerAccepter as T,removeVpcPeerAccepter as S}from"./edits/vpcPeerAccepter.js";import{addCrossPlanConnection as C,modifyCrossPlanConnection as A,removeCrossPlanConnection as V}from"./edits/crossPlanConnection.js";import{resolveDriftPolicy as y}from"./edits/driftPolicy.js";import{listResources as D}from"./listResources.js";import{resolveConstructByLiteralProperty as N}from"./semanticIndex/index.js";import{parse as F}from"./fileRewriter/parse.js";import{CrossPlanConnectionResourcePlanSchema as I,VpcPeerAccepterResourcePlanSchema as M,VpcPeerResourcePlanSchema as O}from"../schemas/index.js";import{detectDrift as k,mergeProperties as B,snapshotProperties as U}from"./drift/index.js";import{computeLinesDelta as Y}from"./_internal.js";import{ResourceNameSchema as q,StatementTypeSchema as w}from"./types.js";import{REGISTERED_STATEMENT_TYPES as H,STATEMENT_REGISTRY as J}from"./registry.js";import{evaluateEmitGuard as W,UNRESOLVED as X}from"./emitGuard.js";import{CODEMOD_ERROR_KINDS as $}from"./telemetry/errorKinds.js";import{buildEgressBlockedEvent as re,buildFiredEvent as oe,buildGateFailedEvent as te,buildGatePassedEvent as ce,buildRejectedEvent as pe,buildSucceededEvent as me,buildTimeoutEvent as se,estimateCostUsd as ae,FALLBACK_EVENTS as ne,GATE_EVENTS as de,PARSE_GATE as Ee,RUNTIME_GATE as ie,runFallback as le,shouldTryFallback as fe}from"./llmFallback/index.js";export{$ as CODEMOD_ERROR_KINDS,I as CrossPlanConnectionResourcePlanSchema,ne as FALLBACK_EVENTS,de as GATE_EVENTS,Ee as PARSE_GATE,H as REGISTERED_STATEMENT_TYPES,ie as RUNTIME_GATE,q as ResourceNameSchema,J as STATEMENT_REGISTRY,w as StatementTypeSchema,X as UNRESOLVED,M as VpcPeerAccepterResourcePlanSchema,O as VpcPeerResourcePlanSchema,C as addCrossPlanConnection,o as addResource,f as addVpcPeer,R as addVpcPeerAccepter,a as appendAccountToStage,re as buildEgressBlockedEvent,oe as buildFiredEvent,te as buildGateFailedEvent,ce as buildGatePassedEvent,pe as buildRejectedEvent,me as buildSucceededEvent,se as buildTimeoutEvent,Y as computeLinesDelta,i as connectResourceToCompute,k as detectDrift,ae as estimateCostUsd,W as evaluateEmitGuard,D as listResources,B as mergeProperties,A as modifyCrossPlanConnection,m as modifyResource,u as modifyVpcPeer,T as modifyVpcPeerAccepter,F as parse,V as removeCrossPlanConnection,c as removeResource,P as removeVpcPeer,S as removeVpcPeerAccepter,N as resolveConstructByLiteralProperty,y as resolveDriftPolicy,le as runFallback,d as setContainerSecrets,fe as shouldTryFallback,U as snapshotProperties};
1
+ import{addResource as o}from"./edits/addResource.js";import{removeResource as c}from"./edits/removeResource.js";import{modifyResource as m}from"./edits/modifyResource.js";import{appendAccountToStage as s}from"./edits/appendAccountToStage.js";import{setContainerSecrets as E}from"./edits/setContainerSecrets.js";import{connectResourceToCompute as l}from"./edits/connectResourceToCompute.js";import{addVpcPeer as u,modifyVpcPeer as f,removeVpcPeer as T}from"./edits/vpcPeer.js";import{addVpcPeerAccepter as R,modifyVpcPeerAccepter as x,removeVpcPeerAccepter as S}from"./edits/vpcPeerAccepter.js";import{addCrossPlanConnection as v,modifyCrossPlanConnection as C,removeCrossPlanConnection as N}from"./edits/crossPlanConnection.js";import{resolveDriftPolicy as b}from"./edits/driftPolicy.js";import{listResources as y}from"./listResources.js";import{resolveConstructByLiteralProperty as G}from"./semanticIndex/index.js";import{parse as I}from"./fileRewriter/parse.js";import{CrossPlanConnectionResourcePlanSchema as F,VpcPeerAccepterResourcePlanSchema as L,VpcPeerResourcePlanSchema as U}from"../schemas/index.js";import{detectDrift as k,mergeProperties as B,snapshotProperties as M}from"./drift/index.js";import{computeLinesDelta as Y}from"./_internal.js";import{ResourceNameSchema as q,StatementTypeSchema as w}from"./types.js";import{REGISTERED_STATEMENT_TYPES as H,STATEMENT_REGISTRY as J}from"./registry.js";import{evaluateEmitGuard as W,UNRESOLVED as X}from"./emitGuard.js";import{CODEMOD_ERROR_KINDS as $}from"./telemetry/errorKinds.js";import{buildEgressBlockedEvent as re,buildFiredEvent as oe,buildGateFailedEvent as te,buildGatePassedEvent as ce,buildRejectedEvent as pe,buildSucceededEvent as me,buildTimeoutEvent as ae,estimateCostUsd as se,FALLBACK_EVENTS as ne,GATE_EVENTS as Ee,gateFallbackOutput as de,PARSE_GATE as le,RUNTIME_GATE as ie,runFallback as ue,shouldTryFallback as fe,UNATTRIBUTED_ORGANISATION as Te}from"./llmFallback/index.js";export{$ as CODEMOD_ERROR_KINDS,F as CrossPlanConnectionResourcePlanSchema,ne as FALLBACK_EVENTS,Ee as GATE_EVENTS,le as PARSE_GATE,H as REGISTERED_STATEMENT_TYPES,ie as RUNTIME_GATE,q as ResourceNameSchema,J as STATEMENT_REGISTRY,w as StatementTypeSchema,Te as UNATTRIBUTED_ORGANISATION,X as UNRESOLVED,L as VpcPeerAccepterResourcePlanSchema,U as VpcPeerResourcePlanSchema,v as addCrossPlanConnection,o as addResource,u as addVpcPeer,R as addVpcPeerAccepter,s as appendAccountToStage,re as buildEgressBlockedEvent,oe as buildFiredEvent,te as buildGateFailedEvent,ce as buildGatePassedEvent,pe as buildRejectedEvent,me as buildSucceededEvent,ae as buildTimeoutEvent,Y as computeLinesDelta,l as connectResourceToCompute,k as detectDrift,se as estimateCostUsd,W as evaluateEmitGuard,de as gateFallbackOutput,y as listResources,B as mergeProperties,C as modifyCrossPlanConnection,m as modifyResource,f as modifyVpcPeer,x as modifyVpcPeerAccepter,I as parse,N as removeCrossPlanConnection,c as removeResource,T as removeVpcPeer,S as removeVpcPeerAccepter,G as resolveConstructByLiteralProperty,b as resolveDriftPolicy,ue as runFallback,E as setContainerSecrets,fe as shouldTryFallback,M as snapshotProperties};
@@ -1 +1 @@
1
- var k=Object.defineProperty;var p=(t,n)=>k(t,"name",{value:n,configurable:!0});import{gateEgress as d}from"./egressGate.js";import{buildPrompt as E}from"./prompt.js";import{applyStrReplaceOps as b}from"./apply.js";import{withTierTimeout as w}from"./tierRunner.js";import{PARSE_GATE as m}from"./types.js";const O=3e4,o="claude",f={name:"str_replace_based_edit_tool",type:"text_editor_20250728"};async function P(t,n){if(!t.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};const s=d(t.content,o);if(s!==void 0)return s;const e=d(JSON.stringify(t.intent.properties),o);if(e!==void 0)return e;const{systemPrompt:i,userPrompt:c}=E({content:t.content,intent:t.intent,tier:o});return w(t.abortSignal,o,O,async({signal:_,started:g})=>{const a=await n.create({model:n.resolveModelId(),max_tokens:4096,system:i,messages:[{role:"user",content:c}],tools:[f],signal:_}),T=Date.now()-g,l=x(a.content);if(l.length===0)return{state:"rejected",tier:o,failedGate:m,diagnostics:"Model produced no str_replace operations"};const r=b(t.content,l);if(!r.success)return{state:"rejected",tier:o,failedGate:m,diagnostics:`Ambiguous str_replace at op ${r.error.opIndex}: "${r.error.old_str.slice(0,40)}\u2026" matched ${r.error.matchCount} times`};const u=d(r.data.content,o);if(u!==void 0)return u;const y={tier:o,elapsedMs:T,inputTokens:a.usage?.input_tokens??0,outputTokens:a.usage?.output_tokens??0,opsApplied:r.data.appliedCount};return{state:"applied",content:r.data.content,telemetry:y}})}p(P,"runClaudeTier");function x(t){const n=[];for(const s of t){if(s.type!=="tool_use"||s.name!==f.name)continue;const e=s.input;if(!("command"in e)||e.command!=="str_replace"||!("old_str"in e)||!("new_str"in e))continue;const i=e.old_str,c=e.new_str;typeof i!="string"||typeof c!="string"||n.push({old_str:i,new_str:c})}return n}p(x,"extractStrReplaceOps");export{f as TEXT_EDITOR_TOOL,P as runClaudeTier};
1
+ var y=Object.defineProperty;var l=(t,r)=>y(t,"name",{value:r,configurable:!0});import{maskSensitiveOutput as S}from"@fjall/util";import{gateEgress as u}from"./egressGate.js";import{buildPrompt as E}from"./prompt.js";import{applyStrReplaceOps as O}from"./apply.js";import{withTierTimeout as b}from"./tierRunner.js";import{PARSE_GATE as d}from"./types.js";const M=3e4,e="claude",f={name:"str_replace_based_edit_tool",type:"text_editor_20250728"};async function C(t,r){if(!t.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};const s=u(t.content,e,"input");if(s!==void 0)return s;const o=u(JSON.stringify(t.intent.properties),e,"input");if(o!==void 0)return o;const{systemPrompt:i,userPrompt:a}=E({content:t.content,intent:t.intent,tier:e});return b(t.abortSignal,e,M,async({signal:_,started:g})=>{const p=await r.create({model:r.resolveModelId(),max_tokens:4096,system:i,messages:[{role:"user",content:a}],tools:[f],signal:_}),T=Date.now()-g,c=w(p.content);if(c.length===0)return{state:"rejected",tier:e,failedGate:d,diagnostics:"Model produced no str_replace operations"};const n=O(t.content,c);if(!n.success){const k=S(n.error.old_str).slice(0,40);return{state:"rejected",tier:e,failedGate:d,diagnostics:`Ambiguous str_replace at op ${n.error.opIndex}: "${k}\u2026" matched ${n.error.matchCount} times`}}if(n.data.appliedCount===0)return{state:"rejected",tier:e,failedGate:d,diagnostics:`Model emitted ${String(c.length)} operation(s) but none matched the file`};if(n.data.content===t.content)return{state:"rejected",tier:e,failedGate:d,diagnostics:`Model emitted ${String(c.length)} operation(s) that left the file unchanged`};const m=u(n.data.content,e,"output");if(m!==void 0)return m;const h={tier:e,elapsedMs:T,inputTokens:p.usage?.input_tokens??0,outputTokens:p.usage?.output_tokens??0,opsApplied:n.data.appliedCount};return{state:"applied",content:n.data.content,telemetry:h}})}l(C,"runClaudeTier");function w(t){const r=[];for(const s of t){if(s.type!=="tool_use"||s.name!==f.name)continue;const o=s.input;if(!("command"in o)||o.command!=="str_replace"||!("old_str"in o)||!("new_str"in o))continue;const i=o.old_str,a=o.new_str;typeof i!="string"||typeof a!="string"||r.push({old_str:i,new_str:a})}return r}l(w,"extractStrReplaceOps");export{f as TEXT_EDITOR_TOOL,C as runClaudeTier};
@@ -1,5 +1,5 @@
1
1
  import type { LlmFallbackTier } from "../types.js";
2
2
  import type { EgressGateResult } from "./egressGate.types.js";
3
- import type { FallbackOutput } from "./types.js";
3
+ import type { EgressStage, FallbackOutput } from "./types.js";
4
4
  export declare function scanForEgressRisk(content: string): EgressGateResult;
5
- export declare function gateEgress(content: string, tier: LlmFallbackTier): FallbackOutput | undefined;
5
+ export declare function gateEgress(content: string, tier: LlmFallbackTier, stage: EgressStage): FallbackOutput | undefined;
@@ -1 +1 @@
1
- var a=Object.defineProperty;var r=(t,n)=>a(t,"name",{value:n,configurable:!0});const h=32,u=4.5,f=8,_=/\barn:aws:[a-z0-9-]+:[a-z0-9-]*:[0-9]*:[^\s"']+/g,H=/(?<![A-Za-z0-9+/=_-])[A-Za-z0-9+/=_-]{32,}(?![A-Za-z0-9+/=_-])/g;function E(t){if(t.length===0)return 0;const n=new Map;for(const o of t)n.set(o,(n.get(o)??0)+1);let e=0;for(const o of n.values()){const s=o/t.length;e-=s*Math.log2(s)}return e}r(E,"shannonEntropy");function c(t){return t.length<=8?t:`${t.slice(0,8)}\u2026`}r(c,"truncateHint");function l(t){const n=[...t.matchAll(_)];if(n.length>0){const o=n[0]?.[0]??"";return{state:"block",reason:"arn-shape",count:n.length,sampleHint:c(o)}}const e=[];for(const o of t.matchAll(H)){const s=o[0]??"";s.length>=32&&E(s)>=4.5&&e.push(s)}return e.length>0?{state:"block",reason:"high-entropy",count:e.length,sampleHint:c(e[0]??"")}:{state:"pass"}}r(l,"scanForEgressRisk");function g(t,n){const e=l(t);if(e.state==="block")return{state:"egress-blocked",tier:n,reason:e.reason,count:e.count}}r(g,"gateEgress");export{g as gateEgress,l as scanForEgressRisk};
1
+ var l=Object.defineProperty;var r=(t,e)=>l(t,"name",{value:e,configurable:!0});import{MASKED_VALUE_MARKER as c,maskSensitiveOutput as h}from"@fjall/util";const i=32,f=4.5,g=/\barn:aws[a-z-]*:[a-z0-9-]+:[a-z0-9-]*:[0-9]*:[^\s"']+/g,E=/(?<![A-Za-z0-9+/=_-])[A-Za-z0-9+/=_-]{32,}(?![A-Za-z0-9+/=_-])/g;function _(t){if(t.length===0)return 0;const e=new Map;for(const n of t)e.set(n,(e.get(n)??0)+1);let o=0;for(const n of e.values()){const s=n/t.length;o-=s*Math.log2(s)}return o}r(_,"shannonEntropy");function u(t,e){let o=0,n=0;for(;;){const s=t.indexOf(e,n);if(s===-1)break;o+=1,n=s+e.length}return o}r(u,"countOccurrences");function p(t){const e=[...t.matchAll(g)];if(e.length>0)return{state:"block",reason:"arn-shape",count:e.length};const o=h(t);if(o!==t){const s=u(o,c)-u(t,c);return{state:"block",reason:"credential-pattern",count:Math.max(1,s)}}const n=[];for(const s of t.matchAll(E)){const a=s[0]??"";a.length>=i&&_(a)>=f&&n.push(a)}return n.length>0?{state:"block",reason:"high-entropy",count:n.length}:{state:"pass"}}r(p,"scanForEgressRisk");function k(t,e,o){const n=p(t);if(n.state==="block")return{state:"egress-blocked",tier:e,reason:n.reason,count:n.count,stage:o}}r(k,"gateEgress");export{k as gateEgress,p as scanForEgressRisk};
@@ -1,9 +1,10 @@
1
- export type EgressRiskReason = "high-entropy" | "arn-shape";
1
+ /** Which egress scan fired: the pre-send input scan or the model-output scan. */
2
+ export type EgressStage = "input" | "output";
3
+ export type EgressRiskReason = "high-entropy" | "arn-shape" | "credential-pattern";
2
4
  export type EgressGateResult = {
3
5
  state: "pass";
4
6
  } | {
5
7
  state: "block";
6
8
  reason: EgressRiskReason;
7
9
  count: number;
8
- sampleHint: string;
9
10
  };
@@ -0,0 +1,32 @@
1
+ import type { ResourceSnapshot } from "../drift/index.js";
2
+ import type { LlmFallbackTier } from "../types.js";
3
+ import { type GateId } from "../validationGate/index.js";
4
+ import type { FallbackIntent } from "./types.js";
5
+ import type { FallbackOutput } from "./types.js";
6
+ export type GateEventAction = "pass" | "fail";
7
+ export interface GateFallbackParams {
8
+ /** The tier's applied content — the candidate for the write. */
9
+ outputContent: string;
10
+ /** The pre-fallback source the model was shown (classify gate's before-side). */
11
+ inputContent: string;
12
+ intent: FallbackIntent;
13
+ tier: LlmFallbackTier;
14
+ /**
15
+ * Drift baseline, threaded from the caller when it has one. Optional for
16
+ * parity with the deterministic path: absent ⇒ the drift gate is a
17
+ * vacuous proceed, exactly as `addResource`/`modifyResource` behave when
18
+ * called without a baseline context.
19
+ */
20
+ baseline?: ResourceSnapshot;
21
+ abortSignal?: AbortSignal;
22
+ onGateResult?: (gate: GateId, action: GateEventAction, durationMs: number) => void;
23
+ }
24
+ /**
25
+ * Run the validation-gate chain on applied fallback output.
26
+ *
27
+ * Returns `undefined` when every gate passes (the caller keeps the applied
28
+ * result), or a substitute `FallbackOutput` — "rejected" carrying the real
29
+ * failed gate id with diagnostics pre-masked at construction, or
30
+ * "cancelled" when the caller's abort signal fired between gates.
31
+ */
32
+ export declare function gateFallbackOutput(params: GateFallbackParams): FallbackOutput | undefined;
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var c=(e,t)=>m(e,"name",{value:t,configurable:!0});import{isDeepStrictEqual as $}from"node:util";import{maskSensitiveOutput as d}from"@fjall/util";import{STATEMENT_REGISTRY as h}from"../registry.js";import{classifyGate as l,createLocateGate as p,driftGate as G,parseGate as f,schemaGate as b}from"../validationGate/index.js";function D(e){const{intent:t,tier:i}=e;if(t.op==="add"&&h[t.type].addContract===void 0)return{state:"rejected",tier:i,failedGate:"schema",diagnostics:`LLM fallback cannot add a ${t.type}: its complete add contract is not yet declared. Nothing has been written.`};const g={type:t.type,name:t.name,properties:t.properties,op:t.op==="add"?"add":"modify"},y={content:e.outputContent,plan:g,inputContent:e.inputContent,...e.baseline!==void 0&&{baseline:e.baseline},...e.abortSignal!==void 0&&{signal:e.abortSignal}};for(const n of E(t.op)){if(e.abortSignal?.aborted===!0)return{state:"cancelled"};const u=Date.now();let a;try{a=n.run(y)}catch(o){return e.onGateResult?.(n.id,"fail",Date.now()-u),{state:"rejected",tier:i,failedGate:n.id,diagnostics:d(o instanceof Error?o.message:String(o))}}const s=Date.now()-u;if(!a.success)return e.onGateResult?.(n.id,"fail",s),{state:"rejected",tier:i,failedGate:n.id,diagnostics:d(S(a.error))};if(a.data.action==="reject")return e.onGateResult?.(n.id,"fail",s),{state:"rejected",tier:i,failedGate:a.data.failedGate??n.id,diagnostics:d(a.data.diagnostics??"gate rejected the output")};if(a.data.driftState!==void 0){const o=a.data.driftState.deltas.filter(r=>r.verdict==="clean"&&Object.hasOwn(t.properties,r.property)&&!$(r.theirs,r.ours)).map(r=>`\`${r.property}\``);if(o.length>0)return e.onGateResult?.(n.id,"fail",s),{state:"rejected",tier:i,failedGate:n.id,diagnostics:d(`output left requested ${o.length===1?"property":"properties"} at the baseline value: ${o.join(", ")}`)}}e.onGateResult?.(n.id,"pass",s)}}c(D,"gateFallbackOutput");function E(e){return e==="remove"?[f,l,p({mode:"absent"})]:[f,l,p({mode:"present"}),b,G]}c(E,"gatesForOp");function S(e){switch(e.kind){case"ParseError":return`output does not parse: ${e.message}`;case"ControlFlowClassifierError":return`output moved ${e.resource.type} "${e.resource.name}" out of top-level scope (${e.reason})`;case"ResourceNotFoundError":return`${e.type} "${e.name}" is missing from the output`;case"DuplicateResourceError":return`${e.type} "${e.name}" is still present in the output`;case"TemplateLiteralNameError":return`output names the resource with a template literal (line ${String(e.line)})`;case"InvalidPropertyError":return`property \`${e.property}\`: ${e.reason}`;case"DriftConflictError":{const t=e.deltas.filter(i=>i.verdict==="conflict").map(i=>`\`${i.property}\``).join(", ");return`output conflicts with the requested properties on ${e.resource.type} "${e.resource.name}"`+(t.length>0?` (${t})`:"")}case"SemanticQueryError":return`output could not be analysed: ${e.reason}`;default:return e.kind}}c(S,"describeGateError");export{D as gateFallbackOutput};
@@ -1,6 +1,7 @@
1
1
  export { runFallback, type FallbackClients, type RunFallbackInput, } from "./runFallback.js";
2
+ export { gateFallbackOutput, type GateEventAction, type GateFallbackParams, } from "./gateFallbackOutput.js";
2
3
  export { shouldTryFallback, type FallbackDecision, type FallbackGuardConfig, } from "./shouldTryFallback.js";
3
- export { buildEgressBlockedEvent, buildFiredEvent, buildGateFailedEvent, buildGatePassedEvent, buildRejectedEvent, buildSucceededEvent, buildTimeoutEvent, estimateCostUsd, FALLBACK_EVENTS, GATE_EVENTS, type FallbackEgressBlockedEvent, type FallbackFiredEvent, type FallbackRejectedEvent, type FallbackSucceededEvent, type FallbackTelemetryEvent, type FallbackTimeoutEvent, type GateFailedEvent, type GatePassedEvent, type TelemetrySource, } from "./telemetryEvents.js";
4
+ export { buildEgressBlockedEvent, buildFiredEvent, buildGateFailedEvent, buildGatePassedEvent, buildRejectedEvent, buildSucceededEvent, buildTimeoutEvent, estimateCostUsd, FALLBACK_EVENTS, GATE_EVENTS, UNATTRIBUTED_ORGANISATION, type FallbackEgressBlockedEvent, type FallbackFiredEvent, type FallbackRejectedEvent, type FallbackSucceededEvent, type FallbackTelemetryEvent, type FallbackTimeoutEvent, type GateFailedEvent, type GatePassedEvent, type TelemetrySource, } from "./telemetryEvents.js";
4
5
  export { PARSE_GATE, RUNTIME_GATE } from "./types.js";
5
- export type { AnthropicClientProvider, AnthropicContentBlock, AnthropicResponse, ApplyResult, FallbackInput, FallbackIntent, FallbackOp, FallbackOutput, FallbackTelemetry, MorphClientProvider, MorphResponse, StrReplaceOp, TriggerReason, } from "./types.js";
6
+ export type { AnthropicClientProvider, AnthropicContentBlock, AnthropicResponse, ApplyResult, EgressStage, FallbackInput, FallbackIntent, FallbackOp, FallbackOutput, FallbackTelemetry, MorphClientProvider, MorphResponse, StrReplaceOp, TriggerReason, } from "./types.js";
6
7
  export type { EgressGateResult, EgressRiskReason } from "./egressGate.types.js";
@@ -1 +1 @@
1
- import{runFallback as E}from"./runFallback.js";import{shouldTryFallback as l}from"./shouldTryFallback.js";import{buildEgressBlockedEvent as r,buildFiredEvent as i,buildGateFailedEvent as u,buildGatePassedEvent as a,buildRejectedEvent as b,buildSucceededEvent as n,buildTimeoutEvent as s,estimateCostUsd as T,FALLBACK_EVENTS as v,GATE_EVENTS as c}from"./telemetryEvents.js";import{PARSE_GATE as A,RUNTIME_GATE as F}from"./types.js";export{v as FALLBACK_EVENTS,c as GATE_EVENTS,A as PARSE_GATE,F as RUNTIME_GATE,r as buildEgressBlockedEvent,i as buildFiredEvent,u as buildGateFailedEvent,a as buildGatePassedEvent,b as buildRejectedEvent,n as buildSucceededEvent,s as buildTimeoutEvent,T as estimateCostUsd,E as runFallback,l as shouldTryFallback};
1
+ import{runFallback as E}from"./runFallback.js";import{gateFallbackOutput as l}from"./gateFallbackOutput.js";import{shouldTryFallback as r}from"./shouldTryFallback.js";import{buildEgressBlockedEvent as a,buildFiredEvent as T,buildGateFailedEvent as i,buildGatePassedEvent as b,buildRejectedEvent as A,buildSucceededEvent as n,buildTimeoutEvent as s,estimateCostUsd as c,FALLBACK_EVENTS as m,GATE_EVENTS as v,UNATTRIBUTED_ORGANISATION as p}from"./telemetryEvents.js";import{PARSE_GATE as G,RUNTIME_GATE as N}from"./types.js";export{m as FALLBACK_EVENTS,v as GATE_EVENTS,G as PARSE_GATE,N as RUNTIME_GATE,p as UNATTRIBUTED_ORGANISATION,a as buildEgressBlockedEvent,T as buildFiredEvent,i as buildGateFailedEvent,b as buildGatePassedEvent,A as buildRejectedEvent,n as buildSucceededEvent,s as buildTimeoutEvent,c as estimateCostUsd,l as gateFallbackOutput,E as runFallback,r as shouldTryFallback};
@@ -1,3 +1,3 @@
1
- var m=Object.defineProperty;var c=(e,o)=>m(e,"name",{value:o,configurable:!0});import{gateEgress as r}from"./egressGate.js";import{buildPrompt as T}from"./prompt.js";import{withTierTimeout as k}from"./tierRunner.js";import{PARSE_GATE as E}from"./types.js";const b=15e3,t="morph";async function _(e,o){if(!e.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};if(!o.isAvailable())return{state:"disabled",reason:"env-flag"};const s=r(e.content,t);if(s!==void 0)return s;const i=r(JSON.stringify(e.intent.properties),t);if(i!==void 0)return i;const{systemPrompt:p,userPrompt:u}=T({content:e.content,intent:e.intent,tier:t});return k(e.abortSignal,t,b,async({signal:l,started:d})=>{const n=await o.apply({originalFile:e.content,update:`${p}
1
+ var m=Object.defineProperty;var c=(t,o)=>m(t,"name",{value:o,configurable:!0});import{gateEgress as r}from"./egressGate.js";import{buildPrompt as T}from"./prompt.js";import{withTierTimeout as k}from"./tierRunner.js";import{PARSE_GATE as E}from"./types.js";const b=15e3,e="morph";async function _(t,o){if(!t.orgAllowsFallback)return{state:"disabled",reason:"org-opt-out"};if(!o.isAvailable())return{state:"disabled",reason:"env-flag"};const s=r(t.content,e,"input");if(s!==void 0)return s;const i=r(JSON.stringify(t.intent.properties),e,"input");if(i!==void 0)return i;const{systemPrompt:p,userPrompt:u}=T({content:t.content,intent:t.intent,tier:e});return k(t.abortSignal,e,b,async({signal:l,started:d})=>{const n=await o.apply({originalFile:t.content,update:`${p}
2
2
 
3
- ${u}`,signal:l}),f=Date.now()-d;if(n.content===e.content)return{state:"rejected",tier:t,failedGate:E,diagnostics:"Morph returned unchanged content"};const a=r(n.content,t);if(a!==void 0)return a;const g={tier:t,elapsedMs:f,inputTokens:n.usage?.inputTokens??0,outputTokens:n.usage?.outputTokens??0,opsApplied:1};return{state:"applied",content:n.content,telemetry:g}})}c(_,"runMorphTier");export{_ as runMorphTier};
3
+ ${u}`,signal:l}),f=Date.now()-d;if(n.content===t.content)return{state:"rejected",tier:e,failedGate:E,diagnostics:"Morph returned unchanged content"};const a=r(n.content,e,"output");if(a!==void 0)return a;const g={tier:e,elapsedMs:f,inputTokens:n.usage?.inputTokens??0,outputTokens:n.usage?.outputTokens??0,opsApplied:1};return{state:"applied",content:n.content,telemetry:g}})}c(_,"runMorphTier");export{_ as runMorphTier};
@@ -1,4 +1,7 @@
1
- import type { AnthropicClientProvider, FallbackInput, FallbackOutput, MorphClientProvider } from "./types.js";
1
+ import type { ResourceSnapshot } from "../drift/index.js";
2
+ import type { GateId } from "../validationGate/types.js";
3
+ import { type GateEventAction } from "./gateFallbackOutput.js";
4
+ import { type AnthropicClientProvider, type FallbackInput, type FallbackOutput, type MorphClientProvider } from "./types.js";
2
5
  export interface FallbackClients {
3
6
  claude: AnthropicClientProvider;
4
7
  morph?: MorphClientProvider;
@@ -9,5 +12,13 @@ export interface RunFallbackInput {
9
12
  orgAllowsFallback: boolean;
10
13
  morphTierEnabled: boolean;
11
14
  abortSignal?: AbortSignal;
15
+ /**
16
+ * Drift baseline for the post-apply gate run. Optional — absent means the
17
+ * drift gate proceeds vacuously, matching the deterministic edit path when
18
+ * called without a baseline context.
19
+ */
20
+ baseline?: ResourceSnapshot;
21
+ /** Per-gate observability hook for the post-apply validation chain. */
22
+ onGateResult?: (gate: GateId, action: GateEventAction, durationMs: number) => void;
12
23
  }
13
24
  export declare function runFallback(input: RunFallbackInput, clients: FallbackClients): Promise<FallbackOutput>;
@@ -1 +1 @@
1
- var a=Object.defineProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});import{runClaudeTier as l}from"./claudeTier.js";import{runMorphTier as i}from"./morphTier.js";function n(r,e){return{content:r.content,intent:r.intent,tier:e,orgAllowsFallback:r.orgAllowsFallback,abortSignal:r.abortSignal}}o(n,"buildTierInput");async function d(r,e){const t=await l(n(r,"claude"),e.claude);return!(t.state==="rejected"||t.state==="timeout")||!r.morphTierEnabled||e.morph===void 0?t:i(n(r,"morph"),e.morph)}o(d,"runFallback");export{d as runFallback};
1
+ var c=Object.defineProperty;var a=(e,t)=>c(e,"name",{value:t,configurable:!0});import{maskSensitiveOutput as s}from"@fjall/util";import{runClaudeTier as d}from"./claudeTier.js";import{gateFallbackOutput as u}from"./gateFallbackOutput.js";import{runMorphTier as b}from"./morphTier.js";import{RUNTIME_GATE as f}from"./types.js";function l(e,t){return{content:e.content,intent:e.intent,tier:t,orgAllowsFallback:e.orgAllowsFallback,abortSignal:e.abortSignal}}a(l,"buildTierInput");async function i(e,t,n){try{const r=await n();return r.state!=="applied"?r:u({outputContent:r.content,inputContent:e.content,intent:e.intent,tier:t,...e.baseline!==void 0&&{baseline:e.baseline},...e.abortSignal!==void 0&&{abortSignal:e.abortSignal},...e.onGateResult!==void 0&&{onGateResult:e.onGateResult}})??r}catch(r){return e.abortSignal?.aborted===!0?{state:"cancelled"}:{state:"rejected",tier:t,failedGate:f,diagnostics:s(r instanceof Error?r.message:String(r))}}}a(i,"runGatedTier");async function G(e,t){const n=await i(e,"claude",()=>d(l(e,"claude"),t.claude));if(!(n.state==="rejected"||n.state==="timeout"))return n;const o=t.morph;return!e.morphTierEnabled||o===void 0?n:i(e,"morph",()=>b(l(e,"morph"),o))}a(G,"runFallback");export{G as runFallback};
@@ -1,5 +1,5 @@
1
1
  import type { GateId } from "../validationGate/types.js";
2
- import type { FallbackOp, FallbackTelemetry, TriggerReason } from "./types.js";
2
+ import type { EgressStage, FallbackOp, FallbackTelemetry, TriggerReason } from "./types.js";
3
3
  import type { EgressRiskReason } from "./egressGate.types.js";
4
4
  import type { LlmFallbackTier } from "../types.js";
5
5
  export declare const FALLBACK_EVENTS: {
@@ -13,6 +13,13 @@ export declare const GATE_EVENTS: {
13
13
  readonly PASSED: "codemod.gate.passed";
14
14
  readonly FAILED: "codemod.gate.failed";
15
15
  };
16
+ /**
17
+ * Sentinel for events emitted before an organisation identity is resolved.
18
+ * Coupled value at 2+ consumers (CLI + webapp emitters): analytics forks
19
+ * silently if the spellings diverge, so import this — never inline the
20
+ * literal.
21
+ */
22
+ export declare const UNATTRIBUTED_ORGANISATION = "unknown";
16
23
  export type TelemetrySource = "cli" | "webapp_service" | "webapp_api" | "webapp_ui" | "mcp";
17
24
  export interface FallbackFiredEvent {
18
25
  event: typeof FALLBACK_EVENTS.FIRED;
@@ -64,6 +71,7 @@ export interface FallbackEgressBlockedEvent {
64
71
  tier: LlmFallbackTier;
65
72
  reason: EgressRiskReason;
66
73
  count: number;
74
+ stage: EgressStage;
67
75
  organisationId: string;
68
76
  };
69
77
  }
@@ -123,6 +131,7 @@ export declare function buildEgressBlockedEvent(params: {
123
131
  tier: LlmFallbackTier;
124
132
  reason: EgressRiskReason;
125
133
  count: number;
134
+ stage: EgressStage;
126
135
  organisationId: string;
127
136
  }): FallbackEgressBlockedEvent;
128
137
  export declare function buildGatePassedEvent(params: {
@@ -1 +1 @@
1
- var d=Object.defineProperty;var t=(e,n)=>d(e,"name",{value:n,configurable:!0});const o={FIRED:"codemod.llm_fallback.fired",SUCCEEDED:"codemod.llm_fallback.succeeded",REJECTED:"codemod.llm_fallback.rejected",TIMEOUT:"codemod.llm_fallback.timeout",EGRESS_BLOCKED:"codemod.llm_fallback.egress_blocked"},r={PASSED:"codemod.gate.passed",FAILED:"codemod.gate.failed"},i=3/1e6,u=15/1e6;function c(e){if(e.tier!=="claude")return 0;const n=e.inputTokens*i,E=e.outputTokens*u;return Math.round((n+E)*1e6)/1e6}t(c,"estimateCostUsd");function s(e){return{event:o.FIRED,properties:e}}t(s,"buildFiredEvent");function p(e){return{event:o.SUCCEEDED,properties:{source:e.source,operation:e.operation,tier:e.telemetry.tier,durationMs:e.telemetry.elapsedMs,estimatedCostUsd:c(e.telemetry),organisationId:e.organisationId}}}t(p,"buildSucceededEvent");function _(e){return{event:o.REJECTED,properties:e}}t(_,"buildRejectedEvent");function a(e){return{event:o.TIMEOUT,properties:e}}t(a,"buildTimeoutEvent");function T(e){return{event:o.EGRESS_BLOCKED,properties:e}}t(T,"buildEgressBlockedEvent");function f(e){return{event:r.PASSED,properties:e}}t(f,"buildGatePassedEvent");function D(e){return{event:r.FAILED,properties:e}}t(D,"buildGateFailedEvent");export{o as FALLBACK_EVENTS,r as GATE_EVENTS,T as buildEgressBlockedEvent,s as buildFiredEvent,D as buildGateFailedEvent,f as buildGatePassedEvent,_ as buildRejectedEvent,p as buildSucceededEvent,a as buildTimeoutEvent,c as estimateCostUsd};
1
+ var d=Object.defineProperty;var t=(e,n)=>d(e,"name",{value:n,configurable:!0});const o={FIRED:"codemod.llm_fallback.fired",SUCCEEDED:"codemod.llm_fallback.succeeded",REJECTED:"codemod.llm_fallback.rejected",TIMEOUT:"codemod.llm_fallback.timeout",EGRESS_BLOCKED:"codemod.llm_fallback.egress_blocked"},r={PASSED:"codemod.gate.passed",FAILED:"codemod.gate.failed"},s="unknown",i=3/1e6,u=15/1e6;function c(e){if(e.tier!=="claude")return 0;const n=e.inputTokens*i,E=e.outputTokens*u;return Math.round((n+E)*1e6)/1e6}t(c,"estimateCostUsd");function p(e){return{event:o.FIRED,properties:e}}t(p,"buildFiredEvent");function _(e){return{event:o.SUCCEEDED,properties:{source:e.source,operation:e.operation,tier:e.telemetry.tier,durationMs:e.telemetry.elapsedMs,estimatedCostUsd:c(e.telemetry),organisationId:e.organisationId}}}t(_,"buildSucceededEvent");function T(e){return{event:o.REJECTED,properties:e}}t(T,"buildRejectedEvent");function a(e){return{event:o.TIMEOUT,properties:e}}t(a,"buildTimeoutEvent");function D(e){return{event:o.EGRESS_BLOCKED,properties:e}}t(D,"buildEgressBlockedEvent");function f(e){return{event:r.PASSED,properties:e}}t(f,"buildGatePassedEvent");function C(e){return{event:r.FAILED,properties:e}}t(C,"buildGateFailedEvent");export{o as FALLBACK_EVENTS,r as GATE_EVENTS,s as UNATTRIBUTED_ORGANISATION,D as buildEgressBlockedEvent,p as buildFiredEvent,C as buildGateFailedEvent,f as buildGatePassedEvent,T as buildRejectedEvent,_ as buildSucceededEvent,a as buildTimeoutEvent,c as estimateCostUsd};
@@ -1,6 +1,7 @@
1
1
  import type { StatementType, ResourceName, LlmFallbackTier } from "../types.js";
2
2
  import type { GateId } from "../validationGate/types.js";
3
- import type { EgressRiskReason } from "./egressGate.types.js";
3
+ import type { EgressRiskReason, EgressStage } from "./egressGate.types.js";
4
+ export type { EgressStage } from "./egressGate.types.js";
4
5
  export declare const PARSE_GATE: GateId;
5
6
  export declare const RUNTIME_GATE: GateId;
6
7
  export type FallbackOp = "add" | "modify" | "remove" | "resolve-drift-merge";
@@ -17,6 +18,12 @@ export interface FallbackInput {
17
18
  orgAllowsFallback: boolean;
18
19
  abortSignal?: AbortSignal;
19
20
  }
21
+ /**
22
+ * `rejected.diagnostics` is pre-masked at construction — every construction
23
+ * site (tier rejections, `tierRunner` throw containment, `gateFallbackOutput`)
24
+ * routes dynamic content through `maskSensitiveOutput`. Consumers MUST NOT
25
+ * re-mask (security-standards § "One mask per output path").
26
+ */
20
27
  export type FallbackOutput = {
21
28
  state: "applied";
22
29
  content: string;
@@ -26,6 +33,7 @@ export type FallbackOutput = {
26
33
  tier: LlmFallbackTier;
27
34
  reason: EgressRiskReason;
28
35
  count: number;
36
+ stage: EgressStage;
29
37
  } | {
30
38
  state: "timeout";
31
39
  tier: LlmFallbackTier;
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { ResourceNameSchema } from "../schemas/baseSchemas.js";
3
3
  import type { GateId } from "./validationGate/types.js";
4
- import type { EgressRiskReason } from "./llmFallback/egressGate.types.js";
4
+ import type { EgressRiskReason, EgressStage } from "./llmFallback/egressGate.types.js";
5
5
  export declare const DriftPolicySchema: z.ZodObject<{
6
6
  force: z.ZodOptional<z.ZodBoolean>;
7
7
  resolutionMap: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -301,6 +301,12 @@ export interface ControlFlowClassifierError {
301
301
  remediation?: string;
302
302
  }
303
303
  export type LlmFallbackTier = "claude" | "morph";
304
+ /**
305
+ * `diagnostics` is pre-masked at construction — the generator's tier
306
+ * rejections, throw containment and gate-chain rejections all route dynamic
307
+ * content through `maskSensitiveOutput` before it lands here (see
308
+ * `llmFallback/types.ts` § FallbackOutput). Consumers MUST NOT re-mask.
309
+ */
304
310
  export interface LlmFallbackRejectedError {
305
311
  kind: "LlmFallbackRejectedError";
306
312
  tier: LlmFallbackTier;
@@ -316,5 +322,7 @@ export interface LlmFallbackUnsafeInputError {
316
322
  kind: "LlmFallbackUnsafeInputError";
317
323
  reason: EgressRiskReason;
318
324
  count: number;
325
+ /** Which egress scan fired — the pre-send input scan or the model-output scan. */
326
+ stage: EgressStage;
319
327
  }
320
328
  export type CodemodError = ParseError | TemplateLiteralNameError | DuplicateResourceError | ResourceNotFoundError | ReferencesRemainError | InvalidPropertyError | SemanticQueryError | MissingAppInitError | DriftConflictError | DriftUnmergeableError | PermissionError | ControlFlowClassifierError | LlmFallbackRejectedError | LlmFallbackTimeoutError | LlmFallbackUnsafeInputError;
@@ -2,5 +2,5 @@ export { runPipeline, runPipelineAsync, type AsyncGate, type Gate, type GateActi
2
2
  export { driftGate } from "./gates/drift.js";
3
3
  export { schemaGate } from "./gates/schema.js";
4
4
  export { parseGate } from "./gates/parse.js";
5
- export { locateGate } from "./gates/locate.js";
5
+ export { createLocateGate, locateGate, type LocateGateOptions, type LocateMode, } from "./gates/locate.js";
6
6
  export { classifyGate } from "./gates/classify.js";
@@ -1 +1 @@
1
- import{runPipeline as o,runPipelineAsync as t}from"./types.js";import{driftGate as p}from"./gates/drift.js";import{schemaGate as m}from"./gates/schema.js";import{parseGate as x}from"./gates/parse.js";import{locateGate as s}from"./gates/locate.js";import{classifyGate as c}from"./gates/classify.js";export{c as classifyGate,p as driftGate,s as locateGate,x as parseGate,o as runPipeline,t as runPipelineAsync,m as schemaGate};
1
+ import{runPipeline as t,runPipelineAsync as o}from"./types.js";import{driftGate as p}from"./gates/drift.js";import{schemaGate as m}from"./gates/schema.js";import{parseGate as i}from"./gates/parse.js";import{createLocateGate as G,locateGate as n}from"./gates/locate.js";import{classifyGate as l}from"./gates/classify.js";export{l as classifyGate,G as createLocateGate,p as driftGate,n as locateGate,i as parseGate,t as runPipeline,o as runPipelineAsync,m as schemaGate};
@@ -24,7 +24,7 @@ ${l} certificates: [
24
24
  ],
25
25
  records: ${d},
26
26
  });
27
- `}r(k,"generateDefaultInfrastructureTs");function g(t){return JSON.stringify({name:`domain-${t}`,version:u,scripts:{},devDependencies:{"@types/node":"20.4.9","ts-node":"^10.9.1",typescript:"~5.1.6"},dependencies:{"@fjall/components-infrastructure":`^${u}`,"aws-cdk-lib":"^2.263.0",constructs:"^10.7.2"}},null,2)+`
27
+ `}r(k,"generateDefaultInfrastructureTs");function g(t){return JSON.stringify({name:`domain-${t}`,version:u,scripts:{},devDependencies:{"@types/node":"20.4.9","ts-node":"^10.9.1",typescript:"~5.1.6"},dependencies:{"@fjall/components-infrastructure":`^${u}`,"aws-cdk-lib":"^2.265.0",constructs:"^10.7.2"}},null,2)+`
28
28
  `}r(g,"generateDomainPackageJson");const y=`node_modules/
29
29
  cdk.out/
30
30
  *.d.ts
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
2
  export declare const EcsServiceAlarmConfigSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
3
- cpuThreshold: z.ZodOptional<z.ZodNumber>;
4
- memoryThreshold: z.ZodOptional<z.ZodNumber>;
3
+ cpuThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
4
+ memoryThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
5
5
  runningTasksMinimum: z.ZodOptional<z.ZodNumber>;
6
- http5xxThreshold: z.ZodOptional<z.ZodNumber>;
6
+ http5xxThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
7
7
  }, z.core.$strict>]>;
8
8
  export declare const RdsAlarmConfigSchema: z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
9
9
  cpuThreshold: z.ZodOptional<z.ZodNumber>;
@@ -1 +1 @@
1
- import{z as o}from"zod";import{VALIDATION_MESSAGES as n}from"../validation/patterns.js";const e=o.number().min(1,n.ALARM.PERCENTAGE.MIN).max(100,n.ALARM.PERCENTAGE.MAX),r=o.number().min(1,n.ALARM.FREE_STORAGE_GIB.MIN),a=o.union([o.literal(!1),o.object({cpuThreshold:e.optional(),memoryThreshold:e.optional(),runningTasksMinimum:o.number().int().min(0).optional(),http5xxThreshold:e.optional()}).strict()]),l=o.union([o.literal(!1),o.object({cpuThreshold:e.optional(),freeStorageThresholdGiB:r.optional(),connectionsThreshold:o.number().int().min(1).optional()}).strict()]),h=o.union([o.literal(!1),o.object({errorRateThreshold:e.optional(),durationThresholdPercent:e.optional()}).strict()]);export{a as EcsServiceAlarmConfigSchema,h as LambdaAlarmConfigSchema,l as RdsAlarmConfigSchema};
1
+ import{z as o}from"zod";import{VALIDATION_MESSAGES as n}from"../validation/patterns.js";const e=o.number().min(1,n.ALARM.PERCENTAGE.MIN).max(100,n.ALARM.PERCENTAGE.MAX),r=o.union([e,o.literal(!1)]),t=o.number().min(1,n.ALARM.FREE_STORAGE_GIB.MIN),l=o.union([o.literal(!1),o.object({cpuThreshold:r.optional(),memoryThreshold:r.optional(),runningTasksMinimum:o.number().int().min(0).optional(),http5xxThreshold:r.optional()}).strict()]),s=o.union([o.literal(!1),o.object({cpuThreshold:e.optional(),freeStorageThresholdGiB:t.optional(),connectionsThreshold:o.number().int().min(1).optional()}).strict()]),h=o.union([o.literal(!1),o.object({errorRateThreshold:e.optional(),durationThresholdPercent:e.optional()}).strict()]);export{l as EcsServiceAlarmConfigSchema,h as LambdaAlarmConfigSchema,s as RdsAlarmConfigSchema};
@@ -657,10 +657,10 @@ export declare const ApplicationResourcePlanSchema: z.ZodObject<{
657
657
  sourceText: z.ZodString;
658
658
  }, z.core.$strict>>>;
659
659
  alarms: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
660
- cpuThreshold: z.ZodOptional<z.ZodNumber>;
661
- memoryThreshold: z.ZodOptional<z.ZodNumber>;
660
+ cpuThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
661
+ memoryThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
662
662
  runningTasksMinimum: z.ZodOptional<z.ZodNumber>;
663
- http5xxThreshold: z.ZodOptional<z.ZodNumber>;
663
+ http5xxThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
664
664
  }, z.core.$strict>]>>;
665
665
  }, z.core.$strict>>>;
666
666
  docker: z.ZodOptional<z.ZodObject<{
@@ -266,10 +266,10 @@ export declare const EcsServiceConfigSchema: z.ZodObject<{
266
266
  sourceText: z.ZodString;
267
267
  }, z.core.$strict>>>;
268
268
  alarms: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
269
- cpuThreshold: z.ZodOptional<z.ZodNumber>;
270
- memoryThreshold: z.ZodOptional<z.ZodNumber>;
269
+ cpuThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
270
+ memoryThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
271
271
  runningTasksMinimum: z.ZodOptional<z.ZodNumber>;
272
- http5xxThreshold: z.ZodOptional<z.ZodNumber>;
272
+ http5xxThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
273
273
  }, z.core.$strict>]>>;
274
274
  }, z.core.$strict>;
275
275
  /**
@@ -419,10 +419,10 @@ export declare const ComputeResourcePlanSchema: z.ZodObject<{
419
419
  sourceText: z.ZodString;
420
420
  }, z.core.$strict>>>;
421
421
  alarms: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
422
- cpuThreshold: z.ZodOptional<z.ZodNumber>;
423
- memoryThreshold: z.ZodOptional<z.ZodNumber>;
422
+ cpuThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
423
+ memoryThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
424
424
  runningTasksMinimum: z.ZodOptional<z.ZodNumber>;
425
- http5xxThreshold: z.ZodOptional<z.ZodNumber>;
425
+ http5xxThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
426
426
  }, z.core.$strict>]>>;
427
427
  }, z.core.$strict>>>;
428
428
  docker: z.ZodOptional<z.ZodObject<{
@@ -822,10 +822,10 @@ export declare const ComputeGeneratorSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
822
822
  sourceText: z.ZodString;
823
823
  }, z.core.$strict>>>;
824
824
  alarms: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<false>, z.ZodObject<{
825
- cpuThreshold: z.ZodOptional<z.ZodNumber>;
826
- memoryThreshold: z.ZodOptional<z.ZodNumber>;
825
+ cpuThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
826
+ memoryThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
827
827
  runningTasksMinimum: z.ZodOptional<z.ZodNumber>;
828
- http5xxThreshold: z.ZodOptional<z.ZodNumber>;
828
+ http5xxThreshold: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<false>]>>;
829
829
  }, z.core.$strict>]>>;
830
830
  }, z.core.$strict>>;
831
831
  docker: z.ZodOptional<z.ZodObject<{
@@ -1 +1 @@
1
- export declare const GENERATOR_VERSION = "12.0.0";
1
+ export declare const GENERATOR_VERSION = "12.1.1";
@@ -1 +1 @@
1
- const E="12.0.0";export{E as GENERATOR_VERSION};
1
+ const E="12.1.1";export{E as GENERATOR_VERSION};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fjall/generator",
3
- "version": "12.0.0",
3
+ "version": "12.1.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/fjall-tech/fjall.git",
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "license": "SEE LICENSE IN LICENSE",
55
55
  "dependencies": {
56
- "@fjall/util": "^12.0.0",
56
+ "@fjall/util": "^12.1.1",
57
57
  "ast-types": "^0.16.1",
58
58
  "recast": "^0.23.12",
59
59
  "ts-morph": "^28.0.0",