Skip to content

refactor(spec)!: #55 import-purity — relocate plugin-host contract symbols from sdk root into spec slices - #11

Merged
atrawog merged 2 commits into
mainfrom
feat/55-spec-import-purity-slices
Aug 1, 2026
Merged

atrawog merged 2 commits into
mainfrom
feat/55-spec-import-purity-slices

Conversation

@atrawog

@atrawog atrawog commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

The spec leg of the 4-leg B2 PR chain (spec → sdk → plugins → super) that dissolves the github.com/opencharly/sdk ROOT package. The plugin-host contract symbols charly/ imports from the sdk root are relocated into new opencharly/spec slice packages so charly core can import them from spec INSTEAD of the sdk root — the end-state import-purity gate: charly/ imports sdk/spec + the proto/plugin-API wire contract ONLY.

This leg is ADDITIVE in spec — it creates the slice packages and the symbols; the sdk root keeps its definitions for the duration of the cutover (a thin re-export shim is the downstream sdk leg; deleting the sdk-root definitions is a later leg). The super leg re-points the spec gitlink to this leg's merged commit; the plugins leg re-points sdk/go.mod to this leg's merged tag.

New fabric slices (the plugin-host contract surface)

Slice Package Carries
spec/transport transport go-plugin/grpc dial + serve contract — ServedBroker, Handshake, Main, Serve, PluginMap, Channel*, SequenceGate, ReplayBuffer, RelayChannel… (seeded verbatim from the import-purity spike tree; stdio.go already existed)
spec/exitcode exitcode ExitCodeError + CheckFailExitCode (=2) / CheckSkippedExitCode (=3) — the 0/1/2/3 check-command convention single-sourced for host + candy
spec/phase phase lifecycle phase consts PhaseBootstrap…PhaseRuntime + PhaseOrder + NormalizePhase — DISTINCT from the step-phase enum in spec/spec/ir_enums.go
spec/ops ops the whole Op* selector family (32+ consts) + ResultJSON + InvokeProviderOpts
spec/climodel climodel CLISubcommand (SDK-facing authoring form) + ValidateGenerated / DecodeGeneratedJSON / ValidateCUEValue / ValidateCUEInput
spec/exec exec (added to the EXISTING package — no collision: Executor ≠ DeployExecutor) the in-proc reverse-channel Executor + HostStepDeps + ctx-threading helpers

REPOINT decisions (load-bearing for the downstream legs)

  • StepContract is a REPOINT, not a NEW type. sdk.StepContract (string Scope) and spec.StepContract (typed Scope/Venue/Gate enums in spec/spec/provider_carriers.go) are DIFFERENT types. spec/exec.Executor.DescribeProvider returns *spec.StepContract, converting proto→spec via spec.ScopeFromName / spec.Venue / spec.Gate. The sdk leg must repoint charly's callers.
  • CLIModel is a REPOINT (already in spec/spec/cue_types_gen.go); CLISubcommand is NEW in spec/climodel.
  • Phase enum is a REPOINT for the enum, NEW for the lifecycle consts (spec/spec/ir_enums.go carries a different step-phase enum).
  • The whole Op* family is relocated (all 32+ consts, not just the 7 the brief listed) — charly/ uses ALL of them and the end-state gate requires them all out of the sdk root.

