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 deploy/helm/maestro/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.operatingLayer.enabled }}
- name: MAESTRO_OPERATING_LAYER_ENABLED

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wire the Helm operating-layer flag to runtime capture

When operatingLayer.enabled=true, this chart now advertises production evidence capture by setting MAESTRO_OPERATING_LAYER_ENABLED, but I only found these MAESTRO_OPERATING_LAYER_* names in the Helm template/tests and no runtime code path reads them or writes to operatingLayerEvidence. In that deployment scenario the pod starts with the flag set yet no evidence is captured or retained in Postgres, so operators can enable the chart value and get a false-positive configuration.

Useful? React with 👍 / 👎.

value: "1"
- name: MAESTRO_OPERATING_LAYER_EVIDENCE_STORE
value: {{ .Values.operatingLayer.evidenceStore | quote }}
- name: MAESTRO_OPERATING_LAYER_EVIDENCE_RETENTION_DAYS
value: {{ .Values.operatingLayer.evidenceRetentionDays | quote }}
{{- end }}
{{- if .Values.writableTmp.enabled }}
volumeMounts:
- name: tmp
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm/maestro/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ headlessRuntime:
# durable-owner when Platform routes by a durable runtime-owner record.
mode: single-replica

operatingLayer:
# Enables production operating-layer evidence capture. Requires a configured
# MAESTRO_DATABASE_URL/DATABASE_URL secret so evidence persists in Postgres.
enabled: false
evidenceStore: database
evidenceRetentionDays: 90

image:
repository: ghcr.io/evalops/maestro
# Defaults to Chart.appVersion when empty. Prefer immutable sha-* tags or digest.
Expand Down
10 changes: 10 additions & 0 deletions src/db/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const CRITICAL_DATABASE_TABLES = [
"distributed_locks",
"usage_metrics",
"execution_traces",
"operating_layer_evidence",
"workspace_config",
"revenue_attribution",
] as const;
Expand Down Expand Up @@ -39,6 +40,15 @@ const CRITICAL_DATABASE_COLUMNS: Partial<
"delivered_at",
"created_at",
],
operating_layer_evidence: [
"id",
"capability_id",
"evidence_kind",
"subject",
"status",
"evidence",
"recorded_at",
],
};

export async function checkCriticalTables(
Expand Down
30 changes: 30 additions & 0 deletions src/db/migrations/0009_operating_layer_evidence.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
CREATE TABLE IF NOT EXISTS "operating_layer_evidence" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"org_id" uuid,
"session_id" varchar(255),
"capability_id" varchar(64) NOT NULL,
"evidence_kind" varchar(128) NOT NULL,
"subject" varchar(255) NOT NULL,
"status" varchar(32) DEFAULT 'recorded' NOT NULL,
"score" integer,
"blockers" jsonb DEFAULT '[]'::jsonb NOT NULL,
"warnings" jsonb DEFAULT '[]'::jsonb NOT NULL,
"evidence" jsonb NOT NULL,
"metadata" jsonb DEFAULT '{}'::jsonb,
"recorded_at" timestamp with time zone DEFAULT now() NOT NULL,
"expires_at" timestamp with time zone,
CONSTRAINT "operating_layer_evidence_org_id_organizations_id_fk"
FOREIGN KEY ("org_id") REFERENCES "organizations"("id") ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "operating_layer_evidence_capability_recorded_idx"
ON "operating_layer_evidence" ("capability_id", "recorded_at");
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "operating_layer_evidence_org_recorded_idx"
ON "operating_layer_evidence" ("org_id", "recorded_at");
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "operating_layer_evidence_session_recorded_idx"
ON "operating_layer_evidence" ("session_id", "recorded_at");
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "operating_layer_evidence_expiry_idx"
ON "operating_layer_evidence" ("expires_at");
7 changes: 7 additions & 0 deletions src/db/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
"when": 1777303800000,
"tag": "0008_reconcile_legacy_webhook_deliveries",
"breakpoints": true
},
{
"idx": 9,
"version": "7",
"when": 1781749800000,
"tag": "0009_operating_layer_evidence",
"breakpoints": true
}
]
}
41 changes: 41 additions & 0 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,47 @@ export const hostedSessionEntries = pgTable(
}),
);

// ============================================================================
// OPERATING LAYER EVIDENCE
// ============================================================================

export const operatingLayerEvidence = pgTable(
"operating_layer_evidence",
{
id: uuid("id").primaryKey().defaultRandom(),
orgId: uuid("org_id").references(() => organizations.id, {
onDelete: "cascade",
}),
sessionId: varchar("session_id", { length: 255 }),
capabilityId: varchar("capability_id", { length: 64 }).notNull(),
evidenceKind: varchar("evidence_kind", { length: 128 }).notNull(),
subject: varchar("subject", { length: 255 }).notNull(),
status: varchar("status", { length: 32 }).default("recorded").notNull(),
score: integer("score"),
blockers: jsonb("blockers").$type<string[]>().default([]).notNull(),
warnings: jsonb("warnings").$type<string[]>().default([]).notNull(),
evidence: jsonb("evidence").$type<unknown>().notNull(),
metadata: jsonb("metadata").$type<Record<string, unknown>>().default({}),
recordedAt: timestamp("recorded_at", { withTimezone: true })
.defaultNow()
.notNull(),
expiresAt: timestamp("expires_at", { withTimezone: true }),
},
(table) => ({
capabilityRecordedIdx: index(
"operating_layer_evidence_capability_recorded_idx",
).on(table.capabilityId, table.recordedAt),
orgRecordedIdx: index("operating_layer_evidence_org_recorded_idx").on(
table.orgId,
table.recordedAt,
),
sessionRecordedIdx: index(
"operating_layer_evidence_session_recorded_idx",
).on(table.sessionId, table.recordedAt),
expiryIdx: index("operating_layer_evidence_expiry_idx").on(table.expiresAt),
}),
);

// ============================================================================
// AUDIT LOGS
// ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion test/db/hosted-session-storage.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ vi.mock("../../src/session/session-memory.js", () => ({
const BASE_DB_URL =
process.env.MAESTRO_DATABASE_URL || process.env.DATABASE_URL;
const describeDb = BASE_DB_URL ? describe : describe.skip;
const EXPECTED_MIGRATION_COUNT = 9;
const EXPECTED_MIGRATION_COUNT = 10;

const originalEnv = { ...process.env };

Expand Down
24 changes: 24 additions & 0 deletions test/db/migration-files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ describe("database migration packaging", () => {
expect(journal.entries.map((entry) => entry.tag)).toContain(
"0008_reconcile_legacy_webhook_deliveries",
);
expect(journal.entries.map((entry) => entry.tag)).toContain(
"0009_operating_layer_evidence",
);

for (const entry of journal.entries) {
expect(
Expand Down Expand Up @@ -152,4 +155,25 @@ describe("database migration packaging", () => {
);
expect(migration).toContain("webhook_delivery_retry_idx");
});

it("adds the operating layer evidence migration for production readiness", () => {
const migration = readFileSync(
path.join(migrationsDir, "0009_operating_layer_evidence.sql"),
"utf8",
);

expect(migration).toContain(
'CREATE TABLE IF NOT EXISTS "operating_layer_evidence"',
);
expect(migration).toContain('"capability_id" varchar(64) NOT NULL');
expect(migration).toContain('"evidence_kind" varchar(128) NOT NULL');
expect(migration).toContain('"evidence" jsonb NOT NULL');
expect(migration).toContain(
"operating_layer_evidence_org_id_organizations_id_fk",
);
expect(migration).toContain(
"operating_layer_evidence_capability_recorded_idx",
);
expect(migration).toContain("operating_layer_evidence_expiry_idx");
});
});
25 changes: 25 additions & 0 deletions test/deploy/helm-maestro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe("maestro Helm chart", () => {
expect(result.stdout).toMatch(/mountPath:\s+\/tmp/);
expect(result.stdout).toContain("name: HOME");
expect(result.stdout).toContain("name: XDG_CACHE_HOME");
expect(result.stdout).not.toContain("MAESTRO_OPERATING_LAYER_ENABLED");
expect(result.stdout).toContain("startupProbe:");
expect(result.stdout).toContain("preStop:");
expect(result.stdout).toContain("/.well-known/evalops/remote-runner/drain");
Expand Down Expand Up @@ -82,6 +83,30 @@ describe("maestro Helm chart", () => {
},
);

helmIt(
"renders production operating layer evidence settings when enabled",
() => {
const result = renderChart([
"--set",
"operatingLayer.enabled=true",
"--set",
"operatingLayer.evidenceRetentionDays=120",
]);

expect(result.status).toBe(0);
expect(result.stdout).toContain("name: MAESTRO_OPERATING_LAYER_ENABLED");
expect(result.stdout).toContain('value: "1"');
expect(result.stdout).toContain(
"name: MAESTRO_OPERATING_LAYER_EVIDENCE_STORE",
);
expect(result.stdout).toContain('value: "database"');
expect(result.stdout).toContain(
"name: MAESTRO_OPERATING_LAYER_EVIDENCE_RETENTION_DAYS",
);
expect(result.stdout).toContain('value: "120"');
},
);

helmIt("can render an HPA without a fixed deployment replica count", () => {
const result = renderChart([
"--set",
Expand Down
4 changes: 4 additions & 0 deletions test/web-health.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ vi.mock("../src/db/health.js", () => ({
"distributed_locks",
"usage_metrics",
"execution_traces",
"operating_layer_evidence",
"workspace_config",
"revenue_attribution",
],
Expand Down Expand Up @@ -67,6 +68,7 @@ describe("Health Checks", () => {
{ name: "distributed_locks", exists: true },
{ name: "usage_metrics", exists: true },
{ name: "execution_traces", exists: true },
{ name: "operating_layer_evidence", exists: true },
{ name: "workspace_config", exists: true },
{ name: "revenue_attribution", exists: true },
]);
Expand Down Expand Up @@ -102,6 +104,7 @@ describe("Health Checks", () => {
{ name: "distributed_locks", exists: false },
{ name: "usage_metrics", exists: true },
{ name: "execution_traces", exists: true },
{ name: "operating_layer_evidence", exists: true },
{ name: "workspace_config", exists: true },
{ name: "revenue_attribution", exists: true },
]);
Expand Down Expand Up @@ -132,6 +135,7 @@ describe("Health Checks", () => {
{ name: "distributed_locks", exists: true },
{ name: "usage_metrics", exists: true },
{ name: "execution_traces", exists: true },
{ name: "operating_layer_evidence", exists: true },
{ name: "workspace_config", exists: true },
{ name: "revenue_attribution", exists: true },
]);
Expand Down
Loading