Skip to content

Generator and tools hygiene: reuse, simplification and tooling performance #24

Closed as not planned

Description

@Blind-Striker

Source: review of PR #16, 2026-08-13. The reuse and simplification items were maintenance/drift observations requiring re-check; P6/P7 were confirmed tooling-only findings. Milestone 1.1: take remaining items when their files are next changed. References below describe the original review unless a current status is stated.

Reuse / drift:

  • R1 compile probe re-types the provenance header (tests/OpenCode.Sdk.Tools.Tests/Support/GeneratedSourceCompiler.cs:50-53) instead of GenerationProvenance.HasHeader → wording change causes false duplicate-type reds. Use the shared helper (or a shared byte/span helper).
  • R2 — completed PipelineTests originally reimplemented UserAgentPolicy.Compose (PipelineTests.cs:307-315). Current request expectations use UserAgentPolicy.Resolve(), and one metadata-integration test remains (tests/OpenCode.Sdk.Tests/Transport/PipelineTests.cs:275,1127-1135).
  • R3 Basic-auth tests rebuild the header with hard-coded opencode (PipelineTests.cs:52,69) vs Pipeline.BasicUser — centralize the expected wire credential in a test contract constant/builder; do not expose production privates solely for tests.
  • R5 nullable readonly field emission duplicated (ClientEmitter.cs:99-105, EnvelopeEmitter.cs:53-60) → EmissionSyntax if both stay structurally identical.
  • R6 SchemaNameResolver reparses GraphKeyBuilder.UnionBranch's marker=value format ad hoc with silent whole-token fallback (SchemaNameResolver.cs:102-113) → centralize branch-key format/parse; refuse malformed identities.

Simplification (maintainer picks scope; none delays correctness):

  • S1 one-field PendingOperationPlan → IReadOnlyList<string> · S2 primary-ctor mirror fields (OperationPlanBinder.cs:200-207) · S3 RefuseNull/RefuseNullTags → one generic (:529-539) · S4 — completed EmitPipelineAssignments is parameterless (tools/OpenCode.Sdk.Tools/Generator/Emission/ClientEmitter.cs:251) · S5 — retired EmitHandleFactory uses client.Emission (tools/OpenCode.Sdk.Tools/Generator/Emission/ClientEmitter.cs:352-353) · S6 duplicated ctor guard/assignment syntax (:181-230) · S7 stored IsHandleOperation derivable from Plan.Parameters (OperationPlanBinder.cs:186-197,237) · S8 — completed formerly constant ClientPlan.Namespace (ClientPlan.cs:7); it is now a required property (tools/OpenCode.Sdk.Tools/Generator/Binding/Models/ClientPlan.cs:9).

Tooling perf (speed matters in tooling — standing posture; fix when in the file):

  • P6 Re-check provenance reads in ManifestStore, the before-snapshot and comparison reads in GenerationWriter, and path normalization across GenerationWriter / ManifestStore / StagedWrite (tools/OpenCode.Sdk.Tools/Output/). GenerationProvenance.HasHeader already compares spans (tools/OpenCode.Sdk.Tools/Generator/Emission/GenerationProvenance.cs:23-47). The remaining direction is to fold provenance into the before-snapshot read and cache validated paths per run.
  • P7 — completed StagedWrite.InstallAsync writes ReadOnlyMemory<byte> directly to the stream, without the payload ToArray() copy (tools/OpenCode.Sdk.Tools/Output/StagedWrite.cs:50-65); only skip formatting with proof of canonical bytes.

Activity

  1. added
    ready-for-agent
    on Aug 13, 2026
  2. Blind-Striker commented on Aug 14, 2026

    @Blind-Striker
    CollaboratorAuthor

    PR #26 verification (2026-08-14) adds seven low-severity hygiene items to this sweep:

    • V26 · QueryRequestPlan.DerivesFromListRequest and per-property IsInherited encode one fact twice; a mismatch silently mis-emits. Collapse to a single source of truth (or a construction-time invariant).
    • V31 · No-change generate --verify rereads and rewrites the complete generated set (provenance pass + two snapshots + format over unchanged bytes). Tooling-perf only.
    • V32 · SchemaAliasApplier reconstructs the full projected document for one sparse alias. Tooling-perf only.
    • V33 · Identical internal response-DTO shapes are emitted once per operation (SessionResponseEnvelope ≡ SessionCreateResponseEnvelope); shape-keyed dedup would shrink the registry.
    • V34 · UnionNormalizer's oneOf purity wall duplicates the anyOf predicate verbatim — unify so a future constraint cannot fork the mirrored rules.
    • V35 · ResponseAdapterEmitter.CreateSuccess duplicates the common status/payload initializer for the cursor arm — unify.
    • V36 · BoundOperation.Group is dead state since grouping moved to the curated client name — delete.
  3. Blind-Striker commented on Aug 17, 2026

    @Blind-Striker
    CollaboratorAuthor

    The 1ee8c30 review adds confirmed correctness follow-ups to the tooling areas already owned here.

    GenerationWriter safety and recovery

    • Output-root symlink: RefuseSymbolicLinks checks children but not OutputRoot itself, so a symlinked root can redirect writes outside the intended physical tree.
    • Linux case-variant foreign file: an unmanifested Models/widget.cs does not block planned Models/Widget.cs; exact File.Exists misses the case-insensitive ownership collision and both files remain.
    • Interrupted write recovery: cancellation/failure after a new source write but before manifest commit leaves a file the next run refuses as unmanifested. Manual cleanup works, but automatic retry is poisoned.

    Add real-filesystem tests where the fake cannot model case/symlink behavior. Correctness must land before P6/P7 writer optimization.

    Small correctness/hygiene riders

    • SpecDocument.Schemas retains a caller-owned dictionary despite the immutable SpecIR contract; take an ordinal defensive copy.
    • Expected command failures bypass configured file logging; route domain exceptions through MEL. Exit-code policy can remain a separate decision, but the log file must contain the failure.

    Trigger: next GenerationWriter/tool-error handling change. These correctness follow-ups must land before the writer optimizations.

  4. Blind-Striker commented on Aug 18, 2026

    @Blind-Striker
    CollaboratorAuthor

    Hosted CI evidence for a new tooling-test determinism follow-up: attempt 1 failed only on Windows in OperationPlanBinderTests.Bind_Should_Refuse_A_Payload_Name_Colliding_With_Record_Members(PrintMembers). Microsoft.OpenApi ingestion translated a RegexMatchTimeoutException at the document boundary; the same test and full Windows matrix passed unchanged on attempt 2 at the identical SHA 7123627, while Linux/macOS were green. This was unrelated to the alias increment and was not hidden or retried locally. If it recurs, investigate reader regex timeout behavior under Windows/parallel test load and add deterministic containment rather than a retry/skip. Evidence: https://github.com/Blind-Striker/opencode-sdk-dotnet/actions/runs/32128587050

  5. Blind-Striker commented on Sep 14, 2026

    @Blind-Striker
    CollaboratorAuthor

    Status 2026-09-14: still an opportunistic hygiene sweep; nothing here blocks the preview line. R1–R3 and S-items were drift observations to take when the file is next open; P6/P7 were tooling-perf leftovers in GenerationWriter. See the body for the updated R2 and S8 status.

  6. added this to the 1.1 milestone on Oct 14, 2026
  7. changed the title [-]M6 (opportunistic earlier): hygiene sweep — reuse/simplification/tooling-perf leftovers (R1-R3 R5 R6, S1-S8, P6 P7)[/-] [+]Hygiene sweep: reuse, simplification and tooling-performance leftovers (R1-R3, R5, R6, S1-S8, P6, P7)[/+] on Oct 14, 2026
  8. Blind-Striker commented on Oct 14, 2026

    @Blind-Striker
    CollaboratorAuthor

    Milestone 1.1. No row of this issue moved to a 1.0 issue. The generator performance baseline (#186) measures the P6, P7 and V31 candidates before any of them is optimized. The remaining rows are trigger-based: each is taken when its file is next changed, and the GenerationWriter correctness riders still land before P6 and P7.

  9. changed the title [-]Hygiene sweep: reuse, simplification and tooling-performance leftovers (R1-R3, R5, R6, S1-S8, P6, P7)[/-] [+]Generator and tools hygiene: reuse, simplification and tooling performance[/+] on Nov 6, 2026
  10. Blind-Striker commented on Nov 7, 2026

    @Blind-Striker
    CollaboratorAuthor

    Recurrence of the tooling-test regex timeout under parallel load, this time on macOS arm64 and inside a third-party regex: Testably.Abstractions.Testing's FilePlatformIndependenceExtensions.NormalizePath, reached from MockFileSystem.Initialize in SpecScenario.Build. Test: SessionScopedEventBinderTests.Bind_Should_Refuse_A_Required_Payload_That_Can_Be_Null, 1 of 11,196, in run https://github.com/opencode-dotnet/opencode-sdk-dotnet/actions/runs/42314702596 (job 128224410576) on #807, which touches neither the binder nor the test helpers. Only the failed job was rerun at the same SHA. Two sites now, one of them not ours: a deterministic containment probably has to bound the timeout the process gives every regex, rather than fix a single pattern.

  11. Blind-Striker commented on Nov 10, 2026

    @Blind-Striker
    CollaboratorAuthor

    V31, after #827 (closes #302): only the write half retires.

    generate --verify no longer rewrites the working tree. It no longer snapshots it twice or runs the provenance pass on it; it reads the committed set once to compare.

    It still projects, binds and emits, then formats the whole generated set, now in a staging mirror under the temp directory, because verifying formatted bytes requires formatting them. That formatting remains the dominant cost. Three alternating runs on one Linux host measured generate --verify at 220.9 s on the base and 221.2 s with #827, so the change is neutral. The rest of V31 stays with the P6/P7 formatting candidates.

  12. Blind-Striker commented on Nov 22, 2026

    @Blind-Striker
    CollaboratorAuthor

    Moved to the roadmap board as a draft item. This is internal backlog rather than a request an outside user or contributor would act on, so it no longer lives in Issues. The history stays here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions