refactor(onboard): extract agent policy finalization FSM phases#4484
Conversation
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Signed-off-by: Carlos Villela <cvillela@nvidia.com> # Conflicts: # src/lib/onboard.ts # src/lib/onboard/machine/README.md # src/lib/onboard/machine/definition.test.ts # src/lib/onboard/machine/definition.ts # src/lib/onboard/machine/handlers/preflight.test.ts # src/lib/onboard/machine/handlers/provider-inference.ts # src/lib/onboard/machine/progress.ts # src/lib/onboard/machine/record-only-runner.test.ts # src/lib/onboard/machine/record-only-runner.ts # src/lib/onboard/machine/result.test.ts # src/lib/onboard/machine/result.ts # src/lib/onboard/machine/runner.test.ts # src/lib/onboard/machine/runner.ts # src/lib/onboard/machine/runtime.test.ts # src/lib/onboard/machine/runtime.ts # src/lib/onboard/machine/sequence-runner.test.ts # src/lib/onboard/machine/sequence-runner.ts # src/lib/onboard/runtime-boundary.test.ts # src/lib/onboard/runtime-boundary.ts # src/lib/state/onboard-session.test.ts # src/lib/state/onboard-session.ts
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
…preflight-gateway-phases
…onboard-fsm-provider-sandbox-phases
…nboard-fsm-agent-policy-finalization-phases
…into stack/onboard-fsm-preflight-gateway-phases
…way-phases' into stack/onboard-fsm-provider-sandbox-phases
…ox-phases' into stack/onboard-fsm-agent-policy-finalization-phases
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/onboard/machine/flow-phases/agent-policy-finalization.test.ts`:
- Around line 60-62: The updateSession helper currently discards in-place
mutations because it uses `mutator(cloneSession(session)) ?? session`; change it
to keep the mutated draft when the mutator returns void by capturing the draft
result and falling back to that draft instead of the original session. In other
words, call the mutator with a cloned draft, store the draft after the mutator
runs, and use the mutator's return value if present or the mutated draft
otherwise before assigning/returning the cloned session; update references to
`updateSession`, `mutator`, `cloneSession`, `Session`, and the
`OnboardRuntimeDeps.updateSession` contract accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 95e00996-91cf-4f8f-84a9-c3858e851c9c
📒 Files selected for processing (2)
src/lib/onboard/machine/flow-phases/agent-policy-finalization.test.tssrc/lib/onboard/machine/flow-phases/agent-policy-finalization.ts
| const updateSession = (mutator: (value: Session) => Session | void): Session => { | ||
| session = cloneSession(mutator(cloneSession(session)) ?? session); | ||
| return cloneSession(session); |
There was a problem hiding this comment.
Preserve in-place session mutations when mutator returns void.
At Line 61, mutator(...) ?? session drops mutations if the mutator uses the allowed void return path. Use the mutated draft as fallback to honor the OnboardRuntimeDeps.updateSession contract.
Suggested patch
const updateSession = (mutator: (value: Session) => Session | void): Session => {
- session = cloneSession(mutator(cloneSession(session)) ?? session);
+ const draft = cloneSession(session);
+ session = cloneSession(mutator(draft) ?? draft);
return cloneSession(session);
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const updateSession = (mutator: (value: Session) => Session | void): Session => { | |
| session = cloneSession(mutator(cloneSession(session)) ?? session); | |
| return cloneSession(session); | |
| const updateSession = (mutator: (value: Session) => Session | void): Session => { | |
| const draft = cloneSession(session); | |
| session = cloneSession(mutator(draft) ?? draft); | |
| return cloneSession(session); | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/lib/onboard/machine/flow-phases/agent-policy-finalization.test.ts` around
lines 60 - 62, The updateSession helper currently discards in-place mutations
because it uses `mutator(cloneSession(session)) ?? session`; change it to keep
the mutated draft when the mutator returns void by capturing the draft result
and falling back to that draft instead of the original session. In other words,
call the mutator with a cloned draft, store the draft after the mutator runs,
and use the mutator's return value if present or the mutated draft otherwise
before assigning/returning the cloned session; update references to
`updateSession`, `mutator`, `cloneSession`, `Session`, and the
`OnboardRuntimeDeps.updateSession` contract accordingly.
Selective E2E Results — ✅ All requested jobs passedRun: 27229119067
|
Summary
Add reusable FSM phase wrappers for agent setup, policy setup, finalization, and post-verification. These wrappers cover the branch-to-completion half of onboarding.
Changes
Type of Change
Verification
npx prek run --all-filespassesnpm testpassesnpm run docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Tests
Refactor