erdos-problems 0.1.12 → 0.2.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 (37) hide show
  1. package/README.md +93 -4
  2. package/docs/RESEARCH_LOOP.md +16 -2
  3. package/package.json +1 -1
  4. package/packs/number-theory/README.md +13 -0
  5. package/packs/number-theory/problems/1/CONTEXT.md +8 -0
  6. package/packs/number-theory/problems/1/context.yaml +25 -0
  7. package/packs/number-theory/problems/2/CONTEXT.md +8 -0
  8. package/packs/number-theory/problems/2/context.yaml +25 -0
  9. package/packs/sunflower/README.md +17 -4
  10. package/packs/sunflower/problems/20/CHECKPOINT_TEMPLATE.md +29 -0
  11. package/packs/sunflower/problems/20/FRONTIER_NOTE.md +13 -0
  12. package/packs/sunflower/problems/20/OPS_DETAILS.yaml +44 -0
  13. package/packs/sunflower/problems/20/REPORT_TEMPLATE.md +23 -0
  14. package/packs/sunflower/problems/20/ROUTE_HISTORY.md +18 -0
  15. package/packs/sunflower/problems/536/OPS_DETAILS.yaml +39 -0
  16. package/packs/sunflower/problems/856/OPS_DETAILS.yaml +39 -0
  17. package/packs/sunflower/problems/857/CHECKPOINT_TEMPLATE.md +32 -0
  18. package/packs/sunflower/problems/857/FRONTIER_NOTE.md +18 -0
  19. package/packs/sunflower/problems/857/OPS_DETAILS.yaml +65 -0
  20. package/packs/sunflower/problems/857/REPORT_TEMPLATE.md +26 -0
  21. package/packs/sunflower/problems/857/ROUTE_HISTORY.md +25 -0
  22. package/src/cli/index.js +16 -2
  23. package/src/commands/archive.js +46 -0
  24. package/src/commands/maintainer.js +20 -2
  25. package/src/commands/problem.js +3 -0
  26. package/src/commands/pull.js +127 -4
  27. package/src/commands/sunflower.js +432 -13
  28. package/src/commands/upstream.js +129 -0
  29. package/src/commands/workspace.js +4 -0
  30. package/src/runtime/archive.js +87 -0
  31. package/src/runtime/checkpoints.js +27 -0
  32. package/src/runtime/maintainer-seed.js +70 -0
  33. package/src/runtime/paths.js +16 -0
  34. package/src/runtime/state.js +32 -3
  35. package/src/runtime/sunflower.js +329 -2
  36. package/src/runtime/workspace.js +4 -0
  37. package/src/upstream/literature.js +83 -0
