Skip to content

fix(environment): bound create learning and invalidate stale write proofs - #6929

Merged
gensokyo-dev merged 49 commits into
morluto:mainfrom
earakely-scale:feat/environment-build
Oct 24, 2026
Merged

gensokyo-dev merged 49 commits into
morluto:mainfrom
earakely-scale:feat/environment-build

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Create learning buffered future requests to relax guards, although request variation cannot rebuild copied dependent references or state. Withdrawn array-sorting rules also left stale write confirmations or snapshot overrides.

  • Lease the current parsed request, remove variation lookahead, and keep unsupported dependent values pinned.
  • Retire inconsistent read views with their confirmations and snapshot overrides. Continue checking later observations for value contradictions without restoring serving proof; distinguish changed values from array order.
  • Preserve the shared CLI/MCP report and complete retained-event scan already integrated through feat(environment): build agent environments from a prompt #6946, with duplicate-content regression coverage.

Verification

Final head: a6c145a21468224a915f73c27af028fbc454a1e5, preserving all author updates. Local: 1,353 source cases; 46 CLI/MCP/process cases with five platform skips; static/typecheck/module boundaries, architecture, docs and packaged build passed. The unchanged SDK/schema contracts passed 16 cases at fc8176694 after regenerating stale test metadata.

Greptile passed; no unresolved review threads. CI passed 18,159 source cases (13 skipped), static/docs/package/Windows-controls builds, Linux native-package baseline and the actual agentenv runner.

Unrelated CI failure: PR shard 2 has the same two Windows-path error-category assertions as main 798450638 shard 2. Normalized failure sections are byte-identical; test blob and PR ownership scope are unchanged. Seven other shards were cancelled by fail-fast and remain unverified in this run. The user explicitly authorized bypassing confirmed unrelated main failures.

Current-head real workflows:

  • Four pinned public recordings (NocoDB, Ghost, Metabase, Mailpit): generated-bundle HTTP MCP completed 412 SDK calls with shared-engine-equivalent outcomes. Recorded read bodies match in 302/358 comparisons, preserving known recording/model limits. Original third-party apps were not rerun.
  • Real Chromium → owned SQLite HTTP app → one-command bundle → HTTP MCP: seven successful native response bodies and an atomic missing-target refusal matched an independently reset database.
  • Actual browser-scenario CLI → build CLI with an untyped URL-encoded request: three credential-name pointers, byte-identical Evidence copy, verified owned-browser cleanup.
  • Three write regressions fail at frozen 0895c89bc; the later-retired-observation regression fails at fc8176694 and passes at this head.

Post-merge 41cf869949b82bd0f24d425f6557432ae3a63545: rebuilt the actual merged runtime and bundles. All four recordings retained identical write plans and per-record read/write outcomes; generated-bundle HTTP MCP and independent Chromium/SQLite qualification passed again.

Measured workflow costs

Three alternating rounds per input, 15 matched pairs; complete bundles were byte-identical. Evidence workflows take two CLI calls → one; HAR takes three → one. One-CPU medians:

Input Elapsed seconds CPU seconds Peak process-family MiB
NocoDB 6.26 → 3.45 6.06 → 3.28 416.1 → 418.7
Ghost 5.97 → 3.65 5.80 → 3.41 420.8 → 424.4
Metabase 6.37 → 4.15 6.21 → 3.90 430.0 → 429.7
Mailpit 5.56 → 3.24 5.37 → 3.01 413.8 → 416.3
NativeSQLite 8.18 → 3.75 7.91 → 3.43 399.1 → 402.9

Fresh CLI processes; OS caches uncontrolled; persistent-process warm runs unmeasured. Includes orchestration/hashing, excludes install/download/package preparation. These compare equivalent workflows on the same implementation. Payload-exit counters and cleanup verified; final whole-scope counters unavailable. Maximum build-workflow peak: 433.7 MiB; no general memory-saving claim.

cl100k_base estimates: coverage replies 1,892–2,031 tokens versus full state 8,907–64,282, preserving parent/artifact/coverage/unknowns and retained Evidence. Already-redirected workflows' arguments + final stdout increase from 521–591 to 630–986 tokens because build reports include coverage/warnings. No blanket token-saving claim: actual model usage, schemas, prompts, orchestration and retries are outside that estimate. The affected SDK entry separately measures 114,557 tokens (20,088 for name/description/input).

Author readiness

Human owner: @earakely-scale

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

earakely-scale and others added 8 commits October 23, 2026 16:33
…ent-coverage view

A new inspect_analysis_view kind over capture Evidence. It projects the
state an environment derives with the given template rules and reports
each tool as answered from state, replayed with its view reason, a served
write, or a withheld write with its reason, the records behind it and a
hint about what to record next. The hints cover every write reason, so a
new reason without one fails to compile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rea environment-build <capture> [directory] inspects a HAR (or reads
capture Evidence), projects the environment manifest from the in-memory
Evidence, authenticates the pair, prepares the state and writes the bundle
environment-export writes. Every bundle file is byte-identical to the
three-step path for the same capture and options.

The report adds the capture and manifest identities, the coverage summary,
warnings (a loopback capture named after its file, credential-named body
members by pointer) and the next command. --dry-run writes nothing. The
default template rules are the four the published environments use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Domain tests check the hint table against the state view's reasons, the
summary, and the view against the environment-state view it summarizes.
Service tests build the fixture capture and compare every file with the
three-step path, a dry run, loopback naming and the refusals. A CLI test
compares a HAR built in one step with the three CLI steps byte for byte,
and an MCP test projects the view from every source kind.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ment-build

The lane now runs the command users run: it builds the Grafana-shaped HAR
with environment-build and the packed checkout, checks the report, then
runs the bundle with agent-env as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The agent environments guide opens with the one-step build: the report,
the hint for each withheld write reason, and what a bundle ships. The CLI
guide, the capture guide and the skill reference name the command and the
environment-coverage view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The credential scan walks with its own stack, so a deeply nested body
  cannot crash the build, and it also reports credential-named header
  names, query names, form body members and string arrays.
- The build checks SIGINT between stages: cancelled before the bundle
  stage it writes nothing, during the write it names the written bundle.
- A dry run opens the package tarball, so it refuses what a build refuses.
- Repeated template rules are refused, a HAR saved as .json gets a hint,
  file-derived names follow the bundle name rules, `localhost.` counts as
  a loopback origin, and the next command is shell-quoted.
- --capture-timeout-ms passes through to the HAR inspection, and a
  missing directory is refused before inspection.
- The no-observation hint covers updates and deletes of entities the state
  never held; the coverage view states that it does not apply the
  serve-time admission checks; the inspect_analysis_view description
  names the view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cation

The guides now state when the one-step bundle equals the three-step one,
which headers inspection excludes, what the credential warning scans, how
cancellation behaves, and that the coverage view does not apply the
serve-time admission checks. The spec folder records the census, the end
to end runs, the gates and the review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e check

The manifest, state and coverage stages run synchronously, so a SIGINT
that arrived during them was only dispatched once the bundle write had
begun. Each check now yields first, so an interrupt before the bundle
stage cancels the build with nothing written.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@earakely-scale
earakely-scale marked this pull request as ready for review October 24, 2026 00:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-24T15:43:55.378811Z
We couldn’t complete this review. Comment @codex review to try again.
a6c145a New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: bc35ef3cc0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

earakely-scale and others added 5 commits October 23, 2026 19:02
The export file read returns permission refusals through Result under the calling operation's name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and serialize Evidence once

A browser scenario's retained header values and the query parameters of its recorded URLs are scanned for credential
names as a HAR's are, through a review projection of its records. A dry run admits and releases the package tarball
through the export's regular-file scope, so a close it cannot confirm keeps its owner, and checks for cancellation
after that last await. Evidence is written into one exactly sized buffer instead of chunks joined by a copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Scenario records keep main's response-body retention map beside the review projection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: fce1aba86b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

…odies

The build's credential scan collapsed form bodies with Object.fromEntries, so a
repeated field kept only its last occurrence: `api_key=secret&api_key=` warned
about nothing although the Evidence ships the value, and repeated values were
undercounted. Form fields are now scanned as ordered name/value pairs, as
headers and query strings already are.

The review projection of a capture_browser_scenario dropped a request body
recorded without a media type, so the scan never saw it. Review keeps such a
body's text with an empty media type; the manifest projection still reads only
bodies it can classify.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

On behalf of the repo owner, I pushed eeab0bd to this branch. It closes the two Codex P2 findings on fce1aba. I pushed only because your last push was ~55 minutes earlier, to avoid racing you.

What changed and why

  • environmentBuildReport.ts: form bodies are scanned as ordered name/value pairs instead of Object.fromEntries. Before, api_key=secret&api_key= produced no warning although evidence.json ships the value, and repeated values were undercounted. Headers and query strings were already scanned per occurrence; form bodies now follow the same rule.
  • scenarioCaptureRecords.ts: the review projection keeps a scenario request body recorded without a media type (mimeType: ""), so the credential scan sees it. The manifest projection is unchanged.
  • The environment-build spec now states both behaviors.

Evidence

  • 3 new tests fail without the change and pass with it (repeated form fields; MIME-less body in the review projection, with the manifest unchanged; end-to-end scan of a MIME-less scenario body).
  • I also checked your four P1 fixes in 212c998. With its source changes reverse-applied, 6 of its tests fail: credential scan ×2, tarball owner retained after a failed close ×2, cancellation after the tarball read ×1, single-buffer Evidence ×1. So each P1 fix has a test that fails without it.
  • Passing locally (Node 24.22.1): environmentBuild*, environmentExport*, environmentBundle* and scenarioCapture* tests (6 files, 67 tests), npm run check:fast, npm run format:check, npm run docs:check.

CI note: the Test shard (1/8) / Portable tests failure on fce1aba is in tests/boundary/providers/native/nativeProvider.test.ts (plist parsing). The same native plist tests fail on main (cd10ee1, 7f70797, e09b063) while maintainers land plist fixes there, so it is not from this PR.

🤖 Generated with Claude Code

The environment-coverage sentence joins main's BEAM additions to the view description.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: 53a03c06a5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@earakely-scale

Copy link
Copy Markdown
Contributor Author

@morluto this is ready for review: CI is green at 53a03c06, every review thread is resolved, it merges cleanly with main, and all 54 bundles it builds are byte-identical to the three-step path's. #6946 builds on this PR.

…e of unattributed scenario transactions

A HAR request recorded with postData.params and no text is scanned by those parameters, each occurrence counting, and
the review projection keeps the request side of a scenario transaction whose response cannot be attributed, so the
credential warning covers what evidence.json ships in both cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@earakely-scale

Copy link
Copy Markdown
Contributor Author

Correction: two Codex threads surfaced after this comment; both are fixed in 74f7ad28 and resolved, and CI is re-running on it.

@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: 74f7ad28ae

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/cli/environmentCommands.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

This PR keeps create inputs pinned when copied fields cannot be rebuilt. It also retires inconsistent read views and removes their write proofs and saved overrides.

  • Create writes keep unsupported values pinned to their recorded evidence.
  • Reads that disprove a learned sort retire the view and its write proof.
  • Credential-scan tests cover duplicate events and more captured request bodies.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read contradicts learned array order] --> B[Retire read view]
  B --> C[Remove earlier write confirmations]
  B --> D[Remove saved view overrides]
  B --> E[Keep comparison-only view]
  E --> F[Check later reads without array order]
  F --> G{Values match?}
  G -->|Yes| H[Add no write proof]
  G -->|No| I[Reject affected writes after ownership checks]
Loading

Reviews (17) · Last reviewed commit: "fix(environment): keep checking retired ..." · Reviewed by Greptile

morluto and others added 5 commits October 24, 2026 22:27
Integrating main took main's credential scan and coverage view, which
dropped 0895c89's tests and its body-unusable hint. Main's scan passes
the tests, now reading the scenario by event. The hint names the
response too, since extraction and serving also withhold a write as
body-unusable when its recorded response cannot be read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's event scan reads both content events of a transaction whose
content the capture recorded twice; the test fails on 0895c89, whose
review projection dropped that transaction's response. The spec names
event pointers among the first 20.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gensokyo-dev gensokyo-dev changed the title fix(environment): bound request comparisons and preserve write proofs fix(environment): bound create learning and invalidate stale write proofs Oct 24, 2026
@earakely-scale

