Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(lane-e): CI round 1 — gate unreachable-target free steps on a live worker, keep provider-config embed failures failing, schema check before no_worker, spec-mandated test updates
garrytan2764810c8552
diff --git a/src/commands/jobs/submit.ts b/src/commands/jobs/submit.tsindex d03a387069..7b2a7da30c 100644--- a/src/commands/jobs/submit.ts+++ b/src/commands/jobs/submit.ts@@ -99,14 +99,14 @@ export async function runJobsSubmit({ args, engine, queue }: JobsCommandContext)return;}+ try { await queue.ensureSchema(); }+ catch (e) { console.error(e instanceof Error ? e.message : String(e)); process.exit(1); }+if (engine.kind === 'pglite' && !follow && !hasFlag(args, '--queue-only')) {await refuseNoWorker(args, name, queueName);return;}- try { await queue.ensureSchema(); }- catch (e) { console.error(e instanceof Error ? e.message : String(e)); process.exit(1); }-// v0.35.8.0: pre-enqueue shell-job validation. Validates `inherit:`// closed enum, rejects secret env-keys, fail-fasts on missing config.// Throws UnrecoverableError BEFORE `queue.add` so a bad payload neverdiff --git a/src/core/cycle.ts b/src/core/cycle.tsindex 3be393d1ea..1cd15dbb9c 100644--- a/src/core/cycle.ts+++ b/src/core/cycle.ts@@ -1618,8 +1618,6 @@ async function runPhaseEmbed(engine: BrainEngine, dryRun: boolean, signal?: Abor},};} catch (e) {- const { EmbeddingCredentialError } = await import('./embed-preflight.ts');- if (e instanceof EmbeddingCredentialError) return { phase: 'embed', status: 'warn', duration_ms: 0, summary: `embeddings not run: ${e.message.split('\n')[0]}`, details: { reason: 'embedding_unconfigured' } };return {phase: 'embed',status: 'fail',diff --git a/src/core/remediation/run.ts b/src/core/remediation/run.tsindex 96af97e7d8..0a1ecf57ca 100644--- a/src/core/remediation/run.ts+++ b/src/core/remediation/run.ts@@ -12,6 +12,7 @@import crypto from 'crypto';import type { BrainEngine } from '../engine.ts';+import { queueWorkerAlive } from '../minions/no-worker.ts';import {computeRecommendations,} from '../brain-score-recommendations.ts';@@ -43,11 +44,14 @@ import type {/*** E3: the job steps a run executes. An unreachable score target skips the* PAID steps only (their ids land in `job_steps_skipped.skipped`); free steps- * still run so the brain improves as far as it can.+ * still run so the brain improves as far as it can — when a worker serves the+ * queue. With no worker (PGLite, or no supervisor) they would wait out their+ * timeout, so every job step is skipped as before.*/function planJobSteps(planned: RemediationStep[], manifest: { job_ids: string[] } | undefined, unreachable?: { target: number; ceiling: number }) {const remediable = planned.filter((r) => r.status === 'remediable' && (!manifest || manifest.job_ids.includes(r.id)));- const freeRecs = remediable.filter((r) => (r.est_usd_cost ?? 0) === 0);+ const workerRuns = !unreachable || queueWorkerAlive('default') === true;+ const freeRecs = workerRuns ? remediable.filter((r) => (r.est_usd_cost ?? 0) === 0) : [];if (!unreachable) return { recs: remediable, freeRecs, jobStepsSkipped: undefined };return {recs: freeRecs, freeRecs,diff --git a/test/doctor-calibration-checks.test.ts b/test/doctor-calibration-checks.test.tsindex 2eeefedace..05121010cc 100644--- a/test/doctor-calibration-checks.test.ts+++ b/test/doctor-calibration-checks.test.ts@@ -171,13 +171,15 @@ describe('checkVoiceGateHealth', () => {expect(out.message).toContain('1/10 failed');});- test('30%+ fail rate → warn with rubric-review hint', async () => {+ test('30%+ fail rate → warn telling the agent to report it (no pointer into gbrain source)', async () => {const out = await checkVoiceGateHealth(buildMockEngine({ voiceTotal: 10, voiceFailures: 4 }),);expect(out.status).toBe('warn');expect(out.message).toContain('4/10');- expect(out.message).toContain('voice-gate.ts');+ expect(out.message).not.toContain('voice-gate.ts');+ expect(out.message).toContain('gbrain doctor --json');+ expect(out.fix_unavailable_reason).toBe('operator_judgement');});test('engine throw → warn with diagnostic', async () => {diff --git a/test/doctor-mode-matrix.serial.test.ts b/test/doctor-mode-matrix.serial.test.tsindex ce8c59035a..0b128ba8c8 100644--- a/test/doctor-mode-matrix.serial.test.ts+++ b/test/doctor-mode-matrix.serial.test.ts@@ -245,9 +245,11 @@ describe('doctor mode matrix (registry runner, EO11)', () => {expect(run.ran.map((r) => r.entry)).toEqual(upTo(DB_GATE));expect(run.ran.at(-1)?.result).toBe('stop');expect(run.ran.find((r) => r.entry === indexOf(OFFLINE))?.result).toBeGreaterThanOrEqual(1);- expect(run.checks.filter((c) => c.name === 'connection')).toEqual([- { name: 'connection', status: 'warn', message: 'No database configured (filesystem checks only). Set GBRAIN_DATABASE_URL or run `gbrain init`.' },- ]);+ const conn = run.checks.filter((c) => c.name === 'connection');+ expect(conn).toHaveLength(1);+ // E10: the message names the config path it looked in; the check carries a fix and an unknown readiness.+ expect(conn[0]).toMatchObject({ name: 'connection', status: 'warn', readiness_state: 'unknown', fix: { argv: ['gbrain', 'init', '--pglite'] } });+ expect(conn[0].message).toMatch(/^No database configured \(filesystem checks only; no URL in the environment or in .*config\.json\)\. Set GBRAIN_DATABASE_URL or run `gbrain init`\.$/);expect(run.ctx?.connectionFailed).toBe(false);}, 180_000);diff --git a/test/doctor.test.ts b/test/doctor.test.tsindex 28c31b868e..b4eb864330 100644--- a/test/doctor.test.ts+++ b/test/doctor.test.ts@@ -233,7 +233,9 @@ describe('doctor command', () => {} as any);expect(check.status).toBe('warn');expect(check.message).toContain('budget/pricing');- expect(check.message).toContain('embedding-pricing.ts');+ // E1: the fix registers the rate with `gbrain pricing set`, never an edit to gbrain's source.+ expect(check.message).not.toContain('embedding-pricing.ts');+ expect(check.fix).toMatchObject({ argv: expect.arrayContaining(['gbrain', 'pricing', 'set']) });expect(check.message).toContain('--max-cost');});} finally {diff --git a/test/dream.test.ts b/test/dream.test.tsindex 78ce15a164..a5c86570cc 100644--- a/test/dream.test.ts+++ b/test/dream.test.ts@@ -56,6 +56,10 @@ afterAll(async () => {beforeEach(async () => {await resetPgliteState(engine);+ // Keyless by choice: a full cycle must not reach a real embedding provider,+ // and since a failed phase now exits 1 (E4) an unkeyed provider would end+ // the in-process run. The embed phase reports skipped(embedding_disabled).+ await engine.setConfig('embedding_disabled', 'true');fixture.reset();}, 300_000);diff --git a/test/e2e/onboard-full-flow.test.ts b/test/e2e/onboard-full-flow.test.tsindex 773f2243f7..88477ce4ba 100644--- a/test/e2e/onboard-full-flow.test.ts+++ b/test/e2e/onboard-full-flow.test.ts@@ -72,13 +72,13 @@ describe('onboard E2E — runAllOnboardChecks', () => {]);});- test('empty brain: stale/link/timeline ok, takes_count warns (0 takes)', async () => {+ test('empty brain: stale/link/timeline ok, takes_count is opt-in information (0 takes)', async () => {const results = await runAllOnboardChecks(engine);const byName = Object.fromEntries(results.map((r) => [r.check.name, r.check.status]));expect(byName.embed_staleness).toBe('ok');expect(byName.entity_link_coverage).toBe('ok');expect(byName.timeline_coverage).toBe('ok');- expect(byName.takes_count).toBe('warn'); // 0 takes is a warn+ expect(byName.takes_count).toBe('ok'); // 0 takes with the bootstrap off is opt-in: ok + severity info (E2)});test('empty brain remediations: takes_count gated, pack_upgrade_available may surface', async () => {diff --git a/test/fixtures/goldens/cli/literal-imports.json b/test/fixtures/goldens/cli/literal-imports.jsonindex 12ad2b1202..8f8b25ec7a 100644--- a/test/fixtures/goldens/cli/literal-imports.json+++ b/test/fixtures/goldens/cli/literal-imports.json@@ -177,7 +177,9 @@"./commands/sweep.ts"],"sync": [- "./commands/sync.ts"+ "./commands/sync.ts",+ "./core/agent-output.ts",+ "./core/cli-force-exit.ts"],"takes": ["./commands/takes.ts"diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.jsonindex c1c1221fe9..df77ada2e3 100644--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json@@ -8,11 +8,14 @@],"exit_code": 0,"report": {- "brain_checks_score": 85,+ "brain_checks_score": 100,+ "capped_by": [+ "embeddings_disabled"+ ],"category_scores": {- "brain": 85,+ "brain": 100,"meta": 100,- "ops": 95,+ "ops": 100,"skill": 95},"checks": [@@ -141,6 +144,7 @@"webhook-transforms"]},+ "fix_unavailable_reason": "unstructured","message": "64 new built-in skill(s) available that this workspace hasn't installed: academic-verify, archive-crawler, article-enrichment, ask-user, blog-ingest, book-mirror, brain-ingest-gate, brain-link-discipline, … +56 more. Add them with `gbrain skillpack sync`.","name": "skill_currency","status": "warn"@@ -315,6 +319,42 @@"name": "embedding_key_source","status": "ok"},+ {+ "category": "ops",+ "details": {+ "reason": "no_harness_detected"+ },+ "fix": {+ "actor": "user",+ "consent": [+ "persistent_install"+ ],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/protocol/MEMORY_VERBS_v1.md#install-the-4-command-quickstart",+ "next": "report",+ "requires_exclusive": false,+ "user_message": "Which agent app should get gbrain memory? The install guide has a one-line command for each.",+ "why": "Register `<absolute path to gbrain> serve --surface verbs` as a stdio MCP server in your agent host; the install section lists the exact command per harness (Claude Code, Codex, Grok Build, opencode, OpenClaw)."+ },+ "message": "No agent harness was detected. Wire one when the user picks an agent app.",+ "name": "harness_wiring",+ "readiness_state": "missing",+ "severity": "info",+ "status": "ok"+ },+ {+ "category": "meta",+ "details": {+ "consent_refused": 0,+ "derived_cap_exhausted": 0,+ "events": 0,+ "internal_errors": 0,+ "json_document_missing": 0,+ "window_days": 7+ },+ "message": "No agent dead ends in the last 7 days (0 non-success event(s) logged).",+ "name": "agent_contract",+ "status": "ok"+ },{"category": "ops","message": "Connected, 0 pages",@@ -416,15 +456,93 @@},{"category": "brain",+ "fix": {+ "actor": "user",+ "argv": [+ "gbrain",+ "init",+ "--force",+ "--embedding-model",+ "voyage:voyage-4",+ "--embedding-dimensions",+ "1024"+ ],+ "command": "gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024",+ "consent": [+ "credentials",+ "paid"+ ],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/search-modes.md",+ "inputs": [+ {+ "how": "Ask the user for an API key for Voyage AI; store it with `gbrain config set voyage_api_key <key>` (every gbrain process reads it), or export VOYAGE_API_KEY in the environment of every gbrain process. Then run the command.",+ "name": "VOYAGE_API_KEY"+ }+ ],+ "next": "tell_user_to_run",+ "requires_exclusive": true,+ "user_message": "Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (VOYAGE_API_KEY), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are.",+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "embeddings",+ "--json"+ ]+ },+ "why": "Embeddings are off, so search is keyword-only, and no configured embedding key fits this brain. Once the key is set this turns on voyage:voyage-4 (1024d) for this Postgres brain. Pages, facts and keyword search are kept; existing chunks and facts are queued for vectors, which `gbrain embed --stale` (or the next maintenance cycle) fills."+ },"message": "Not applicable: embeddings are disabled on this brain (keyword search keeps working).","name": "embeddings",+ "readiness_state": "disabled_by_choice",+ "severity": "info","status": "ok"},{"category": "brain",- "message": "Embedding provider probe failed: This brain has no explicit embedding model. Its stored vectors must not be interpreted using a new default. Run gbrain migrate embeddings --status and preview an explicit migration with --dry-run.",+ "fix": {+ "actor": "user",+ "argv": [+ "gbrain",+ "init",+ "--force",+ "--embedding-model",+ "voyage:voyage-4",+ "--embedding-dimensions",+ "1024"+ ],+ "command": "gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024",+ "consent": [+ "credentials",+ "paid"+ ],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/search-modes.md",+ "inputs": [+ {+ "how": "Ask the user for an API key for Voyage AI; store it with `gbrain config set voyage_api_key <key>` (every gbrain process reads it), or export VOYAGE_API_KEY in the environment of every gbrain process. Then run the command.",+ "name": "VOYAGE_API_KEY"+ }+ ],+ "next": "tell_user_to_run",+ "requires_exclusive": true,+ "user_message": "Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (VOYAGE_API_KEY), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are.",+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "embeddings",+ "--json"+ ]+ },+ "why": "Embeddings are off, so search is keyword-only, and no configured embedding key fits this brain. Once the key is set this turns on voyage:voyage-4 (1024d) for this Postgres brain. Pages, facts and keyword search are kept; existing chunks and facts are queued for vectors, which `gbrain embed --stale` (or the next maintenance cycle) fills."+ },+ "message": "Not probed: embeddings are disabled on this brain by choice (keyword search keeps working).","name": "embedding_provider",- "status": "warn"+ "readiness_state": "disabled_by_choice",+ "severity": "info",+ "status": "ok"},{"category": "brain",@@ -1023,9 +1141,43 @@"unpushed": 0}},- "message": "1 knowledge asset(s) lack verified recovery: default (not_a_git_repo). Current recovery is not verified for all repositories. Run `gbrain backup status` for fix commands (`gbrain bootstrap repo` / `git remote add origin <url>` / `gbrain sources harden <id>`).",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "export",+ "--source",+ "default",+ "--dir",+ "<BACKUP_DIR>/default"+ ],+ "command": "gbrain export --source default --dir '<BACKUP_DIR>/default'",+ "consent": [],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/operations/backup-check.md",+ "inputs": [+ {+ "how": "Ask the user where backups should live (a directory outside the brain, ideally synced or on another disk).",+ "name": "BACKUP_DIR"+ }+ ],+ "next": "run",+ "requires_exclusive": false,+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "backup_coverage",+ "--json"+ ]+ },+ "why": "Writes a Markdown copy of 'default' (pages and facts) to a directory outside the brain so it survives losing the database."+ },+ "message": "Not urgent yet: the brain holds 0 page(s)+fact(s) and is under 7 days old (backup coaching starts at 25 items or 7 days). 1 knowledge asset(s) lack verified recovery: default (not_a_git_repo). A source repo with a pushed git remote restores its Markdown files only, never DB-only pages, facts, config or credentials. Run `gbrain backup status` for each asset's fix command.","name": "backup_coverage",- "status": "warn"+ "readiness_state": "degraded",+ "severity": "info",+ "status": "ok"},{"category": "ops",@@ -1041,9 +1193,11 @@},{"category": "brain",- "message": "Source 'default' has never completed a full cycle. Run `gbrain dream --source <id>` to cycle a source, or start `gbrain autopilot`.",+ "message": "No full cycle yet for 'default': it holds no pages or only pages from the last 24h, so there is nothing to consolidate yet.","name": "cycle_freshness",- "status": "warn"+ "readiness_state": "not_applicable",+ "severity": "info",+ "status": "ok"},{"category": "brain",@@ -1119,6 +1273,8 @@},"message": "Not applicable: embeddings are disabled on this brain (keyword search keeps working).","name": "fact_take_vectors",+ "readiness_state": "disabled_by_choice",+ "severity": "info","status": "ok"},{@@ -1309,8 +1465,47 @@},{"category": "brain",- "message": "No stale chunks",+ "fix": {+ "actor": "user",+ "argv": [+ "gbrain",+ "init",+ "--force",+ "--embedding-model",+ "voyage:voyage-4",+ "--embedding-dimensions",+ "1024"+ ],+ "command": "gbrain init --force --embedding-model voyage:voyage-4 --embedding-dimensions 1024",+ "consent": [+ "credentials",+ "paid"+ ],+ "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/search-modes.md",+ "inputs": [+ {+ "how": "Ask the user for an API key for Voyage AI; store it with `gbrain config set voyage_api_key <key>` (every gbrain process reads it), or export VOYAGE_API_KEY in the environment of every gbrain process. Then run the command.",+ "name": "VOYAGE_API_KEY"+ }+ ],+ "next": "tell_user_to_run",+ "requires_exclusive": true,+ "user_message": "Semantic search needs an embedding API key. Voyage AI works with this brain; if you add a key (VOYAGE_API_KEY), I can turn it on. Embedding costs a little per page; your notes and facts stay as they are.",+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "embeddings",+ "--json"+ ]+ },+ "why": "Embeddings are off, so search is keyword-only, and no configured embedding key fits this brain. Once the key is set this turns on voyage:voyage-4 (1024d) for this Postgres brain. Pages, facts and keyword search are kept; existing chunks and facts are queued for vectors, which `gbrain embed --stale` (or the next maintenance cycle) fills."+ },+ "message": "Not applicable: embeddings are disabled on this brain by choice, so chunks have no vectors by design (keyword search keeps working).","name": "embed_staleness",+ "readiness_state": "disabled_by_choice",+ "severity": "info","status": "ok"},{@@ -1327,9 +1522,38 @@},{"category": "brain",+ "fix": {+ "actor": "agent",+ "argv": [+ "gbrain",+ "config",+ "set",+ "takes.bootstrap_enabled",+ "true"+ ],+ "command": "gbrain config set takes.bootstrap_enabled true",+ "consent": [+ "paid"+ ],+ "next": "ask_user",+ "requires_exclusive": false,+ "user_message": "gbrain can extract typed claims (\"takes\") from your pages so it can track calibration over time. It uses a paid chat model (roughly $5 once). Turn it on?",+ "verify": {+ "argv": [+ "gbrain",+ "doctor",+ "--only",+ "takes_count",+ "--json"+ ]+ },+ "why": "Takes (typed claims) are opt-in. Enabling the bootstrap lets maintenance extract them from existing pages with a chat model (about $5 on a typical brain), which feeds calibration."+ },"message": "0 takes (takes.bootstrap_enabled is false; opt in to enable)","name": "takes_count",- "status": "warn"+ "readiness_state": "disabled_by_choice",+ "severity": "info",+ "status": "ok"},{"category": "meta",@@ -1352,39 +1576,15 @@],"db_url_source": null,"engine": "postgres",- "health_score": 75,+ "health_score": 95,"schema_version": 2,"status": "warnings","top_issues": [- {- "fix": "1 knowledge asset(s) lack verified recovery: default (not_a_git_repo). Current recovery is not verified for all repositories. Run `gbrain backup status` for fix commands (`gbrain bootstrap repo` / `git remote add origin <url>` / `gbrain sources harden <id>`).",- "name": "backup_coverage",- "status": "warn",- "tier": "symptom"- },- {- "fix": "Source 'default' has never completed a full cycle. Run `gbrain dream --source <id>` to cycle a source, or start `gbrain autopilot`.",- "name": "cycle_freshness",- "status": "warn",- "tier": "symptom"- },- {- "fix": "Embedding provider probe failed: This brain has no explicit embedding model. Its stored vectors must not be interpreted using a new default. Run gbrain migrate embeddings --status and preview an explicit migration with --dry-run.",- "name": "embedding_provider",- "status": "warn",- "tier": "symptom"- },{"fix": "64 new built-in skill(s) available that this workspace hasn't installed: academic-verify, archive-crawler, article-enrichment, ask-user, blog-ingest, book-mirror, brain-ingest-gate, brain-link-discipline, … +56 more. Add them with `gbrain skillpack sync`.","name": "skill_currency","status": "warn","tier": "symptom"- },- {- "fix": "0 takes (takes.bootstrap_enabled is false; opt in to enable)",- "name": "takes_count",- "status": "warn",- "tier": "symptom"}]},diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.jsonindex ca12d551f7..fc5e86a59e 100644--- a/test/fixtures/goldens/exports/types.json+++ b/test/fixtures/goldens/exports/types.json@@ -5454,7 +5454,7 @@{"kind": "class","members": [- "canonical?: \"unknown\" | \"projection_pending\" | \"timeout\" | \"writer_lock_unavailable\" | \"writer_pool_capacity\" | \"owner_unavailable\" | \"recovery_required\" | \"queue_capacity\" | \"revision_required\" | \"revision_conflict\" | \"idempotency_conflict\" | \"source_changed\" | \"write_pending\" | \"storage_error\" | \"cancelled\" | \"permission_denied\" | \"scope_denied\" | \"invalid_params\" | \"not_found\" | \"page_not_found\" | \"page_identity_changed\" | \"write_claim_lost\" | \"request_too_large\" | \"response_too_large\" | \"writer_registration_required\" | \"writer_identity_invalid\" | \"writer_not_initialized\" | \"writer_coordinator_required\" | \"fact_already_expired\" | \"source_writeback_required\" | \"unsupported_mutation_protocol\" | \"writer_upgrade_required\" | \"writer_not_quiesced\" | \"skill_bundle_required\" | \"take_row_collision\" | \"invalid_source_uri\" | \"writer_admin_locked\" | \"connector_account_changed\" | \"connector_intent_outdated\" | \"checkpoint_validation_timeout\" | \"invalid_connector_text\" | \"connector_holds_exhausted\" | \"connector_fence_below_timeline\" | \"embedding_failed\" | \"bucket_not_found\" | \"database_error\" | \"unknown_transport\" | \"rate_limited\" | \"extraction_failed\" | \"fact_not_found\" | \"provenance_required\" | \"unavailable\" | \"budget_unsatisfiable\" | \"embedding_budget_below_worst_case\" | \"access_command_failed\" | \"access_denied_test_user\" | \"access_env_missing\" | \"acknowledgment_unavailable\" | \"admin_policy_enforced\" | \"ambiguous_id\" | \"ambiguous_skill\" | \"api_not_enabled\" | \"approval_required\" | \"autopilot_job_owned_by_other_brain\" | \"benchmark_duplicate_task_id\" | \"benchmark_empty\" | \"benchmark_exists\" | \"benchmark_judge_llm_no_rubric\" | \"benchmark_judge_qrels_no_expected\" | \"benchmark_judge_rule_no_checks\" | \"benchmark_judge_unknown_kind\" | \"benchmark_malformed\" | \"benchmark_missing_judge\" | \"benchmark_missing_task\" | \"benchmark_missing_task_id\" | \"benchmark_not_found\" | \"benchmark_rule_check_bad_arg\" | \"benchmark_rule_check_malformed\" | \"benchmark_rule_check_unknown_op\" | \"bootstrap_empty\" | \"bootstrap_pending_review\" | \"bridge_ownership_conflict\" | \"catalog_unavailable\" | \"checkpoint_missing\" | \"claim_already_used\" | \"client_json_unreadable\" | \"client_json_wrong_type\" | \"client_shape_invalid\" | \"code_callees_requires_symbol\" | \"code_callers_requires_symbol\" | \"code_def_requires_symbol\" | \"code_refs_requires_symbol\" | \"code_reused\" | \"colon_slug_windows_write_through\" | \"command_failed\" | \"config_error\" | \"confirmation_required\" | \"conflicting_source_scope\" | \"consent_timeout\" | \"cost_cap_exceeded\" | \"cost_preview_requires_yes\" | \"d_sel_too_small\" | \"demo_graph_failed\" | \"demo_import_failed\" | \"demo_verification_failed\" | \"derived_cap_exhausted\" | \"destination_not_ready\" | \"dirty_tree\" | \"effect_not_failed\" | \"embedding_auth_failed\" | \"embedding_configuration\" | \"embedding_disabled\" | \"embedding_model_mismatch\" | \"embedding_plane_split\" | \"embedding_storage_unavailable\" | \"embedding_unavailable\" | \"embedding_unconfigured\" | \"embedding_width_mismatch\" | \"export_limit\" | \"extractor_identity_mismatch\" | \"facts_absorb_write_refused\" | \"facts_payload_expired\" | \"fetch_failed\" | \"full_resync_required\" | \"git_index_locked\" | \"git_index_stale\" | \"git_push_unavailable\" | \"git_target_unsafe\" | \"git_unavailable\" | \"graph_incomplete\" | \"held_out_overlaps_benchmark\" | \"held_out_required_for_bundled\" | \"independent_principal_required\" | \"insufficient_scope\" | \"internal\" | \"internal_error\" | \"interrupted\" | \"invalid_client\" | \"invalid_grant_clock_skew\" | \"invalid_grant_revoked\" | \"invalid_grant_testing_expiry\" | \"invalid_request\" | \"invalid_source\" | \"invalid_source_pin\" | \"invalid_token\" | \"invalid_write_wait\" | \"legacy_job_selection_invalid\" | \"legacy_jobs_active\" | \"local_conflict\" | \"lock_busy\" | \"managed_pull_skipped\" | \"method_not_allowed\" | \"missing_source_scope\" | \"missing_source_value\" | \"models_strict_violation\" | \"no_pricing\" | \"no_refresh_token\" | \"no_routing_eval\" | \"no_skill_md\" | \"no_worker_surface\" | \"not_a_git_repo\" | \"not_connected\" | \"overlapping_path\" | \"parse_error\" | \"pasted_wrong_url\" | \"payload_too_large\" | \"pending_writes\" | \"plan_output_failed\" | \"plan_stale\" | \"port_in_use\" | \"preview_changed\" | \"profile_incompatible\" | \"projection_owner_resident\" | \"publication_pending\" | \"redirect_uri_mismatch\" | \"refresh_dirty\" | \"refresh_diverged\" | \"refresh_drain_timeout\" | \"refresh_no_upstream\" | \"refresh_not_managed\" | \"refresh_not_owner\" | \"refresh_source_changed\" | \"relay_disabled\" | \"relay_session_expired\" | \"relay_unreachable\" | \"request_already_submitted\" | \"requirements_changed\" | \"resume_spec_mismatch\" | \"revision_unavailable\" | \"scope_missing\" | \"shared_skills_unavailable\" | \"shared_skills_unsupported\" | \"skill_asset_not_found\" | \"skill_candidate_invalid\" | \"skill_not_found\" | \"skill_retention_capacity\" | \"source_binding_required\" | \"source_id_taken\" | \"source_not_ready\" | \"source_profile_no_backfill\" | \"source_referenced\" | \"source_root_conflict\" | \"split_bad_ratio\" | \"split_unparseable\" | \"state_mismatch\" | \"sync_in_progress\" | \"target_escape\" | \"topology_change_required\" | \"unexpected_file_bytes\" | \"unexpected_staging_bytes\" | \"unknown_flag\" | \"unknown_method\" | \"unknown_source\" | \"unknown_tool\" | \"unmanaged_path\" | \"unsupported_export_data\" | \"upstream\" | \"verification_failed\" | \"withdrawal_capacity\" | \"withdrawal_provenance\" | \"writer_admin_intent_required\" | \"writer_admin_state_changed\" | \"writer_busy\" | \"writer_identity_publish_failed\" | \"writer_manifest_mismatch\" | \"writer_manifest_unsafe\" | \"writer_regrant_required\" | \"writer_transfer_conflict\" | \"writer_transfer_required\" | \"wrong_account_consented\" | undefined",+ "canonical?: \"unknown\" | \"projection_pending\" | \"timeout\" | \"writer_lock_unavailable\" | \"writer_pool_capacity\" | \"owner_unavailable\" | \"recovery_required\" | \"queue_capacity\" | \"revision_required\" | \"revision_conflict\" | \"idempotency_conflict\" | \"source_changed\" | \"write_pending\" | \"storage_error\" | \"cancelled\" | \"permission_denied\" | \"scope_denied\" | \"invalid_params\" | \"not_found\" | \"page_not_found\" | \"page_identity_changed\" | \"write_claim_lost\" | \"request_too_large\" | \"response_too_large\" | \"writer_registration_required\" | \"writer_identity_invalid\" | \"writer_not_initialized\" | \"writer_coordinator_required\" | \"fact_already_expired\" | \"source_writeback_required\" | \"unsupported_mutation_protocol\" | \"writer_upgrade_required\" | \"writer_not_quiesced\" | \"skill_bundle_required\" | \"take_row_collision\" | \"invalid_source_uri\" | \"writer_admin_locked\" | \"connector_account_changed\" | \"connector_intent_outdated\" | \"checkpoint_validation_timeout\" | \"invalid_connector_text\" | \"connector_holds_exhausted\" | \"connector_fence_below_timeline\" | \"embedding_failed\" | \"bucket_not_found\" | \"database_error\" | \"unknown_transport\" | \"rate_limited\" | \"extraction_failed\" | \"fact_not_found\" | \"provenance_required\" | \"unavailable\" | \"budget_unsatisfiable\" | \"embedding_budget_below_worst_case\" | \"access_command_failed\" | \"access_denied_test_user\" | \"access_env_missing\" | \"acknowledgment_unavailable\" | \"admin_policy_enforced\" | \"ambiguous_id\" | \"ambiguous_skill\" | \"api_not_enabled\" | \"approval_required\" | \"autopilot_job_owned_by_other_brain\" | \"benchmark_duplicate_task_id\" | \"benchmark_empty\" | \"benchmark_exists\" | \"benchmark_judge_llm_no_rubric\" | \"benchmark_judge_qrels_no_expected\" | \"benchmark_judge_rule_no_checks\" | \"benchmark_judge_unknown_kind\" | \"benchmark_malformed\" | \"benchmark_missing_judge\" | \"benchmark_missing_task\" | \"benchmark_missing_task_id\" | \"benchmark_not_found\" | \"benchmark_rule_check_bad_arg\" | \"benchmark_rule_check_malformed\" | \"benchmark_rule_check_unknown_op\" | \"bootstrap_empty\" | \"bootstrap_pending_review\" | \"bridge_ownership_conflict\" | \"catalog_unavailable\" | \"checkpoint_missing\" | \"claim_already_used\" | \"client_json_unreadable\" | \"client_json_wrong_type\" | \"client_shape_invalid\" | \"code_callees_requires_symbol\" | \"code_callers_requires_symbol\" | \"code_def_requires_symbol\" | \"code_refs_requires_symbol\" | \"code_reused\" | \"colon_slug_windows_write_through\" | \"command_failed\" | \"config_error\" | \"confirmation_required\" | \"conflicting_source_scope\" | \"consent_timeout\" | \"cost_cap_exceeded\" | \"cost_preview_requires_yes\" | \"d_sel_too_small\" | \"demo_graph_failed\" | \"demo_import_failed\" | \"demo_verification_failed\" | \"derived_cap_exhausted\" | \"destination_not_ready\" | \"dirty_tree\" | \"effect_not_failed\" | \"embedding_auth_failed\" | \"embedding_configuration\" | \"embedding_disabled\" | \"embedding_model_mismatch\" | \"embedding_plane_split\" | \"embedding_storage_unavailable\" | \"embedding_unavailable\" | \"embedding_unconfigured\" | \"embedding_width_mismatch\" | \"export_limit\" | \"extractor_identity_mismatch\" | \"facts_absorb_write_refused\" | \"facts_payload_expired\" | \"fetch_failed\" | \"full_resync_required\" | \"git_index_locked\" | \"git_index_stale\" | \"git_push_unavailable\" | \"git_target_unsafe\" | \"git_unavailable\" | \"graph_incomplete\" | \"held_out_overlaps_benchmark\" | \"held_out_required_for_bundled\" | \"independent_principal_required\" | \"insufficient_scope\" | \"internal\" | \"internal_error\" | \"interrupted\" | \"invalid_client\" | \"invalid_grant_clock_skew\" | \"invalid_grant_revoked\" | \"invalid_grant_testing_expiry\" | \"invalid_request\" | \"invalid_source\" | \"invalid_source_pin\" | \"invalid_token\" | \"invalid_write_wait\" | \"legacy_job_selection_invalid\" | \"legacy_jobs_active\" | \"local_conflict\" | \"lock_busy\" | \"managed_pull_skipped\" | \"method_not_allowed\" | \"missing_source_scope\" | \"missing_source_value\" | \"models_strict_violation\" | \"no_pricing\" | \"no_refresh_token\" | \"no_routing_eval\" | \"no_skill_md\" | \"no_worker\" | \"no_worker_surface\" | \"not_a_git_repo\" | \"not_connected\" | \"overlapping_path\" | \"parse_error\" | \"pasted_wrong_url\" | \"payload_too_large\" | \"pending_writes\" | \"plan_output_failed\" | \"plan_stale\" | \"port_in_use\" | \"preview_changed\" | \"profile_incompatible\" | \"projection_owner_resident\" | \"publication_pending\" | \"redirect_uri_mismatch\" | \"refresh_dirty\" | \"refresh_diverged\" | \"refresh_drain_timeout\" | \"refresh_no_upstream\" | \"refresh_not_managed\" | \"refresh_not_owner\" | \"refresh_source_changed\" | \"relay_disabled\" | \"relay_session_expired\" | \"relay_unreachable\" | \"request_already_submitted\" | \"requirements_changed\" | \"resume_spec_mismatch\" | \"revision_unavailable\" | \"scope_missing\" | \"shared_skills_unavailable\" | \"shared_skills_unsupported\" | \"skill_asset_not_found\" | \"skill_candidate_invalid\" | \"skill_not_found\" | \"skill_retention_capacity\" | \"source_binding_required\" | \"source_id_taken\" | \"source_not_ready\" | \"source_profile_no_backfill\" | \"source_referenced\" | \"source_root_conflict\" | \"split_bad_ratio\" | \"split_unparseable\" | \"state_mismatch\" | \"sync_not_applicable\" | \"sync_in_progress\" | \"target_escape\" | \"topology_change_required\" | \"unexpected_file_bytes\" | \"unexpected_staging_bytes\" | \"unknown_flag\" | \"unknown_method\" | \"unknown_source\" | \"unknown_tool\" | \"unmanaged_path\" | \"unsupported_export_data\" | \"upstream\" | \"verification_failed\" | \"withdrawal_capacity\" | \"withdrawal_provenance\" | \"writer_admin_intent_required\" | \"writer_admin_state_changed\" | \"writer_busy\" | \"writer_identity_publish_failed\" | \"writer_manifest_mismatch\" | \"writer_manifest_unsafe\" | \"writer_regrant_required\" | \"writer_transfer_conflict\" | \"writer_transfer_required\" | \"wrong_account_consented\" | undefined","canonicalCode: string","cause?: unknown","code: ErrorCode",diff --git a/test/remediation-run-extras.serial.test.ts b/test/remediation-run-extras.serial.test.tsindex 62c36d52be..2b809e3e31 100644--- a/test/remediation-run-extras.serial.test.ts+++ b/test/remediation-run-extras.serial.test.ts@@ -117,14 +117,30 @@ describe('runRemediation extraRemediations threading', () => {est_usd_cost: 2, rationale: 'synthetic paid extra', status: 'remediable',});let unreachable = false;- const result = await runRemediation(- engine,- { targetScore: 101, extraRemediations: [extra('onboard.free_step', 'extract-ner'), paid], maxJobs: 5, maxUsd: 10 },- { onTargetUnreachable: () => { unreachable = true; } },- );+ const { registerWorker } = await import('../src/core/minions/worker-registry.ts');+ const unregister = registerWorker({ pid: process.pid, queue: 'default', nice_requested: null, nice_effective: null, started_at: Date.now() });+ let result;+ try {+ result = await runRemediation(+ engine,+ { targetScore: 101, extraRemediations: [extra('onboard.free_step', 'extract-ner'), paid], maxJobs: 5, maxUsd: 10 },+ { onTargetUnreachable: () => { unreachable = true; } },+ );+ } finally {+ unregister();+ }expect(unreachable).toBe(true);expect(result.submitted.map((s) => s.id)).toEqual(['onboard.free_step']);expect(result.job_steps_skipped).toMatchObject({ reason: 'target_unreachable', target: 101, skipped: ['onboard.paid_step'] });expect(submittedJobs.map((j) => j.name)).toEqual(['extract-ner']);});++ test('E3: with no worker serving the queue, an unreachable target runs no job step (it would only time out)', async () => {+ const { runRemediation } = await import('../src/core/remediation/run.ts');+ submittedJobs.length = 0;+ const result = await runRemediation(engine, { targetScore: 101, extraRemediations: [extra('onboard.free_step', 'extract-ner')], maxJobs: 5 });+ expect(result.submitted).toEqual([]);+ expect(result.target_unreachable).toMatchObject({ target: 101 });+ expect(submittedJobs).toEqual([]);+ });});