@@ -0,0 +1,87 @@
1
+ import path from 'node:path';
2
+ import { getProblem } from '../atlas/catalog.js';
3
+ import { ensureDir, writeJson, writeText } from './files.js';
4
+ import { getWorkspaceArchiveDir, getWorkspaceRoot } from './paths.js';
5
+
6
+ function isSolved(problem) {
7
+ return String(problem?.siteStatus ?? '').toLowerCase() === 'solved'
8
+ || Boolean(problem?.researchState?.problem_solved);
9
+ }
10
+
11
+ export function getArchiveView(problemId) {
12
+ const problem = getProblem(problemId);
13
+ if (!problem) {
14
+ return null;
15
+ }
16
+
17
+ return {
18
+ problemId: problem.problemId,
19
+ displayName: problem.displayName,
20
+ title: problem.title,
21
+ siteStatus: problem.siteStatus,
22
+ repoStatus: problem.repoStatus,
23
+ solved: isSolved(problem),
24
+ archiveMode: isSolved(problem) ? 'method_exemplar' : 'inactive',
25
+ nextMove: isSolved(problem)
26
+ ? 'Extract reusable methods, references, and formalization hooks without treating this as an open-problem cockpit.'
27
+ : 'This problem is not currently in solved archival mode.',
28
+ };
29
+ }
30
+
31
+ export function scaffoldArchive(problemId, workspaceRoot = getWorkspaceRoot()) {
32
+ const problem = getProblem(problemId);
33
+ if (!problem) {
34
+ throw new Error(`Unknown problem: ${problemId}`);
35
+ }
36
+ if (!isSolved(problem)) {
37
+ throw new Error(`Problem ${problemId} is not solved, so archival mode is not active.`);
38
+ }
39
+
40
+ const archiveDir = getWorkspaceArchiveDir(problemId, workspaceRoot);
41
+ ensureDir(archiveDir);
42
+
43
+ const payload = {
44
+ generatedAt: new Date().toISOString(),
45
+ problemId: problem.problemId,
46
+ displayName: problem.displayName,
47
+ title: problem.title,
48
+ siteStatus: problem.siteStatus,
49
+ repoStatus: problem.repoStatus,
50
+ archiveMode: 'method_exemplar',
51
+ };
52
+
53
+ writeJson(path.join(archiveDir, 'ARCHIVE.json'), payload);
54
+ writeText(
55
+ path.join(archiveDir, 'ARCHIVE_SUMMARY.md'),
56
+ [
57
+ `# ${problem.displayName} Archive Summary`,
58
+ '',
59
+ `- Title: ${problem.title}`,
60
+ `- Site status: ${problem.siteStatus}`,
61
+ `- Repo status: ${problem.repoStatus}`,
62
+ '',
63
+ 'Archive posture:',
64
+ '- treat this solved problem as a method exemplar',
65
+ '- extract reusable arguments, formalization hooks, and references',
66
+ '- do not run the open-problem frontier loop here',
67
+ '',
68
+ ].join('\n'),
69
+ );
70
+ writeText(
71
+ path.join(archiveDir, 'METHOD_PACKET.md'),
72
+ [
73
+ `# ${problem.displayName} Method Packet`,
74
+ '',
75
+ 'Prompts:',
76
+ '- What method or reduction pattern is reusable?',
77
+ '- What verification surface is already clean here?',
78
+ '- What should be ported into open-problem packs as technique, not as status inflation?',
79
+ '',
80
+ ].join('\n'),
81
+ );
82
+
83
+ return {
84
+ archiveDir,
85
+ payload,
86
+ };
87
+ }
@@ -62,6 +62,13 @@ function renderProblemCheckpoint(problem, state) {
62
62
 
63
63
  - ${checkpointFocus}
64
64
 
65
+ ## Pack Context
66
+
67
+ - Frontier Note: ${sunflower?.frontierNotePath ?? '(none)'}
68
+ - Route History: ${sunflower?.routeHistoryPath ?? '(none)'}
69
+ - Checkpoint Template: ${sunflower?.checkpointTemplatePath ?? '(none)'}
70
+ - Report Template: ${sunflower?.reportTemplatePath ?? '(none)'}
71
+
65
72
  ## Next Honest Move
66
73
 
67
74
  - ${nextHonestMove}
@@ -92,6 +99,20 @@ function renderRouteCheckpoint(problem, state) {
92
99
  const mirageLine = sunflower
93
100
  ? `- Mirage Frontiers: ${sunflower.mirageFrontierCount}`
94
101
  : null;
102
+ const routeDetailLine = sunflower?.activeRouteDetail?.summary
103
+ ? `- Route Detail: ${sunflower.activeRouteDetail.summary}`
104
+ : null;
105
+ const ticketDetailLine = sunflower?.activeTicketDetail?.currentBlocker
106
+ ? `- Ticket Blocker: ${sunflower.activeTicketDetail.currentBlocker}`
107
+ : null;
108
+ const packArtifactLines = sunflower
109
+ ? [
110
+ `- Frontier Note: ${sunflower.frontierNotePath ?? '(none)'}`,
111
+ `- Route History: ${sunflower.routeHistoryPath ?? '(none)'}`,
112
+ `- Checkpoint Template: ${sunflower.checkpointTemplatePath ?? '(none)'}`,
113
+ `- Report Template: ${sunflower.reportTemplatePath ?? '(none)'}`,
114
+ ].join('\n')
115
+ : null;
95
116
 
96
117
  return `# Problem ${problem.problemId} Active Route Checkpoint
97
118
 
@@ -107,6 +128,8 @@ function renderRouteCheckpoint(problem, state) {
107
128
  - ${frontier}
108
129
  ${activeTicketLine}
109
130
  ${readyAtomLine}
131
+ ${routeDetailLine ? `\n${routeDetailLine}` : ''}
132
+ ${ticketDetailLine ? `\n${ticketDetailLine}` : ''}
110
133
  ${mirageLine ? `\n${mirageLine}` : ''}
111
134
 
112
135
  ## Route Story
@@ -117,6 +140,10 @@ ${mirageLine ? `\n${mirageLine}` : ''}
117
140
 
118
141
  - ${checkpointFocus}
119
142
 
143
+ ## Pack Artifacts
144
+
145
+ ${packArtifactLines ?? '- Frontier Note: *(none)*'}
146
+
120
147
  ## Continuation Frame
121
148
 
122
149
  - Continuation mode: ${state.continuation.mode}
@@ -397,9 +397,18 @@ function renderAgentStartMarkdown(problemId, record) {
397
397
  `- Harness depth: ${record.harness.depth}`,
398
398
  `- Site status: ${record.status.site_status}`,
399
399
  '',
400
+ 'Read in this order:',
401
+ '- `STATEMENT.md`',
402
+ '- `REFERENCES.md`',
403
+ '- `EVIDENCE.md`',
404
+ '- `FORMALIZATION.md`',
405
+ '- `PUBLIC_STATUS_REVIEW.md`',
406
+ '- `AGENT_WEBSEARCH_BRIEF.md`',
407
+ '',
400
408
  'First honest move:',
401
409
  `- tighten the local dossier for problem ${problemId} against its pull bundle, references, and upstream provenance before widening claims.`,
402
410
  '- read `PUBLIC_STATUS_REVIEW.md` and run the suggested queries in `AGENT_WEBSEARCH_BRIEF.md` before trusting a single public status surface.',
411
+ '- write down the smallest route hypothesis that would make the next session cleaner, even if it remains provisional.',
403
412
  '',
404
413
  ].join('\n');
405
414
  }
@@ -421,6 +430,10 @@ function renderRoutesMarkdown(problemId, record) {
421
430
  `- Current seeded route placeholder for problem ${problemId}: \`${activeRoute}\``,
422
431
  '- Treat this as a workspace-level route marker until a curated route tree is written.',
423
432
  '- Keep route progress separate from global problem status.',
433
+ '- Suggested route-writing prompts:',
434
+ ' - What is the smallest honest route name?',
435
+ ' - What theorem, evidence bundle, or survey note does it point at?',
436
+ ' - What would count as a route breakthrough versus only route clarification?',
424
437
  '',
425
438
  ].join('\n');
426
439
  }
