package main import ( "encoding/json" "fmt" "os" "path/filepath" ) var required = []string{ "task_id", "task_revision", "architecture_revision", "base_repo_revision", "risk_tier", "intent", "requirement_ids", "allowed_change_scope", "forbidden_change_scope", "allowed_architecture_delta", "contracts", "semantic_owner", "canonical_state", "state_transitions", "side_effects_and_privileges", "persistence_and_migrations", "failure_retry_restart", "assumptions", "acceptance_scenarios", "required_tests", "terminal_gap_states", } func main() { activePath := filepath.FromSlash("dev/ACTIVE_TASK.json") var active struct { TaskFile string `json:"task_file"` TaskID string `json:"task_id"` TaskRevision int `json:"task_revision"` } if err := decode(activePath, &active); err != nil { fail("active pointer: %v", err) } if active.TaskFile == "" || active.TaskID == "" || active.TaskRevision < 1 { fail("active pointer is incomplete") } var raw map[string]json.RawMessage if err := decode(filepath.FromSlash(active.TaskFile), &raw); err != nil { fail("task packet: %v", err) } for _, key := range required { if _, ok := raw[key]; !ok { fail("task packet missing required field %q", key) } } var packet struct { TaskID string `json:"task_id"` TaskRevision int `json:"task_revision"` } if err := decode(filepath.FromSlash(active.TaskFile), &packet); err != nil { fail("task identity: %v", err) } if packet.TaskID != active.TaskID || packet.TaskRevision != active.TaskRevision { fail("active pointer and packet identity differ") } fmt.Printf("independent governance verification: OK task=%s revision=%d\n", packet.TaskID, packet.TaskRevision) } func decode(path string, target any) error { b, err := os.ReadFile(path) if err != nil { return err } return json.Unmarshal(b, target) } func fail(format string, args ...any) { fmt.Fprintf(os.Stderr, "independent verifier: "+format+"\n", args...) os.Exit(1) }