rungate 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/lib/ac-quality.ts +119 -0
  2. package/lib/brief-precedence.ts +114 -0
  3. package/lib/ci-checkout.ts +27 -1
  4. package/lib/compliance-backfill.ts +16 -4
  5. package/lib/compliance-report.ts +109 -8
  6. package/lib/config-loader.ts +129 -5
  7. package/lib/config-readers.ts +86 -0
  8. package/lib/conformity.ts +520 -27
  9. package/lib/context-docs.ts +182 -0
  10. package/lib/create-brief.ts +22 -17
  11. package/lib/create-sc.ts +55 -33
  12. package/lib/decomposition-waves.ts +197 -0
  13. package/lib/doc-scan-targets.ts +435 -0
  14. package/lib/gate-check-audit.ts +190 -0
  15. package/lib/generators/agents-md.ts +10 -5
  16. package/lib/issue-extraction.ts +368 -0
  17. package/lib/organize.ts +129 -40
  18. package/lib/package-closure.ts +111 -0
  19. package/lib/phase2-decomposition.ts +270 -0
  20. package/lib/prior-branch.ts +24 -1
  21. package/lib/project-aliases.ts +100 -0
  22. package/lib/prove-label-gate.ts +93 -0
  23. package/lib/release-preflight.ts +225 -15
  24. package/lib/rungate-schema.ts +36 -2
  25. package/lib/sc-cover.ts +92 -1
  26. package/lib/sc-ids.ts +151 -0
  27. package/lib/scaffold/pre-push-hook.ts +165 -0
  28. package/lib/scaffold/rehearsal.ts +330 -0
  29. package/lib/scaffold/steps.ts +175 -122
  30. package/lib/scaffold/write-steps.ts +167 -0
  31. package/lib/scope-denylist.ts +258 -0
  32. package/lib/scratch-cleanup.ts +198 -0
  33. package/lib/scratch-roots.ts +94 -0
  34. package/lib/task-completion-checks.ts +50 -3
  35. package/lib/typescript-project.ts +233 -0
  36. package/lib/validators/spec-validators.ts +23 -34
  37. package/lib/verified-push.ts +179 -2
  38. package/lib/workflow-security.ts +51 -7
  39. package/lib/worktree-cleanup.ts +318 -20
  40. package/lib/worktree-repo.ts +465 -0
  41. package/package.json +8 -2
  42. package/scripts/audit-specs.ts +134 -37
  43. package/scripts/audit-transcript.ts +259 -0
  44. package/scripts/create-sc.ts +15 -1
  45. package/scripts/detect-sc-drift.ts +200 -0
  46. package/scripts/extract-constraints.ts +16 -36
  47. package/scripts/scaffold-project.ts +26 -136
  48. package/scripts/split-spec.ts +315 -0
  49. package/scripts/sync-sc-status.ts +751 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Thin typed accessors over the resolved config (#214, ADR-001 D1).
3
+ *
4
+ * ADR-001 decided on 2026-10-05 that `lib/config-loader.ts` is the sole config
5
+ * access point and named the enforcement: a conformity check that FAILS the
6
+ * suite. The check shipped under #309 as CONFIG-1/CONFIG-2 with a
7
+ * known-violations ratchet. This module is the other half — the migration the
8
+ * ratchet exists to let happen one commit at a time.
9
+ *
10
+ * ## Why accessors and not "just call the loader at each site"
11
+ *
12
+ * Six call sites wanted the same three values and each hand-rolled the whole
13
+ * read: `existsSync`, `JSON.parse`, pick a key, and — at four of them — a bare
14
+ * `catch` returning a default. Pointing six copies of that at the loader would
15
+ * remove the path construction and keep the six private answers to "what does
16
+ * unresolvable mean", which ADR-002 names as the defect under the defect:
17
+ *
18
+ * > Drift was not the failure. Defaulting was.
19
+ *
20
+ * Each function here answers that question once, in the open:
21
+ *
22
+ * - **absent config** — a legitimate state for every one of these callers
23
+ * (an unscaffolded directory, a consumer repo that has never run rungate),
24
+ * so the empty value is returned and that is the whole of the contract.
25
+ * - **malformed config** — THROWS, inherited from `tryLoadRungateConfig` and
26
+ * deliberately not caught here. ADR-001 D2's corollary: a malformed config
27
+ * is never a missing config. The bare `catch` at `scripts/fresh-eyes-test`
28
+ * and `scripts/grade-deterministic` converted a corrupt config into an
29
+ * unconfigured project, which is exactly how #70 stayed silent.
30
+ *
31
+ * ## What the migration actually fixes, beyond the policy
32
+ *
33
+ * Every site these replace read `.claude/rungate.json` and nothing else. A
34
+ * consumer on the directory layout — the layout
35
+ * `specs/CONFIG-DIRECTORY-STRUCTURE-SPEC.md` D-1 asks every consumer to
36
+ * migrate to — got `{}` from all of them, silently: no roles, no slug, no
37
+ * pre-flight hosts. The documented migration switched the features off.
38
+ */
39
+
40
+ import { tryLoadRungateConfig } from "./config-loader";
41
+ import type { RoleConfig } from "./rungate-schema";
42
+
43
+ /**
44
+ * Every configured role, keyed by name. `{}` when the project has no config.
45
+ *
46
+ * `roles` is `z.record(z.unknown()).default({})` in the resolved shape — the
47
+ * loader merges `roles.json` in but does not validate each entry against
48
+ * `RoleSchema`, so consumers carrying a role with a missing `brief` reach
49
+ * here. Narrowing is therefore an assertion about shape, not a guarantee of
50
+ * it; callers that index `brief` already handle it being absent.
51
+ */
52
+ export function loadRoleConfig(projectRoot: string): Record<string, RoleConfig> {
53
+ const config = tryLoadRungateConfig(projectRoot);
54
+ if (!config) return {};
55
+ return (config.roles ?? {}) as Record<string, RoleConfig>;
56
+ }
57
+
58
+ /**
59
+ * The project slug, or null when the config does not name one.
60
+ *
61
+ * Null rather than a `"project"` default: the caller that wanted that default
62
+ * uses it to name a worktree directory, and a second project falling back to
63
+ * the same literal would collide with the first. The default belongs at the
64
+ * site that can see the collision, not here.
65
+ */
66
+ export function readProjectSlug(projectRoot: string): string | null {
67
+ const config = tryLoadRungateConfig(projectRoot);
68
+ const slug = config?.project;
69
+ return typeof slug === "string" && slug.trim() ? slug : null;
70
+ }
71
+
72
+ /**
73
+ * Pre-flight SSH hosts, keyed by name. `{}` when none are configured.
74
+ *
75
+ * `remoteHosts` is not in `ProjectHarnessSchema`; it reaches the resolved
76
+ * config through `.passthrough()`, which is why the value is `unknown` and
77
+ * every field access downstream is guarded. Declaring it would be a schema
78
+ * change affecting every consumer config in the wild — out of scope here, and
79
+ * recorded rather than done.
80
+ */
81
+ export function readRemoteHosts(projectRoot: string): Record<string, unknown> {
82
+ const config = tryLoadRungateConfig(projectRoot);
83
+ const hosts = (config as Record<string, unknown> | null)?.remoteHosts;
84
+ if (!hosts || typeof hosts !== "object" || Array.isArray(hosts)) return {};
85
+ return hosts as Record<string, unknown>;
86
+ }