fix: update init scaffolds with pluginContracts, observe sinks, chaos strategy examples

This commit is contained in:
John Dvorak
2026-05-22 13:01:26 -07:00
parent a186146c69
commit 4891b0883e
2 changed files with 41 additions and 0 deletions
+32
View File
@@ -45,6 +45,13 @@ export function safeCiScaffold(): ScaffoldResult {
profiles: { quick: profile }, profiles: { quick: profile },
presets: { 'safe-ci': preset }, presets: { 'safe-ci': preset },
environments: { local: envLocal }, environments: { local: envLocal },
// Uncomment to enforce cross-cutting behavioral rules across all matching routes:
// pluginContracts: {
// 'auth-presence': {
// appliesTo: '/api/**',
// hooks: { onRequest: { requires: ['request_headers(this).authorization != null'] } },
// },
// },
}; };
const readmeContent = ` const readmeContent = `
@@ -98,6 +105,9 @@ export function platformObserveScaffold(): ScaffoldResult {
parallel: true, parallel: true,
chaos: false, chaos: false,
observe: true, observe: true,
sampling: 0.1,
blocking: false,
sinks: { logs: true, metrics: true },
}; };
const profile: ProfileDefinition = { const profile: ProfileDefinition = {
@@ -115,6 +125,7 @@ export function platformObserveScaffold(): ScaffoldResult {
allowChaos: false, allowChaos: false,
allowBlocking: false, allowBlocking: false,
requireSink: true, requireSink: true,
sinks: { logs: true, metrics: true },
}; };
const envProduction: EnvironmentPolicy = { const envProduction: EnvironmentPolicy = {
@@ -136,6 +147,12 @@ export function platformObserveScaffold(): ScaffoldResult {
staging: envStaging, staging: envStaging,
production: envProduction, production: envProduction,
}, },
// pluginContracts: {
// 'request-id': {
// appliesTo: '/api/**',
// hooks: { onSend: { ensures: ['response_headers(this).x-request-id != null'] } },
// },
// },
}; };
const readmeContent = ` const readmeContent = `
@@ -207,6 +224,12 @@ export function llmSafeScaffold(): ScaffoldResult {
profiles: { 'llm-check': profile }, profiles: { 'llm-check': profile },
presets: { 'llm-safe': preset }, presets: { 'llm-safe': preset },
environments: { local: envLocal }, environments: { local: envLocal },
// pluginContracts: {
// 'auth-presence': {
// appliesTo: '/api/**',
// hooks: { onRequest: { requires: ['request_headers(this).authorization != null'] } },
// },
// },
}; };
const readmeContent = ` const readmeContent = `
@@ -259,6 +282,9 @@ export function protocolLabScaffold(): ScaffoldResult {
parallel: false, parallel: false,
chaos: true, chaos: true,
observe: false, observe: false,
// chaosStrategy: 'sample', // 'one' | 'all' | 'sample' | 'routes'
// chaosSampleSize: 3, // routes to target when strategy is 'sample'
// chaosSampleRoutes: [], // explicit route list when strategy is 'routes'
}; };
const profile: ProfileDefinition = { const profile: ProfileDefinition = {
@@ -298,6 +324,12 @@ export function protocolLabScaffold(): ScaffoldResult {
local: envLocal, local: envLocal,
test: envTest, test: envTest,
}, },
// pluginContracts: {
// 'rate-limit': {
// appliesTo: 'POST /api/**',
// hooks: { onResponse: { ensures: ['status != 429'] } },
// },
// },
}; };
const readmeContent = ` const readmeContent = `
+9
View File
@@ -95,6 +95,7 @@ export interface EnvironmentPolicy {
allowChaos?: boolean; allowChaos?: boolean;
allowBlocking?: boolean; allowBlocking?: boolean;
requireSink?: boolean; requireSink?: boolean;
sinks?: Record<string, unknown>;
} }
/** /**
@@ -145,6 +146,14 @@ export interface PresetDefinition {
parallel?: boolean; parallel?: boolean;
chaos?: boolean; chaos?: boolean;
observe?: boolean; observe?: boolean;
runs?: number;
sampling?: number;
blocking?: boolean;
sinks?: Record<string, unknown>;
features?: string[];
chaosStrategy?: 'one' | 'all' | 'sample' | 'routes';
chaosSampleSize?: number;
chaosSampleRoutes?: string[];
} }
/** /**