Skip to content

[codex] Branch 9N OpenCode result report model#103

Merged
Ian747-tw merged 9 commits into
mainfrom
redesign/branch9n-opencode-result-report-model
Jul 8, 2026
Merged

[codex] Branch 9N OpenCode result report model#103
Ian747-tw merged 9 commits into
mainfrom
redesign/branch9n-opencode-result-report-model

Conversation

@Ian747-tw

@Ian747-tw Ian747-tw commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds durable OpenCode result-report records for one launched OpenCode session.
  • Supports preview, dry-run, record, list, show, latest, and summary surfaces across runtime, TUI, fake runtime, and E2E.
  • Records executor result evidence only; it does not accept results, complete missions, ingest research, create checkpoints, or prompt/control OpenCode.

Result report model

  • Adds bounded result kinds: completion_report, partial_report, failure_report, inconclusive_report, blocked_report, status_report, and unknown.
  • Maps report kinds to report-only dispositions such as reported_done, reported_partial, and reported_failed.
  • Stores changed files, tests, test results, artifacts, metrics, claims, known failures, follow-ups, confidence, and linked evidence IDs as bounded previews.

Result disposition/review-state behavior

  • Completion, partial, failure, inconclusive, and blocked reports require Commander or human review.
  • status_report defaults to review_not_required, unless an explicit review queue is requested.
  • Accepted/rejected review states are blocked because result acceptance belongs to a future branch.

Launch/progress/evidence anchoring behavior

  • Preview/record requires a resolvable planned session and 9D launch in launch_started or launched state.
  • Optional 9E/9F/9G/9H/9I/9L/9M links are validated against the same session/launch chain.
  • Progress completion/failure evidence can provide bounded defaults where appropriate.

Preview/dry-run/record/list/latest/summary behavior

  • Preview/list/get/latest/summary are read-like and do not auto-start runtime/OpenCode.
  • Dry-run uses the same validation path and appends no events.
  • Non-dry record appends one bounded opencode_result_report_recorded event through the metadata write path.

Duplicate behavior

  • Multiple distinct result reports are allowed over time.
  • Exact duplicate report hashes for the same session/launch are blocked, including dry-run.
  • Duplicate detection scans durable records beyond the public list cap.

Event persistence/redaction behavior

  • Events are persisted to .nxl/events.jsonl with bounded/redacted payloads.
  • Payloads exclude raw logs, full diffs, file contents, raw OpenCode output, provider output, full event logs, research.db dumps, prompt transcripts, checkpoint payloads, and mission mutation payloads.

Fake-vs-real runtime behavior

  • Fake runtime supports deterministic preview, dry-run, record, duplicate handling, list/show/latest/summary, and fake linked progress defaults.
  • Neither fake nor real result-report paths launch OpenCode, prompt OpenCode, call providers, write research.db, or mutate missions.

Runtime commands/API surface

  • runtime.preview_opencode_result_report
  • runtime.record_opencode_result_report
  • runtime.list_opencode_result_reports
  • runtime.get_opencode_result_report
  • runtime.latest_opencode_result_report
  • runtime.opencode_result_report_summary

TUI result-report surface

  • Adds /opencode-result-report-preview, /opencode-result-report-dry-run, /opencode-result-report, /opencode-result-reports, /opencode-result-report-latest, /opencode-result-report-show, and /opencode-result-report-summary.
  • Adds aliases /result-report-preview, /result-report-dry-run, /result-report, /result-reports, /result-report-latest, and /result-report-summary.
  • Renders the OpenCode result reports section with evidence links, review state, false side-effect flags, and explicit out-of-scope notes.

No-mission-completion guarantee

  • Result reports are executor evidence only.
  • mission_mutated=false is persisted and rendered.
  • No mission/session completion, success, failure, proposal, review, or apply mutation is performed.

No-researchdb-ingestion guarantee

  • research_db_written=false and checkpoint_created=false are persisted and rendered.
  • No research findings are ingested or promoted.
  • No checkpoint or result-review acceptance event is created.

No-provider/no-OpenCode-prompt/no-process-control guarantees

  • Result-report commands do not call MiniMax or any provider.
  • They do not call MCPs or online research.
  • They do not send prompts to OpenCode, launch additional sessions, or pause/resume/stop/kill processes.

Authority registry update

  • Adds safe-read authority records for preview/dry-run/list/latest/show/summary commands.
  • Adds metadata-write authority for /opencode-result-report and /result-report.
  • Authority notes state result reports are metadata only and do not complete missions, ingest research, call providers, prompt OpenCode, control processes, mutate mission/proposal/review/apply records, or create checkpoints.

Targeted validation output

cd agentcore/runtime && bun test && bun run typecheck
624 pass
0 fail
4835 expect() calls
Ran 624 tests across 2 files. [45.50s]
$ tsc --noEmit

cd agentcore/tui && bun test && bun run typecheck
274 pass
0 fail
3629 expect() calls
Ran 274 tests across 7 files. [5.42s]
$ tsc --noEmit

uv run pytest tests/integration/cli/test_tui_launcher.py tests/integration/cli/test_tui_entrypoint.py -q
.......                                                                  [100%]
7 passed in 1.24s

uv run pytest tests/e2e_user/scenarios/test_opencode_result_report_tui.py -q
.                                                                        [100%]
1 passed in 78.18s (0:01:18)

uv run pytest tests/e2e_user/scenarios/test_command_authority_inventory_tui.py -q
.                                                                        [100%]
1 passed in 111.85s (0:01:51)

uv run pytest tests/e2e_user/scenarios/test_opencode_wake_action_execution_tui.py tests/e2e_user/scenarios/test_opencode_progress_heartbeat_tui.py tests/e2e_user/scenarios/test_opencode_wake_supervisor_execution_tui.py -q
...                                                                      [100%]
3 passed in 194.62s (0:03:14)

Full regression status

  • Full historical E2E was not run; this branch did not broadly change runtime-client lifecycle, adapter startup/shutdown, process management, shared event-store behavior, research backend storage/projection behavior, or scheduler/wake execution beyond the result-report metadata surface.
  • OpenCode adapter smoke was not run because adapter startup/shutdown and live process-control code were not touched.

Secret/redaction behavior

  • Secret-looking report, outcome, metric, artifact, and evidence text is redacted before state, snapshot, and event persistence.
  • Raw logs, full diffs, file contents, provider output, raw OpenCode output, full event logs, and research.db dumps are blocked.

Explicit out-of-scope list

  • Commander result review, result acceptance/rejection, research.db writes/ingestion, research promotion, mission/proposal/review/apply mutation, checkpoint creation, provider calls, MCP/online research, OpenCode prompts, process control, automatic wake action execution, raw diff parsing, artifact upload/storage, result approval gates, and follow-up mission creation.

Notes about Branch 9O Commander result review gate

  • 9N intentionally leaves every completion/partial/failure/inconclusive/blocked report in a review-needed state.
  • 9O should add the explicit Commander/human result review gate that can inspect these reports and decide acceptance/rejection without overloading the result-report metadata event.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f050dd38ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

private async findDuplicate(reportHash: string, sessionId: string, launchId?: string): Promise<OpenCodeResultReportRecord | undefined> {
return (await this.list({ session_id: sessionId, launch_id: launchId, limit: MAX_LIST })).find((record) => record.report_hash === reportHash)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scan all prior reports when deduplicating

When a session/launch has more than 100 result reports, this duplicate check only searches the capped public list, so an identical older report outside the latest 100 records is no longer found and can be appended again. Since result reports are durable executor evidence for later Commander review, duplicate prevention should scan the uncapped event projection for the matching session/launch hash rather than reusing the display limit.

Useful? React with 👍 / 👎.

Comment on lines +325 to +326
wake_execution_id: optional(input.wakeExecutionId ?? input.wake_execution_id ?? input.wake_execution),
wake_action_execution_id: optional(input.wakeActionExecutionId ?? input.wake_action_execution_id ?? input.wake_action),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3 Badge Honor advertised wake aliases in report input

The runtime client overload advertises wakeExecution and wakeAction as accepted payload aliases, but these reader lines only consume the *Id, snake_case, and lower snake aliases. API callers that supply only wakeExecution or wakeAction therefore get their linked evidence dropped and a preview/record can be blocked as missing session/launch even though the referenced wake record exists.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09210bd7d2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const resultKind = readResultKind(input.result_kind, evidence.progress?.kind)
const disposition = dispositionForKind(resultKind)
const reviewState = readReviewState(input.review_state, defaultReviewState(resultKind), blockers)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require Commander review for terminal reports

When an operator supplies reviewState=review_not_required with kind=completion_report (or partial/failure/inconclusive/blocked), this call accepts the override and can_record can still remain true. Those non-status result reports are supposed to be executor evidence awaiting Commander review, so persisting them as review_not_required lets later review consumers miss exactly the terminal reports they need to adjudicate.

Useful? React with 👍 / 👎.

Comment thread agentcore/tui/src/runtime-effects.ts Outdated
} else throw new Error("OpenCode result report arg is unsupported")
}
if (!effect.sessionId && !effect.launchId && !effect.progressId && !effect.watchdogId && !effect.questionId && !effect.guidanceId && !effect.deliveryId && !effect.wakeExecutionId && !effect.wakeActionExecutionId) throw new Error("OpenCode result report requires session=<id>, launch=<id>, or linked evidence")
if (requireSummary && !effect.summary) throw new Error("OpenCode result report requires summary=<text>")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Allow progress-linked reports to use progress summaries

For /opencode-result-report and dry-run commands with only linked progress evidence, this parser throws before the runtime can apply its bounded defaults from the progress record. A user with a completion/failure progress record cannot run /opencode-result-report progress=<id> even though the runtime model supports linked progress supplying omitted report fields, so the TUI/headless surface does not actually mirror the runtime API for that advertised flow.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8163d5825

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +170 to +171
const reviewState = readReviewState(input.review_state, defaultReviewState(resultKind), blockers)
if (resultKind !== "status_report" && reviewState === "review_not_required") blockers.push("terminal OpenCode result reports require Commander or human review")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep terminal reports in review queues