@@ -439,6 +452,7 @@ function renderCheckpointNotesMarkdown(problemId, record) {
439
452
  '- Which upstream/public truth changed, if any?',
440
453
  '- What did the public-status review and agent websearch brief surface beyond erdosproblems.com?',
441
454
  '- Which artifact or literature bundle should the next agent read first?',
455
+ '- What route, evidence, and formalization notes should be promoted out of scratch space into canonical dossier files?',
442
456
  '',
443
457
  ].join('\n');
444
458
  }
@@ -508,3 +522,59 @@ export function seedProblemFromPullBundle(problemId, options = {}) {
508
522
  starterLoopArtifacts: STARTER_LOOP_ARTIFACTS,
509
523
  };
510
524
  }
525
+
526
+ function renderReviewChecklist(problemId, bundle, destinationDir) {
527
+ return [
528
+ `# Problem ${problemId} Maintainer Review Checklist`,
529
+ '',
530
+ `- Pull bundle: ${bundle.pullDir}`,
531
+ `- Proposed destination: ${destinationDir}`,
532
+ '',
533
+ '## Provenance',
534
+ '',
535
+ `- Upstream record included: ${bundle.upstreamRecord ? 'yes' : 'no'}`,
536
+ `- Site snapshot included: ${bundle.siteExtract || bundle.siteSummary ? 'yes' : 'no'}`,
537
+ `- Public search review included: ${bundle.publicStatusReview || bundle.publicStatusReviewMarkdown ? 'yes' : 'no'}`,
538
+ '',
539
+ '## Review questions',
540
+ '',
541
+ '- Is the public site status clearly open right now?',
542
+ '- Does the seeded short statement capture the actual mathematical focus cleanly?',
543
+ '- Are the cluster and family tags honest?',
544
+ '- Does the dossier need a deeper route starter before publication?',
545
+ '- Should this problem remain dossier-depth or enter a family pack later?',
546
+ '',
547
+ '## Ready-to-promote checks',
548
+ '',
549
+ '- Statement reviewed',
550
+ '- References reviewed',
551
+ '- Evidence starter reviewed',
552
+ '- Formalization starter reviewed',
553
+ '- Public-status review read',
554
+ '- Agent websearch brief read',
555
+ '',
556
+ ].join('\n');
557
+ }
558
+
559
+ export function reviewPullBundleForSeeding(problemId, options = {}) {
560
+ const bundle = loadPullBundle(problemId, options.fromPullDir);
561
+ const destinationRoot = path.resolve(options.destRoot ?? path.join(repoRoot, 'problems'));
562
+ const destinationDir = path.join(destinationRoot, String(problemId));
563
+ const reviewPath = path.resolve(options.dest ?? path.join(bundle.pullDir, 'REVIEW_CHECKLIST.md'));
564
+ const title = deriveTitle(problemId, bundle, options.title);
565
+ const shortStatement = deriveShortStatement(problemId, bundle, title);
566
+
567
+ writeText(reviewPath, renderReviewChecklist(problemId, bundle, destinationDir));
568
+
569
+ return {
570
+ problemId: String(problemId),
571
+ reviewPath,
572
+ pullDir: bundle.pullDir,
573
+ destinationDir,
574
+ usedUpstreamRecord: Boolean(bundle.upstreamRecord),
575
+ usedSiteSnapshot: Boolean(bundle.siteExtract || bundle.siteSummary),
576
+ usedPublicStatusReview: Boolean(bundle.publicStatusReview || bundle.publicStatusReviewMarkdown),
577
+ title,
578
+ shortStatement,
579
+ };
580
+ }
@@ -120,6 +120,22 @@ export function getWorkspaceCheckpointsDir(workspaceRoot = getWorkspaceRoot()) {
120
120
  return path.join(getWorkspaceDir(workspaceRoot), 'checkpoints');
121
121
  }
