open-research-protocol 0.4.33 → 0.4.35

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.
@@ -0,0 +1,187 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import fs from "node:fs/promises";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+
7
+ import { buildHostedWorkspaceState } from "../src/index.js";
8
+
9
+ async function makeFrontierProject() {
10
+ const root = await fs.mkdtemp(path.join(os.tmpdir(), "orp-hosted-state-frontier-"));
11
+ const frontierRoot = path.join(root, "orp", "frontier");
12
+ const linkRoot = path.join(root, ".git", "orp", "link");
13
+ await fs.mkdir(frontierRoot, { recursive: true });
14
+ await fs.mkdir(linkRoot, { recursive: true });
15
+ await fs.writeFile(
16
+ path.join(frontierRoot, "TAS.md"),
17
+ [
18
+ "# ORP TAS: Evidence-Backed Conditional Strategy Controls",
19
+ "",
20
+ "## Active Task Order",
21
+ "",
22
+ "1. Define a small replay metadata taxonomy for semantic regimes.",
23
+ "2. Add a metadata-quality gate.",
24
+ ].join("\n"),
25
+ "utf8",
26
+ );
27
+ await fs.writeFile(
28
+ path.join(frontierRoot, "state.json"),
29
+ JSON.stringify(
30
+ {
31
+ active_version: "v0",
32
+ active_milestone: "v0.2",
33
+ active_phase: "regime-metadata-quality",
34
+ next_action: "Implement replay metadata taxonomy and metadata-quality gates.",
35
+ },
36
+ null,
37
+ 2,
38
+ ),
39
+ "utf8",
40
+ );
41
+ await fs.writeFile(
42
+ path.join(frontierRoot, "version-stack.json"),
43
+ JSON.stringify(
44
+ {
45
+ versions: [
46
+ {
47
+ id: "v0",
48
+ label: "Dry-run Topstep 50K lab",
49
+ milestones: [
50
+ {
51
+ id: "v0.2",
52
+ label: "Evidence-backed conditional strategy controls",
53
+ phases: [
54
+ {
55
+ id: "signal-quality-and-control-provenance",
56
+ label: "Signal quality and control provenance",
57
+ status: "completed",
58
+ },
59
+ {
60
+ id: "regime-metadata-quality",
61
+ label: "Regime metadata quality",
62
+ status: "active",
63
+ },
64
+ {
65
+ id: "first-regime-sample-capture",
66
+ label: "First regime sample capture",
67
+ status: "planned",
68
+ },
69
+ ],
70
+ },
71
+ ],
72
+ },
73
+ ],
74
+ },
75
+ null,
76
+ 2,
77
+ ),
78
+ "utf8",
79
+ );
80
+ await fs.writeFile(
81
+ path.join(linkRoot, "project.json"),
82
+ JSON.stringify(
83
+ {
84
+ idea_id: "idea-123",
85
+ idea_title: "Canonical futures idea",
86
+ active_feature_id: "feature-regime-metadata-quality",
87
+ frontier_feature_ids: {
88
+ "regime-metadata-quality": "feature-regime-metadata-quality",
89
+ },
90
+ project_root: root,
91
+ },
92
+ null,
93
+ 2,
94
+ ),
95
+ "utf8",
96
+ );
97
+ return root;
98
+ }
99
+
100
+ test("buildHostedWorkspaceState compiles local ORP frontier plan and tasks", async () => {
101
+ const projectRoot = await makeFrontierProject();
102
+ const state = buildHostedWorkspaceState({
103
+ version: "1",
104
+ workspaceId: "main-cody-1",
105
+ title: "main-cody-1",
106
+ tabs: [
107
+ {
108
+ title: "futures-prop-trading-lab",
109
+ path: projectRoot,
110
+ resumeTool: "codex",
111
+ resumeSessionId: "019d4f24-c8ba-78b2-a726-48b1ce9f0fe9",
112
+ },
113
+ ],
114
+ });
115
+
116
+ assert.equal(state.tabs.length, 1);
117
+ assert.equal(state.tabs[0].plan.summary, "ORP TAS: Evidence-Backed Conditional Strategy Controls");
118
+ assert.equal(state.tabs[0].plan.source, "orp/frontier/TAS.md");
119
+ assert.equal(state.tabs[0].linked_idea_id, "idea-123");
120
+ assert.equal(state.tabs[0].linked_feature_id, "feature-regime-metadata-quality");
121
+ assert.match(state.tabs[0].plan.body, /Current next action: Implement replay metadata taxonomy/);
122
+ assert.deepEqual(
123
+ state.tabs[0].tasks.map((task) => [task.id, task.status]),
124
+ [
125
+ ["signal-quality-and-control-provenance", "done"],
126
+ ["regime-metadata-quality", "in_progress"],
127
+ ["first-regime-sample-capture", "todo"],
128
+ ],
129
+ );
130
+ assert.equal(state.projects[0].plan.summary, "ORP TAS: Evidence-Backed Conditional Strategy Controls");
131
+ assert.equal(state.projects[0].tasks.length, 3);
132
+ assert.equal(state.projects[0].linked_idea_id, "idea-123");
133
+ assert.equal(state.projects[0].linked_feature_id, "feature-regime-metadata-quality");
134
+ });
135
+
136
+ test("buildHostedWorkspaceState preserves manifest plan tasks and activity timestamps", () => {
137
+ const state = buildHostedWorkspaceState(
138
+ {
139
+ version: "1",
140
+ workspaceId: "main-cody-1",
141
+ title: "main-cody-1",
142
+ tabs: [
143
+ {
144
+ title: "tailnet-app",
145
+ path: "/Volumes/Code_2TB/code/tailnet-app",
146
+ resumeTool: "codex",
147
+ resumeSessionId: "019dcd50-111d-7451-bd01-dbc21336c679",
148
+ linkedIdeaId: "idea-tailnet",
149
+ linkedFeatureId: "feature-tailnet",
150
+ plan: {
151
+ summary: "Ship Tailnet App workspace sync",
152
+ body: "Keep the hosted workspace aligned with local project inventory.",
153
+ },
154
+ tasks: [
155
+ {
156
+ id: "sync-contract",
157
+ title: "Define sync contract",
158
+ status: "in_progress",
159
+ },
160
+ ],
161
+ lastActivityAt: "2026-04-30T02:59:15.000Z",
162
+ lastSyncedAt: "2026-04-30T12:00:00.000Z",
163
+ syncSource: "orp-project-startup",
164
+ },
165
+ ],
166
+ },
167
+ {
168
+ updatedAt: "2026-04-30T12:30:00.000Z",
169
+ localInventory: {
170
+ contract: {
171
+ source_of_truth: "orp-workspace-ledger",
172
+ },
173
+ },
174
+ },
175
+ );
176
+
177
+ assert.equal(state.tabs[0].plan.summary, "Ship Tailnet App workspace sync");
178
+ assert.equal(state.tabs[0].tasks[0].id, "sync-contract");
179
+ assert.equal(state.tabs[0].linked_idea_id, "idea-tailnet");
180
+ assert.equal(state.tabs[0].linked_feature_id, "feature-tailnet");
181
+ assert.equal(state.tabs[0].last_activity_at_utc, "2026-04-30T02:59:15.000Z");
182
+ assert.equal(state.tabs[0].last_synced_at_utc, "2026-04-30T12:00:00.000Z");
183
+ assert.equal(state.tabs[0].sync_source, "orp-project-startup");
184
+ assert.equal(state.projects[0].last_activity_at_utc, "2026-04-30T02:59:15.000Z");
185
+ assert.equal(state.projects[0].sessions[0].last_synced_at_utc, "2026-04-30T12:00:00.000Z");
186
+ assert.equal(state.source_contract.source_of_truth, "orp-workspace-ledger");
187
+ });
@@ -0,0 +1,126 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import fs from "node:fs/promises";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+
7
+ import { mergeLocalProjectInventoryIntoManifest } from "../src/index.js";
8
+
9
+ async function makeTempDir() {
10
+ return fs.mkdtemp(path.join(os.tmpdir(), "orp-local-inventory-"));
11
+ }
12
+
13
+ async function writeJson(filePath, payload) {
14
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
15
+ await fs.writeFile(filePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
16
+ }
17
+
18
+ test("mergeLocalProjectInventoryIntoManifest reconciles ORP startup, Clawdad, and known Codex sessions", async () => {
19
+ const root = await makeTempDir();
20
+ const codexHome = path.join(root, "codex-home");
21
+ const clawdadStatePath = path.join(root, "clawdad", "state.json");
22
+ const existingPath = path.join(root, "existing");
23
+ const tailnetPath = path.join(root, "tailnet-app");
24
+ const financialPath = path.join(root, "financial-stack");
25
+
26
+ await fs.mkdir(existingPath, { recursive: true });
27
+ await writeJson(path.join(tailnetPath, "orp", "state.json"), {
28
+ startup: {
29
+ updated_at_utc: "2026-04-30T02:59:15Z",
30
+ workspace: {
31
+ requested: true,
32
+ workspace: "main",
33
+ path: tailnetPath,
34
+ result: {
35
+ manifest: {
36
+ version: "1",
37
+ workspaceId: "main",
38
+ title: "main",
39
+ tabs: [
40
+ {
41
+ title: "financial-stack",
42
+ path: financialPath,
43
+ resumeTool: "codex",
44
+ resumeSessionId: "019dc348-ce52-7f52-8ac8-0200a9bf946a",
45
+ },
46
+ ],
47
+ },
48
+ tab: {
49
+ title: "Tailnet App",
50
+ path: tailnetPath,
51
+ bootstrapCommand: "npm test",
52
+ resumeTool: "codex",
53
+ resumeSessionId: "019dcd50-111d-7451-bd01-dbc21336c679",
54
+ },
55
+ },
56
+ },
57
+ },
58
+ });
59
+ await writeJson(clawdadStatePath, {
60
+ projects: {
61
+ [financialPath]: {
62
+ status: "completed",
63
+ last_dispatch: "2026-04-25T20:47:50Z",
64
+ last_response: "2026-04-25T20:49:37Z",
65
+ registered_at: "2026-04-25T20:11:21.625Z",
66
+ sessions: {
67
+ "019dc348-ce52-7f52-8ac8-0200a9bf946a": {
68
+ slug: "financial-stack",
69
+ provider: "codex",
70
+ quarantined: "true",
71
+ },
72
+ "019dc644-d31d-78e1-a3ed-8575aead1c96": {
73
+ slug: "financial-stack",
74
+ provider: "codex",
75
+ tracked_at: "2026-04-25T20:11:21.625Z",
76
+ },
77
+ },
78
+ quarantined_sessions: {
79
+ "019dc348-ce52-7f52-8ac8-0200a9bf946a": true,
80
+ },
81
+ },
82
+ },
83
+ });
84
+ const codexSessionPath = path.join(codexHome, "sessions", "2026", "04", "30", "rollout-existing.jsonl");
85
+ await fs.mkdir(path.dirname(codexSessionPath), { recursive: true });
86
+ await fs.writeFile(codexSessionPath, `${JSON.stringify({
87
+ timestamp: "2026-04-30T12:00:00.000Z",
88
+ type: "session_meta",
89
+ payload: {
90
+ id: "019df000-1111-7222-8333-444455556666",
91
+ cwd: existingPath,
92
+ timestamp: "2026-04-30T12:00:00.000Z",
93
+ },
94
+ })}\n`, "utf8");
95
+
96
+ const merged = await mergeLocalProjectInventoryIntoManifest(
97
+ {
98
+ version: "1",
99
+ workspaceId: "main",
100
+ title: "main",
101
+ tabs: [
102
+ {
103
+ title: "existing",
104
+ path: existingPath,
105
+ resumeTool: "codex",
106
+ resumeSessionId: "019d0000-1111-7222-8333-444455556666",
107
+ },
108
+ ],
109
+ },
110
+ {
111
+ localProjectRoots: [root],
112
+ clawdadStatePath,
113
+ codexHome,
114
+ workspaceSelector: "main",
115
+ codexScanDays: 30,
116
+ },
117
+ );
118
+
119
+ const byPath = new Map(merged.manifest.tabs.map((tab) => [tab.path, tab]));
120
+ assert.equal(byPath.get(existingPath)?.resumeSessionId, "019df000-1111-7222-8333-444455556666");
121
+ assert.equal(byPath.get(tailnetPath)?.bootstrapCommand, "npm test");
122
+ assert.equal(byPath.get(tailnetPath)?.resumeSessionId, "019dcd50-111d-7451-bd01-dbc21336c679");
123
+ assert.equal(byPath.get(financialPath)?.resumeSessionId, "019dc644-d31d-78e1-a3ed-8575aead1c96");
124
+ assert.equal([...byPath.values()].some((tab) => tab.resumeSessionId === "019dc348-ce52-7f52-8ac8-0200a9bf946a"), false);
125
+ assert.equal(merged.inventory.projectCount, 3);
126
+ });
@@ -6,6 +6,7 @@ import path from "node:path";
6
6
 
7
7
  import {
8
8
  chooseImplicitMainCandidate,
9
+ findHostedWorkspaceByWorkspaceId,
9
10
  loadWorkspaceSource,
10
11
  resolveWorkspaceSelectorFromCollections,
11
12
  resolveWorkspaceWatchTargets,
@@ -44,6 +45,24 @@ test("resolveWorkspaceSelectorFromCollections matches hosted ideas by saved work
44
45
  assert.equal(byTitleSlug?.title, "Main Cody 1");
45
46
  });
46
47
 
48
+ test("findHostedWorkspaceByWorkspaceId matches hosted workspace records by durable id", () => {
49
+ const workspace = findHostedWorkspaceByWorkspaceId(
50
+ [
51
+ {
52
+ workspace_id: "focused-items",
53
+ title: "focused-items",
54
+ },
55
+ {
56
+ workspace_id: "captured-iterm-window-20260401t032225z",
57
+ title: "main-workspace",
58
+ },
59
+ ],
60
+ "captured-iterm-window-20260401t032225z",
61
+ );
62
+
63
+ assert.equal(workspace?.title, "main-workspace");
64
+ });
65
+
47
66
  test("resolveWorkspaceSelectorFromCollections can match local tracked workspaces by title", () => {
48
67
  const resolved = resolveWorkspaceSelectorFromCollections("ORP Main", {
49
68
  localWorkspaces: [