When a caller supplies reviewState=unknown or reviewState=not_ready_for_review for a non-status report, readReviewState accepts it and this guard only rejects review_not_required, so a completion/failure/partial report can be recorded without needs_commander_review or needs_human_review. That breaks the terminal-report disposition model and causes opencode_result_report_summary to omit the report from review counts.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: f49b6f89a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

1 similar comment
@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19ec98627c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +154 to +156
if (!launch && sessionId) {
const launches = await this.options.launchGateService.list({ session_id: sessionId, limit: MAX_LIST })
launch = launches.find((item) => LAUNCHED_STATUSES.has(item.status)) ?? launches[0] ?? null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve the latest launch status before accepting reports

When callers provide only session_id, this selects a launch_started record directly from launchGateService.list(). A failed launch writes both a start event and a later failure event, and the public list can still contain the stale launch_started record for that same launch; in that case the preview/record path treats the session as active and allows a result report even though launchGateService.get(launch_id) would return launch_failed. This should re-resolve the chosen launch id through get() (as the other OpenCode metadata services do) before applying LAUNCHED_STATUSES.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d71e5ba03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agentcore/tui/src/runtime.ts Outdated
}

function fakeResultReviewState(input: string | undefined, kind: string): string {
if (input === "needs_commander_review" || input === "needs_human_review" || input === "not_ready_for_review" || input === "review_not_required" || input === "unknown") return input

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Block non-review terminal states in fake reports

When the default fake TUI runtime is used, a terminal command such as /opencode-result-report kind=completion_report review_state=review_not_required ... is accepted because the fake model returns any recognized review state here and only blocks accepted/rejected later. The real result-report service blocks terminal reports unless they are queued for Commander or human review, so the default TUI can record a completion/failure report as review_not_required, bypassing the review-needed safety contract and diverging from real runtime behavior.

Useful? React with 👍 / 👎.

Comment thread agentcore/tui/src/runtime.ts Outdated
if (resultKind === "inconclusive_report" && !outcome && followups.length === 0 && knownFailures.length === 0) blockers.push("inconclusive_report requires outcome, followups, or known_failures")
if (resultKind === "blocked_report" && followups.length === 0 && knownFailures.length === 0) blockers.push("blocked_report requires followups or known_failures")
if (String(payload.reviewState ?? payload.review_state ?? "").match(/accepted|rejected/i)) blockers.push("accepted/rejected review states belong to a future Commander result review gate")
const rawValues = [summary, outcome, ...changedFiles, ...testsRun, ...testResults, ...artifacts, ...metrics, ...claims, ...knownFailures, ...followups].filter(Boolean).join("\n")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check fake raw payloads before truncating them

In the fake runtime path, summary and the CSV fields have already gone through preview()/readCsvPayload() before this raw-payload check, so a long log or full diff with markers past the first 160 characters is truncated and can be recorded instead of blocked. Since the real runtime rejects raw result payloads, the default TUI fake client accepts out-of-scope report data and can let user-simulation coverage miss the production validation.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

1 similar comment
@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6e7c27338

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +160 to +162
if (sessionId) {
const session = await this.options.opencodeSessionService.get(sessionId)
if (!session) blockers.push("session_id does not resolve to a planned OpenCode session")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate launch-derived sessions before recording

When callers provide only launch_id/launch=<id>, sessionId is still empty here, so the planned-session lookup is skipped; the code then copies launch.session_id later and can record a result report for any orphan/restored/corrupt launch event whose session plan is missing. Since this feature's contract requires a resolvable planned OpenCode session as well as a launch, derive the session from the launch before this check or re-run the session validation after line 166.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

1 similar comment
@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 310ea5e912

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const LAUNCHED_STATUSES = new Set(["launch_started", "launched"])
const RAW_PATTERNS = [
/\n.{100,}\n.{100,}/s,
/(stdout|stderr|traceback|stack trace|bun test v|npm error|diff --git|@@ |\+\+\+ |--- ).{0,120}\n/i,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Block all advertised raw payload markers

When a result summary/outcome contains a short provider output, file contents, events.jsonl, or research.db snippet, this regex does not mark it as raw, so /opencode-result-report can persist exactly the payloads the blocker text says are out of scope. The human-control service already blocks these keyword classes; without the same coverage here, bounded-looking raw provider/file/event data can be recorded into opencode_result_report_recorded events instead of being rejected.

Useful? React with 👍 / 👎.

@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

1 similar comment
@Ian747-tw

Copy link
Copy Markdown
Owner Author

@codex review the Branch 9N OpenCode result report model

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 96631b0658

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Ian747-tw Ian747-tw merged commit 57e1783 into main Jul 8, 2026
2 checks passed
@Ian747-tw Ian747-tw deleted the redesign/branch9n-opencode-result-report-model branch July 8, 2026 16:38
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