122
122
 
123
+ export function getWorkspaceRunsDir(workspaceRoot = getWorkspaceRoot()) {
124
+ return path.join(getWorkspaceDir(workspaceRoot), 'runs');
125
+ }
126
+
127
+ export function getWorkspaceRunDir(runId, workspaceRoot = getWorkspaceRoot()) {
128
+ return path.join(getWorkspaceRunsDir(workspaceRoot), String(runId));
129
+ }
130
+
131
+ export function getWorkspaceArchivesDir(workspaceRoot = getWorkspaceRoot()) {
132
+ return path.join(getWorkspaceDir(workspaceRoot), 'archives');
133
+ }
134
+
135
+ export function getWorkspaceArchiveDir(problemId, workspaceRoot = getWorkspaceRoot()) {
136
+ return path.join(getWorkspaceArchivesDir(workspaceRoot), String(problemId));
137
+ }
138
+
123
139
  export function getWorkspaceProblemCheckpointsDir(workspaceRoot = getWorkspaceRoot()) {
124
140
  return path.join(getWorkspaceCheckpointsDir(workspaceRoot), 'problem-checkpoints');
125
141
  }
@@ -35,6 +35,9 @@ function defaultState(config, workspaceRoot) {
35
35
  routeStory: null,
36
36
  checkpointFocus: null,
37
37
  nextHonestMove: 'Select or bootstrap an Erdős problem to begin.',
38
+ packArtifacts: null,
39
+ activeTicketId: null,
40
+ activeAtomId: null,
38
41
  lastCheckpointSyncAt: null,
39
42
  };
40
43
  }
