Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/client/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export type WorkflowRunEvent =
modelType: string;
methodName: string;
}
| {
kind: "env_var_warning";
jobId: string;
stepId: string;
modelName: string;
envVars: Array<{ path: string; envVar: string }>;
message: string;
}
| {
kind: "method_executing";
jobId: string;
Expand Down
9 changes: 9 additions & 0 deletions src/domain/workflows/execution_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import type { MethodExecutionEvent } from "../models/method_events.ts";
import type { DataHandle } from "../models/model.ts";
import type { EnvVarUsageDetail } from "../models/validation_service.ts";
// deno-lint-ignore verbatim-module-syntax
import { WorkflowRun } from "./workflow_run.ts";

Expand Down Expand Up @@ -74,6 +75,14 @@ export type WorkflowExecutionEvent =
modelType: string;
methodName: string;
}
| {
kind: "env_var_warning";
jobId: string;
stepId: string;
modelName: string;
envVars: EnvVarUsageDetail[];
message: string;
}
| {
kind: "method_executing";
jobId: string;
Expand Down
15 changes: 15 additions & 0 deletions src/domain/workflows/execution_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { getAutoResolver } from "../extensions/auto_resolver_context.ts";
import { DefaultMethodExecutionService } from "../models/method_execution_service.ts";
import { DefaultModelValidationService } from "../models/validation_service.ts";
import { buildOutputSpecs } from "../models/output_spec_builder.ts";
import { detectEnvVarUsageInDefinition } from "../models/env_var_detector.ts";
import type { Definition } from "../definitions/definition.ts";
import { findDefinitionByIdOrName } from "../models/model_lookup.ts";
import type { MethodExecutionEvent } from "../models/method_events.ts";
Expand Down Expand Up @@ -230,6 +231,20 @@ export class DefaultStepExecutor implements StepExecutor {
methodName: task.methodName,
});

// --- Check for env var usage and warn ---
const envVarUsages = detectEnvVarUsageInDefinition(originalDefinition);
if (envVarUsages.length > 0) {
ctx.emitEvent?.({
kind: "env_var_warning",
jobId: ctx.jobName,
stepId: ctx.stepName,
modelName: originalDefinition.name,
envVars: envVarUsages,
message:
"Data stored under this model will vary depending on these environment variables at runtime. Consider using separate models per environment, or vault.get() for sensitive values.",
});
}

// Get the model definition from registry (auto-resolve if needed)
const modelDef = await resolveModelType(modelType, getAutoResolver());
if (!modelDef) {
Expand Down
10 changes: 10 additions & 0 deletions src/libswamp/workflows/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
WorkflowExecutionService,
} from "../../domain/workflows/execution_service.ts";
import type { MethodExecutionEvent } from "../../domain/models/method_events.ts";
import type { EnvVarUsageDetail } from "../../domain/models/validation_service.ts";
import type { Workflow } from "../../domain/workflows/workflow.ts";
import type { WorkflowRun } from "../../domain/workflows/workflow_run.ts";
import type { StepRun } from "../../domain/workflows/workflow_run.ts";
Expand Down Expand Up @@ -108,6 +109,14 @@ export type WorkflowRunEvent =
modelType: string;
methodName: string;
}
| {
kind: "env_var_warning";
jobId: string;
stepId: string;
modelName: string;
envVars: EnvVarUsageDetail[];
message: string;
}
| {
kind: "method_executing";
jobId: string;
Expand Down Expand Up @@ -339,6 +348,7 @@ function mapEvent(
case "step_skipped":
case "step_failed":
case "model_resolved":
case "env_var_warning":
case "method_executing":
case "method_output":
case "method_event":
Expand Down
16 changes: 16 additions & 0 deletions src/presentation/renderers/workflow_run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ class LogWorkflowRunRenderer implements WorkflowRunRenderer {
{ name: e.modelName, type: e.modelType },
);
},
env_var_warning: (e) => {
const logger = getWorkflowRunLogger(
this.workflowName,
e.jobId,
e.stepId,
);
logger.warn("Environment variables detected in model definition");
for (const detail of e.envVars) {
logger.warn(" {path} uses {envVar}", {
path: detail.path,
envVar: detail.envVar,
});
}
logger.warn(e.message);
},
method_executing: (e) => {
getRunLogger(e.modelName, e.methodName).info(
"Executing method {method}",
Expand Down Expand Up @@ -229,6 +244,7 @@ class JsonWorkflowRunRenderer implements WorkflowRunRenderer {
step_skipped: () => {},
step_failed: () => {},
model_resolved: () => {},
env_var_warning: () => {},
method_executing: () => {},
method_output: () => {},
method_event: () => {},
Expand Down
1 change: 1 addition & 0 deletions src/presentation/renderers/workflow_run_tree/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class InkWorkflowRunRenderer implements WorkflowRunRenderer {
step_skipped: forward,
step_failed: forward,
model_resolved: forward,
env_var_warning: forward,
method_executing: forward,
method_output: forward,
method_event: forward,
Expand Down
1 change: 1 addition & 0 deletions src/presentation/renderers/workflow_run_tree/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ function treeReducerSingle(
return { ...state, jobs };
}

case "env_var_warning":
case "method_executing":
return state;

Expand Down
Loading