Skip to content

Commit c0b2816

Browse files
authored
feat: add branch-driven discovery and archive runner v2 (#5)
* feat: add branch-driven archive runner v2 * docs: clarify archive runner v2 workflow
1 parent a8e210a commit c0b2816

6 files changed

Lines changed: 1167 additions & 213 deletions

File tree

README.md

Lines changed: 110 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,92 @@ This project explores mathematical creativity in AI—whether it can move beyond
1212

1313
## Mathematical Object Origin Archive Runner
1414

15-
This runner supports the first research direction by generating and verifying origin archives for mathematical concepts and objects. It processes an ordered collection serially, gives each object its own Moonshine project and session, and writes the final Markdown archive only after verification passes.
15+
This runner supports the first research direction by creating verified origin archives for mathematical concepts, objects, and methods. Each archive focuses on the mathematical problem that motivated the object, the difficulty that had to be overcome, the ideas that led to its formation, and the essential role of its defining structure.
1616

17-
## Moonshine dependency
17+
Objects are processed serially. Each object receives its own Moonshine project and session, and the final Markdown archive is published only after verification passes.
18+
19+
## What Changed in v2
20+
21+
The original runner accepted a predefined JSON queue. Version 2 retains that workflow and adds branch-driven archive discovery.
22+
23+
- Select objects directly from supplied mathematical branches; no object list is required in advance.
24+
- Choose objects that arose in response to a concrete mathematical problem or a well-defined problem class.
25+
- Select, write, and verify one object within one Moonshine task.
26+
- Continue until the requested number of verified archives has been published.
27+
- Pass previously attempted object names into later tasks to reduce repetition.
28+
- Record failed attempts without counting them toward the requested total.
29+
- Resume interrupted projects and sessions from persistent runner state.
30+
- Show normal Moonshine output in the terminal with `--stream-output`.
31+
- Preserve the predefined JSON queue mode for collections assembled manually.
32+
33+
The archive specification and verification criteria now emphasize precise mathematical context rather than a chronology of people, publications, and dates.
34+
35+
The previous queue-focused implementation is preserved on the [`archive-runner-v1`](https://github.com/DeepMathLLM/Creative-Intelligence/tree/archive-runner-v1) branch.
36+
37+
## Moonshine Dependency
1838

1939
This is a Moonshine runtime extension, not a standalone application. Install, initialize, and configure Moonshine by following the [Moonshine repository](https://github.com/DeepMathLLM/Moonshine/tree/main).
2040

21-
Place this repository directly inside the initialized Moonshine runtime home, not inside the Moonshine source-code package. With the default Moonshine setup, the runtime home is `~/.moonshine`. If Moonshine was initialized with `--home`, use that directory instead.
41+
Place this repository directly inside the initialized Moonshine runtime home, not inside the Moonshine source-code package:
2242

2343
```text
2444
<MOONSHINE_HOME>/
25-
├── config.yaml
26-
├── config/
27-
├── projects/ # Moonshine projects created for individual objects
28-
├── sessions/ # Moonshine session records
29-
├── skills/
30-
│ └── installed/ # Runtime copies installed automatically by the runner
31-
└── Creative-Intelligence/ # This GitHub repository
45+
└── Creative-Intelligence/
3246
├── README.md
3347
├── run_archive.py
3448
├── archive-format-specification.md
3549
├── tests/
36-
│ └── test_run_archive_offline.py
37-
├── skills/
38-
│ ├── math-object-origin-archive/
39-
│ │ └── SKILL.md
40-
│ └── verify-math-object-origin-archive/
41-
│ └── SKILL.md
50+
└── skills/
51+
├── math-object-origin-archive/
52+
│ └── SKILL.md
53+
└── verify-math-object-origin-archive/
54+
└── SKILL.md
55+
```
56+
57+
The runner treats the parent of `Creative-Intelligence` as `MOONSHINE_HOME` and automatically installs its two task-specific skills into that runtime when it starts.
58+
59+
Run all commands from the initialized Moonshine runtime home:
60+
61+
```bash
62+
cd <MOONSHINE_HOME>
4263
```
4364

44-
`config.yaml` and the other runtime directories are created by `python -m moonshine init`. The runner treats its parent directory as `MOONSHINE_HOME` and automatically installs the two included skills into that runtime when it starts.
65+
## Branch-Driven Discovery
66+
67+
This is the primary v2 workflow. Supply one or more mathematical branches, the number of verified archives to produce, and a stable run name:
68+
69+
```bash
70+
python Creative-Intelligence/run_archive.py --branches "Differential Geometry" "Algebraic Topology" "Functional Analysis" --target-archives 10 --run-name graduate-math-v2 --stream-output
71+
```
72+
73+
The runner repeatedly performs one complete object task:
74+
75+
1. Select a distinct object from the supplied branches.
76+
2. Create its archive according to `archive-format-specification.md`.
77+
3. Submit the archive to the verification tool.
78+
4. Publish it only if verification passes.
79+
80+
Only successfully verified archives count toward `--target-archives`. Failed attempts remain in the run state and their names are treated as previously attempted objects.
81+
82+
### Resume a Discovery Run
83+
84+
Run the same command again with the same:
85+
86+
- `--run-name`;
87+
- branches in the same order;
88+
- `--target-archives` value.
89+
90+
These values define the identity of the run. Changing them while reusing the same run name is rejected to prevent an interrupted run from being resumed with different inputs.
4591

46-
## Input
92+
To retry recorded verification failures before discovering additional objects, add:
4793

48-
Create a UTF-8 JSON file containing an ordered list of objects. The JSON file may be stored anywhere:
94+
```bash
95+
--retry-failed
96+
```
97+
98+
## Predefined JSON Queue
99+
100+
Use this mode when the mathematical objects have already been selected or local materials have been collected. Create a UTF-8 JSON file:
49101

50102
```json
51103
{
@@ -65,31 +117,21 @@ Create a UTF-8 JSON file containing an ordered list of objects. The JSON file ma
65117
}
66118
```
67119

68-
`materials` is optional and accepts local UTF-8 text or Markdown files. Relative material paths are resolved from the directory containing the input JSON file, not from the repository or runtime home.
69-
70-
## Run
71-
72-
Run commands from the initialized Moonshine runtime home. Replace `<MOONSHINE_HOME>` with the runtime directory used during Moonshine initialization:
73-
74-
```bash
75-
cd <MOONSHINE_HOME>
76-
```
77-
78-
This must be the same directory previously passed to `python -m moonshine --home <MOONSHINE_HOME> init`, or the runtime directory created by the default initialization.
120+
`materials` is optional and accepts local UTF-8 text or Markdown files. Relative paths are resolved from the directory containing the input JSON file. PDF, Word, and other binary files must first be converted to UTF-8 text or Markdown.
79121

80122
Process every object serially:
81123

82124
```bash
83125
python Creative-Intelligence/run_archive.py path/to/concepts.json
84126
```
85127

86-
Optionally validate the input without starting Moonshine sessions:
128+
Validate the input without creating runtime state:
87129

88130
```bash
89131
python Creative-Intelligence/run_archive.py path/to/concepts.json --validate-only
90132
```
91133

92-
Start from a specific 1-based index:
134+
Start at a specific 1-based index:
93135

94136
```bash
95137
python Creative-Intelligence/run_archive.py path/to/concepts.json --start-index 5
@@ -101,23 +143,50 @@ Retry objects previously marked as failed:
101143
python Creative-Intelligence/run_archive.py path/to/concepts.json --retry-failed
102144
```
103145

104-
Optional flags include `--max-turns N` and `--verbose`. Run the same command again to resume the saved Moonshine sessions. After a run has started, keep its input JSON unchanged; use a new, uniquely named JSON file for another queue.
146+
Useful options include:
147+
148+
- `--max-turns N`: set the maximum repair turns for queued or retried objects;
149+
- `--verbose`: print Moonshine status events;
150+
- `--stream-output`: show reasoning, text, tool summaries, and candidate archives in the terminal.
105151

106-
## Generated files
152+
Run the same command again to resume. After a queue has started, do not modify its JSON file or referenced material files. Use a new JSON filename for a different queue.
107153

108-
The following directories are created automatically when the runner is used and are not part of the initial repository structure:
154+
## Verification and Publication
109155

110-
- Final archives: `Creative-Intelligence/archives/<input-name>/`
111-
- Queue state and project/session associations: `Creative-Intelligence/runs/<input-name>.state.json`
156+
The runner exposes a session-bound verification tool that checks:
112157

113-
## Offline regression tests
158+
- mathematical correctness;
159+
- accuracy and specificity of the mathematical context and formation;
160+
- whether the archive identifies the concrete problem, obstacle, structural mechanism, and resulting change;
161+
- compliance with the active format specification.
114162

115-
The deterministic runner contracts can be tested from a standalone checkout without an initialized Moonshine runtime, provider credentials, network access, or model calls. The test harness uses only the Python standard library and provides import-time stubs for the narrow Moonshine symbols required to load `run_archive.py`.
163+
Accepted verifier output is bound to the expected project, session, and archive hash. The runner refuses to publish unverified content or overwrite a different existing archive.
116164

117-
Run from the `Creative-Intelligence` repository root:
165+
Resumed sessions must also match the expected Moonshine mode, project, and agent identity. Local materials are bound to their resolved paths and SHA-256 hashes, so changed material cannot silently enter an existing run.
166+
167+
## Generated Files
168+
169+
These directories are created by the runner and are not part of the initial repository:
170+
171+
- Final Markdown archives: `Creative-Intelligence/archives/<run-name>/`
172+
- Run state and project/session associations: `Creative-Intelligence/runs/<run-name>.state.json`
173+
174+
For JSON queue mode, `<run-name>` is derived from the input filename. Moonshine stores the associated projects and sessions in its own runtime directories.
175+
176+
## Tests
177+
178+
Run the deterministic offline regression suite from the repository root:
118179

119180
```bash
120181
python -m unittest discover -s tests -p "test_*.py" -v
121182
```
122183

123-
These tests cover runner-owned deterministic behavior such as queue validation, immutable queue state, format-placeholder checks, verifier-output integrity, archive overwrite protection, and provider preflight logic. They do **not** simulate Moonshine agent execution, session storage, MCP tools, or real verification-provider behavior; those remain runtime integration concerns.
184+
These tests require no configured provider, credentials, network access, or live Moonshine session.
185+
186+
The separate integration suite exercises the real Moonshine runtime with deterministic provider substitutes:
187+
188+
```bash
189+
python -m unittest -v tests.integration_run_archive_moonshine
190+
```
191+
192+
It covers session persistence, skill and tool registration, material staging, verification-event storage, recovery, identity rejection, and archive publication. It does not evaluate live model quality, live provider availability, or web/MCP behavior.

archive-format-specification.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
{Content}
1919

20-
### Background
20+
### Mathematical Context and Formation
2121

2222
{Content}
2323

@@ -27,7 +27,7 @@
2727

2828
## 3. Notes
2929

30-
{Relevant precursors, historical disputes, related objects, or other supplementary information.}
30+
{Related objects, terminology distinctions, limitations, or other supplementary information.}
3131

3232
## 4. Sources
3333

@@ -38,14 +38,18 @@
3838

3939
## Writing Instructions
4040

41-
1. Each archive must document exactly one mathematical object.
41+
1. Each archive must document exactly one mathematical object that arose in response to a concrete mathematical problem or a well-defined class of problems.
4242

43-
2. “Archive Information,” “Core Record,” and “Sources” are required sections. “Notes” is optional.
43+
2. “Archive Information” and “Core Recordare required sections. “Notes” and “Sources” are optional.
4444

45-
3. The Core Record must contain the three fixed subsections “Precise Description,” “Background,” and “Essential Role.” “Precise Description” states the object accurately in mathematical terms. “Background” explains the setting from which it arose.
45+
3. The Core Record must contain the three fixed subsections “Precise Description,” “Mathematical Context and Formation,” and “Essential Role.” “Precise Description” states the object accurately in mathematical terms.
4646

47-
4. Cite important historical claims with numbered references such as `[1]` and `[2]`. State uncertainty explicitly when the evidence is limited or disputed.
47+
4. “Mathematical Context and Formation” presents a clear and coherent account of the concrete mathematical problem, or well-defined class of problems, that motivated the object. It explains where the mathematical difficulty lay, why the available concepts or methods were inadequate, and which ideas or insights led to the object’s formation. These elements must be connected through their mathematical relationships rather than listed as separate facts, while their emphasis and order depend on the object. The archive concerns mathematical meaning and formation, not a historical story.
4848

49-
5. Distinguish mathematical facts, documented historical facts, and interpretive synthesis. Maintain a professional and objective tone.
49+
5. “Essential Role” explains precisely which part of the motivating problem the object made tractable, which difficulties it overcame, bypassed, or reformulated, and how specific features of its definition or structure did so. It should distinguish this direct contribution from generic importance or later applications, while also explaining any deeper understanding or structural viewpoint the object introduced.
5050

51-
6. Write mathematical symbols and formulas in LaTeX.
51+
6. If the archive refers to any material, include “Sources” and list that material there. Use numbered citations such as `[1]` and `[2]` consistently.
52+
53+
7. Distinguish established mathematical facts from interpretive synthesis. State uncertainty explicitly when a claim is uncertain or disputed. Maintain a professional and objective tone.
54+
55+
8. Write mathematical symbols and formulas in LaTeX.

0 commit comments

Comments
 (0)