Skip to content

[codex] Flatten app config and prelaunch configured app#48

Merged
arnoldlaishram merged 8 commits into
mainfrom
codex/require-app-config-prelaunch
Apr 3, 2026
Merged

[codex] Flatten app config and prelaunch configured app#48
arnoldlaishram merged 8 commits into
mainfrom
codex/require-app-config-prelaunch

Conversation

@droid-ash
Copy link
Copy Markdown
Contributor

@droid-ash droid-ash commented Apr 3, 2026

Summary

  • make .finalrun/config.yaml app identity mandatory and treat it as the source of truth for repo-local runs
  • replace the old nested app schema with a flat app object: name, packageName, bundleId
  • allow .finalrun/env/<env>.yaml to replace the base app object for env-specific app identity
  • keep --app as a binary override only, validate it against the configured app identity, and prelaunch the resolved app once before AI execution
  • pass the bootstrap launch summary into the planner and avoid default reinstall when relaunching the known app
  • update the FinalRun generation skill and test coverage for the new schema

Config Contract

This PR changes the app config shape.

Before:

app:
  android:
    packageName: com.example.android
  ios:
    bundleId: com.example.ios

After:

app:
  name: Example
  packageName: com.example.android
  bundleId: com.example.ios

Env overrides use the same flat shape and replace the base app object for that env:

app:
  packageName: com.example.android.staging

Important behavior changes:

  • nested app.android / app.ios is no longer accepted
  • empty strings are not allowed in app
  • base .finalrun/config.yaml must define at least one of app.packageName or app.bundleId
  • if both identifiers are configured, --platform is required unless --app already disambiguates with .apk or .app

Runtime Behavior

  • check, test, and suite now resolve the effective app identity from config first and print the chosen Android package or iOS bundle ID before execution
  • --app remains an install artifact override, not the source of truth for app identity
  • after device setup, the CLI prelaunches the resolved app once and sends that launch summary into the planner as pre_context
  • later launch_app actions keep working, but relaunching the known app no longer defaults to uninstall/reinstall

Why

The CLI previously carried app identity in a more complicated nested config shape and depended too heavily on --app during execution. This change makes the repo config the stable source of truth, simplifies authoring, keeps env-specific app identity in one obvious place, and starts the planner from a known app-under-test state.

Validation

  • npm run build --workspace=@finalrun/common --workspace=@finalrun/goal-executor --workspace=@finalrun/finalrun-agent
  • npm test --workspace=@finalrun/finalrun-agent

Summary by CodeRabbit

Release Notes

  • New Features

    • App configuration support via .finalrun/config.yaml with environment-specific overrides for Android and iOS app identities.
    • CLI now pre-launches the primary app before test execution.
  • Improvements

    • Increased default maximum iterations from 50 to 110.
    • Enhanced app identity logging and resolution for clearer test execution context.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

This PR introduces run-scoped primary app context resolution and bootstrapping for the CLI. It adds app configuration support to .finalrun/config.yaml and environment files, resolves app identity (package name or bundle ID) from workspace/environment configs or CLI overrides, pre-launches the resolved app before the first goal, and passes launch context to the planner.

Changes

Cohort / File(s) Summary
App Configuration Resolution
packages/cli/src/appConfig.ts, packages/cli/src/appConfig.test.ts
New module for validating and resolving FinalRun app configuration across Android/iOS, reading repo app configs, resolving effective platform/identifier, discovering APK/app bundle IDs via system tools, and formatting app summaries for console output.
Workspace & Environment Config
packages/cli/src/workspace.ts, packages/cli/src/specLoader.ts, packages/common/src/models/RepoEnvironment.ts, packages/common/src/index.ts
Extended workspace and environment configurations to include optional app field containing platform-specific identifiers (packageName/bundleId), with validation and type exports in common package.
Check & Test Runner Integration
packages/cli/src/checkRunner.ts, packages/cli/bin/finalrun.ts, packages/cli/src/testRunner.ts, packages/cli/src/testRunner.test.ts
Integrated app config resolution into check and test flows; check validates and logs resolved app; test runner derives platform from resolved config and passes app context to goal sessions; increased default --max-iterations from 50 to 110.
Goal Execution Bootstrap
packages/cli/src/goalRunner.ts, packages/cli/src/goalRunner.test.ts
Added pre-launch bootstrapping of primary app before first goal execution, storing launch summary on goal session; passes app context and launch summary to planner via preContext and appIdentifier configuration.
Planner Context Propagation
packages/goal-executor/src/HeadlessGoalExecutor.ts, packages/goal-executor/src/HeadlessGoalExecutor.test.ts, packages/goal-executor/src/HeadlessActionExecutor.ts, packages/goal-executor/src/HeadlessActionExecutor.test.ts
Extended goal executor config to accept preContext, appKnowledge, and appIdentifier; propagates these into planner requests and action executor; updated launch app action to avoid uninstall-before-launch for primary app (configurable via planner).
Run Artifacts & Reporting
packages/common/src/models/RunArtifacts.ts, packages/cli/src/reportWriter.ts
Updated run manifest to record resolved app context in run inputs, including identifier, identifierKind, name, and sourceEnvName; extended environment record to include app config snapshot.
Test Infrastructure
packages/cli/src/finalrun.test.ts, packages/cli/src/workspace.test.ts
Added workspace config helpers (buildWorkspaceConfigYaml, writeWorkspaceConfig) for test setup; updated test assertions to verify app config validation, platform resolution, and bootstrap launch behavior across Android/iOS scenarios.
Constants & Default Values
packages/common/src/constants.ts
Increased DEFAULT_MAX_ITERATIONS from 50 to 110, aligning default iteration limits for CLI and goal execution.
Documentation & Specifications
skills/generate-finalrun-test/SKILL.md, openspec/specs/cli-primary-app-context/spec.md, openspec/changes/archive/2026-04-03-align-cli-app-precontext/*
Added/updated skill guidance for app identity configuration via workspace and environment configs; added specification and design documents defining primary app context resolution, bootstrap launch, and planner integration requirements.

Sequence Diagram(s)

sequenceDiagram
    participant User as User / CLI
    participant Check as Check Runner
    participant Test as Test Runner
    participant Session as Goal Session
    participant Device as Device
    participant Executor as Goal Executor
    participant Planner as AI Planner

    User->>Check: finalrun check --app <path>
    Check->>Check: Validate & resolve app config
    Check->>Check: Log resolved app summary
    
    User->>Test: finalrun test --app <path>
    Test->>Test: Resolve app config from workspace/env/override
    Test->>Session: Create goal session with app config
    
    Session->>Device: ensureAppReady(app)
    Device->>Device: Query installed apps
    Device->>Device: Launch primary app
    Device-->>Session: Return launch summary
    
    Session->>Executor: Execute goal with app context
    Executor->>Planner: plan(preContext: launchSummary, appIdentifier, appKnowledge)
    Planner->>Planner: Generate actions (e.g., LaunchAppAction)
    Planner-->>Executor: Action with shouldUninstallBeforeLaunch=false for primary app
    
    Executor->>Device: Execute action
    Device-->>Executor: Action result
    
    Executor-->>Session: Execution complete
    Session->>Test: Record app context in artifacts
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • arnoldlaishram

🐰 A config and a launch, what a pair!
The app now prepped with utmost care,
Platform resolved, no need to guess,
The planner knows—let's pass the test!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 2.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "[codex] Flatten app config and prelaunch configured app" clearly summarizes the main changes: flattening the nested app config schema and adding prelaunch functionality for the configured app.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/require-app-config-prelaunch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@droid-ash droid-ash marked this pull request as ready for review April 3, 2026 01:18
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/cli/src/appConfig.ts`:
- Around line 177-193: The current resolveSelectedPlatform flow lets a preferred
--platform override an inferred platform from --app and skip validation,
allowing mismatched pairs like `--platform ios --app app.apk`; update
resolveSelectedPlatform to detect when both a requestedPlatform
(normalizePlatform of params.requestedPlatform) and an inferredPlatform
(normalizePlatform of params.inferredPlatform or from params.app) exist and
conflict, and in that case throw or return a validation error instead of
returning the requestedPlatform; ensure the check happens early so callers
(bootstrap/prelaunch) never receive a mismatched platform, referencing the
normalizePlatform calls and resolveSelectedPlatform function to locate where to
add the conflict-detection and error path.
- Around line 347-371: The current resolveAndroidToolCandidates function uses
process.env['ANDROID_HOME'] ?? process.env['ANDROID_SDK_ROOT'] which
short-circuits and ignores ANDROID_SDK_ROOT if ANDROID_HOME is set; change the
logic to collect both env values (ANDROID_HOME and ANDROID_SDK_ROOT) when
present, iterate each root to add candidates for 'aapt' (build-tools/*/toolName)
and 'apkanalyzer' (cmdline-tools/latest/bin and tools/bin), then still append
resolveOnPath(toolName) and pass the combined list through dedupeExistingPaths
to collapse duplicates; update references in resolveAndroidToolCandidates and
keep the existing dedupeExistingPaths and resolveOnPath behavior.

In `@packages/goal-executor/src/HeadlessActionExecutor.ts`:
- Around line 566-568: The runtime uses unsafe TypeScript casts on
output['shouldUninstallBeforeLaunch'] (and similarly allowAllPermissions,
clearState, stopAppBeforeLaunch) which don't validate that the value is actually
a boolean; update the parsing logic around shouldUninstallBeforeLaunch (and the
other three flags) to perform a runtime boolean check (e.g., test for === true
or check typeof === 'boolean') and only use the output value when it is a real
boolean, otherwise fall back to the existing defaults (for
shouldUninstallBeforeLaunch keep the packageName === this._primaryAppIdentifier
? false : true behavior). Ensure you reference the same properties on the output
object and preserve existing default semantics for
packageName/_primaryAppIdentifier.
🪄 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: Pro

Run ID: 55a26643-bd10-42fa-8819-0e428819a2a3

📥 Commits

Reviewing files that changed from the base of the PR and between 085f702 and 802562c.

📒 Files selected for processing (25)
  • openspec/changes/align-cli-app-precontext-with-dart/.openspec.yaml
  • openspec/changes/align-cli-app-precontext-with-dart/design.md
  • openspec/changes/align-cli-app-precontext-with-dart/proposal.md
  • openspec/changes/align-cli-app-precontext-with-dart/specs/cli-primary-app-context/spec.md
  • openspec/changes/align-cli-app-precontext-with-dart/tasks.md
  • packages/cli/bin/finalrun.ts
  • packages/cli/src/appConfig.ts
  • packages/cli/src/checkRunner.ts
  • packages/cli/src/finalrun.test.ts
  • packages/cli/src/goalRunner.test.ts
  • packages/cli/src/goalRunner.ts
  • packages/cli/src/reportWriter.ts
  • packages/cli/src/specLoader.ts
  • packages/cli/src/testRunner.test.ts
  • packages/cli/src/testRunner.ts
  • packages/cli/src/workspace.test.ts
  • packages/cli/src/workspace.ts
  • packages/common/src/index.ts
  • packages/common/src/models/RepoEnvironment.ts
  • packages/common/src/models/RunArtifacts.ts
  • packages/goal-executor/src/HeadlessActionExecutor.test.ts
  • packages/goal-executor/src/HeadlessActionExecutor.ts
  • packages/goal-executor/src/HeadlessGoalExecutor.test.ts
  • packages/goal-executor/src/HeadlessGoalExecutor.ts
  • skills/generate-finalrun-test/SKILL.md

Comment thread packages/cli/src/appConfig.ts
Comment thread packages/cli/src/appConfig.ts
Comment thread packages/goal-executor/src/HeadlessActionExecutor.ts Outdated
@droid-ash droid-ash requested a review from arnoldlaishram April 3, 2026 03:19
@droid-ash droid-ash self-assigned this Apr 3, 2026
Copy link
Copy Markdown
Contributor Author

Launch-defaults summary for this PR:

Shared LaunchAppAction defaults in the code today:

  • allowAllPermissions: true
  • shouldUninstallBeforeLaunch: true
  • clearState: false
  • stopAppBeforeLaunch: false
  • permissions: {}

What this PR changes on top of that:

  • Bootstrap prelaunch before the first AI goal is explicitly sent as:
    • allowAllPermissions: true
    • shouldUninstallBeforeLaunch: false
    • clearState: false
    • stopAppBeforeLaunch: false
  • Planner-driven launch_app keeps the normal defaults except for one case:
    • if the target is the already-known primary app, shouldUninstallBeforeLaunch now defaults to false
    • otherwise it still defaults to true
    • explicit grounder booleans still win

Android behavior:

  • stopAppBeforeLaunch: true -> force-stop via adb before launch
  • clearState: true -> clear app data via adb before launch
  • allowAllPermissions: true -> best-effort grant of all known runtime permissions
    • undeclared permissions are skipped, not treated as errors
  • allowAllPermissions: false + permissions -> only the specified permissions are toggled
  • after that, the launch request is forwarded through the driver path

iOS simulator behavior:

  • stopAppBeforeLaunch: true -> terminate app before launch
  • clearState: true -> currently not supported in finalrun-ts without an install artifact path; launch fails with an explicit error
  • allowAllPermissions: true -> simctl privacy grant all first, then applesimutils is used for the remaining simulator permissions
    • if applesimutils is missing, launch continues with a warning about the skipped pre-grants
  • allowAllPermissions: false + permissions -> only the specified permissions are toggled
    • simulator permissions that need applesimutils also degrade to a warning if that tool is missing

So the practical default for this PR’s bootstrap path is: prelaunch the configured app, do not reinstall it, do not clear data, do not force-stop first, and grant permissions using the platform-default “allow all” path.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
packages/cli/src/appConfig.test.ts (1)

1-94: Consider expanding test coverage.

The existing tests cover important edge cases (platform conflict, SDK fallback), but there's room for additional tests covering:

  • readRepoAppConfig validation (invalid keys, missing platforms)
  • resolveIOSBundleId with plutil fallback
  • normalizePlatform edge cases
  • Error scenarios in resolvePrimaryAppConfig

This can be addressed in a follow-up.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/appConfig.test.ts` around lines 1 - 94, Add follow-up unit
tests to expand coverage: add tests for readRepoAppConfig that supply invalid
config objects (unknown keys, missing platform entries) and assert it
throws/returns validation errors; add tests for resolveIOSBundleId that simulate
missing Info.plist but available plutil output (mock filesystem/child process)
and assert correct bundle id is returned; add edge-case tests for
normalizePlatform with varied inputs (case variants, unexpected strings,
null/undefined) and assert normalized outputs or thrown errors; and add
additional resolvePrimaryAppConfig error-path tests (e.g., missing workspaceApp
entry, ambiguous requestedPlatform/inferredPlatform combos) to assert proper
rejection messages. Ensure tests reference the functions resolveIOSBundleId,
readRepoAppConfig, normalizePlatform, and resolvePrimaryAppConfig so they’re
easy to locate.
packages/cli/src/appConfig.ts (1)

399-410: which is Unix-specific; consider cross-platform note.

The which command works on macOS/Linux but not on Windows. This is likely acceptable for mobile development workflows, but worth documenting if Windows CI runners might be used.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/appConfig.ts` around lines 399 - 410, The resolveOnPath
function currently calls the Unix-only 'which' via execFileAsync, which fails on
Windows CI; update resolveOnPath to be cross-platform by detecting
process.platform === 'win32' and using 'where' on Windows or, preferably,
replace the execFileAsync call with a cross-platform utility (e.g., the npm
'which' package or implement PATH lookup using process.env.PATH and fs.access)
so execFileAsync('which', ...) is no longer relied on; adjust the function and
any callers (resolveOnPath, execFileAsync usage) and add a brief comment noting
cross-platform behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/cli/src/appConfig.test.ts`:
- Around line 1-94: Add follow-up unit tests to expand coverage: add tests for
readRepoAppConfig that supply invalid config objects (unknown keys, missing
platform entries) and assert it throws/returns validation errors; add tests for
resolveIOSBundleId that simulate missing Info.plist but available plutil output
(mock filesystem/child process) and assert correct bundle id is returned; add
edge-case tests for normalizePlatform with varied inputs (case variants,
unexpected strings, null/undefined) and assert normalized outputs or thrown
errors; and add additional resolvePrimaryAppConfig error-path tests (e.g.,
missing workspaceApp entry, ambiguous requestedPlatform/inferredPlatform combos)
to assert proper rejection messages. Ensure tests reference the functions
resolveIOSBundleId, readRepoAppConfig, normalizePlatform, and
resolvePrimaryAppConfig so they’re easy to locate.

In `@packages/cli/src/appConfig.ts`:
- Around line 399-410: The resolveOnPath function currently calls the Unix-only
'which' via execFileAsync, which fails on Windows CI; update resolveOnPath to be
cross-platform by detecting process.platform === 'win32' and using 'where' on
Windows or, preferably, replace the execFileAsync call with a cross-platform
utility (e.g., the npm 'which' package or implement PATH lookup using
process.env.PATH and fs.access) so execFileAsync('which', ...) is no longer
relied on; adjust the function and any callers (resolveOnPath, execFileAsync
usage) and add a brief comment noting cross-platform behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b99d12e-90cf-4983-8cc7-459bce2d84fc

📥 Commits

Reviewing files that changed from the base of the PR and between 802562c and 9f911eb.

📒 Files selected for processing (4)
  • packages/cli/src/appConfig.test.ts
  • packages/cli/src/appConfig.ts
  • packages/goal-executor/src/HeadlessActionExecutor.test.ts
  • packages/goal-executor/src/HeadlessActionExecutor.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/goal-executor/src/HeadlessActionExecutor.ts
  • packages/goal-executor/src/HeadlessActionExecutor.test.ts

Comment thread skills/generate-finalrun-test/SKILL.md Outdated

**App configuration (required):**
- FinalRun runs require `.finalrun/config.yaml` to define the default app identity for the repo.
- Use `app.android.packageName` for Android and `app.ios.bundleId` for iOS.
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.

We can read the codebase if they have different package name for different environments and do the setup.

Comment thread packages/cli/src/goalRunner.test.ts Outdated
const session = await prepareGoalSession(
{
platform: PLATFORM_ANDROID,
primaryApp: {
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.

we can simply call it app

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/goalRunner.ts (1)

301-309: ⚠️ Potential issue | 🟠 Major

Forward appKnowledge into the executor.

This call wires preContext and primaryAppIdentifier, but it drops the optional app knowledge carried on the resolved primary app. As written, the planner never receives appKnowledge, so part of the new precontext feature is silently inactive.

Suggested fix
     const executor = dependencies.createExecutor({
       goal: config.goal,
       platform: session.platform,
       maxIterations: config.maxIterations,
       agent: session.device,
       aiAgent,
       preContext: session.launchSummary,
+      appKnowledge: session.primaryApp?.appKnowledge,
       primaryAppIdentifier: session.primaryApp?.identifier,
       runtimeBindings: config.runtimeBindings,
     });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/goalRunner.ts` around lines 301 - 309, The executor is
