{"record":{"id":"fc6b4115eccb7239","repo":"Yeachan-Heo/oh-my-codex","slug":"generated-aggregate-codex-objective-exceeds-the-4","errorCode":null,"errorMessage":"Generated aggregate Codex objective exceeds the 4,000 character goal limit.","messagePattern":"Generated aggregate Codex objective exceeds the 4,000 character goal limit\\.","errorType":"validation","errorClass":"UltragoalError","httpStatus":null,"severity":"error","filePath":"src/ultragoal/artifacts.ts","lineNumber":734,"sourceCode":"\nfunction isResolvedStatus(status: UltragoalStatus): boolean {\n  return status === 'complete' || status === 'review_blocked';\n}\n\nfunction isScheduleEligibleGoal(goal: UltragoalItem): boolean {\n  return goal.steeringStatus !== 'superseded' && goal.steeringStatus !== 'blocked';\n}\n\nexport const ULTRAGOAL_AGGREGATE_CODEX_OBJECTIVE = buildAggregateCodexObjective('');\n\nfunction buildAggregateCodexObjective(statePathPrefix: string): string {\n  return `Complete the durable ultragoal plan in ${prefixedStatePath(statePathPrefix, ULTRAGOAL_GOALS)}, including later accepted/appended stories, under the original brief constraints; use ${prefixedStatePath(statePathPrefix, ULTRAGOAL_LEDGER)} as the audit trail.`;\n}\n\nfunction aggregateCodexObjective(statePathPrefix: string): string {\n  const objective = buildAggregateCodexObjective(statePathPrefix);\n  if (objective.length <= 4000) return objective;\n  throw new UltragoalError('Generated aggregate Codex objective exceeds the 4,000 character goal limit.');\n}\n\nfunction isLegacyEnumeratedAggregateObjective(objective: string | undefined): boolean {\n  if (!objective) return false;\n  return (\n    objective.startsWith(`Complete all ultragoal stories in ${ULTRAGOAL_DIR}/${ULTRAGOAL_GOALS}: `)\n    || objective === `Complete all ultragoal stories listed in ${ULTRAGOAL_DIR}/${ULTRAGOAL_GOALS}. Use ${ULTRAGOAL_DIR}/${ULTRAGOAL_LEDGER} as the durable audit trail.`\n  );\n}\n\nfunction compatibleCodexObjectives(plan: UltragoalPlan): string[] {\n  return (plan.codexObjectiveAliases ?? [])\n    .filter((objective) => isLegacyEnumeratedAggregateObjective(objective)\n      || objective === ULTRAGOAL_AGGREGATE_CODEX_OBJECTIVE);\n}\n\nfunction expectedCodexObjective(plan: UltragoalPlan, goal: UltragoalItem): string {\n  return codexGoalMode(plan) === 'aggregate'","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/ultragoal/artifacts.ts#L716-L752","documentation":"aggregateCodexObjective builds a single objective string pointing at the ultragoal goals/ledger files, and throws if it exceeds 4,000 characters. Because the aggregate objective is essentially a fixed template plus prefixed state paths, this fires when the state-path prefix (repo layout / configured prefix) itself is long enough to push the rendered template over the limit — the goals content is referenced by path, not embedded.","triggerScenarios":"Calling aggregateCodexObjective(statePathPrefix) where prefixedStatePath renders paths whose combined length pushes the template past 4000 chars — i.e. a deeply nested repo or a very long configured statePathPrefix (absolute paths, long workspace names, nested monorepo directories).","commonSituations":"CI checkouts into very deep directories (/home/runner/work/<org>/<repo>/<long-name>/...); absolute rather than repo-relative state prefixes; long generated workspace/team names concatenated into the prefix; platform path-length limits compounding on Windows.","solutions":["Shorten the state path prefix: use a short repo-relative prefix instead of a deep absolute path","Move the repo/state directory higher in the filesystem (shallower checkout path) to shrink rendered paths","Reduce workspace/team name lengths that feed into the prefix","If you control the caller, pass an explicit short prefix argument rather than deriving one from cwd"],"exampleFix":"// before\naggregateCodexObjective('/var/lib/ci/workspaces/team-alpha-long-name/state/ultragoal'); // >4000 chars\n\n// after\naggregateCodexObjective('.ultragoal'); // short repo-relative prefix","handlingStrategy":"validation","validationCode":"function prefixFitsAggregateObjective(statePathPrefix: string): boolean {\n  const templateOverhead = 512; // conservative fixed-template budget\n  return statePathPrefix.length + templateOverhead <= 4000;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const objective = aggregateCodexObjective(prefix);\n} catch (e) {\n  if (e instanceof UltragoalError && /4,000 character goal limit/.test(e.message)) {\n    // shorten prefix to a repo-relative path and rebuild\n  } else throw e;\n}","preventionTips":["Use short repo-relative state path prefixes, not deep absolute paths","Keep workspace/team names short in CI","Fail fast in config loading if the rendered prefix is unusually long"],"tags":["ultragoal","objective","limit","path-length"],"backgroundTag":"content-exceeds-length-limit","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}