{"record":{"id":"fc9bad78437ef3e9","repo":"can1357/oh-my-pi","slug":"invalid-compiled-revision-term-in-compiled-sourc","errorCode":null,"errorMessage":"invalid compiled revision term in ${compiled.source}","messagePattern":"invalid compiled revision term in (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/catalog/src/compat/cascade.ts","lineNumber":71,"sourceCode":"\tconst last = segments[segments.length - 1];\n\treturn last === \"\" || remainder.endsWith(last);\n}\n\ninterface IndexedRule {\n\tcompiled: CompiledRule;\n\trevision?: RevisionTerm[];\n\tpriority: number;\n\tdimensions: number;\n\thasExactEffortsRule: boolean;\n}\n\nlet ruleIndex: IndexedRule[] | undefined;\n\nfunction buildRuleIndex(cascade: CompiledCascade): IndexedRule[] {\n\treturn cascade.rules.map(compiled => {\n\t\tconst revision = compiled.revision?.map(term => {\n\t\t\tconst parsed = parseRevision(term.revision);\n\t\t\tif (!parsed) throw new Error(`invalid compiled revision term in ${compiled.source}`);\n\t\t\treturn { op: term.op, revision: parsed } satisfies RevisionTerm;\n\t\t});\n\t\tconst dimensions =\n\t\t\tNumber(compiled.class !== undefined) +\n\t\t\tNumber(compiled.providers !== undefined) +\n\t\t\tNumber(compiled.family !== undefined) +\n\t\t\tNumber(compiled.revision !== undefined) +\n\t\t\tNumber(compiled.models !== undefined);\n\t\treturn {\n\t\t\tcompiled,\n\t\t\trevision,\n\t\t\tpriority: compiled.priority ?? 0,\n\t\t\tdimensions,\n\t\t\thasExactEffortsRule: compiled.thinking !== undefined && \"efforts\" in compiled.thinking,\n\t\t};\n\t});\n}\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/catalog/src/compat/cascade.ts#L53-L89","documentation":"Thrown by buildRuleIndex while indexing a compiled compat cascade: a revision condition term compiled from KDL could not be parsed back into a valid RevisionTerm via parseRevision. This indicates the compiled rules.json (or hand-written cascade data) contains a revision string the parser doesn't recognize — i.e. corrupted or out-of-sync generated data, not user input at runtime.","triggerScenarios":"getRuleIndex/resolveCascadeRules on a CompiledCascade whose rules contain a `revision` term with an unparseable revision string (typo in KDL, hand-edited rules.json, or stale rules.json after changing the revision grammar).","commonSituations":"Editing revision-parsing grammar in code without regenerating rules.json; hand-editing packages/catalog/src/compat/rules.json; adding a KDL rule with a malformed revision selector like `rev: 17.5x`.","solutions":["Find the offending rule via the `${compiled.source}` in the message and fix the revision selector in the KDL file under packages/catalog/src/compat/rules/.","Run `bun run gen:compat` to regenerate rules.json and commit it with the KDL change.","If rules.json was hand-edited, restore it from git and change the .kdl source instead."],"exampleFix":"// before (rules/taxonomy.kdl)\nrevision \"17.5\"\n// after — use the supported comparison/revision syntax, then regenerate\nrevision \">=17.5\"\n# then: bun run gen:compat","handlingStrategy":"validation","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const policy = resolveModelPolicy(provider, model);\n} catch (err) {\n  if (err.message.includes(\"invalid compiled revision term\")) {\n    throw new Error(`rules.json out of sync with KDL: ${err.message} — run bun run gen:compat`);\n  }\n  throw err;\n}","preventionTips":["Never hand-edit rules.json; always edit KDL then `bun run gen:compat`.","Commit regenerated rules.json in the same change as the .kdl edit.","After grammar changes to revision parsing, regenerate before running tests."],"tags":["catalog","compat","generated-code","configuration"],"backgroundTag":"invalid-generated-rules-data","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}