created without forwarding the optional app knowledge from the resolved primary
app, so include the appKnowledge when calling dependencies.createExecutor: pass
the property (e.g. appKnowledge: session.primaryApp?.appKnowledge) alongside
preContext and primaryAppIdentifier so the planner receives the new precontext
data; update the createExecutor call site (where executor is built) to add the
appKnowledge field and ensure any downstream executor usage expects it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@openspec/changes/align-cli-app-precontext/design.md`:
- Around line 29-35: Update the "Non-Goals" and the related design/migration
text so they reflect that repo app identity is required (not `--app`-first) and
that config-backed rollout mandates a mandatory `.finalrun/config.yaml` with
environment-specific overrides in `.finalrun/env/<env>.yaml`; specifically,
replace any language saying primary-app resolution is `--app`-first or that
`.finalrun/config.yaml` support is out of scope with statements that the system
requires a repo-level app identity, documents how primary app is resolved from
that config, and describes migration guidance for converting existing `--app`
usage to the new mandatory `.finalrun/config.yaml` plus
`.finalrun/env/<env>.yaml` override pattern (also update the matching guidance
in the other referenced section around lines 113-126).

In
`@openspec/changes/align-cli-app-precontext/specs/cli-primary-app-context/spec.md`:
- Around line 3-18: Update the normative requirements so primary app context is
set not only when an explicit `--app` override is provided but also when a
repo-config app identity exists; revise the Scenario sections under "CLI run
resolves a primary app context for explicit app inputs" to (1) add a new
scenario describing that when `.finalrun/config.yaml` defines the app identity
(with optional environment-specific overrides in `.finalrun/env/<env>.yaml`),
the run SHALL resolve and store a primary app context containing platform,
user-facing label, source, and a launchable app identifier, and (2) modify the
"No explicit app input" scenario to clarify it applies only when neither `--app`
nor repo-config/app env overrides are present; ensure language uses normative
"SHALL" for repo-config behavior and references `.finalrun/config.yaml` and
`.finalrun/env/<env>.yaml` as valid sources of the primary app identity.

---

Outside diff comments:
In `@packages/cli/src/goalRunner.ts`:
- Around line 301-309: The executor is created without forwarding the optional
app knowledge from the resolved primary app, so include the appKnowledge when
calling dependencies.createExecutor: pass the property (e.g. appKnowledge:
session.primaryApp?.appKnowledge) alongside preContext and primaryAppIdentifier
so the planner receives the new precontext data; update the createExecutor call
site (where executor is built) to add the appKnowledge field and ensure any
downstream executor usage expects it.
🪄 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: Pro

Run ID: dff1663a-44a5-42ab-a1c3-2a4a39d285f8

📥 Commits

Reviewing files that changed from the base of the PR and between 9f911eb and b70bd70.

📒 Files selected for processing (9)
  • openspec/changes/align-cli-app-precontext/.openspec.yaml
  • openspec/changes/align-cli-app-precontext/design.md
  • openspec/changes/align-cli-app-precontext/proposal.md
  • openspec/changes/align-cli-app-precontext/specs/cli-primary-app-context/spec.md
  • openspec/changes/align-cli-app-precontext/tasks.md
  • packages/cli/bin/finalrun.ts
  • packages/cli/src/goalRunner.ts
  • packages/goal-executor/src/HeadlessActionExecutor.ts
  • packages/goal-executor/src/HeadlessGoalExecutor.ts
✅ Files skipped from review due to trivial changes (3)
  • openspec/changes/align-cli-app-precontext/.openspec.yaml
  • packages/cli/bin/finalrun.ts
  • openspec/changes/align-cli-app-precontext/tasks.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/goal-executor/src/HeadlessGoalExecutor.ts
  • packages/goal-executor/src/HeadlessActionExecutor.ts

Comment on lines +29 to +35
**Non-Goals:**

- Introduce a full multi-app orchestration system for YAML tests.
- Change YAML `setup:` into a separately executed setup phase.
- Add a UI/editor app registry.
- Make primary app context mandatory for all runs. Runs without a resolvable primary app should continue to work as they do now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Update the design scope to match the config-backed rollout.

This still describes primary-app resolution as --app-first and treats mandatory .finalrun/config.yaml support as out of scope. The PR objective is the opposite: repo app identity is required, with .finalrun/env/<env>.yaml overrides. Please rewrite these sections so the design and migration guidance match the behavior being shipped.

Also applies to: 113-126

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openspec/changes/align-cli-app-precontext/design.md` around lines 29 - 35,
Update the "Non-Goals" and the related design/migration text so they reflect
that repo app identity is required (not `--app`-first) and that config-backed
rollout mandates a mandatory `.finalrun/config.yaml` with environment-specific
overrides in `.finalrun/env/<env>.yaml`; specifically, replace any language
saying primary-app resolution is `--app`-first or that `.finalrun/config.yaml`
support is out of scope with statements that the system requires a repo-level
app identity, documents how primary app is resolved from that config, and
describes migration guidance for converting existing `--app` usage to the new
mandatory `.finalrun/config.yaml` plus `.finalrun/env/<env>.yaml` override
pattern (also update the matching guidance in the other referenced section
around lines 113-126).

Comment on lines +3 to +18
### Requirement: CLI run resolves a primary app context for explicit app inputs

When a CLI run includes an explicit primary app input, the system SHALL resolve a run-scoped primary app context that includes the platform, user-facing label, source, and a launchable app identifier such as package name or bundle identifier.

#### Scenario: App override resolves primary app identity

- **WHEN** a user runs `finalrun test` or `finalrun suite` with `--app <path>`
- **AND** the CLI successfully validates and installs that override
- **THEN** the run SHALL store a primary app context for the shared goal session
- **AND** that context SHALL include the resolved app identifier needed to launch the installed app again without relying on the override file path

#### Scenario: No explicit app input leaves primary app context unset

- **WHEN** a CLI run starts without an explicit primary app input
- **THEN** the system SHALL leave primary app context unset
- **AND** it SHALL preserve existing goal-execution behavior without bootstrap app launch
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

The requirements still exclude the mandatory repo-config flow.

These scenarios make primary app context depend on explicit --app input and say runs without it keep the context unset. That no longer matches the PR: .finalrun/config.yaml app identity is required, and .finalrun/env/<env>.yaml can provide environment-specific overrides. Please update the normative requirements so acceptance coverage includes the repo-config path, not just override-backed runs.

Also applies to: 67-75

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@openspec/changes/align-cli-app-precontext/specs/cli-primary-app-context/spec.md`
around lines 3 - 18, Update the normative requirements so primary app context is
set not only when an explicit `--app` override is provided but also when a
repo-config app identity exists; revise the Scenario sections under "CLI run
resolves a primary app context for explicit app inputs" to (1) add a new
scenario describing that when `.finalrun/config.yaml` defines the app identity
(with optional environment-specific overrides in `.finalrun/env/<env>.yaml`),
the run SHALL resolve and store a primary app context containing platform,
user-facing label, source, and a launchable app identifier, and (2) modify the
"No explicit app input" scenario to clarify it applies only when neither `--app`
nor repo-config/app env overrides are present; ensure language uses normative
"SHALL" for repo-config behavior and references `.finalrun/config.yaml` and
`.finalrun/env/<env>.yaml` as valid sources of the primary app identity.

@droid-ash droid-ash changed the title [codex] Require repo app config and prelaunch primary app [codex] Flatten app config and prelaunch configured app Apr 3, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/cli/src/finalrun.test.ts (1)

68-82: Tighten app: detection to avoid accidental false positives in test fixtures.

Line 77 uses /^app:/m, which can match unintended app: lines in multi-line scalar content. A stricter top-level key check (or lightweight YAML parse) would make fixture generation more deterministic.

Suggested tweak
-  if (/^app:/m.test(configYaml)) {
+  if (/^app:\s*$/m.test(configYaml)) {
     return configYaml;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/cli/src/finalrun.test.ts` around lines 68 - 82, In
buildWorkspaceConfigYaml the regexp /^app:/m can match “app:” inside multiline
scalar content; replace that loose check with a strict top-level key detection
by parsing only the first non-empty, non-comment line (or do a lightweight YAML
parse) to verify it equals "app:" (e.g., inspect the first left-aligned key
before any indentation) and only then return configYaml; otherwise append the
defaultAppConfig as before. Ensure changes reference buildWorkspaceConfigYaml
and preserve the existing null/undefined behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/cli/src/finalrun.test.ts`:
- Around line 68-82: In buildWorkspaceConfigYaml the regexp /^app:/m can match
“app:” inside multiline scalar content; replace that loose check with a strict
top-level key detection by parsing only the first non-empty, non-comment line
(or do a lightweight YAML parse) to verify it equals "app:" (e.g., inspect the
first left-aligned key before any indentation) and only then return configYaml;
otherwise append the defaultAppConfig as before. Ensure changes reference
buildWorkspaceConfigYaml and preserve the existing null/undefined behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4b100b30-2cc4-4c8e-b1a4-16c8468d56bd

📥 Commits

Reviewing files that changed from the base of the PR and between 6e7d195 and cb76c48.

📒 Files selected for processing (8)
  • packages/cli/src/appConfig.test.ts
  • packages/cli/src/appConfig.ts
  • packages/cli/src/finalrun.test.ts
  • packages/cli/src/testRunner.test.ts
  • packages/cli/src/workspace.test.ts
  • packages/common/src/index.ts
  • packages/common/src/models/RepoEnvironment.ts
  • skills/generate-finalrun-test/SKILL.md
✅ Files skipped from review due to trivial changes (3)
  • packages/common/src/models/RepoEnvironment.ts
  • packages/cli/src/appConfig.test.ts
  • packages/cli/src/appConfig.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/common/src/index.ts
  • skills/generate-finalrun-test/SKILL.md
  • packages/cli/src/workspace.test.ts

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
openspec/changes/archive/2026-04-03-align-cli-app-precontext/specs/cli-primary-app-context/spec.md (2)

67-75: ⚠️ Potential issue | 🟠 Major

Run-artifact requirements are incomplete for config/env-backed runs.

Line 71-Line 75 only specify override-backed artifact recording. The spec should also require recording resolved primary app identity when source is config/env, including source classification and resolved identifier fields, so artifacts match the new mandatory config flow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@openspec/changes/archive/2026-04-03-align-cli-app-precontext/specs/cli-primary-app-context/spec.md`
around lines 67 - 75, The spec currently only mandates recording resolved
primary app identity for override-backed runs (Scenario: Override-backed run
records resolved app identity); extend the requirement to also cover
config/env-backed runs by adding language that the run inputs artifact SHALL
record the app source classification (e.g., "config" or "env") and the resolved
app identifier used for primary-app launch behavior when the primary app is
determined from configuration or environment, either by adding a new scenario
(e.g., "Config/env-backed run records resolved app identity") or by generalizing
the existing requirement to enumerate all possible sources (override, config,
env) and the two required fields (source and resolved identifier).

