Skip to content

ANS-1118: Add Semantic Optimization CLI commands - #34

Merged
jharris1679 merged 2 commits into
mainfrom
josh/ans-1118-ship-the-first-configurable-semantic-optimization-run
Sep 5, 2026
Merged

ANS-1118: Add Semantic Optimization CLI commands#34
jharris1679 merged 2 commits into
mainfrom
josh/ans-1118-ship-the-first-configurable-semantic-optimization-run

Conversation

@jharris1679

Copy link
Copy Markdown
Collaborator

Summary

  • add answerlayer optimize commands for starting, listing, inspecting, pausing, resuming, stopping, cloning, reviewing, and promoting Semantic Optimization Runs
  • expose case selectors, all six semantic component types, proposal and search strategies, autonomy/review/promotion policies, phase-specific models, budgets, and objectives
  • document the workflow and aliases

Verification

  • npm test: 68 passed
  • includes payload coverage for configurable run creation and explicit proposal approval

Companion change

Linear: ANS-1118

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Semantic Optimization CLI support across the complete run lifecycle.

  • Introduces commands to create, list, inspect, control, clone, review, and promote optimization runs.
  • Exposes case selectors, component types, policies, models, budgets, and objectives.
  • Requires promotion callers to provide the frozen base hash for atomic compare-and-swap behavior.
  • Validates the required evaluation and proposal models, including structured-data input.
  • Documents the workflow and adds request-payload regression coverage.

Confidence Score: 5/5

The PR appears safe to merge; both previously reported contract defects are fully addressed and regression-tested.

Promotion now requires and sends expected_active_sha256, and structured model validation explicitly requires nonblank eval_execution and proposal values. No actionable new failure or repository-rule violation remains.

Important Files Changed

Filename Overview
src/cli.js Adds optimization routing, payload construction, lifecycle operations, explicit model validation, and base-hash-protected promotion.
test/cli.test.js Covers configurable run creation, review decisions, promotion concurrency tokens, and rejection of empty structured model configuration.
README.md Documents the optimization workflow and the frozen base hash required for promotion.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Start[optimize start] --> Run[Optimization run]
    Run --> Inspect[ list / get ]
    Run --> Control[ pause / resume / stop ]
    Run --> Clone[clone]
    Run --> Review{Review decision}
    Review -->|approve| Approved[Approved proposal]
    Review -->|reject| Rejected[Rejected proposal]
    Approved --> Promote[promote with frozen base hash]
    Promote --> CAS{Active hash matches?}
    CAS -->|yes| Active[Promote semantic layer]
    CAS -->|no| Conflict[Reject stale promotion]
Loading

Reviews (2): Last reviewed commit: "fix: require safe optimization inputs" | Re-trigger Greptile

Comment thread src/cli.js Outdated
Comment on lines +823 to +827
if (["pause", "resume", "stop", "promote"].includes(command)) {
return requestAndPrint(client, "POST", `${base}/${encodeURIComponent(runId)}/${command}`, parsed, io, {
body: { reason: firstValue(parsed.flags.reason) },
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Promotion Omits Base Hash

promote is documented as using an optimistic base-hash check, but this branch sends only reason and provides no flag or request-data path for the expected hash. Callers therefore cannot supply the concurrency token needed to reject a promotion against a stale semantic layer, so promotion will either fail API validation or bypass the documented stale-base protection.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in f4f0304: optimize promote now requires a base-hash flag and sends it as expected_active_sha256. The README and a request-payload regression test cover the atomic compare-and-swap contract.

Comment thread src/cli.js Outdated
Comment on lines +813 to +815
if (!Object.values(payload.models || {}).every(Boolean)) {
throw usage("optimize start requires --model or every phase-specific model flag");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Empty Models Pass Validation

Structured data shallowly replaces the default models object, while this check validates only the values that remain. Because Object.values({}).every(Boolean) is true, --data '{"models":{}}' bypasses the model requirement and sends a run with no phase models, leaving the API to reject or mishandle the request.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved in f4f0304: validation now checks the explicit required keys eval_execution and proposal and rejects missing, non-string, or blank values. A regression test covers an empty structured models object.

@jharris1679

Copy link
Copy Markdown
Collaborator Author

@greptileai Please re-review the latest commit (f4f0304). Both findings from the previous review have been addressed and regression-tested.

@jharris1679
jharris1679 merged commit 659418e into main Sep 5, 2026
2 checks passed
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 0.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant