diff --git a/biome.json b/biome.json index 2f16ea0..78b4148 100644 --- a/biome.json +++ b/biome.json @@ -1,43 +1,43 @@ { - "$schema": "https://biomejs.dev/schemas/2.4.11/schema.json", - "vcs": { - "enabled": true, - "clientKind": "git", - "useIgnoreFile": true - }, - "files": { - "ignoreUnknown": true, - "includes": ["packages/**/*.ts"] - }, - "formatter": { - "enabled": true, - "indentStyle": "space", - "indentWidth": 2 - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true, - "suspicious": { - "noExplicitAny": "off" - }, - "style": { - "noNonNullAssertion": "off" - } - } - }, - "javascript": { - "formatter": { - "quoteStyle": "single", - "semicolons": "always" - } - }, - "assist": { - "enabled": true, - "actions": { - "source": { - "organizeImports": "on" - } - } - } + "$schema": "https://biomejs.dev/schemas/2.4.11/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": true, + "includes": ["packages/**/*.ts"] + }, + "formatter": { + "enabled": true, + "indentStyle": "space", + "indentWidth": 2 + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "suspicious": { + "noExplicitAny": "off" + }, + "style": { + "noNonNullAssertion": "off" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "single", + "semicolons": "always" + } + }, + "assist": { + "enabled": true, + "actions": { + "source": { + "organizeImports": "on" + } + } + } } diff --git a/packages/pulse/src/e2e/t7-survival.test.ts b/packages/pulse/src/e2e/t7-survival.test.ts index 52befe7..afa4a9c 100644 --- a/packages/pulse/src/e2e/t7-survival.test.ts +++ b/packages/pulse/src/e2e/t7-survival.test.ts @@ -18,15 +18,15 @@ import { import { MAX_RESTART_COUNT, ROLLBACK_ERROR_THRESHOLD, -} from '../survival/constants.js'; -import { rebuildHealth, survivalRules } from '../survival/index.js'; +} from '../rules/constants.js'; +import { rebuildHealth, survivalRules } from '../rules/index.js'; import { autoRollback, llmWatchdog, processWatchdog, resourceGuard, type SurvivalSnapshot, -} from '../survival/rules.js'; +} from '../rules/survival.js'; // ── Helpers ──────────────────────────────────────────────────── diff --git a/packages/pulse/src/executors/index.ts b/packages/pulse/src/executors/index.ts index c5ff6ae..9fdd86d 100644 --- a/packages/pulse/src/executors/index.ts +++ b/packages/pulse/src/executors/index.ts @@ -5,3 +5,9 @@ export { type CursorEffect, createCursorExecutor, } from './cursor-agent.js'; + +export { + executeSurvivalEffect, + type SurvivalEffect, + type SurvivalExecDeps, +} from './survival.js'; diff --git a/packages/pulse/src/survival/executors.test.ts b/packages/pulse/src/executors/survival.test.ts similarity index 99% rename from packages/pulse/src/survival/executors.test.ts rename to packages/pulse/src/executors/survival.test.ts index 2c4ae43..7ba4ade 100644 --- a/packages/pulse/src/survival/executors.test.ts +++ b/packages/pulse/src/executors/survival.test.ts @@ -5,7 +5,7 @@ import { beforeEach, describe, expect, jest, test } from 'bun:test'; import * as os from 'node:os'; import * as path from 'node:path'; -import { executeSurvivalEffect, type SurvivalExecDeps } from './executors'; +import { executeSurvivalEffect, type SurvivalExecDeps } from './survival.js'; // All mocks via dependency injection — NO global jest.mock to avoid cross-file pollution const mockExecSync = jest.fn(); diff --git a/packages/pulse/src/survival/executors.ts b/packages/pulse/src/executors/survival.ts similarity index 99% rename from packages/pulse/src/survival/executors.ts rename to packages/pulse/src/executors/survival.ts index 03f4806..dc493df 100644 --- a/packages/pulse/src/survival/executors.ts +++ b/packages/pulse/src/executors/survival.ts @@ -13,7 +13,7 @@ import * as os from 'node:os'; import * as path from 'node:path'; /** Allowlist pattern for safe shell arguments (service names, git refs, etc.) */ -const SAFE_ARG = /^[a-zA-Z0-9._\/@:-]+$/; +const SAFE_ARG = /^[a-zA-Z0-9._/@:-]+$/; export interface SurvivalEffect { type: string; diff --git a/packages/pulse/src/index.ts b/packages/pulse/src/index.ts index d6a94e4..527bdd2 100644 --- a/packages/pulse/src/index.ts +++ b/packages/pulse/src/index.ts @@ -366,7 +366,12 @@ export { // ── Built-in Rules ───────────────────────────────────────────── -export { adaptiveInterval, clampTick, dedup, errorBackoff } from './rules.js'; +export { + adaptiveInterval, + clampTick, + dedup, + errorBackoff, +} from './rules/builtin.js'; // ── Watcher ──────────────────────────────────────────────────── @@ -384,7 +389,7 @@ export * from './watchers/index.js'; // ── Survival Layer ────────────────────────────────────────────── -export * from './survival/index.js'; +export * from './rules/index.js'; // ── Executors ───────────────────────────────────────────────── diff --git a/packages/pulse/src/rules.test.ts b/packages/pulse/src/rules/builtin.test.ts similarity index 99% rename from packages/pulse/src/rules.test.ts rename to packages/pulse/src/rules/builtin.test.ts index 7a51630..0a22a5f 100644 --- a/packages/pulse/src/rules.test.ts +++ b/packages/pulse/src/rules/builtin.test.ts @@ -4,7 +4,7 @@ import { describe, expect, it } from 'bun:test'; -import { adaptiveInterval, clampTick, dedup, errorBackoff } from './rules.js'; +import { adaptiveInterval, clampTick, dedup, errorBackoff } from './builtin.js'; // Helper to apply rule with new onion middleware signature async function apply( diff --git a/packages/pulse/src/rules.ts b/packages/pulse/src/rules/builtin.ts similarity index 98% rename from packages/pulse/src/rules.ts rename to packages/pulse/src/rules/builtin.ts index fc0f740..fd040ab 100644 --- a/packages/pulse/src/rules.ts +++ b/packages/pulse/src/rules/builtin.ts @@ -5,7 +5,7 @@ * adaptive intervals, effect deduplication. */ -import type { Rule } from './index.js'; +import type { Rule } from '../index.js'; /** * Clamp tickMs within [min, max]. diff --git a/packages/pulse/src/survival/constants.ts b/packages/pulse/src/rules/constants.ts similarity index 100% rename from packages/pulse/src/survival/constants.ts rename to packages/pulse/src/rules/constants.ts diff --git a/packages/pulse/src/survival/health.ts b/packages/pulse/src/rules/health.ts similarity index 100% rename from packages/pulse/src/survival/health.ts rename to packages/pulse/src/rules/health.ts diff --git a/packages/pulse/src/rules/index.ts b/packages/pulse/src/rules/index.ts new file mode 100644 index 0000000..bcadfe1 --- /dev/null +++ b/packages/pulse/src/rules/index.ts @@ -0,0 +1,10 @@ +export { adaptiveInterval, clampTick, dedup, errorBackoff } from './builtin.js'; +export { + ESSENTIAL_PROCESSES, + IDEMPOTENT_WINDOW_MS, + MAX_RESTART_COUNT, + ROLLBACK_ERROR_THRESHOLD, + ROLLBACK_WINDOW_MS, +} from './constants.js'; +export { type HealthSnapshot, rebuildHealth } from './health.js'; +export { type SurvivalSnapshot, survivalRules } from './survival.js'; diff --git a/packages/pulse/src/survival/rules.test.ts b/packages/pulse/src/rules/survival.test.ts similarity index 99% rename from packages/pulse/src/survival/rules.test.ts rename to packages/pulse/src/rules/survival.test.ts index 9dc7290..dd1d5da 100644 --- a/packages/pulse/src/survival/rules.test.ts +++ b/packages/pulse/src/rules/survival.test.ts @@ -3,7 +3,7 @@ */ import { beforeEach, describe, expect, jest, test } from 'bun:test'; -import { MAX_RESTART_COUNT, ROLLBACK_ERROR_THRESHOLD } from './constants'; +import { MAX_RESTART_COUNT, ROLLBACK_ERROR_THRESHOLD } from './constants.js'; import { autoRollback, errorEscalate, @@ -13,7 +13,7 @@ import { panicRollback, processWatchdog, resourceGuard, -} from './rules'; +} from './survival.js'; // Mock inner function const mockInner = jest.fn(async () => [[], 15000]); diff --git a/packages/pulse/src/survival/rules.ts b/packages/pulse/src/rules/survival.ts similarity index 99% rename from packages/pulse/src/survival/rules.ts rename to packages/pulse/src/rules/survival.ts index de15d7f..7c9de74 100644 --- a/packages/pulse/src/survival/rules.ts +++ b/packages/pulse/src/rules/survival.ts @@ -5,6 +5,7 @@ * Rules are applied in array order (first element is outermost layer). */ +import type { SurvivalEffect } from '../executors/survival.js'; import type { Rule, Sensed } from '../index.js'; import type { ErrorLogData } from '../watchers/error-log.js'; import type { GatewayHealthData } from '../watchers/gateway-health.js'; @@ -18,7 +19,6 @@ import { ROLLBACK_ERROR_THRESHOLD, ROLLBACK_WINDOW_MS, } from './constants.js'; -import type { SurvivalEffect } from './executors.js'; import type { HealthSnapshot } from './health.js'; // Define proper type for survival snapshot diff --git a/packages/pulse/src/survival/index.ts b/packages/pulse/src/survival/index.ts deleted file mode 100644 index 70c84cc..0000000 --- a/packages/pulse/src/survival/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Survival layer exports - */ - -export { - ESSENTIAL_PROCESSES, - IDEMPOTENT_WINDOW_MS, - MAX_RESTART_COUNT, -} from './constants.js'; -export { executeSurvivalEffect, type SurvivalEffect } from './executors.js'; -export { type HealthSnapshot, rebuildHealth } from './health.js'; -export { type SurvivalSnapshot, survivalRules } from './rules.js';