From 3954872d33bae00a829a6e72026befbe151cad84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C4=B0rgin?= Date: Tue, 17 Nov 2026 12:32:23 +0300 Subject: [PATCH] docs: correct engineering, protocol, ADR and roadmap documentation Correct statements a documentation audit found wrong against the code and canon at the current pin. CONTRIBUTING and the pull request template point at the completion gate's fresh-checkout preparation and its local exemption; the Windows guide's WSL server recipe gets the isolation the hermetic-server rule requires. The snapshot recipe relays its production rule to canon, and the protocol canon states the session-scoped event rule the generator implements. Five ADRs keep their decisions and drop stale details: the binary response mapping, the open-model AdditionalProperties exception, the IOpenCodeError interface, the server handle's stop and restart, and the generated envelopes beside the hand-written response spine. The ROADMAP states why the next release is 2.0.0 (the shared event connection on the same opencode 2.3.0 pin), that milestone Next is the unversioned parity and fix queue, and the current version facts in place of the pre-1.0 framing. The GLOSSARY separates children from forks, and the CHANGELOG describes the plugin wait as the CLI's bounded, best-effort poll. --- .github/CONTRIBUTING.md | 11 +++-- .github/PULL_REQUEST_TEMPLATE.md | 2 +- CHANGELOG.md | 2 +- GLOSSARY.md | 4 +- docs/ROADMAP.md | 44 +++++++++++++------ docs/adr/0004-generated-model-principles.md | 3 +- docs/adr/0007-error-model.md | 3 +- docs/adr/0008-generated-operation-methods.md | 6 ++- ...4-runtime-materializes-the-dotnet-shape.md | 11 +++-- ...4-owned-and-shared-local-server-handles.md | 5 ++- ...generated-tostring-masks-secret-members.md | 4 +- docs/architecture/protocol-and-generation.md | 7 +++ docs/engineering/developing-on-windows.md | 16 ++++--- spec/SNAPSHOT.md | 7 +-- 14 files changed, 81 insertions(+), 44 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 83e264815..cebdf0152 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -35,10 +35,9 @@ sign. - The **.NET 10 runtime**, for the `net10.0` test legs (the .NET 10 SDK carries it). It must be the latest .NET 10 runtime patch: the build targets the newest patch the pinned SDK knows (`TargetLatestRuntimePatch`) -- On Windows, the **.NET Framework 4.7.2 targeting pack** for the `net472` legs - [Bun](https://bun.sh/) at the exact version in `external/opencode/package.json`'s - `packageManager` field, first on `PATH` — the pinned-server fixture and CI use that runtime, and - `OpenCode.Sdk.Tests` refuses to run under any other Bun + `packageManager` field, first on `PATH` — required by default and in CI; the explicit local-host + exception is in [quality-gates.md](../docs/engineering/quality-gates.md#completion-gate) - [ripgrep 15.1.0](https://github.com/BurntSushi/ripgrep/releases/tag/15.1.0) on `PATH` — the filesystem live tests run against an offline simulated server that refuses the on-demand download upstream would otherwise perform @@ -61,9 +60,9 @@ sign. `external/` holds read-only upstream checkouts used as protocol evidence and as the pinned-server test fixture. They are **never** hand-edited. If you cloned without `--recurse-submodules`, run - `git submodule update --init --depth 1 external/opencode`. Then install the pinned server's - dependencies once, with the pinned Bun first on `PATH`: - `cd external/opencode && bun install --frozen-lockfile --ignore-scripts`. + `git submodule update --init --depth 1 external/opencode`. Complete the + [fresh-checkout preparation](../docs/engineering/quality-gates.md#completion-gate) before the + build and tests below; it installs both the pinned server's dependencies and the clone detector. 2. **Build the Project** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1fd4de43b..3f75ff51c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -71,7 +71,7 @@ Run from the repository root — see [`docs/engineering/quality-gates.md`](../do - [ ] No new analyzer warnings; any new suppression follows the policy in [`docs/engineering/slop-review.md`](../docs/engineering/slop-review.md) and is named below - [ ] The change passes the slop rubric in the same file - [ ] No tests skipped, weakened, or deleted to make the suite pass -- [ ] All tests pass locally +- [ ] The [required local checks](../docs/engineering/quality-gates.md#completion-gate) pass, or the documented exemption applies - [ ] Branch is up to date with the target branch, no merge conflicts - [ ] Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) and carry **no AI-attribution trailers** diff --git a/CHANGELOG.md b/CHANGELOG.md index 77563e2ea..b7633e4c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ The next SDK version is **2.0.0**, on the same opencode **2.3.0** pin already re - `OpenCodeClientOptions.Headers` and `OpenCodeRequestOptions.Headers` set client-wide and per-call HTTP headers, with per-call values winning; on the message and inbox reads, the capability header `MediaReferences` sends replaces both. - `OpenCodeServer.ResolveAsync` selects an explicit endpoint, an owned standalone server or the shared service with the CLI's precedence, including the saved `disabled` flag. Connections expose resolve-time `ServerVersion`; explicit mismatches can invoke `OnServerVersionMismatch`. Managed `ServiceOperations` reconnect or restart with a best-effort persistent-terminal handoff using the resolve-time snapshot. - `OpenCodeServerStopOptions.Pty` accepts `OpenCodeServerStopPtyMode.Handoff` so that `StopAsync` attempts a best-effort persistent-terminal handoff after it reads the registration and before it signals the process. Follow it with `EnsureAsync` using the same registration selection to restart as the managed connection does; preservation depends on preparing and adopting the ticket before it expires. Null and `Clear` keep the default: terminals end with the service, as with the CLI's `service restart`. -- `Plugins.WaitForPluginsAsync` waits for a location's plugins to load, as the CLI does before listing agents, models and integrations; `LanguageModels.WaitForDefaultAsync` now runs it. +- `Plugins.WaitForPluginsAsync` runs the bounded, best-effort plugin poll that opencode's CLI runs before it lists agents, models and integrations; returning does not guarantee activation completed. `LanguageModels.WaitForDefaultAsync` now runs it. - `OpenCodeServer.ShutdownPersistentPtyAsync` discovers the background service and, when one is running, shuts down its persistent terminals, as opencode's CLI does before an uninstall; with no service it does nothing. It is experimental (`OPENCODE002`). - Virtual `EventsClient.GetConnectionState()` and `WatchConnectionAsync(CancellationToken)` expose `EventConnectionState` and `EventConnectionStatus` (Idle, Connecting, Connected, Reconnecting). Watches coalesce to the latest unread state and do not start or retain a source. - `OpenCodeEventSubscriberOverflowException.Capacity` reports the SDK's fixed 4,096 bound, including for instances constructed through its standard public constructors. diff --git a/GLOSSARY.md b/GLOSSARY.md index b540ce165..55c4a23cb 100644 --- a/GLOSSARY.md +++ b/GLOSSARY.md @@ -15,8 +15,8 @@ A persistent conversation with an Agent, and the API's central concept. **Session metadata**: Host-supplied annotations on a Session: arbitrary keys with JSON values, opaque to opencode and -durable from creation. Children and forks inherit the parent's unless their creator supplies its -own. +durable from creation. Children inherit the parent's unless creation supplies an override; forks +copy the parent's metadata. **Message**: One entry in a Session's projected history, of one kind: user, assistant, synthetic, system, skill, diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 8c84af1bf..90a589156 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -10,6 +10,18 @@ to issues in [the milestones](https://github.com/opencode-dotnet/opencode-sdk-do per release, and [`1.x`](https://github.com/opencode-dotnet/opencode-sdk-dotnet/milestone/2) for the work deferred from `1.0.0`. +The next SDK release is **2.0.0**, as `../Directory.Build.props` declares. The shared event connection +([#902](https://github.com/opencode-dotnet/opencode-sdk-dotnet/pull/902), +[ADR-0041](adr/0041-one-shared-event-feed-per-client.md)) replaces per-enumeration connections with one +background source per root client. Ordinary attempt failures retry indefinitely +and reach connection state instead of ending subscriptions. These hand-written runtime/error-channel +breaks require a major release, on the same opencode **2.3.0** pin already shipped in SDK `1.1.0` +([Unreleased breaking changes](../CHANGELOG.md#-breaking-changes)). + +Separately, milestone [`Next`](https://github.com/opencode-dotnet/opencode-sdk-dotnet/milestone/5) +is the current unversioned first-party parity and fix queue, not a promise that every item ships in +`2.0.0`. + ## Status **Released, and the protocol surface is complete.** The callable surface is generated from an @@ -48,27 +60,29 @@ accepted OpenAPI snapshot and rides one hand-written transport runtime. still lists 1.x releases. The pin tracks upstream 2.x release tags and is refreshed under receipt right before a release, not between releases. The accepted protocol identity is owned by `../spec/SNAPSHOT.md`. - **Packages** — the two packages publish as `OpenCodeDotNet.Sdk` and - `OpenCodeDotNet.Sdk.Extensions` (the assemblies stay `OpenCode.Sdk`) and pack at the - single-sourced `VersionPrefix 1.1.1`, the next version. Every `master` push publishes a nightly of - it to the organization's GitHub Packages feed, and `1.1.0`, the latest release, is on NuGet.org, owned by + `OpenCodeDotNet.Sdk.Extensions`; their assembly and namespace names are unchanged + ([package boundary](architecture/platform-and-packaging.md#packages)). They pack at the next version + declared by `../Directory.Build.props`. Nightly publication follows the + [publication policy](architecture/platform-and-packaging.md#repository-and-versioning), and + `1.1.0`, the latest release, is on NuGet.org, owned by `OpenCode.NET` and pushed through the manual lane over Trusted Publishing. The ids carry `OpenCodeDotNet` because nuget.org reserves the `OpenCode.` prefix for an unrelated owner. The earlier ids, `OpenCodeAI.Sdk` and `OpenCodeAI.Sdk.Extensions`, receive no further versions. ## Road to 1.0 -Releases stayed `0.9.0-preview.N` until the freeze; `1.0.0` ships from the release-candidate commit, -with no `-rc` package. Each workstream has a -short plan in the private companion repository when it starts, and its issues sit in milestone -`1.0` on the project board. Only work that breaks or decides the public surface, the gates that enforce the freeze, -and the items named below come before `1.0.0`; additive and internal work waits in milestone -`1.x`. In order: +`1.0.0`, `1.0.1`, and `1.1.0` are released; milestones `1.0` and `1.0.1` are closed. The workstreams +below record the road to 1.0; step 6's release rehearsal is the release check, and +[#796](https://github.com/opencode-dotnet/opencode-sdk-dotnet/issues/796), the `1.0.0` benchmark +record, is still open in milestone `1.x`. +Milestone `1.x` holds deferred additive and internal work. The current release and parity/fix queue +are identified above. 1. **Support policy.** The MCP server's repository (ADR-0030), the target-framework policy (ADR-0002), and the end of the .NET 5–7 promise ([#51](https://github.com/opencode-dotnet/opencode-sdk-dotnet/issues/51)). **Complete.** -2. **Target-framework transition.** `net11.0` joins now on its go-live release candidate and - `net8.0` and `net9.0` leave now, ahead of their end of support on 2026-11-10, across packages, +2. **Target-framework transition.** `net11.0` is targeted; `net8.0` and `net9.0` are not, and + `global.json` pins GA SDK `11.0.100` with prereleases disabled. The matrix covers packages, tests, CI legs, the public API check, and the docs; no non-preview package is built on a pre-GA SDK (one exception, `1.0.0`: step 8). A consumer whose target falls back to the `netstandard2.0` asset on an unsupported runtime gets a build warning. It ships in `0.9.0-preview.10`. Launcher @@ -79,8 +93,10 @@ and the items named below come before `1.0.0`; additive and internal work waits ladder. `OpenCodeServer.Exited` ([#174](https://github.com/opencode-dotnet/opencode-sdk-dotnet/issues/174)) reports how a standalone server ended — exit code, signal, or unknown, as upstream's `exited` does — on every - target and OS. **Landed.** Exit: every leg runs `netstandard2.0`, `net472`, `net10.0`, and - `net11.0` as its platform allows. + target and OS. **Landed.** Exit: build `netstandard2.0`, `net472`, `net10.0`, and `net11.0` package + assets; tests execute on `net10.0`/`net11.0` and on `net472` on Windows + ([target policy](architecture/platform-and-packaging.md#target-frameworks), + [gate](engineering/quality-gates.md#completion-gate)). 3. **Maintainability review.** A time-boxed, read-only review limited to what feeds the freeze: a pass over the public API baseline ([#183](https://github.com/opencode-dotnet/opencode-sdk-dotnet/issues/183)), the terminal receive @@ -142,7 +158,7 @@ and the items named below come before `1.0.0`; additive and internal work waits ## Parallel tracks -These do not block `1.0.0` and run beside the road. +These are parallel workstreams alongside the current release and deferred-work queues. - **MCP server** in its own repository (ADR-0030), a thin adapter over the published SDK. The namespace decision keeps the public namespaces, so code against the SDK can start. diff --git a/docs/adr/0004-generated-model-principles.md b/docs/adr/0004-generated-model-principles.md index f6b876296..d135205cd 100644 --- a/docs/adr/0004-generated-model-principles.md +++ b/docs/adr/0004-generated-model-principles.md @@ -19,7 +19,8 @@ null. A source-generation-proven in-band JSON-null carrier remains non-nullable. uses `IReadOnlyList` / `IReadOnlyDictionary` without defensive copies, read-only wrappers, empty normalization, or recursive item/value validation. `IReadOnly*` is an API view, not a deep-immutability guarantee; caller-supplied collection ownership stays with the caller -(ADR-0014). +(ADR-0014). The open-model `AdditionalProperties` bag is the exception; its ownership rules live in +[Generated model shape](../architecture/protocol-and-generation.md#generated-model-shape). A literal used for union dispatch emits as a constant/get-only property because successful dispatch already proved it; a prefix-tagged discriminator emits as a required string because diff --git a/docs/adr/0007-error-model.md b/docs/adr/0007-error-model.md index e38c16a99..65c97b37b 100644 --- a/docs/adr/0007-error-model.md +++ b/docs/adr/0007-error-model.md @@ -27,7 +27,8 @@ from selecting a member a stream or traversal must refuse at run time. Outside the shared event bus's retry loop, transport and protocol failures throw `OpenCodeTransportException`. The spec's tagged error -payloads are generated as typed models under an `OpenCodeError` base and ride **as data** on either +payloads are generated as typed models implementing `IOpenCodeError` (the interface representation +of [ADR-0011](0011-union-membership-as-interfaces.md)) and ride **as data** on either channel, pattern-matchable without string sniffing. There is no client-level switch. Throwing API errors retain the raw body on `OpenCodeApiException`; `NoThrow` responses retain it on their shared response spine, including when a typed error cannot be parsed. This deliberately renders upstream's diff --git a/docs/adr/0008-generated-operation-methods.md b/docs/adr/0008-generated-operation-methods.md index 4773abcd4..5b49a2bf0 100644 --- a/docs/adr/0008-generated-operation-methods.md +++ b/docs/adr/0008-generated-operation-methods.md @@ -39,8 +39,10 @@ breaks the build for explicit review. Exclusion is reserved for transports the HTTP pipeline cannot carry: `pty.connect` upgrades to WebSocket, which leaves HTTP after the handshake and needs a different client stack entirely. Non-JSON response bodies stay generated via a fail-closed -content-type→payload map (`application/octet-stream` → `Stream` payload on a disposable -envelope; `text/*` → `string`); an unknown content type breaks generation. +content-type→payload map (`text/*` → `string`); an unknown content type breaks generation. +The current binary response rule is in +[Operations, streams, and exclusions](../architecture/protocol-and-generation.md#operations-streams-and-exclusions) +and ADR-0029. ## Consequences diff --git a/docs/adr/0014-runtime-materializes-the-dotnet-shape.md b/docs/adr/0014-runtime-materializes-the-dotnet-shape.md index 500bd62b5..4201ab0dd 100644 --- a/docs/adr/0014-runtime-materializes-the-dotnet-shape.md +++ b/docs/adr/0014-runtime-materializes-the-dotnet-shape.md @@ -25,7 +25,9 @@ optional-and-nullable property uses `WhenWritingDefault` instead, because its ab wrapper's `default` rather than CLR null. Optional collections remain nullable rather than normalizing absence to empty. Generated collections are shallow `init`-only `IReadOnlyList` / `IReadOnlyDictionary` surfaces: the SDK does not copy or wrap -caller-supplied collections, and callers own later mutation. +caller-supplied collections, and callers own later mutation. The open-model `AdditionalProperties` +bag is the exception to the collection rules; its ownership and absent-bag representation live in +[Generated model shape](../architecture/protocol-and-generation.md#generated-model-shape). Union discriminator checks remain because they select the concrete C# type; unknown tags retain their explicit raw-payload carriers. Required members, non-null top-level payloads, enum token @@ -35,9 +37,10 @@ string enums: ADR-0035. ## Consequences -- Null-rejecting optional-property converters, collection-child scans, empty normalization, - defensive collection copies, and non-discriminator literal validation are removed. The closed - `Optional` converters are not that validation returning: they carry an admitted JSON null +- Apart from the open-model bag's collection rules, null-rejecting optional-property converters, + collection-child scans, empty normalization, defensive collection copies, and non-discriminator + literal validation are removed. The closed `Optional` converters are not that validation + returning: they carry an admitted JSON null into a distinct CLR state instead of refusing it, and refuse nothing the schema admits. - A valid UTF-8 one-shot success may materialize directly from bytes. Charset/BOM selection and malformed-UTF-8 replacement remain equivalent to `HttpContent` string decoding, so the fast path diff --git a/docs/adr/0024-owned-and-shared-local-server-handles.md b/docs/adr/0024-owned-and-shared-local-server-handles.md index 4fb703159..d634b51ae 100644 --- a/docs/adr/0024-owned-and-shared-local-server-handles.md +++ b/docs/adr/0024-owned-and-shared-local-server-handles.md @@ -4,8 +4,9 @@ Date: 2026-09-16 `OpenCodeServer` is the one process-backed local-server handle. `StartAsync` returns an owned standalone child whose disposal stops it; `DiscoverAsync` and `EnsureAsync` return a shared -registered service whose disposal is a no-op, and only the static `StopAsync` ends the current -registration. Ownership stays visible through `OwnsProcess`. A discovered handle has one operation +registered service whose disposal is a no-op. Deliberate stop and restart follow the +[connection lifecycle](../architecture/client-runtime.md#connection-modes). +Ownership stays visible through `OwnsProcess`. A discovered handle has one operation (`CreateClient`) and an empty disposal, the shape ADR-0019 rejects for generated API handles; that ceremony is accepted here as the price of one type instead of a second near-identical public type whose only difference would be disposal semantics. ADR-0019 governs generated family handles and diff --git a/docs/adr/0028-generated-tostring-masks-secret-members.md b/docs/adr/0028-generated-tostring-masks-secret-members.md index 76e4de753..b5241fa93 100644 --- a/docs/adr/0028-generated-tostring-masks-secret-members.md +++ b/docs/adr/0028-generated-tostring-masks-secret-members.md @@ -76,8 +76,8 @@ generator's format pass strips it; structural unions override `ToString()` for t unchanged. - A refresh that adds a secret-shaped member fails generation until a row decides it; the pending-operation probe sets that wall aside, since a missing row is curation, not a shape wall. -- Response envelopes are hand-written records outside this mechanism; their printed form leaves - out the raw error body. +- Response envelopes use separate envelope emission and inherit raw-error-body omission from the + hand-written `OpenCodeResponse` spine. - Reversal: upstream projects a secret marker into the OpenAPI document (for example `format: password` or `writeOnly` from Effect's `Schema.Redacted`); the marker then becomes the floor and the recorder list a cross-check. diff --git a/docs/architecture/protocol-and-generation.md b/docs/architecture/protocol-and-generation.md index 4b5e23776..4f9cbbb99 100644 --- a/docs/architecture/protocol-and-generation.md +++ b/docs/architecture/protocol-and-generation.md @@ -176,6 +176,13 @@ Curation may: operation identity, never an `operationNames` row (ADR-0008); - declare that a family emits an internal raw layer rather than a public surface, where hand-written code owns that family's public doors (ADR-0021); +- project session ownership through `sessionScopedEvent`: its configured unions (`IEvent` and + `ISessionEventDurable`) and member path (`data.sessionID`) qualify an event only when the + identifier is required and references the configured schema (`Session.ID`), not merely a + string-shaped schema. A qualifying event's payload must be required and non-nullable and its + identifier must bind to a non-nullable string, or generation fails. A row with no qualifying event + refuses as stale. Qualified records implement + `ISessionScopedEvent.SessionId` explicitly through that path, leaving serialization unchanged; - document a generated type or one of its members where the wire says too little, through a reason-bearing `descriptions` row keyed by the generated C# type and optional member: its summary replaces the generated one and its remarks join any the type already carries; a row on an diff --git a/docs/engineering/developing-on-windows.md b/docs/engineering/developing-on-windows.md index e8e630b1d..92a1a30e4 100644 --- a/docs/engineering/developing-on-windows.md +++ b/docs/engineering/developing-on-windows.md @@ -1,6 +1,6 @@ # Developing on Windows -Date: 2026-11-06 +Date: 2026-11-17 Operational guidance for a Windows workstation. Everything here is about the developer's machine; the test suite's own isolation rules live in `testing-style.md` and the gates in `quality-gates.md`. @@ -55,14 +55,20 @@ so the two installs clobber each other's daemon binary. cd ~/repos/opencode-sdk-dotnet/external/opencode bun install --frozen-lockfile --ignore-scripts ``` -4. Serve from `packages/cli` under isolated XDG roots and a fixed password, so the run touches no - real profile and the Windows side can authenticate: +4. Serve from `packages/cli` with a fresh `/tmp/ocsdk` tree and a fixed password. The clean child + environment drops inherited config/database and provider selectors; the isolation rules are in + [testing-style.md](testing-style.md#6-owned-servers-are-hermetic). The server also reads + `/etc/opencode`; if it exists, move it aside first. ```sh cd ~/repos/opencode-sdk-dotnet/external/opencode/packages/cli - mkdir -p /tmp/ocsdk/data /tmp/ocsdk/cache /tmp/ocsdk/config /tmp/ocsdk/state + rm -rf /tmp/ocsdk + mkdir -p /tmp/ocsdk/{data,cache,config,state,home,tmp} + touch /tmp/ocsdk/home/.zshrc + env -i PATH="$PATH" HOME=/tmp/ocsdk/home OPENCODE_TEST_HOME=/tmp/ocsdk/home \ XDG_DATA_HOME=/tmp/ocsdk/data XDG_CACHE_HOME=/tmp/ocsdk/cache \ XDG_CONFIG_HOME=/tmp/ocsdk/config XDG_STATE_HOME=/tmp/ocsdk/state \ - OPENCODE_CONFIG_CONTENT='{}' OPENCODE_DISABLE_MODELS_FETCH=1 OPENCODE_PASSWORD= \ + TMPDIR=/tmp/ocsdk/tmp OPENCODE_DISABLE_PROJECT_CONFIG=1 \ + OPENCODE_CONFIG_CONTENT='{}' OPENCODE_DISABLE_MODELS_FETCH=1 OPENCODE_PASSWORD='' \ bun src/index.ts serve --port 4097 ``` 5. On Windows, point the fixture at it and run the persistent PTY legs: diff --git a/spec/SNAPSHOT.md b/spec/SNAPSHOT.md index 92bf53c32..bebb32aff 100644 --- a/spec/SNAPSHOT.md +++ b/spec/SNAPSHOT.md @@ -39,11 +39,12 @@ The `refresh-spec` synchronizer owns refreshes (ADR-0020): 1. `dotnet run --file tools/opencode-tool.cs -- refresh-spec --ref ` prepares a candidate: it resolves the reference once to a full SHA and produces the normalized document by running the exact pinned upstream generator, over the ordered Restore patches - when `spec/patches/` has any — never by copying upstream's committed document, which upstream - does not regenerate in CI — writing the receipt and document to + when `spec/patches/` has any — never by copying upstream's committed document — writing the + receipt and document to `.scratchpad/refresh//` without touching accepted state. A patch whose repair predicate raw upstream already satisfies refuses, forcing an empty-patch retirement - refresh. + refresh. The [production policy](../docs/architecture/protocol-and-generation.md#snapshot-production) + owns this rule. 2. Review the receipt: identity, hashes, operation delta, patch preimages, and prepare's `Moved for` and `Lost anchor for` lines. A line for `opencode-agents-ai` goes to that product; a lost anchor of either owner refuses apply until the anchor is rewritten.