feat: Surface defaultOptions as AI schema hints for function-form enum fields#5286
feat: Surface defaultOptions as AI schema hints for function-form enum fields#5286burieberry wants to merge 4 commits into
defaultOptions as AI schema hints for function-form enum fields#5286Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a1d8ce1ec
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Preview deploymentsHost Test Results 1 files + 1 1 suites +1 1h 58m 32s ⏱️ + 1h 58m 32s Results for commit 1990daa. ± Comparison against earlier commit 04c175b. Realm Server Test Results 1 files ±0 1 suites ±0 12m 29s ⏱️ -10s Results for commit 1990daa. ± Comparison against earlier commit 04c175b. |
defaultOptions as AI schema hints for function-form enum fields
6e4222d to
88d8401
Compare
88d8401 to
03f91aa
Compare
There was a problem hiding this comment.
Pull request overview
Adds a defaultOptions escape hatch for function-form enumField options so AI JSON-schema generation can surface “typical values” hints when runtime option resolution depends on a model instance.
Changes:
- Extend
enumFieldto optionally carrystatic defaultOptionsfor function-form enums. - Update AI schema generation to emit either a hard
enum(static options) or a soft “Typical values: …” description hint (dynamic options withdefaultOptions). - Refactor Software Factory kanban option resolution helpers and update tests to assert the new hint behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/base/enum.gts | Adds defaultOptions support on enum FieldDef subclasses for function-form options. |
| packages/runtime-common/helpers/ai.ts | Emits schema hints for dynamic enums and keeps hard enums for static options. |
| packages/software-factory/realm/kanban-config.gts | Wires defaultOptions into kanban enum fields and consolidates option-resolution helpers. |
| packages/software-factory/realm/issue-tracker.gts | Updates consumers to use the renamed/consolidated kanban option helpers and type cleanup. |
| packages/host/tests/unit/ai-function-generation-test.ts | Adds unit tests covering dynamic defaultOptions hinting and static enum behavior. |
| packages/software-factory/tests/runtime-schema.spec.ts | Updates integration assertions to expect description hints for dynamic enum fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let hint = `Typical values: ${enumResult.values.map((v) => `"${v}"`).join(', ')}`; | ||
| return { ...schema, description: hint } as AttributesSchema; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Summary
Enum fields configured with a function-form
optionscallback were previously invisible to AI schema generation — the generator has no model instance at schema-generation time, so it emitted noenumconstraint and agents had no guidance. This PR adds adefaultOptionsescape hatch: a static array you can pass alongside the function to give the generator a representative set of values, emitted as a non-constraining description hint rather than a hardenumso agents can still accept custom project-defined values that differ from the defaults.packages/base/enum.gts— addsdefaultOptions?: any[]to theenumFieldconfig and stores it asstatic defaultOptionson the generated class. Only set whenoptionsis a function anddefaultOptionsis a non-empty array; ignored whenoptionsis a static array (which already emits a hardenumthrough the existing path).packages/runtime-common/helpers/ai.ts— renamesgetStaticEnumValues→getEnumValueswith an updated return type{ values, isDynamic }. For function-form fields withdefaultOptions, emitsdescription: "Typical values: …"instead ofenum; for static fields, emits the hardenumconstraint as before. Empty or absentdefaultOptionscorrectly emits nothing.packages/software-factory/realm/kanban-config.gts— wiresdefaultOptionsinto all four enum fields (IssueStatusField,IssueTypeField,IssuePriorityField,ProjectStatusField). Also consolidates three near-identicalhasProjectFor*type guards into one generichasProject<S>and extracts the repeated map/filter/fallback logic into aresolveOptionshelper.packages/software-factory/realm/issue-tracker.gts— consolidates six separate per-field project/issue types into oneIssueWithProject, renamesconfigured*helpers toget*, and removes now-redundant single-line wrapper functions.Tests
ai-function-generation-test.ts— three new unit tests: rich-objectdefaultOptions(.valueextraction → description hint), bare-primitivedefaultOptions(→ description hint), emptydefaultOptions(no hint), nodefaultOptions(no hint), and static-arrayoptionswithdefaultOptionssupplied (description ignored; hardenumemitted).runtime-schema.spec.ts— updated integration test:issueType,priority, andstatusonIssuenow assert the expecteddescriptionhint strings rather than assertingenumisundefined.Review notes
defaultOptionsis a schema-generation-only hint and is never consulted at render time — the runtime option-resolution logic inget*Optionsis unchanged.enumwould cause agents to reject valid custom values.