fc94326b0e
P00 — Re-architecture Foundation (deprecation/migration/test-infra/persona/docs). Deprecation sweep (REQ-068, REQ-072, REQ-089): - Add // Deprecated: doc comments to internal/daemon (R-001), internal/transport (REQ-073), internal/security/ca.go+csr.go (D-101/REQ-076), internal/engine/ dispatcher.go+peer.go (CLI-side scheduler), internal/cli/daemon.go. - orca daemon emits slog.Warn deprecation banner on every run (ungated); fires R-001 + v0.10-P05 drain-and-stop + v0.10-P14 deletion. - orca cert and orca node join (mTLS path) emit deprecation warnings; proxmox SSH path (the v0.9 replacement) does not warn. - Add --no-deprecation-warnings global flag on root command (PersistentPreRunE) for orca upgrade migrations. - 12 new daemon/cert/node deprecation tests in internal/cli/daemon_test.go (cli coverage 81.9%, warnDeprecated 100%). - Add DEPRECATED banners to v0.8 sections of ARCHITECTURE.md (verified the v0.9 supersession section + Supersession Table from prior turn are present). Bash tooling gate (grill C-06, C-15, C-16, C-17, C-18): - scripts/tests/test_helper.bash + example_test.bash — bats framework + helpers. - scripts/lib/orca-log.sh — slog-compatible JSON logging to syslog (C-17). - scripts/orca-verify-render.sh — render-contract validator skeleton (C-16). - scripts/tests/orca-log_test.bash + orca-verify-render_test.bash — 20 bats tests total (happy + failure paths per C-15). - .shellcheckrc — project shellcheck config. - Makefile: test-bash + lint-bash targets (graceful skip if tools missing); wired into test + lint targets. - internal/emit/contract.go + contract_test.go — versioned JSON render contract (orca.emit/v1) between Go emitters and bash appliers (C-16). - .ciagent/BASH_CAPABILITY_MAP_v0.9.md — maps shipped internal/transport capabilities to bash-side equivalents or accepted drops (C-18). - D-186 recorded in PROJECT.md: bash exempt from Go coverage gate; compensating control is bats + shellcheck + shfmt (C-06). verify-reqs: 90 requirements consistent. Build/test/lint/fmt all green. 20 bats tests pass. Go tests pass. No v0.8 code deleted — only marked deprecated (deletion deferred to v0.10-P14 per REQ-090 dual-write window). ---ci--- project: orca phase: P00 milestone: v0.9 status: execute ---/ci---
81 lines
2.5 KiB
Go
81 lines
2.5 KiB
Go
// Package emit defines the render-format contract between Go-side emitters
|
|
// and bash-side appliers (grill C-16). Every rendered artifact is a JSON
|
|
// object with a versioned schema; both sides validate against it to prevent
|
|
// emitter/applier drift.
|
|
package emit
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// SchemaVersion is the canonical versioned schema identifier for render
|
|
// contracts. Bump the suffix when the contract shape changes.
|
|
const SchemaVersion = "orca.emit/v1"
|
|
|
|
// Kind enumerates the rendered-artifact kinds. Each maps to an emitter
|
|
// implementation and a matching bash-side applier.
|
|
type Kind string
|
|
|
|
const (
|
|
KindSystemd Kind = "systemd"
|
|
KindTraefik Kind = "traefik"
|
|
KindSyncthing Kind = "syncthing"
|
|
KindSudoers Kind = "sudoers"
|
|
KindSSHD Kind = "sshd"
|
|
KindEnvFile Kind = "envfile"
|
|
KindCredential Kind = "credential"
|
|
)
|
|
|
|
// Artifact is a single rendered file destined for a peer. The bash-side
|
|
// applier reads this JSON and writes Content to Path with the given Mode.
|
|
type Artifact struct {
|
|
SchemaVersion string `json:"schema_version"`
|
|
Kind Kind `json:"kind"`
|
|
Path string `json:"path"`
|
|
Content string `json:"content"`
|
|
Mode string `json:"mode"`
|
|
}
|
|
|
|
// Validate checks that an Artifact conforms to the render contract.
|
|
// Returns a structured error if any field is missing or invalid.
|
|
func (a *Artifact) Validate() error {
|
|
if a.SchemaVersion != SchemaVersion {
|
|
return fmt.Errorf("emit: schema_version mismatch: got %q want %q", a.SchemaVersion, SchemaVersion)
|
|
}
|
|
if a.Kind == "" {
|
|
return errors.New("emit: kind is required")
|
|
}
|
|
if a.Path == "" {
|
|
return errors.New("emit: path is required")
|
|
}
|
|
if a.Mode == "" {
|
|
return errors.New("emit: mode is required")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Marshal serializes an Artifact to JSON for transport to the bash applier.
|
|
func (a *Artifact) Marshal() ([]byte, error) {
|
|
if err := a.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
return json.Marshal(a)
|
|
}
|
|
|
|
// UnmarshalArtifact parses a JSON byte slice into an Artifact and validates
|
|
// it against the contract. The bash-side applier (via orca-verify-render.sh)
|
|
// uses this same validation; the bash side rejects unparseable input with a
|
|
// structured error, never silently (grill C-16).
|
|
func UnmarshalArtifact(data []byte) (*Artifact, error) {
|
|
var a Artifact
|
|
if err := json.Unmarshal(data, &a); err != nil {
|
|
return nil, fmt.Errorf("emit: unmarshal: %w", err)
|
|
}
|
|
if err := a.Validate(); err != nil {
|
|
return nil, err
|
|
}
|
|
return &a, nil
|
|
}
|