@viraatdas/rudder 1.0.73 → 1.1.0

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 (73) hide show
  1. package/README.md +169 -510
  2. package/dist/auth.d.ts +2 -0
  3. package/dist/auth.js +22 -1
  4. package/dist/auth.js.map +1 -1
  5. package/dist/backends.js +88 -1
  6. package/dist/backends.js.map +1 -1
  7. package/dist/board/board.css +1 -0
  8. package/dist/board/board.js +2 -0
  9. package/dist/board/daemon.d.ts +21 -0
  10. package/dist/board/daemon.js +838 -0
  11. package/dist/board/daemon.js.map +1 -0
  12. package/dist/brain.d.ts +9 -0
  13. package/dist/brain.js +36 -9
  14. package/dist/brain.js.map +1 -1
  15. package/dist/bus.d.ts +9 -0
  16. package/dist/bus.js +23 -0
  17. package/dist/bus.js.map +1 -0
  18. package/dist/cloud.js +80 -350
  19. package/dist/cloud.js.map +1 -1
  20. package/dist/daemon.d.ts +21 -0
  21. package/dist/daemon.js +141 -0
  22. package/dist/daemon.js.map +1 -0
  23. package/dist/git.d.ts +19 -13
  24. package/dist/git.js +283 -35
  25. package/dist/git.js.map +1 -1
  26. package/dist/goal.d.ts +30 -0
  27. package/dist/goal.js +75 -0
  28. package/dist/goal.js.map +1 -0
  29. package/dist/graph.d.ts +56 -0
  30. package/dist/graph.js +213 -0
  31. package/dist/graph.js.map +1 -0
  32. package/dist/index.js +0 -0
  33. package/dist/jj.d.ts +121 -0
  34. package/dist/jj.js +524 -0
  35. package/dist/jj.js.map +1 -0
  36. package/dist/main.js +191 -17
  37. package/dist/main.js.map +1 -1
  38. package/dist/migration.js +8 -1
  39. package/dist/migration.js.map +1 -1
  40. package/dist/models.js +21 -36
  41. package/dist/models.js.map +1 -1
  42. package/dist/native/rudder-native +0 -0
  43. package/dist/planner.d.ts +27 -0
  44. package/dist/planner.js +540 -0
  45. package/dist/planner.js.map +1 -0
  46. package/dist/repl.js +6 -2
  47. package/dist/repl.js.map +1 -1
  48. package/dist/run-manager.d.ts +10 -0
  49. package/dist/run-manager.js +225 -54
  50. package/dist/run-manager.js.map +1 -1
  51. package/dist/scheduler.d.ts +124 -0
  52. package/dist/scheduler.js +849 -0
  53. package/dist/scheduler.js.map +1 -0
  54. package/dist/state.d.ts +18 -1
  55. package/dist/state.js +139 -3
  56. package/dist/state.js.map +1 -1
  57. package/dist/surfaces.d.ts +23 -0
  58. package/dist/surfaces.js +196 -0
  59. package/dist/surfaces.js.map +1 -0
  60. package/dist/task-summary.d.ts +18 -0
  61. package/dist/task-summary.js +132 -0
  62. package/dist/task-summary.js.map +1 -1
  63. package/dist/tmux-dashboard.js +58 -7
  64. package/dist/tmux-dashboard.js.map +1 -1
  65. package/dist/tui.js +112 -17
  66. package/dist/tui.js.map +1 -1
  67. package/dist/types.d.ts +214 -1
  68. package/dist/types.js +1 -1
  69. package/dist/types.js.map +1 -1
  70. package/dist/util.d.ts +6 -1
  71. package/dist/util.js +37 -7
  72. package/dist/util.js.map +1 -1
  73. package/package.json +10 -2
package/dist/graph.js ADDED
@@ -0,0 +1,213 @@
1
+ import path from "node:path";
2
+ import { projectStateDir } from "./state.js";
3
+ import { nowIso, readJson, shortHash, updateJson } from "./util.js";
4
+ // ---------------------------------------------------------------------------
5
+ // graph.json IO. The graph is the daemon-owned DAG topology. nodes/edges are
6
+ // objects keyed by id so two branches that each add nodes merge as a clean key
7
+ // union (no line conflicts). Keys are sorted on write for minimal diffs.
8
+ // ---------------------------------------------------------------------------
9
+ export function graphPath(repoRoot) {
10
+ return path.join(projectStateDir(repoRoot), "graph.json");
11
+ }
12
+ function emptyGraph(repoRoot) {
13
+ return {
14
+ version: 1,
15
+ repoRoot,
16
+ nodes: {},
17
+ edges: {},
18
+ updatedAt: nowIso(),
19
+ };
20
+ }
21
+ /**
22
+ * Read the graph for a repo. Returns an empty graph (not null) when graph.json
23
+ * is absent or malformed, so callers never special-case the first-write path.
24
+ */
25
+ export async function readGraph(repoRoot) {
26
+ const graph = await readJson(graphPath(repoRoot));
27
+ if (graph && graph.version === 1 && graph.nodes && graph.edges) {
28
+ return {
29
+ version: 1,
30
+ repoRoot: graph.repoRoot || repoRoot,
31
+ ...(graph.integrationChangeId ? { integrationChangeId: graph.integrationChangeId } : {}),
32
+ nodes: graph.nodes,
33
+ edges: graph.edges,
34
+ updatedAt: graph.updatedAt || nowIso(),
35
+ };
36
+ }
37
+ return emptyGraph(repoRoot);
38
+ }
39
+ /**
40
+ * Content-hashed node id: stable mergeable key from the title, the current
41
+ * time, and a nonce so two nodes with the same title never collide.
42
+ */
43
+ export function newNodeId(title) {
44
+ return shortHash(`${title}:${nowIso()}:${Math.random()}`);
45
+ }
46
+ export function newEdgeId(from, to) {
47
+ return shortHash(`${from}->${to}:${nowIso()}:${Math.random()}`);
48
+ }
49
+ /**
50
+ * Atomically read-modify-write the graph under the per-path lock (daemon-only
51
+ * writer). The transform mutates/returns the graph; keys are sorted and the
52
+ * updatedAt stamp refreshed before write so diffs stay minimal.
53
+ */
54
+ export async function updateGraph(repoRoot, fn) {
55
+ let result = emptyGraph(repoRoot);
56
+ await updateJson(graphPath(repoRoot), (current) => {
57
+ const base = current && current.version === 1 && current.nodes && current.edges
58
+ ? current
59
+ : emptyGraph(repoRoot);
60
+ const next = fn(base) ?? base;
61
+ next.version = 1;
62
+ next.repoRoot = next.repoRoot || repoRoot;
63
+ next.updatedAt = nowIso();
64
+ const sorted = sortGraph(next);
65
+ result = sorted;
66
+ return sorted;
67
+ });
68
+ return result;
69
+ }
70
+ function sortGraph(graph) {
71
+ const nodes = {};
72
+ for (const key of Object.keys(graph.nodes).sort()) {
73
+ const node = graph.nodes[key];
74
+ if (node) {
75
+ nodes[key] = node;
76
+ }
77
+ }
78
+ const edges = {};
79
+ for (const key of Object.keys(graph.edges).sort()) {
80
+ const edge = graph.edges[key];
81
+ if (edge) {
82
+ edges[key] = edge;
83
+ }
84
+ }
85
+ return {
86
+ version: 1,
87
+ repoRoot: graph.repoRoot,
88
+ ...(graph.integrationChangeId ? { integrationChangeId: graph.integrationChangeId } : {}),
89
+ nodes,
90
+ edges,
91
+ updatedAt: graph.updatedAt,
92
+ };
93
+ }
94
+ // ---------------------------------------------------------------------------
95
+ // Pure queries. None of these mutate or read disk.
96
+ // ---------------------------------------------------------------------------
97
+ export function hardParents(graph, id) {
98
+ const parents = [];
99
+ for (const edge of Object.values(graph.edges)) {
100
+ if (edge.to === id && edge.type === "hard") {
101
+ parents.push(edge.from);
102
+ }
103
+ }
104
+ return parents;
105
+ }
106
+ export function softParents(graph, id) {
107
+ const parents = [];
108
+ for (const edge of Object.values(graph.edges)) {
109
+ if (edge.to === id && edge.type === "soft") {
110
+ parents.push(edge.from);
111
+ }
112
+ }
113
+ return parents;
114
+ }
115
+ /**
116
+ * Judge parents of a node: the variants a judge node compares. A judge edge
117
+ * gates readiness on the variant REACHING review (finishing its work), not on
118
+ * merge. Fan-out-and-judge uses this so the judge launches once every variant
119
+ * has produced a diff to compare.
120
+ */
121
+ export function judgeParents(graph, id) {
122
+ const parents = [];
123
+ for (const edge of Object.values(graph.edges)) {
124
+ if (edge.to === id && edge.type === "judge") {
125
+ parents.push(edge.from);
126
+ }
127
+ }
128
+ return parents;
129
+ }
130
+ /**
131
+ * Direct dependents (children) of a node: nodes with an edge `from` this id.
132
+ */
133
+ export function dependents(graph, id) {
134
+ const out = [];
135
+ for (const edge of Object.values(graph.edges)) {
136
+ if (edge.from === id) {
137
+ out.push(edge.to);
138
+ }
139
+ }
140
+ return out;
141
+ }
142
+ /**
143
+ * A node is ready when it is still `planned` AND every hard-dep parent has
144
+ * merged AND every judge parent has reached review or merged. Soft parents
145
+ * never block readiness. A judge node (which has judge parents) launches only
146
+ * once all of its variants have finished their work (review or merged), so it
147
+ * has every variant's diff to compare.
148
+ */
149
+ export function isReady(graph, node) {
150
+ if (node.status !== "planned") {
151
+ return false;
152
+ }
153
+ const hardMet = hardParents(graph, node.id).every((parentId) => graph.nodes[parentId]?.status === "merged");
154
+ if (!hardMet) {
155
+ return false;
156
+ }
157
+ return judgeParents(graph, node.id).every((parentId) => {
158
+ const status = graph.nodes[parentId]?.status;
159
+ return status === "review" || status === "merged";
160
+ });
161
+ }
162
+ /**
163
+ * Every node eligible to launch: planned with all hard parents merged.
164
+ */
165
+ export function readyNodes(graph) {
166
+ return Object.values(graph.nodes).filter((node) => isReady(graph, node));
167
+ }
168
+ /**
169
+ * The frontier: non-merged leaves. A node is on the frontier when it is not
170
+ * merged AND has no non-merged child (every dependent is already merged, or it
171
+ * has no dependents). Injection reconciliation attaches new nodes here.
172
+ */
173
+ export function frontier(graph) {
174
+ return Object.values(graph.nodes).filter((node) => {
175
+ if (node.status === "merged") {
176
+ return false;
177
+ }
178
+ const children = dependents(graph, node.id);
179
+ return children.every((childId) => graph.nodes[childId]?.status === "merged");
180
+ });
181
+ }
182
+ /**
183
+ * Project a worker-owned RunStatus into the DAG-level NodeStatus. With no run
184
+ * yet, the node keeps its deps-derived status (planned/ready/blocked); the
185
+ * scheduler decides those. Mirrors plan section 2's projection table.
186
+ */
187
+ export function projectNodeStatus(node, run) {
188
+ if (!run) {
189
+ return node.status === "ready" || node.status === "blocked" ? node.status : "planned";
190
+ }
191
+ return nodeStatusFromRunStatus(run.status, node.status);
192
+ }
193
+ function nodeStatusFromRunStatus(runStatus, fallback) {
194
+ switch (runStatus) {
195
+ case "created":
196
+ case "running":
197
+ case "steering":
198
+ case "verifying":
199
+ return "running";
200
+ case "completed":
201
+ return "review";
202
+ case "failed":
203
+ case "cancelled":
204
+ return "failed";
205
+ case "merged":
206
+ return "merged";
207
+ case "merge-conflict":
208
+ return "failed";
209
+ default:
210
+ return fallback;
211
+ }
212
+ }
213
+ //# sourceMappingURL=graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO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C,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAc,EAAE,GAAe;IAC/D,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,CAAC;IACD,OAAO,uBAAuB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,uBAAuB,CAAC,SAAoB,EAAE,QAAoB;IACzE,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,WAAW;YACd,OAAO,SAAS,CAAC;QACnB,KAAK,WAAW;YACd,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW;YACd,OAAO,QAAQ,CAAC;QAClB,KAAK,QAAQ;YACX,OAAO,QAAQ,CAAC;QAClB,KAAK,gBAAgB;YACnB,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC"}
package/dist/index.js CHANGED
File without changes
package/dist/jj.d.ts ADDED
@@ -0,0 +1,121 @@
1
+ import type { RunRecord } from "./types.js";
2
+ export type MergeNodeResult = {
3
+ mergeChangeId: string;
4
+ opId: string;
5
+ conflictedFiles: string[];
6
+ };
7
+ /**
8
+ * Hard requirement: jj must be installed. Throws MissingToolError otherwise.
9
+ */
10
+ export declare function ensureJj(): void;
11
+ /**
12
+ * Parse `jj --version`. Returns the version string (e.g. "0.40.0") or "".
13
+ * Warns (does not throw) when below MIN_JJ.
14
+ */
15
+ export declare function jjVersion(): Promise<string>;
16
+ /**
17
+ * Idempotently colocate a jj repo with the git repo at repoRoot. If already a
18
+ * jj repo, no-op. Otherwise runs `jj git init --colocate`.
19
+ */
20
+ export declare function ensureColocated(repoRoot: string): Promise<void>;
21
+ export declare function isJjRepo(cwd: string): boolean;
22
+ export declare function findJjRoot(cwd: string): string;
23
+ /**
24
+ * The change id of `@` (the working-copy commit) in the given workspace.
25
+ */
26
+ export declare function currentJjChangeId(workspacePath: string): Promise<string>;
27
+ export declare function jjStatus(workspacePath: string): Promise<string[]>;
28
+ export declare function parseJjStatus(stdout: string): string[];
29
+ export declare function jjDiff(workspacePath: string): Promise<string>;
30
+ /**
31
+ * Create a new empty change parented on the given changes. Reads the new change
32
+ * id back by querying a unique marker embedded in the description, never by
33
+ * scraping stdout. Returns the new change id.
34
+ */
35
+ export declare function createEmptyChange(params: {
36
+ repoRoot: string;
37
+ parents: string[];
38
+ description: string;
39
+ }): Promise<string>;
40
+ export declare function describeChange(repoRoot: string, changeId: string, message: string): Promise<void>;
41
+ /**
42
+ * Create a jj workspace for a node/run. Workspace name matches the original
43
+ * rudder regex `rudder-<id.slice(0,14)>-<shortHash(id).slice(0,6)>`. If
44
+ * `atChangeId` is given, parent the working-copy commit on it; falls back to
45
+ * `jj workspace add` + `jj edit <atChangeId>` if `-r` is unsupported.
46
+ */
47
+ export declare function createNodeWorkspace(params: {
48
+ repoRoot: string;
49
+ nodeId?: string;
50
+ runId?: string;
51
+ task?: string;
52
+ atChangeId?: string;
53
+ }): Promise<{
54
+ workspaceName: string;
55
+ path: string;
56
+ }>;
57
+ /**
58
+ * Phase-1 entry point used by run-manager. Delegates to createNodeWorkspace.
59
+ */
60
+ export declare function createRunJjWorkspace(params: {
61
+ repoRoot: string;
62
+ runId: string;
63
+ task: string;
64
+ }): Promise<{
65
+ workspaceName: string;
66
+ path: string;
67
+ }>;
68
+ /**
69
+ * Merge a run's jj change into the current (main) workspace `@`. Captures the
70
+ * operation id before the merge and records it on merge.operationId. On
71
+ * conflict sets merge.status="conflict" + conflictedFiles + mergeChangeId.
72
+ */
73
+ export declare function mergeJjRunIntoCurrentWorkspace(run: RunRecord, allowDirty?: boolean): Promise<RunRecord>;
74
+ /**
75
+ * Merge two changes into a new change. Captures the op id (after the merge),
76
+ * returns the new merge change id and any conflicted files. jj merges never
77
+ * fail on conflict; the conflict is recorded in the merge change.
78
+ */
79
+ export declare function mergeNode(params: {
80
+ repoRoot: string;
81
+ nodeChangeId: string;
82
+ intoChangeId: string;
83
+ message: string;
84
+ }): Promise<MergeNodeResult>;
85
+ export declare function jjConflictedFiles(workspacePath: string): Promise<string[]>;
86
+ /**
87
+ * Alias matching the plan's API name.
88
+ */
89
+ export declare function listConflicts(workspacePath: string): Promise<string[]>;
90
+ export declare function parseJjConflictedFiles(stdout: string): string[];
91
+ /**
92
+ * The id of the latest operation in the op log.
93
+ */
94
+ export declare function currentOpId(repoRoot: string): Promise<string>;
95
+ /**
96
+ * Restore the repo to an earlier operation. One call rewinds all workspaces and
97
+ * refs atomically (op restore is global).
98
+ */
99
+ export declare function undoToOp(repoRoot: string, opId: string): Promise<void>;
100
+ export declare function undoLast(repoRoot: string): Promise<void>;
101
+ /**
102
+ * Export jj changes to the colocated git repo. Call after each merge, before
103
+ * opening a Hunk review, and before a PR.
104
+ */
105
+ export declare function exportToGit(repoRoot: string): Promise<void>;
106
+ export declare function createBookmark(repoRoot: string, name: string, atChangeId: string): Promise<void>;
107
+ export declare function pushBookmark(repoRoot: string, name: string): Promise<void>;
108
+ /**
109
+ * Forget a jj workspace and remove its directory.
110
+ */
111
+ export declare function forgetWorkspace(params: {
112
+ repoRoot: string;
113
+ workspaceName: string;
114
+ workspacePath: string;
115
+ }): Promise<void>;
116
+ export declare function removeRunWorkspace(run: RunRecord): Promise<void>;
117
+ /**
118
+ * Rebase a run's node change onto the trunk. jj records conflicts in place and
119
+ * never blocks, so there is no rebase-in-progress dance.
120
+ */
121
+ export declare function syncRunWorkspace(run: RunRecord, baseBranch: string): Promise<RunRecord>;