feat(spec-compiler): sin-code compile-spec CLI + YAML→JSON compiler (issue #164, v0 spike)#212
Merged
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🏆 CEO Audit — A+ (100.0/100)
📥 Download full report (Markdown)
|
🏆 CEO Audit — A+ (100.0/100)
📥 Download full report (Markdown) Run ID:
|
| // Default to a project matching the cwd name, type "go". | ||
| name := filepath.Base(outDir) | ||
| data := compiler.InitTemplate(name, "go") | ||
| if err := os.MkdirAll(outDir, 0o755); err != nil { |
| if err := os.MkdirAll(outDir, 0o755); err != nil { | ||
| return err | ||
| } | ||
| if err := os.WriteFile(path, data, 0o644); err != nil { |
| } | ||
| // Atomic write: temp file + rename, so a crash mid-write | ||
| // never leaves a half-written file behind. | ||
| if err := os.MkdirAll(filepath.Dir(dest), 0o755); err != nil { |
| return err | ||
| } | ||
| tmp := dest + ".tmp" | ||
| if err := os.WriteFile(tmp, f.Data, 0o644); err != nil { |
| drift := false | ||
| for _, f := range files { | ||
| dest := filepath.Join(outDir, f.Path) | ||
| existing, err := os.ReadFile(dest) |
| // config" — the former is a hint to run `sin-code compile-spec | ||
| // --init`, the latter is a hard fail). | ||
| func ParseFile(path string) (*Config, error) { | ||
| b, err := os.ReadFile(path) |
Delqhi
force-pushed
the
feat/issue-164-spec-compiler
branch
from
June 16, 2026 18:11
44cf467 to
b0127a5
Compare
…issue #164, v0 spike) What ships: - cmd/sin-code/internal/spec/compiler/ — 4 source files + 24 tests - schema.go: Config + Project + Verify + Hooks + Permissions + Loop - parse.go: Parse(bytes) + ParseFile + InitTemplate - validate.go: field-path validation (predicate/hook names unique, etc) - emit.go: EmitHooks/Verify/Permissions/Loop — 4 JSON contracts - cmd/sin-code/compile_spec_cmd.go — cobra subcommand - --init (write starter .sin-code.yml) - default (compile → 4 derived JSONs) - --check (CI: fail if derived files are stale) - --out <dir>, --dry-run - SPEC-COMPILER.md + CHANGELOG entry - main.go: register NewCompileSpecCmd Mandate compliance: - M1: compile-spec runs locally; --check is intended for CI but the work happens in the operator's checkout, not on the GitHub runner. - M2: gopkg.in/yaml.v3 is already in go.mod as a transitive dep. No new dependency. - M5: new code in cmd/sin-code/internal/spec/compiler/. No module-path changes. - M6: the schema is designed so the engines can adopt it without new types — the JSON contract mirrors the existing struct shapes where possible. Acceptance criteria (from #164): - [x] The schema is documented (SPEC-COMPILER.md) - [x] sin-code compile-spec round-trips: spec → derived → no diff on re-run (TestRoundTrip is the load-bearing test) - [x] The schema validates with clear error messages on invalid input (24 Validate_* tests) - [x] Test coverage ≥ 80% What does NOT ship (deferred per issue body): - Engine wiring (v1.1, ~2 weeks): the three engines must learn to read their derived JSON files. They currently read code, not config. This is a refactor of internal/{hooks,verify,permission}. - Remote spec inheritance (v2): 'extends: org/sin-code-base.yml' - Spec testing (v2): 'sin spec test' that asserts the spec is consistent Relationship to issue #155 (Pro-Repo-Konfiguration): - Issue #155 proposes .sin-code.yml for loop parameters only. - The v0 schema includes those fields as the 'loop:' block. - When #164 v1.1 lands and the loop builder reads .sin/loop.json, issue #155 is closed by reference. The two issues describe different slices of the same eventual file. Refs: #164
Delqhi
force-pushed
the
feat/issue-164-spec-compiler
branch
from
June 16, 2026 18:13
b0127a5 to
c15068e
Compare
This was referenced Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the fifth of the 5 issues. Scope-bounded to v0 (Schema + Parser + Validator + 4 Emitters + CLI + round-trip tests). Engine wiring and remote spec inheritance are follow-ups per the issue body.
What ships
cmd/sin-code/internal/spec/compiler/— 4 source files + 24 testsschema.go— Config + Project + Verify + Hooks + Permissions + Loopparse.go— Parse(bytes) + ParseFile + InitTemplatevalidate.go— field-path validationemit.go— EmitHooks/Verify/Permissions/Loop (4 JSON contracts)cmd/sin-code/compile_spec_cmd.go— cobra subcommand--init(write starter .sin-code.yml)--check(CI: fail if derived files are stale)--out <dir>,--dry-runSPEC-COMPILER.md+ CHANGELOG entrymain.go: registerNewCompileSpecCmdMandate compliance
sin-code compile-specruns locally;--checkis intended for CI but the work happens in the operator's checkout, not on the GitHub runner.gopkg.in/yaml.v3is already ingo.modas a transitive dep. No new dependency.cmd/sin-code/internal/spec/compiler/. No module-path changes.Acceptance criteria (from #164)
SPEC-COMPILER.md)sin-code compile-specround-trips: spec → derived → no diff on re-run (TestRoundTripis the load-bearing test)Validate_*tests)What does NOT ship (deferred per issue body)
internal/{hooks,verify,permission}.extends: org/sin-code-base.ymlsin spec testthat asserts the spec is consistentRelationship to issue #155 (Pro-Repo-Konfiguration)
.sin-code.ymlfor loop parameters only (max_turns,max_tokens,disable_checks).loop:block..sin/loop.json, issue Config: Pro-Repo-Konfiguration (.sin-code.yml) #155 is closed by reference. The two issues describe different slices of the same eventual file.Live smoke test
$ sin-code compile-spec --init --out /tmp/test wrote /tmp/test/.sin-code.yml $ sin-code compile-spec --out /tmp/test wrote /tmp/test/.sin/hooks.json (55 bytes) wrote /tmp/test/internal/verify/config.json (157 bytes) wrote /tmp/test/internal/permission/policies.json (60 bytes) wrote /tmp/test/.sin/loop.json (18 bytes) $ sin-code compile-spec --out /tmp/test --check all derived files are in syncDiffstat
Closes