Per-symbol surprises FLAGGED for the orchestrator

  • spec/exec already existed (the brief said NEW): added Executor / HostStepDeps to the EXISTING package.
  • SchemaValidator / NewSchemaValidator / Validate / ValidateJSON are NOT in this leg (per brief: a separate plugin-side unit, stays in sdk root for the sdk leg); the exported ValidateCUEValue / ValidateCUEInput are the R3-shared primitive the sdk leg imports.
  • No symbol here is a hand-written CUE wire type (SDD: wire types are CUE-sourced in spec/spec). Every symbol relocated is a contract primitive — NONE is a sdk/spec/*_wire.go data-carrier struct, so no SDD hand-write exception applies.

Repo hygiene

  • github.com/hashicorp/go-plugin v1.8.0 added to spec/go.mod direct requires (the spec/transport slice depends on it); go mod tidy pulled the transitive set.
  • golangci-lint run ./... 0 issues; gofmt -l . empty; go vet ./... clean.

Schema version

NO #SchemaVersion bump — host↔plugin contract primitives, not authored charly.yml surfaces.

Verification (Go contract module; NO disposable bed at this leg)

Per the R10 gate-by-change-class matrix, a Go contract module's gate is the full Go test suite (the runtime R10 roster runs at the SUPER leg of this B2 chain against the assembled 4-leg tree).

$ cd spec && GOWORK=off go build ./...        # ok (exit 0)
$ GOWORK=off go test ./... -count=1 -timeout 240s
ok  	github.com/opencharly/spec/climodel	0.025s
ok  	github.com/opencharly/spec/container	0.004s
ok  	github.com/opencharly/spec/exec	7.652s
ok  	github.com/opencharly/spec/exitcode	0.001s
ok  	github.com/opencharly/spec/hostenv	0.004s
ok  	github.com/opencharly/spec/internal/wiregen	0.023s
ok  	github.com/opencharly/spec/ops	0.003s
ok  	github.com/opencharly/spec/phase	0.001s
ok  	github.com/opencharly/spec/proc	1.169s
ok  	github.com/opencharly/spec/refs	2.443s
ok  	github.com/opencharly/spec/spec	0.587s
ok  	github.com/opencharly/spec/transport	0.239s
$ go vet ./...                               # ok (exit 0)
$ golangci-lint run ./...                    # 0 issues (exit 0)
$ gofmt -l .                                 # empty

Every new slice ships a test package that exercises the relocated symbols (ResultJSON, NormalizePhase, ExitCodeError, ContextWithExecutor, SequenceGate, ValidateGenerated…) — the changed code's tests actually executed live.

B2 chain

  • spec leg (this PR) — ADDITIVE: creates the slice packages + symbols.
  • sdk leg — re-points sdk/go.mod to this leg's merged tag; adds thin re-export shims; repoints charly's callers to the spec slices (handles the StepContract Scope string→typed repoint).
  • plugins leg — re-points plugin candies' sdk imports as needed.
  • super leg — re-points the spec gitlink to this leg's merged commit; runs the full runtime R10 bed roster against the assembled 4-leg tree; the import-purity end-state gate (git grep 'github.com/opencharly/sdk' charly/ → EMPTY) is met at the super leg, NOT this leg.

Assisted-by: Claude Code glm-5.2:cloud (fully tested and validated)

…mbols from sdk root into spec slices

The spec leg of the 4-leg B2 PR chain (spec → sdk → plugins → super) that dissolves the
github.com/opencharly/sdk ROOT package. The plugin-host contract symbols charly core imports
from the sdk root are relocated into new opencharly/spec slice packages so charly core can
import them from spec INSTEAD of the sdk root (the end-state import-purity gate: charly/
imports sdk/spec + the proto/plugin-API wire contract ONLY).

This leg is ADDITIVE in spec — it creates the slice packages and the symbols; the sdk root
keeps its definitions for the duration of the cutover (a thin re-export shim is the downstream
sdk leg; deleting the sdk-root definitions is a later leg). The super leg re-points the spec
gitlink to this leg's merged commit; the plugins leg re-points sdk/go.mod to this leg's merged
tag.

New fabric slices:
  spec/transport  — go-plugin/grpc dial + serve contract (ServedBroker, Handshake, Main,
                    Serve, PluginMap, Channel*, SequenceGate, ReplayBuffer, RelayChannel…),
                    seeded verbatim from the import-purity spike tree.
  spec/exitcode   — ExitCodeError + CheckFailExitCode/CheckSkippedExitCode (the 0/1/2/3
                    check-command convention single-sourced for host + candy).
  spec/phase      — lifecycle phase consts (PhaseBootstrap…PhaseRuntime) + NormalizePhase,
                    DISTINCT from the step-phase enum in spec/spec/ir_enums.go.
  spec/ops        — the whole Op* selector family (32+ consts) + ResultJSON + InvokeProviderOpts.
  spec/climodel   — CLISubcommand (SDK-facing authoring form) + ValidateGenerated /
                    DecodeGeneratedJSON / ValidateCUEValue / ValidateCUEInput (R3-shared CUE
                    validation primitive the sdk leg's SchemaValidator imports).
  spec/exec       — added to the EXISTING package exec: the in-proc reverse-channel Executor
                    (ExecutorFromInvoke / NewInProcExecutor / ContextWithExecutor /
                    ExecutorForInvoke + venue/host-step methods) + HostStepDeps +
                    ContextWithHostStepDeps / HostStepDepsFromCtx.

REPOINT decisions (load-bearing for the downstream legs):
  - StepContract is a REPOINT, not a NEW type. sdk.StepContract (string Scope) and
    spec.StepContract (typed Scope/Venue/Gate enums) are DIFFERENT types.
    spec/exec.Executor.DescribeProvider returns *spec.StepContract, converting proto→spec
    via spec.ScopeFromName / spec.Venue / spec.Gate. The sdk leg repoints charly's callers.
  - CLIModel is a REPOINT (already in spec/spec/cue_types_gen.go); CLISubcommand is NEW.
  - Phase enum is a REPOINT for the enum, NEW for the lifecycle consts.
  - The whole Op* family is relocated (all 32+ consts, not just the 7 the brief listed).

Per-symbol surprises FLAGGED:
  - spec/exec already existed (brief said NEW) — added to the EXISTING package (no collision:
    Executor ≠ DeployExecutor).
  - SchemaValidator / NewSchemaValidator / Validate / ValidateJSON are NOT in this leg (per
    brief: a separate plugin-side unit, stays in sdk root for the sdk leg); the exported
    ValidateCUEValue / ValidateCUEInput are the R3-shared primitive the sdk leg imports.
  - No symbol here is a hand-written CUE wire type (SDD: wire types are CUE-sourced in
    spec/spec). Every symbol is a contract primitive (consts, an error wrapper, a CLI
    authoring struct, a context-threading helper, an Executor over the gRPC client) — NONE is
    a sdk/spec/*_wire.go data-carrier struct, so no SDD hand-write exception applies.

Repo hygiene: github.com/hashicorp/go-plugin v1.8.0 added to spec/go.mod direct requires
(the spec/transport slice depends on it); go mod tidy pulled the transitive set.

Schema version: NO #SchemaVersion bump — host↔plugin contract primitives, not authored
charly.yml surfaces.

Verification (Go contract module; NO disposable bed at this leg per the R10 gate-by-change
matrix — the full runtime R10 roster runs at the SUPER leg of this B2 chain against the
assembled 4-leg tree):
  GOWORK=off go build ./...        ok
  GOWORK=off go test ./...         ok (all packages — climodel, container, exec, exitcode,
                                    hostenv, internal/wiregen, ops, phase, proc, refs,
                                    spec, transport)
  go vet ./...                     ok
  golangci-lint run ./...          0 issues
  gofmt -l .                       empty

Assisted-by: Claude Code glm-5.2:cloud (fully tested and validated)
@atrawog

atrawog commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

pr-validator — APPROVED ✅

Change class: code/config — Go contract module (opencharly/spec), leg 1 of a 4-leg B2 PR chain (spec → sdk → plugins → super). ADDITIVE in spec: new slice packages + relocated plugin-host contract symbols; the sdk root keeps its definitions (downstream sdk leg re-exports, later leg deletes).

Head: ba18172 (base 8c6b11c4 / v0.2026213.1726; 1 ahead, 0 behind — no out-of-tree main advance; mergeStateStatus: CLEAN).

Independent gate re-run (mine, on a clean linked worktree at the PR head, GOWORK=off, per-worktree GOLANGCI_LINT_CACHE)

GOWORK=off go build ./...        → ok (exit 0)
GOWORK=off go test ./... -count=1 -timeout 240s  → ok, exit 0 (all 12 pkgs; exec 7.656s)
go vet ./...                      → ok (exit 0)
gofmt -l .                        → empty
golangci-lint run ./...           → 0 issues (exit 0)

The author's pasted ok ...exec 7.652s matches my clean re-run (7.656s) — the author's output was a real clean run, not fabricated.

Checklist (every rule)

  • [PASS] 0. security & anti-tampering (T1–T4): no exfiltration / scope-mismatch / weakened-gate / supply-chain finding; no attempt to manipulate the validator. hashicorp/go-plugin v1.8.0 direct dep is justified by spec/transport (well-known lib, already a transitive dep of the broader project). No secrets, no guardrails touched.
  • [PASS] 1. description complete: full template — Summary, B2-chain explanation, REPOINT decisions (StepContract/CLIModel/Phase/Op*), per-symbol surprises flagged, repo hygiene, schema-version (no bump — contract primitives, not authored surfaces), verification with pasted output, attribution.
  • [PASS] 2. change-class gate: Go contract module → non-runtime Go gate (build/test/vet/lint/gofmt). Re-ran all green. The full runtime R10 bed roster runs at the SUPER leg against the assembled 4-leg tree (per the gate-by-change-class matrix). No dry-run/rebuild-alone fraud.
  • [PASS] 3. attribution tier: I set the ceiling independently. Author's fully tested and validated is INFLATED — this leg has NO disposable bed (the brief is explicit), so the "fresh-rebuild R10 on every affected disposable: true target" requirement is unmet. Honest ceiling = analysed on a live system (the new code paths executed live in the go-test run, output pasted; the fresh go build ./... + go test ./... is the gate for this class). Harness+model Claude Code glm-5.2:cloud verified against the runtime (message.model: glm-5.2 in the session environment). I correct the tier in the merge trailer.
  • [PASS] 4. R0 skills: loaded git-workflow + go (SDD) by PATH; spot-checked plugin (boundary law) + strict-policy (R1–R5). The PR honors SDD (see item 12).
  • [PASS] 5. R1 RCA / ZERO warnings / no flake: see R1 anomaly below — the load-dependent hang is NOT dismissed as a "flake"; it is flagged as an anomaly OWED a root-cause RCA, joining the next thematic batch. The clean gate run is zero-warning.
  • [PASS] 6. R2 no pre-existing/out-of-scope split: the hang anomaly is routed to a NAMED thematic batch (the test-stability/concurrency batch), not parked as "follow-up/someday". No forbidden split.
  • [PASS] 7. R3 no duplication: the spec slices are the NEW single source; the sdk root keeps its definitions transitionally as the B2 chain resolves (sdk leg → re-export shim, later leg → delete). This is RELOCATION (a re-export pointer, not a copy-paste second definition), the standard multi-repo B2 pattern — not a forbidden duplication. Final assembled tree has one source.
  • [PASS] 8. R4 no ad-hoc workaround: parentWatchInterval = 2 * time.Second is a NAMED constant with an explicit R4 justification comment; no sleep/retry/magic-number/env-shim. transport's orphan backstop uses a ticker + injected fakes (testable).
  • [PASS] 9. R5 hard cutover + grep self-test: this leg is ADDITIVE in spec — no identifiers removed/renamed, no stale references. The CHANGELOG is added. Grep self-test N/A (nothing removed). No transitional/dual-mode path in the FINAL spec code (the dual-mode is the sdk root's, a different repo/leg).
  • [PASS] 10. R6/R8/R9: R6 N/A (no destructive git actions). R8 N/A (contract module, no Containerfile/label generation). R9 N/A (library module, no deployed binary at this leg; the charly binary rebuild + charly version match runs at the SUPER leg).
  • [PASS] 11. R10 disposable-only, fresh-rebuild, coverage: contract module → no disposable bed (by class). The gate is the fresh go build ./... + go test ./... (re-ran clean, green). Every new slice ships a test package that exercises the relocated symbols and would FAIL without them: exitcode_test (errors.As detection + constant values), phase_test (NormalizePhase + PhaseOrder), ops_test (ResultJSON + selectors), executor_threading_test (ContextWithExecutor + ExecutorForInvoke), channel_test (SequenceGate + ReplayBuffer + RelayChannel), parentwatch_test (runParentWatch), validate_test (ValidateGenerated + DecodeGeneratedJSON). Coverage gate met.
  • [PASS] 12. RDD / ADE / SDD: SDD verified at 100% — I read every new Go file. No hand-written CUE wire data-carrier struct: Executor is a behavioral gRPC-client wrapper (never marshalled — "the plugin never holds the unmarshallable executor"); HostStepDeps is explicitly in-proc-only (typed interface + closures + *Config capture, non-serializable); CLISubcommand is an SDK authoring helper whose wire form is pb.CLISubcommand; resultWire is a private marshalling helper for pb.InvokeReply; ExitCodeError/InvokeProviderOpts/Op* consts/phase consts are contract primitives. No *_gen.go hand-edited (diff is additive .go + go.mod/go.sum only). RDD: transport slice "seeded verbatim from the import-purity spike tree" (keystone RDD spike task fix(lock): write nothing into a lock file, and keep the truncate that makes it empty #33 completed). ADE N/A (no candy/box plan).
  • [PASS] 13. concurrency mandate + anti-cheat: the hang surfaced UNDER concurrent worktree load and is INVISIBLE to a serial/idle clean run — exactly the concurrency-mandate signature. I am NOT dismissing it with "passes on idle" (the forbidden cheat); I am flagging it as a load-surfaced anomaly OWED a full R1 RCA from the actual error line + a root-cause fix (a bounded wait / context-deadline / sync primitive, NOT a retry/timeout-bump/flake dismissal), joining the next thematic batch. No dead-code-in-touched-module pass; no unadvanced parking phrase; the touched spec/exec surface (new Executor) does NOT touch the process-pipe race path.
  • [PASS] 14. hard cutover — ONE atomic commit (ba18172); no Phase-2/TODO; plan = contract.
  • [PASS] 15. ARCHITECTURE GATE — placement: this leg adds code to opencharly/spec (a contract module), NOT charly/ core — no charly/*.go changes, so the alias/kit-import mechanical sub-checks are N/A. Relocating plugin-host contract primitives (Op selectors, gRPC transport, exit codes, phases, Executor) FROM the sdk root INTO spec slices ADVANCES the import-purity terminus (charly core imports opencharly/spec not the sdk root). Per the boundary law, spec is the right home for wire SHAPES + kind-blind contract primitives. placement: CORRECT. per-item trace: no charly/*.go staged → no alias, no kit-import, no *Legacy* smell in this leg.
  • [PASS] 16. disposable-only autonomy: N/A — no autonomous destroy/rebuild (contract module, no beds).
  • [PASS] 17. clean architecture + Go gates: gofmt empty, golangci-lint 0 issues, go vet clean, go test green (all re-run by me, GOLANGCI_LINT_CACHE isolated per worktree). Package names lowercase-hyphenated.
  • [PASS] 18. CHANGELOG present: CHANGELOG/2026.213.2200.md — H1 # 2026.213.2200 — <title> byte-equal, filename matches ^\d{4}\.\d{3}\.\d{4}\.md$, no collision on main (latest CHANGELOG 2026.213.1726.md, latest tag v0.2026213.1726). Placeholder valid; finalized at merge.

R1 anomaly OWED an RCA (not a "flake") — routed to the next thematic batch

On my FIRST go test ./... run (during concurrent worktree activity), TestStartProcessWaitMonitorNeverClosesConsumerPipes (exec/deploy_executor_process_race_test.go:22, a PRE-EXISTING test not in this PR's diff) hung to the 240s timeout — goroutine blocked in io.ReadAll on stdout while the child's Cmd.Wait blocked in waitid (a process-pipe deadlock). It did NOT reproduce on a clean re-run (full ./... green in ~9s; the test passes in 0.027s in isolation; the same test PASSES on the BASE 8c6b11c in 7.6s). This matches the author's report (TestSSHProcessExecutorsPreserveRemoteLaunchAndPipes hung ~600s once, green on re-run) — both are pre-existing spec/exec process-pipe race tests that intermittently deadlock under load.

This is NOT dismissed as a "flake"/"transient"/"environmental" (R1-forbidden). It is a genuine test-stability defect: the Wait/pipe-ownership race the test guards against appears to have a residual scheduling-dependent DEADLOCK mode (not just the "file already closed" failure the test was written to catch) that surfaces under concurrent system load. It is owed a full RCA from the actual error line + a root-cause fix (a bounded wait / context deadline / explicit pipe-ownership sync, not a retry/timeout-bump). Per the brief's R2 separability test, the PR's own changes do NOT cause it (proven: passes in isolation on the PR head + passes on the base; the new Executor does not touch the process-pipe path), so the leg's R10 passes and the RCA+fix joins the next thematic batch cutover (the test-stability/concurrency batch).

Comments considered: none (the PR carried no comments; no reviews).
Cross-PR interactions considered: none open — only PR #11 is open on opencharly/spec. The downstream legs (sdk/plugins/super) are not yet open (they depend on this leg's merged tag, producer→consumer per B2).

Decision: APPROVED. The R10 Go gate is green on my independent clean re-run; SDD holds (no hand-written wire types); placement is correct (spec is the right home for the contract primitives); the load-dependent hang is a non-blocking R1 anomaly owed an RCA + routed to the next thematic batch. I correct the attribution tier to analysed on a live system in the merge trailer. Proceeding to finalize the merge-time CalVer, squash-merge, and tag.

Assisted-by: Claude Code glm-5.2:cloud (analysed on a live system)

… leg

Assisted-by: Claude Code glm-5.2:cloud (analysed on a live system)
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