3-18: ⚠️ Potential issue | 🟠 Major

Spec contradicts mandatory repo-config primary app resolution.

Line 3 and Line 14 still define primary app context as explicit---app-only behavior, and Line 16-Line 18 require context to remain unset without explicit input. That conflicts with the PR contract where .finalrun/config.yaml is mandatory and should resolve primary app context (with optional .finalrun/env/<env>.yaml replacement). Please add a normative config/env-backed scenario and narrow the “unset” case to only when neither CLI input nor repo/env config provides app identity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@openspec/changes/archive/2026-04-03-align-cli-app-precontext/specs/cli-primary-app-context/spec.md`
around lines 3 - 18, Update the spec to add a normative scenario where the repo
config resolves the primary app context: add a new "Scenario: Repo/env config
resolves primary app identity" that describes when .finalrun/config.yaml (and
optional .finalrun/env/<env>.yaml) exist the CLI SHALL derive the run-scoped
primary app context (platform, label, source, launchable identifier) from that
config without requiring --app, and ensure it is used for the shared goal
session; then narrow the existing "No explicit app input" scenario so it states
the primary app context is left unset only when neither an explicit --app nor a
repo/env config provides app identity. Reference the existing scenario headings
("Scenario: App override resolves primary app identity" and "Scenario: No
explicit app input leaves primary app context unset") when making these edits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@openspec/changes/archive/2026-04-03-align-cli-app-precontext/specs/cli-primary-app-context/spec.md`:
- Around line 67-75: The spec currently only mandates recording resolved primary
app identity for override-backed runs (Scenario: Override-backed run records
resolved app identity); extend the requirement to also cover config/env-backed
runs by adding language that the run inputs artifact SHALL record the app source
classification (e.g., "config" or "env") and the resolved app identifier used
for primary-app launch behavior when the primary app is determined from
configuration or environment, either by adding a new scenario (e.g.,
"Config/env-backed run records resolved app identity") or by generalizing the
existing requirement to enumerate all possible sources (override, config, env)
and the two required fields (source and resolved identifier).
- Around line 3-18: Update the spec to add a normative scenario where the repo
config resolves the primary app context: add a new "Scenario: Repo/env config
resolves primary app identity" that describes when .finalrun/config.yaml (and
optional .finalrun/env/<env>.yaml) exist the CLI SHALL derive the run-scoped
primary app context (platform, label, source, launchable identifier) from that
config without requiring --app, and ensure it is used for the shared goal
session; then narrow the existing "No explicit app input" scenario so it states
the primary app context is left unset only when neither an explicit --app nor a
repo/env config provides app identity. Reference the existing scenario headings
("Scenario: App override resolves primary app identity" and "Scenario: No
explicit app input leaves primary app context unset") when making these edits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 517408a0-4eb7-432f-8bfd-6cef0c105ae1

📥 Commits

Reviewing files that changed from the base of the PR and between cb76c48 and 55e4226.

📒 Files selected for processing (6)
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/.openspec.yaml
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/design.md
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/proposal.md
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/specs/cli-primary-app-context/spec.md
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/tasks.md
  • openspec/specs/cli-primary-app-context/spec.md
✅ Files skipped from review due to trivial changes (4)
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/.openspec.yaml
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/tasks.md
  • openspec/changes/archive/2026-04-03-align-cli-app-precontext/proposal.md
  • openspec/specs/cli-primary-app-context/spec.md

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants