Skip to content

Commit 54e2274

Browse files
authored
Merge pull request #3037 from lidge-jun/codex/promote-main-2370
[WRONG BRANCH] promote dev to main for the v2.37.0 release
2 parents c7d8407 + 4180067 commit 54e2274

60 files changed

Lines changed: 4527 additions & 78 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Dev version bump
2+
3+
# When a release publishes, open a pull request that moves `dev` past the published
4+
# version. Without this, `dev` keeps carrying a version that is at or behind a released
5+
# one, and `tests/release-version-line.test.ts` fails on `dev` and on every pull request
6+
# opened against it - inherited red a contributor cannot fix from their own diff.
7+
#
8+
# That has been repaired by hand four times: 32529c2b2, e4a85d134, 076ad3036, befcac3e1.
9+
# The second of those ADDED the detector and two more repairs followed it, so more
10+
# visibility was never the missing piece; a prepared change was.
11+
#
12+
# WHAT THIS DOES NOT DO. It does not push to `dev`. It opens a pull request and a human
13+
# merges it, because ruleset `Protect dev` requires an approving review and code-owner
14+
# sign-off that a bot cannot supply. Until that merge the red persists. This converts a
15+
# forgotten chore into a queued, reviewable change - not into an automatic repair.
16+
#
17+
# A `release` event resolves this workflow file from the repository DEFAULT branch
18+
# (`main`), not from `dev` - the same trap documented in cleanup-closed-pr-branches.yml.
19+
# So merging this file to `dev` installs it but arms nothing; it first fires after an
20+
# ordinary dev -> main promotion carries it there.
21+
#
22+
# There is deliberately no `workflow_dispatch`: a branch-selected manual run executes
23+
# THAT branch body with `contents: write`. Re-drive a missed run by running
24+
# `bun scripts/bump-dev-version.ts <released> package.json` locally and opening the pull
25+
# request normally.
26+
on:
27+
release:
28+
types: [published]
29+
30+
permissions: {}
31+
32+
concurrency:
33+
group: dev-version-bump
34+
cancel-in-progress: false
35+
36+
jobs:
37+
open-bump-pr:
38+
runs-on: ubuntu-latest
39+
permissions:
40+
# Push the new codex/dev-version-* branch. Ruleset `Protect dev` covers only
41+
# refs/heads/dev, so the bump branch is unprotected and this token cannot
42+
# bypass dev review. It is the ruleset that keeps this job off dev, not the
43+
# permission name.
44+
contents: write
45+
# Open the pull request.
46+
pull-requests: write
47+
steps:
48+
- name: Checkout dev
49+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
50+
with:
51+
ref: dev
52+
# Tags are load-bearing, not decoration: the freeness gate below is a bun
53+
# test that reads the local tag set, and release-version-line.test.ts
54+
# returns EARLY on an empty set. A shallow checkout would make that gate
55+
# silently vacuous instead of failing loudly.
56+
fetch-depth: 0
57+
# Do NOT set persist-credentials: false here as the read-only workflows do.
58+
# This job has to push its bump branch.
59+
60+
# The repository-owned composite action, not a hand-pinned setup-bun SHA: it
61+
# resolves the Bun version from package.json so the runtime SOT stays in one
62+
# place. An independently pinned action here would drift from every other job.
63+
- name: Setup project Bun
64+
uses: ./.github/actions/setup-project-bun
65+
66+
- name: Install dependencies
67+
run: bun install --frozen-lockfile
68+
69+
- name: Decide the version dev should carry
70+
id: decide
71+
env:
72+
RELEASED_VERSION: ${{ github.event.release.tag_name }}
73+
run: |
74+
set -euo pipefail
75+
bun scripts/bump-dev-version.ts "${RELEASED_VERSION}" package.json
76+
77+
- name: Prove the chosen version is unused
78+
if: ${{ steps.decide.outputs.changed == 'true' }}
79+
# The script decides the candidate from the released version SHAPE, which is all
80+
# a pure function can see. Whether that candidate is actually FREE is a property
81+
# of the tag set, so it is settled here by the detector that already owns the
82+
# question. If this fails, no pull request is opened and the job goes red asking
83+
# for a human decision - which is the correct outcome, not a fallback.
84+
run: bun test tests/release-version-line.test.ts
85+
86+
- name: Open the bump pull request
87+
if: ${{ steps.decide.outputs.changed == 'true' }}
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
NEXT_VERSION: ${{ steps.decide.outputs.version }}
91+
RELEASED_VERSION: ${{ github.event.release.tag_name }}
92+
run: |
93+
set -euo pipefail
94+
95+
branch="codex/dev-version-${NEXT_VERSION}"
96+
97+
# Idempotent: a second publish, a re-run, or a manual repair must not turn a
98+
# successful release into a red job.
99+
#
100+
# Check the PULL REQUEST as well as the branch, not just the branch. A security
101+
# review caught that: an open bump pull request whose head branch was deleted
102+
# leaves the branch check passing, so the job would recreate the branch and then
103+
# fail on `gh pr create` with "already exists" — turning a successful release red
104+
# for a repair that was already queued.
105+
open_prs="$(gh pr list --base dev --head "${branch}" --state open --json number --jq 'length')"
106+
if [ "${open_prs}" != "0" ]; then
107+
echo "::notice::a bump pull request for ${branch} is already open; nothing to do"
108+
exit 0
109+
fi
110+
111+
# An existing branch is NOT terminal. If a previous run pushed the branch and then
112+
# failed at `gh pr create`, exiting here would leave the repair permanently unqueued
113+
# while every rerun reports success - the exact failure mode a reviewer caught. So
114+
# reuse the branch and fall through to pull-request creation instead.
115+
if git ls-remote --exit-code --heads origin "${branch}" >/dev/null 2>&1; then
116+
echo "::notice::${branch} exists without an open pull request; validating it"
117+
git fetch origin "${branch}"
118+
119+
# Fail closed on unexpected content. The branch carries the bot's own one-line
120+
# bump, so anything else on it means a human or another job is using that name and
121+
# this job must not push to it or open a pull request from it.
122+
changed_files="$(git diff --name-only "origin/dev...origin/${branch}")"
123+
if [ "${changed_files}" != "package.json" ]; then
124+
echo "::error::${branch} touches unexpected files: ${changed_files:-<none>}"
125+
exit 1
126+
fi
127+
branch_version="$(git show "origin/${branch}:package.json" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version")"
128+
if [ "${branch_version}" != "${NEXT_VERSION}" ]; then
129+
echo "::error::${branch} carries ${branch_version}, expected ${NEXT_VERSION}"
130+
exit 1
131+
fi
132+
git checkout -B "${branch}" "origin/${branch}"
133+
else
134+
git config user.name "github-actions[bot]"
135+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
136+
git checkout -b "${branch}"
137+
git add package.json
138+
git commit -m "fix(release): move dev to ${NEXT_VERSION} after ${RELEASED_VERSION}"
139+
git push origin "${branch}"
140+
fi
141+
142+
gh pr create \
143+
--base dev \
144+
--head "${branch}" \
145+
--title "fix(release): move dev to ${NEXT_VERSION} after ${RELEASED_VERSION}" \
146+
--body "$(cat <<BODY
147+
## Summary
148+
149+
\`${RELEASED_VERSION}\` published, so \`dev\` would otherwise keep a version at or
150+
behind a released one and \`tests/release-version-line.test.ts\` would fail on
151+
\`dev\` and on every pull request opened against it. This moves \`dev\` to
152+
\`${NEXT_VERSION}\`.
153+
154+
Opened automatically by \`.github/workflows/dev-version-bump.yml\`. The same
155+
repair was previously done by hand in 32529c2b2, e4a85d134, 076ad3036, and
156+
befcac3e1.
157+
158+
## Verification
159+
160+
\`bun test tests/release-version-line.test.ts\` ran against this exact tree
161+
before the pull request was opened; the workflow refuses to open one if the
162+
chosen version collides with a published release.
163+
164+
## Checklist
165+
166+
- [x] Scope stays focused and avoids unrelated cleanup.
167+
- [x] Docs or release notes were updated when needed.
168+
- [x] Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
169+
BODY
170+
)"

‎MAINTAINERS.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ when a maintainer steps down.
7373
- Direct pushes are reserved for maintainer-owned integration work, urgent repairs, or incident
7474
recovery. The same CI and documentation requirements still apply.
7575
- Promotion from `dev` to `main` and npm releases is maintainer-controlled.
76+
- **Closing out a release includes moving `dev`'s version line forward.** A published
77+
release leaves `dev` carrying a version at or behind it, and
78+
`tests/release-version-line.test.ts` then fails on `dev` and on every pull request
79+
opened against it — red that contributors inherit and cannot fix from their own diff.
80+
This was repaired by hand four times (`32529c2b2`, `e4a85d134`, `076ad3036`,
81+
`befcac3e1`) before it was automated.
82+
83+
`.github/workflows/dev-version-bump.yml` now opens that bump as a pull request when a
84+
release publishes. Merging it is part of closing the release; a bot cannot, because
85+
`Protect dev` requires an approving review and code-owner sign-off. Two caveats worth
86+
knowing: the workflow runs from the DEFAULT branch, so it only fires once it has been
87+
promoted to `main`; and a pull request opened with `GITHUB_TOKEN` does not start
88+
`pull_request` workflows, so the bump pull request arrives without CI. To re-drive a
89+
missed run by hand: `bun scripts/bump-dev-version.ts <released-version> package.json`,
90+
then open the pull request normally.
7691

7792
## The retired `dev2-go` line
7893

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Kiro post-final-answer tool calls — measurement and root cause
2+
3+
Reported symptom, twice: routed through Kiro, the agent keeps issuing tool calls
4+
after its final response has already been delivered.
5+
6+
## Hosts measured
7+
8+
| Host | Proxy | Version | Checkout | Kiro attempt rows |
9+
| --- | --- | --- | --- | --- |
10+
| local (this machine) | PID 99470, port 10100 | 2.36.0 | primary source checkout | 4080 |
11+
| `macmini-cf` | PID 96671, port 10100 | 2.35.0 | `~/opencodex` | 0 |
12+
13+
`macmini-cf` carries no Kiro attempt diagnostics at all, so every behavioral
14+
row below comes from the local 2.36.0 proxy. The remote host is one release
15+
behind and is not the reporting surface.
16+
17+
## What the attempt rows say
18+
19+
`ocx:kiro:attempt_complete` over the local log, bucketed:
20+
21+
| Count | mode | sawText | sawRealTool | completionCalls | stopReason |
22+
| --- | --- | --- | --- | --- | --- |
23+
| 2643 | required | true | true | 0 | TOOL_USE |
24+
| 1400 | required | false | true | 0 | TOOL_USE |
25+
| 23 | required | true | false | 1 | TOOL_USE |
26+
| 10 | disabled | true | false | 0 | END_TURN |
27+
| 2 | required | false | false | 1 | TOOL_USE |
28+
| 1 | required | true | false | 0 | END_TURN |
29+
| 1 | text_fallback | false | false | 1 | TOOL_USE |
30+
31+
4069 of 4080 attempts ran in `required` mode and every one of them ended with
32+
upstream `stopReason: TOOL_USE`. Only 25 attempts ever called the private
33+
completion tool. The model overwhelmingly prefers another tool call to the
34+
completion channel.
35+
36+
## What is NOT the cause
37+
38+
Two candidate mechanisms were ruled out with evidence rather than reading.
39+
40+
Replayed history is not the cause. 532 client rollouts under
41+
`~/.codex/sessions/2026/08/{29,30}` were scanned for a `final_answer` message
42+
followed by a tool call with no intervening user turn. What actually follows a
43+
recorded `final_answer`: END 478, user message 131, developer message 5, tool
44+
call 0. The client never replays a post-answer tool call.
45+
46+
The delivered-answer local terminal is not broken. Two live probes against the
47+
running proxy replayed a closed turn — once with `phase: "final_answer"`
48+
echoed, once without it, matching real Codex traffic — and both returned
49+
`output: []` with `end_turn: true` and added zero upstream Kiro requests.
50+
The guard added in `b557a8140`/`68eaf45d8` works.
51+
52+
It has simply never been needed: `~/.opencodex/usage.jsonl` holds 25042 Kiro
53+
rows with zero `localTerminalReason` and zero `locallyAnswered`. Real turns
54+
never arrive already closed, because the client ends the turn itself. So the
55+
defect lives inside a live turn, not across turns.
56+
57+
## Rejected first hypothesis
58+
59+
The first diagnosis was that the model calls the completion tool, waits for a
60+
tool result that never arrives, and then calls another tool. An independent
61+
read-only audit refuted it with the parser: `flushOpen` consumes a valid
62+
completion call and records `completionAnswer` without emitting any tool-call
63+
event, the stream end yields the answer as `final_answer` followed by
64+
`done(endTurn: true)`, and `parseKiroStream` returns without another request.
65+
A completion call therefore terminates locally inside one inference; there is
66+
no later inference in which the model could "keep going". Mixed
67+
completion-plus-real-tool output in one inference also fails closed before any
68+
answer is delivered.
69+
70+
That refutation is correct, and it narrows the defect rather than dissolving it:
71+
the problem is not what happens AFTER a completion call, it is that the model
72+
mostly never makes one.
73+
74+
## Root cause
75+
76+
The private completion tool is advertised to the model as an ordinary tool.
77+
78+
A source probe (`buildKiroPayload` with an `exec`/`wait` catalog) renders the
79+
wire tool names as `["exec","wait","codex_kiro_final_answer"]` and injects:
80+
81+
> Valid tool names for this turn are exactly \`exec\`, \`wait\`,
82+
> \`codex_kiro_final_answer\`. These listed names are the complete top-level
83+
> tool-call surface for this turn.
84+
85+
That sentence comes from the shared, provider-agnostic nudge in
86+
`src/adapters/tool-catalog-nudge.ts`, which knows nothing about completion
87+
semantics. It cannot distinguish the proxy's private terminal channel from
88+
`exec`, and the same nudge closes with:
89+
90+
> Count a tool call only after its tool result returns.
91+
92+
`KIRO_COMPLETION_INSTRUCTIONS` is the only text that describes the completion
93+
tool, and it never contradicts that:
94+
95+
> When tools are available, ordinary assistant text is mid-task commentary and
96+
> does not end the turn. Continue using tools after progress updates. When the
97+
> task is fully complete and no more tool calls are needed, call
98+
> `codex_kiro_final_answer` exactly once with the complete user-facing final
99+
> answer in `answer`. Do not provide the final answer as ordinary assistant
100+
> text.
101+
102+
Every sentence there is about WHEN to call it. Nothing marks it as different in
103+
kind from `exec`, and nothing states what happens after. So the model holds a
104+
contract in which the terminal channel is one more ordinary tool it may defer
105+
while it keeps working — and the generic nudge's "count a tool call only after
106+
its tool result returns" applies to it as uniformly as to everything else.
107+
108+
The failure that follows is one of SELECTION, not sequencing. Across 4069
109+
required-mode attempts the completion tool was chosen 25 times: 0.6%. The model
110+
keeps emitting finished prose as commentary and calling ordinary tools instead
111+
of completing through the channel built for it.
112+
113+
That is what the user sees. Measured over 1116 Kiro turns in the same two days
114+
of client rollouts: 626 turns ended through the completion channel, 462 ended
115+
on a tool call, and 28 ended with answer-shaped commentary prose and no
116+
completion call at all. Those 28 are answers the model had already finished
117+
writing — they open with "Done.", "완료", "머지까지 끝났습니다", "All ten items are
118+
done" — delivered as mid-task commentary, which by the proxy's own contract
119+
"does not end the turn". Three of them are followed by 4, 10, and 12 further
120+
tool calls after the closing summary was already on screen.
121+
122+
The missing terminal distinction is the leading mechanism behind that measured
123+
selection failure: the terminal channel is advertised as an ordinary, deferrable
124+
tool, and nothing tells the model that this is the one call that ends the turn.
125+
It is a defect in the proxy's own injected text, not a client bug and not a
126+
stream-parsing bug. Causality is not claimed as proven — establishing it
127+
requires a live post-change comparison of the same selection rate, which this
128+
unit records as the follow-up measurement rather than asserting up front.
129+
130+
## Fix direction
131+
132+
State terminal semantics where the model reads them: calling the completion
133+
tool ENDS the turn, returns no tool result, and nothing may follow it. The
134+
completion tool's own schema description is the load-bearing site — it travels
135+
with the tool the nudge enumerates — with the prose contract kept consistent.
136+
137+
Removing the tool from the enumeration is not an option: the nudge states that
138+
names mentioned only in instructions are not callable, so an unlisted
139+
completion tool would be a tool the model is told not to call.

0 commit comments

Comments
 (0)