{"record":{"id":"a07b46cae990c376","repo":"Yeachan-Heo/oh-my-codex","slug":"keep-policy-must-be-one-of-score-improvement-p","errorCode":null,"errorMessage":"--keep-policy must be one of: score_improvement, pass_only","messagePattern":"--keep-policy must be one of: score_improvement, pass_only","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/autoresearch-guided.ts","lineNumber":270,"sourceCode":"}\n\nexport function parseInitArgs(\n\targs: readonly string[],\n): Partial<InitAutoresearchOptions> {\n\tconst result: Partial<InitAutoresearchOptions> = {};\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst arg = args[i];\n\t\tconst next = args[i + 1];\n\t\tif (arg === \"--topic\" && next) {\n\t\t\tresult.topic = next;\n\t\t\ti++;\n\t\t} else if (arg === \"--evaluator\" && next) {\n\t\t\tresult.evaluatorCommand = next;\n\t\t\ti++;\n\t\t} else if (arg === \"--keep-policy\" && next) {\n\t\t\tconst normalized = next.trim().toLowerCase();\n\t\t\tif (normalized !== \"pass_only\" && normalized !== \"score_improvement\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"--keep-policy must be one of: score_improvement, pass_only\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tresult.keepPolicy = normalized;\n\t\t\ti++;\n\t\t} else if (arg === \"--slug\" && next) {\n\t\t\tresult.slug = slugifyMissionName(next);\n\t\t\ti++;\n\t\t} else if (arg.startsWith(\"--topic=\")) {\n\t\t\tresult.topic = arg.slice(\"--topic=\".length);\n\t\t} else if (arg.startsWith(\"--evaluator=\")) {\n\t\t\tresult.evaluatorCommand = arg.slice(\"--evaluator=\".length);\n\t\t} else if (arg.startsWith(\"--keep-policy=\")) {\n\t\t\tconst normalized = arg\n\t\t\t\t.slice(\"--keep-policy=\".length)\n\t\t\t\t.trim()\n\t\t\t\t.toLowerCase();\n\t\t\tif (normalized !== \"pass_only\" && normalized !== \"score_improvement\") {","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/autoresearch-guided.ts#L252-L288","documentation":"The `--keep-policy` flag for the autoresearch guided-setup init command only accepts two values: `score_improvement` or `pass_only`. The value is normalized (trimmed, lowercased) before validation, so anything that doesn't match those exact strings after normalization throws this error. It exists to prevent silently accepting an unknown keep policy that would later break mission compilation.","triggerScenarios":"Calling the CLI with `--keep-policy` in space-separated form, e.g. `autoresearch init --keep-policy best_of`, `--keep-policy PassOnly`, or `--keep-policy \"\"` (empty next token also skips the branch entirely, but any non-empty non-matching value throws).","commonSituations":"Typos like `score-improvement` or `pass-only` (hyphens instead of underscores), capitalized variants, or guessing a policy name like `always`/`all` that doesn't exist. Also passing extra values when copy-pasting from docs of a different version.","solutions":["Use exactly `--keep-policy score_improvement` or `--keep-policy pass_only` (case-insensitive, underscores required).","Check for trailing whitespace or shell quoting that appends characters to the value.","Omit the flag entirely to use the default keep policy."],"exampleFix":"# before\nautoresearch init --keep-policy score-improvement\n\n# after\nautoresearch init --keep-policy score_improvement","handlingStrategy":"validation","validationCode":"const KEEP_POLICIES = new Set(['score_improvement', 'pass_only']);\nconst v = args['--keep-policy']?.trim().toLowerCase();\nif (v && !KEEP_POLICIES.has(v)) throw new UsageError(`--keep-policy must be one of: ${[...KEEP_POLICIES].join(', ')}`);","typeGuard":"const isKeepPolicy = (v: string): v is 'score_improvement' | 'pass_only' =>\n  ['score_improvement', 'pass_only'].includes(v.trim().toLowerCase());","tryCatchPattern":"try { parseInitArgs(argv); } catch (e) { if (String(e.message).startsWith('--keep-policy')) { printUsage(); process.exit(2); } throw e; }","preventionTips":["Derive CLI values from a const array of allowed policies instead of free-text strings.","Print allowed values in your own usage/help text before invoking the CLI."],"tags":["cli","argument-validation","autoresearch"],"backgroundTag":"invalid-cli-argument","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}