Copy link
Copy Markdown
Contributor Author

@gensokyo-dev @morluto heads-up: I pushed 47d820e9c on top of 7c25ad4dc before seeing the 074aa3bb2 candidate in the description. It only adds the following, so merge or drop it as suits the candidate:

  • caa4e4bb1 merges main 3d84215b (feat(pe): inspect TLS callbacks and load configuration #7008). There were no conflicts, and the PR's own files are byte-identical to 7c25ad4dc's.
  • ff56cc44c restores 0895c89bc's tests for form text recorded without a media type, now read by event, and its body-unusable hint with the docs row. Integrating feat(environment): build agent environments from a prompt #6946 had dropped both; main's scan passes the tests.
  • 05566419e adds a test that both content events of a scenario transaction recorded twice are scanned. It fails on 0895c89bc. The spec now says the first 20 pointers are record or event pointers.
  • 47d820e9c records this round's checks in both verification logs.

Checked at 05566419e on macOS with Node v24.22.1:

  • Static gates: passed.
  • domain + services: 10,164 passed, 6 skipped.
  • Focused build/export/serve/analysis-view CLI and MCP boundaries: 93 passed.
  • 50-capture census: every write plan, session replay and served read equals 0895c89bc's (187 write tools, 68 served).
  • Build census: all 54 bundles byte-identical to the three-step path's, with unchanged warnings and credential counts.

I also ran my own stricter sort tests against 7c25ad4dc. They differ only by design: the item-view case is withheld as unconfirmed rather than contradicted, and the list-view case keeps the item view's still-valid confirmation. Neither is a defect.

@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: 47d820e9c3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@earakely-scale

Copy link
Copy Markdown
Contributor Author

@gensokyo-dev I am taking the four threads opened on 47d820e9c now (two Greptile, two Codex). If 074aa3bb2 already covers any of them, push it and I will port the rest onto it instead of pushing over it.

@earakely-scale

Copy link
Copy Markdown
Contributor Author

Validation at a1860e50b, which is fcbf950ac with main 69f99c51 merged, conflict-free. The PR's own files are unchanged from fcbf950ac.

Thread outcome:

  • fcbf950ac covers the three code threads opened on 47d820e9c. I checked each of its tests in a separate worktree: they fail on 47d820e9c and pass on fcbf950ac. A reproduction of Greptile's exact sorted-list scenario also passes.
  • The fourth thread was a false positive (text/plain is JSON-like).

Checks on macOS, Node v24.22.1:

  • Static gates: passed (jscpd 3.62%).
  • domain + services: 10,193 passed, 6 skipped.
  • Focused build/export/serve/analysis-view CLI and MCP boundaries: 93 passed.
  • 50-capture census: every write plan, session replay and served read equals 0895c89bc's (187 write tools, 68 served, 68/68 smoke calls).
  • Build census: all 54 bundles byte-identical to the three-step path's, with unchanged coverage, warnings and credential counts.

@gensokyo-dev, this is a merge-only push; nothing in your integration's files changed.

@morluto morluto changed the title fix(environment): bound create learning and invalidate stale write proofs fix(environment): preserve write proofs and dependent state Oct 24, 2026
@gensokyo-dev gensokyo-dev changed the title fix(environment): preserve write proofs and dependent state fix(environment): bound create learning and invalidate stale write proofs Oct 24, 2026
@earakely-scale

Copy link
Copy Markdown
Contributor Author

Independent check of the integrated head fc8176694 (macOS, Node v24.22.1):

  • static gates: passed;
  • domain + services: 10,195 passed;
  • focused build/export/serve/analysis-view CLI and MCP boundaries: 87 passed.

Over the 50 real captures, every write plan, session replay and served read equals 0895c89bc's: 187 write tools, 68 served, 68/68 smoke calls. All 54 rebuilt bundles are byte-identical to the three-step path's, with unchanged coverage, warnings and credential counts.

@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: fc8176694e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@gensokyo-dev
gensokyo-dev merged commit 41cf869 into morluto:main Oct 24, 2026
37 of 47 checks passed
@morluto morluto added bug Something isn't working area: setup Setup, packaging, upgrade, install, Doctor, and client registration labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants