Skip to content

Run security upgrades through Codex and Claude - #98563

Closed
devjiwonchoi wants to merge 4 commits into
jiwon/agent-upgrade/setupfrom
jiwon/agent-upgrade/workflow
Closed

devjiwonchoi wants to merge 4 commits into
jiwon/agent-upgrade/setupfrom
jiwon/agent-upgrade/workflow

Conversation

@devjiwonchoi

@devjiwonchoi devjiwonchoi commented Sep 11, 2026

Copy link
Copy Markdown
Member

Stacked on #98562.

Why?

An agent working in a Next.js app needs one command that determines whether a security upgrade is necessary and supplies durable migration guidance. A user running that command from a terminal needs background execution with an actionable session receipt.

How?

Expose next upgrade --agent through the prepared resolver and resource packet. Hand instructions back to an existing Codex or Claude session, or select an installed harness and launch detached Codex execution or Claude's native background mode. New workers use Luna or Haiku; existing sessions retain their model.

Add --dry-run to stop after migration, verification and local commits, with no push or PR. Receipts provide session, logs, stop and continuation instructions; Codex continuation requires its active writer to finish or stop. Preserve the legacy non-agent command behavior and keep selection/launcher unit tests with the implementation.

The migration eval suite is tracked separately in #98566 against a fixed implementation snapshot. This layer adds no next dev trigger, adoption skills or eval CI automation.

@devjiwonchoi
devjiwonchoi added this pull request to stack #98564 September 11, 2026 13:22
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Failing test suites

Commit: 83a9715 | About building and testing Next.js

pnpm test-dev test/development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts (job)

  • instant-nav-panel > SPA captures > should capture when CookieStore writes are not reflected in document.cookie (DD)
  • instant-nav-panel > SPA captures > should show loading skeleton during SPA navigation after clicking Start (DD)
Expand output

● instant-nav-panel › SPA captures › should capture when CookieStore writes are not reflected in document.cookie

locator.waitFor: Timeout 60000ms exceeded.
Call log:
  - waiting for locator('[data-testid="dynamic-skeleton"]') to be visible

  278 |     await browser
  279 |       .locator('[data-testid="dynamic-skeleton"]')
> 280 |       .waitFor({ state: 'visible' })
      |        ^
  281 |     await browser
  282 |       .locator('[data-testid="param-skeleton"]')
  283 |       .waitFor({ state: 'visible' })

  at waitFor (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:280:8)
  at Object.expectTargetPageSpaShell (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:607:13)

● instant-nav-panel › SPA captures › should show loading skeleton during SPA navigation after clicking Start

locator.waitFor: Timeout 60000ms exceeded.
Call log:
  - waiting for locator('[data-testid="dynamic-skeleton"]') to be visible

  624 |       await browser
  625 |         .locator('[data-testid="dynamic-skeleton"]')
> 626 |         .waitFor({ state: 'visible' })
      |          ^
  627 |       expect(
  628 |         await browser.locator('[data-testid="dynamic-content"]').count()
  629 |       ).toBe(0)

  at Object.waitFor (development/app-dir/instant-navs-devtools/instant-navs-devtools.test.ts:626:10)

pnpm test-start-turbo test/production/next-server-nft/next-server-nft.test.ts (turbopack) (job)

  • next-server-nft > with output:standalone > should not trace too many files in next-server.js.nft.json (DD)
Expand output

● next-server-nft › with output:standalone › should not trace too many files in next-server.js.nft.json

expect(received).toMatchInlineSnapshot(snapshot)

Snapshot name: `next-server-nft with output:standalone should not trace too many files in next-server.js.nft.json 1`

- Snapshot  - 0
+ Received  + 7

@@ -227,10 +227,17 @@
    "/node_modules/next/dist/lib/typescript/runTypeCheckCli.js",
    "/node_modules/next/dist/lib/typescript/runTypeScriptCli.js",
    "/node_modules/next/dist/lib/typescript/type-paths.js",
    "/node_modules/next/dist/lib/typescript/writeAppTypeDeclarations.js",
    "/node_modules/next/dist/lib/typescript/writeConfigurationDefaults.js",
+   "/node_modules/next/dist/lib/upgrade/codex.js",
+   "/node_modules/next/dist/lib/upgrade/harness.js",
+   "/node_modules/next/dist/lib/upgrade/models.js",
+   "/node_modules/next/dist/lib/upgrade/receipt.js",
+   "/node_modules/next/dist/lib/upgrade/resolve.js",
+   "/node_modules/next/dist/lib/upgrade/resources.js",
+   "/node_modules/next/dist/lib/upgrade/security.js",
    "/node_modules/next/dist/lib/url.js",
    "/node_modules/next/dist/lib/verify-partytown-setup.js",
    "/node_modules/next/dist/lib/verify-root-layout.js",
    "/node_modules/next/dist/lib/verify-typescript-setup.js",
    "/node_modules/next/dist/lib/wait.js",

  130 |         ]
  131 |
> 132 |         expect(traceGrouped).toMatchInlineSnapshot(`
      |                              ^
  133 |          [
  134 |            "/node_modules/@img/colour/*",
  135 |            "/node_modules/@img/sharp-<PLATFORM>-<ARCH>/*",

  at Object.toMatchInlineSnapshot (production/next-server-nft/next-server-nft.test.ts:132:30)

Other failing CI jobs

@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/workflow branch from a43c8e1 to 3a464f7 Compare September 11, 2026 13:28
@devjiwonchoi
devjiwonchoi removed this pull request from stack #98564 September 11, 2026 13:31
@devjiwonchoi
devjiwonchoi added this pull request to stack #98567 September 11, 2026 13:31
@devjiwonchoi devjiwonchoi changed the title jiwon/agent upgrade/workflow Run security upgrades through Codex and Claude Sep 11, 2026
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/setup branch from 7e72fc9 to dd858a0 Compare September 11, 2026 14:16
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/workflow branch from 3a464f7 to 4502a77 Compare September 11, 2026 14:16
@devjiwonchoi
devjiwonchoi removed this pull request from stack #98567 September 11, 2026 14:32
@devjiwonchoi
devjiwonchoi added this pull request to stack #98572 September 11, 2026 14:33
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/workflow branch from 4502a77 to ef8beae Compare September 11, 2026 14:43
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/setup branch from dd858a0 to a8faf6d Compare September 11, 2026 14:43
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/workflow branch from ef8beae to 0e34422 Compare September 11, 2026 14:55
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/setup branch from a8faf6d to 64be173 Compare September 11, 2026 14:55
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/workflow branch from 0e34422 to 3dda56d Compare September 11, 2026 15:02
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/setup branch from 64be173 to 02315c3 Compare September 11, 2026 15:02
An upgrade agent needs an exact safe destination and compatible execution
arguments before it starts editing. Merely choosing the newest release can
introduce an unnecessary major upgrade, and a failed advisory lookup must not
be interpreted as proof that the application is safe.

Add experimental.agenticAutoUpgrade: security and a reusable resolver for the
selected app, installed Next.js, reviewed GitHub advisories and npm advisory
fallback. Choose the latest stable release in the first eligible safe major,
resolve pinned codemod arguments with adoption disabled, and report actionable
blockers. Exit before config evaluation or network access when the selected
directory has no supported Next.js config. Unit tests cover target selection
and failures. This commit prepares the library; command exposure follows later.
Updating Next.js can replace its installed documentation before an agent has
finished resolving codemod leftovers. The agent also needs the original app
state and security evidence to verify what changed and avoid duplicate work.

Prepare a retained context packet with baseline hashes, resolved versions,
advisory evidence and relevant canonical guides. Preserve guide paths and
source provenance, and package workflow instructions for prerequisite checks,
codemods, contextual repairs, supported verification and commit checkpoints.
Carry the dry-run delivery limit through the packet so local validation ends
before publication. Test selection, retention and failed-preparation cleanup;
this layer does not yet expose the command or launch an agent.

Keep the types with the security, resolution and resource modules that own them,
rather than maintaining a separate shared types file.

Bundle the experimental workflow guides through the existing docs pipeline,
mark them as drafts, and retain copies before replacing the installed package.
An agent already working in a Next.js app needs a single entrypoint that checks
whether a security upgrade is necessary and supplies durable migration guidance.
Launching another agent in that situation would lose the current task context.

Connect next upgrade --agent to security resolution and resource preparation.
Return early for disabled, unnecessary or blocked upgrades, then hand the packet
to the detected Codex or Claude session. Preserve the caller's environment and
the legacy non-agent upgrade path. Add --dry-run for migration, verification and
local commits without publication, and refuse that flag without --agent.
The next checkpoint adds ordinary-terminal launch support.
A human invoking next upgrade should be able to delegate an eligible migration
and return to the terminal. Opening an interactive foreground session defeats
that workflow, and suggesting live attachment to a running Codex writer fails.

Discover Codex and Claude, reuse the CLI picker when both are installed, and
launch detached Codex exec or Claude's native background mode. Select Luna for
new Codex workers and Haiku for new Claude workers to match the baseline evals.
Return session, logs, stop and continuation information with actionable launch
errors. Existing-agent handoff retains its current model. Codex continuation
requires the original writer to finish or stop; its link is not live attachment.
Cover selection, launch failures, exit propagation and Claude receipt handling.
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/workflow branch from 3dda56d to 83a9715 Compare September 11, 2026 15:27
@devjiwonchoi
devjiwonchoi force-pushed the jiwon/agent-upgrade/setup branch 2 times, most recently from 6c80ab4 to 8d37a7e Compare September 11, 2026 15:54
@devjiwonchoi
devjiwonchoi removed this pull request from stack #98572 September 11, 2026 15:54
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.

1 participant