@@ -101,6 +104,13 @@ function renderStateMarkdown(state) {
101
104
 
102
105
  - ${state.checkpointFocus || '(none yet)'}
103
106
 
107
+ ## Pack Artifacts
108
+
109
+ - Frontier Note: ${state.packArtifacts?.frontierNotePath || '(none)'}
110
+ - Route History: ${state.packArtifacts?.routeHistoryPath || '(none)'}
111
+ - Checkpoint Template: ${state.packArtifacts?.checkpointTemplatePath || '(none)'}
112
+ - Report Template: ${state.packArtifacts?.reportTemplatePath || '(none)'}
113
+
104
114
  ## Next Honest Move
105
115
 
106
116
  - ${state.nextHonestMove}
@@ -146,6 +156,9 @@ function deriveGenericProblemSummary(problem) {
146
156
  : 'No active route is recorded for this dossier yet.',
147
157
  checkpointFocus: 'Keep dossier truth, upstream provenance, and local route state sharply separated.',
148
158
  nextHonestMove,
159
+ packArtifacts: null,
160
+ activeTicketId: null,
161
+ activeAtomId: null,
149
162
  questionLedger: {
150
163
  openQuestions: ['What is the next smallest honest route or evidence obligation for this problem?'],
151
164
  activeRouteNotes: activeRoute ? [`Current active route: ${activeRoute}`] : [],
@@ -170,10 +183,10 @@ function deriveProblemSummary(problem) {
170
183
  : sunflower.frontierDetail || sunflower.computeSummary || sunflower.bootstrapFocus || problem.shortStatement;
171
184
  const routeStory = sunflower.activeTicket
172
185
  ? `Work ${sunflower.activeTicket.ticketId} (${sunflower.activeTicket.ticketName}) without blurring ticket-local pressure into solved-problem claims.`
173
- : (sunflower.routeStory || sunflower.bootstrapFocus || null);
186
+ : (sunflower.activeRouteDetail?.summary || sunflower.routeStory || sunflower.bootstrapFocus || null);
174
187
  const checkpointFocus = sunflower.activeTicket
175
188
  ? `Keep the board packet honest around ${sunflower.activeTicket.ticketId} while preserving the open-problem / active-route / route-breakthrough ladder.`
176
- : (sunflower.checkpointFocus || null);
189
+ : (sunflower.activeRouteDetail?.whyNow || sunflower.checkpointFocus || null);
177
190
  return {
178
191
  familyRole: sunflower.familyRole,
179
192
  harnessProfile: sunflower.harnessProfile,
@@ -187,7 +200,20 @@ function deriveProblemSummary(problem) {
187
200
  },
188
201
  routeStory,
189
202
  checkpointFocus,
190
- nextHonestMove: sunflower.nextHonestMove || sunflower.computeNextAction || 'Refresh the active route and package a new honest checkpoint.',
203
+ nextHonestMove:
204
+ sunflower.activeAtomDetail?.nextMove
205
+ || sunflower.activeTicketDetail?.nextMove
206
+ || sunflower.nextHonestMove
207
+ || sunflower.computeNextAction
208
+ || 'Refresh the active route and package a new honest checkpoint.',
209
+ packArtifacts: {
210
+ frontierNotePath: sunflower.frontierNotePath,
211
+ routeHistoryPath: sunflower.routeHistoryPath,
212
+ checkpointTemplatePath: sunflower.checkpointTemplatePath,
213
+ reportTemplatePath: sunflower.reportTemplatePath,
214
+ },
215
+ activeTicketId: sunflower.activeTicket?.ticketId ?? null,
216
+ activeAtomId: sunflower.firstReadyAtom?.atomId ?? null,
191
217
  questionLedger: sunflower.questionLedger,
192
218
  };
193
219
  }
@@ -273,6 +299,9 @@ export function syncState(workspaceRoot = getWorkspaceRoot()) {
273
299
  routeStory: summary.routeStory,
274
300
  checkpointFocus: summary.checkpointFocus,
275
301
  nextHonestMove: summary.nextHonestMove,
302
+ packArtifacts: summary.packArtifacts,
303
+ activeTicketId: summary.activeTicketId,
304
+ activeAtomId: summary.activeAtomId,
276
305
  lastCheckpointSyncAt: existing.lastCheckpointSyncAt ?? null,
277
306
  };
278
307