Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
1a00a13
docs(algernon): record H-M0/H-M1 artifact custody and H-M2 verificati…
patrickdugan Nov 3, 2026
06fccf6
tools(algernon): add private Hugging Face archive upload with round-t…
patrickdugan Nov 3, 2026
e7f2bb1
docs: inventory original H-M experimental source files
patrickdugan Nov 3, 2026
aacdda5
test(algernon): recover exact CPU toy-contract test from sandbox archive
patrickdugan Nov 3, 2026
fd1808c
feat(algernon): recover exact toy recurrent graft and RV32 CPU refere…
patrickdugan Nov 3, 2026
2b0a5b1
docs(algernon): add verified CPU source recovery and test command
patrickdugan Nov 3, 2026
12898c9
restore(algernon): recover sandbox experiment unit tests and runtime …
patrickdugan Nov 3, 2026
7b01431
restore(algernon): recover sandbox experiment unit tests and runtime …
patrickdugan Nov 3, 2026
e27afbf
restore(algernon): recover sandbox experiment unit tests and runtime …
patrickdugan Nov 3, 2026
ddf0816
restore(algernon): recover sandbox experiment unit tests and runtime …
patrickdugan Nov 3, 2026
b52531e
restore(algernon): recover exact H-M0 cost-aware stopping comparator
patrickdugan Nov 3, 2026
955f821
restore(algernon): recover original H-M0 probe selection experiment
patrickdugan Nov 3, 2026
3764174
restore(algernon): recover original H-M1 grammar revision controller …
patrickdugan Nov 3, 2026
6018c6a
restore(algernon): recover original H-M0 terminal-utility learner
patrickdugan Nov 3, 2026
f5f5150
docs(algernon): record byte-identical H-M0/H-M1 code recovery and CPU…
patrickdugan Nov 3, 2026
a43f0ef
docs(algernon): update recovery README now that H-M0/H-M1 source is o…
patrickdugan Nov 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions research/algernon/HM_SANDBOX_HANDOFF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# H-M0/H-M1 sandbox handoff and evidence status

This branch exists to bridge the independently executed ChatGPT CPU sandbox experiments into the Algernon research workflow. Based on Algernon PR #33; **no H-M2 results are verified**.

## Artifact custody

The complete archive is named `algernon_claude_handoff.zip`, SHA-256 `88d8e23581f0445aca9ac7b7b9a9c7f8d7df34f00bbc5126fced84511053f7b4`. It contains the original `algernon_hm1_revision_sandbox.zip` payload, whose SHA-256 is `68954e95d8b4c50ac480e22c0ab085e8deaa6f12f959ebc4fc24158df860ac22`, plus a handoff note. Source-only reproducibility archive `algernon_hm_source.tar.gz` has SHA-256 `432b45e513d00eef3b83d41ef1407074d763aa35b373daa5555298b1cc685578`.

**Current GitHub status:** This commit contains the custody manifest and reproduction instructions. The original ZIP and its binaries/raw records have **not** been uploaded to GitHub. They are attached to the ChatGPT conversation as sandbox downloads. Do not claim the data are hosted here until a separate upload has been hash-verified.

## Verified scope

- H-M0 baseline, terminal-utility, and stopping-comparison code and records exist in the original ZIP.
- H-M1 bounded grammar expansion code, trained-policy checkpoint, held-out and confirmation records, metrics, reports, and tests exist in the ZIP.
- The extracted archive's registry validator passed; 5 registry tests and 27 experimental tests passed on CPU.
- These checks establish executable contract tests, not an independent retraining or numerical reproduction.
- H-M2 was described in conversation, but no H-M2 code, manifest, checkpoint or records are available. Its reported numerical scores are **unverified**.
- There is no execution receipt for the actual Qwenputer-4B compiled processor or the Qwen3.5-0.8B recurrent graft.

## Download-to-checkout procedure

Download the attached `algernon_claude_handoff.zip` from the ChatGPT conversation, verify its SHA-256 above, extract the inner archive, and copy the `experiments/` directory plus provenance reports into a local scratch branch. Keep the raw records and model weights in an ignored or release-artifact location rather than the main Git tree.

On Windows PowerShell:

```powershell
$archive = Join-Path $HOME 'Documents\Codex\algernon_claude_handoff.zip'
(Get-FileHash $archive -Algorithm SHA256).Hash.ToLower()
Expand-Archive -LiteralPath $archive -DestinationPath (Join-Path $HOME 'Documents\Codex\algernon_handoff') -Force
# Inspect README within extracted archive for the inner ZIP and expand it.
cd (Join-Path $HOME 'Documents\Codex\algernon_handoff\algernon_sandbox')
python -m research.algernon.validate_register
python -m unittest discover -s research/algernon/tests -v
python -m unittest discover -s experiments/tests -v
```

Compare hashes, do not mix experiments with the four unrun H-C/H-R/H-W/H-J hypotheses, and retain held-out splits. Import source into the research tree only after checks pass.

## Next publication decision

Place the experimental implementation and small receipts in `research/algernon/metacognition/` under a dedicated PR, with raw larger records in a hash-addressed artifact store. A university exploratory paper can cite these after independent reruns, full source/seed inspection, and protocol review. H-M2 must be rerun under a newly frozen specification and named as a new experiment.
24 changes: 24 additions & 0 deletions research/algernon/metacognition/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Algernon H-M0/H-M1: recovered CPU experiment implementation

This folder contains byte-identical imports of the original ChatGPT sandbox's runnable H-M0/H-M1 experimental implementation and the CPU toy contracts. Every imported file has been checked against the archived Git blob hash. See [RECOVERY_STATUS.md](RECOVERY_STATUS.md) for SHA identities, split/seed commands, and exact local setup.

**Now available:** the H-M0 information-gain pruner, terminal-utility controller, cost-aware stopping control, H-M1 bounded grammar revision controller, and all five associated test modules. The optional historical timing benchmark script is still missing.

**Evidence boundary:** these are synthetic CPU experiments. The original raw JSONL records and PyTorch checkpoint binaries remain in the chat sandbox archive and are not yet in this GitHub branch. They can be regenerated from the preserved scripts and seed ranges; independent reproduction should record the new environment and hashes. H-M2 still lacks its original implementation and receipts, so previously reported H-M2 numbers are unverified.

## Run tests

From the Compactification-Theory checkout root, with `numpy` and CPU `torch` installed:

```bash
PYTHONPATH=research/algernon/metacognition python -m unittest discover -s research/algernon/metacognition/experiments/tests -v
```

On PowerShell:

```powershell
$env:PYTHONPATH = "research/algernon/metacognition"
python -m unittest discover -s research/algernon/metacognition/experiments/tests -v
```

The original extracted source suite passes 27/27 unit tests in the sandbox. Rerun the GitHub copy independently before treating its results as a reproduced observation. Training commands are in RECOVERY_STATUS.md.
45 changes: 45 additions & 0 deletions research/algernon/metacognition/RECOVERY_STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# H-M0/H-M1 executable recovery status

This branch is the direct import of the preserved ChatGPT sandbox experiments into Algernon. GitHub blob IDs for the files below were checked against the original ZIP bytes, not rewritten implementations.

| Experiment source | Original Git blob SHA | On GitHub |
| --- | --- | --- |
| `experiments/toy_contracts.py` | `16a92153570e943c4b2e4287bcd7f8ab66c309bb` | yes |
| `experiments/tests/test_toy_contracts.py` | `21805955f4ab283cc0501d608081b177fba57192` | yes |
| `experiments/h_m0_pruner.py` | `d62a43c27f5fa6c1f67208c5f52ae5f5678bbd9f` | yes |
| `experiments/h_m0_terminal.py` | `8e601a330f6e11610ee89e63a4a57689f22ee3ad` | yes |
| `experiments/h_m0_fair_baselines.py` | `36ce308cbc1a22b014d87578be8a864a5d8c9760` | yes |
| `experiments/h_m1_revision.py` | `d438519c0a79aad649302d27704be1a6200efef7` | yes |
| `experiments/tests/test_h_m0_pruner.py` | `f94a8a31cb9277f7b8323cc9241f64ac3ef88c90` | yes |
| `experiments/tests/test_h_m0_terminal.py` | `f71f94145fe7ae1b9cf11dc6786d6fa4e9ecc4cb` | yes |
| `experiments/tests/test_h_m0_fair_baselines.py` | `9628e47be2cfce37ace36770031de16547c31284` | yes |
| `experiments/tests/test_h_m1_revision.py` | `5e1eaec37744423424466e8061638179f560e49c` | yes |
| `experiments/benchmark_terminal_runtime.py` | `ffb3d462bf813cd6ad99b9ff51e73193700d4744` | pending; optional timing script |

The original archive is SHA-256 `88d8e23581f0445aca9ac7b7b9a9c7f8d7df34f00bbc5126fced84511053f7b4`. H-M0/H-M1 original binary weights and full JSONL records remain outside GitHub until a separately verified artifact transfer. **H-M2 remains unverified and requires a new frozen protocol.**

## Commands (CPU)

Use a detached checkout of this branch. From the repository root:

```powershell
$env:PYTHONPATH = "research/algernon/metacognition"
python -m unittest discover -s research/algernon/metacognition/experiments/tests -v

# H-M0 initial policy; creates original predecessor checkpoint in the expected location.
python -m experiments.h_m0_pruner --output research/algernon/metacognition/results/h_m0_01 --train-states 4000 --test-episodes 1000 --epochs 18 --seed 20261103

# H-M0 terminal policy. Expected predecessor checkpoint is results/h_m0_01/policy.pt
# under metacognition/, so copy or symlink the generated initial checkpoint into that layout.
python -m experiments.h_m0_terminal --output research/algernon/metacognition/results/h_m0_02 --train-worlds 700 --validation-worlds 150 --test-worlds 1000 --oracle-test-worlds 100 --rollouts 2 --epochs 18 --seed 20261104

# Second independent held-out stopping comparison.
python -m experiments.h_m0_fair_baselines

# H-M1 grammar-revision study, self-contained and independent of H-M0 checkpoint.
python -m experiments.h_m1_revision --out research/algernon/metacognition/results/h_m1_01 --train 2400 --val 350 --test 1200 --confirm 1000 --epochs 28 --seed 20261103
```

The source imports use `experiments`; `PYTHONPATH` makes that package visible. The generated outputs are research artifacts and should be excluded from normal Git commits. Preserve exact seed ranges and do not tune on the final test/confirmation ranges.

**Scientific status:** the code and tests are on GitHub; results require independent rerun, and old observed measurements await raw-record publication. These are synthetic CPU studies only, distinct from Qwenputer and Qwen3.5 graft benchmarks.
23 changes: 23 additions & 0 deletions research/algernon/metacognition/SOURCE_RECOVERY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# H-M experiment source recovery

The historical ChatGPT sandbox archive has 11 Python files (70,774 source bytes) under `experiments/`, including the H-M0 baseline/pruner, H-M0 terminal-utility model, cost-aware stopping comparisons, H-M1 revision environment, toy contracts, and five test modules.

The corresponding full archive remains in ChatGPT's sandbox. This repository currently holds the handoff and upload instructions, not the full source or all results.

**Reproduction caveat:** H-M2 was reported in conversation without a retained runnable source or evaluation record. Recreate and register it separately.

The GitHub connector supports text file writes. A reliable transfer requires importing the files from a host with access to the original archive. The SHA-256 of the full archive is `88d8e23581f0445aca9ac7b7b9a9c7f8d7df34f00bbc5126fced84511053f7b4`.

## Inventory

- `benchmark_terminal_runtime.py`
- `h_m0_fair_baselines.py`
- `h_m0_pruner.py`
- `h_m0_terminal.py`
- `h_m1_revision.py`
- `toy_contracts.py`
- `tests/test_h_m0_fair_baselines.py`
- `tests/test_h_m0_pruner.py`
- `tests/test_h_m0_terminal.py`
- `tests/test_h_m1_revision.py`
- `tests/test_toy_contracts.py`
82 changes: 82 additions & 0 deletions research/algernon/metacognition/experiments/h_m0_fair_baselines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""H-M0 v2 post-hoc fairness follow-up: fresh 500M worlds and greedy MAP stop.

This study was designed after the 400M final test but before inspecting 500M outcomes.
The exact already-trained terminal model stays frozen. The new baseline can stop
and maximizes one-step expected *terminal MAP decision utility* per probe.
"""
from __future__ import annotations
import hashlib
import json
import time
from pathlib import Path

import numpy as np
import torch
from experiments.h_m0_pruner import N_H, N_PROBES, BUDGET, make_episode, posterior_update
from experiments.h_m0_terminal import (
COST_PENALTY, Selector, TerminalPlanner, paired_interval, results_summary,
run as run_existing, legal_actions, posterior_from_outcomes,
)


def greedy_map(ep):
mask, outcomes, spent, probes = 0, 0, 0., []
while True:
p=posterior_from_outcomes(ep,mask,outcomes)
legal=legal_actions(ep,mask,spent)
if not legal:break
gains=[]
for i in legal:
pi=float(np.dot(p,ep.likelihoods[i]))
pu=posterior_update(p,ep.likelihoods[i],1)
pn=posterior_update(p,ep.likelihoods[i],0)
accuracy_gain=pi*pu.max()+(1-pi)*pn.max()-p.max()
gains.append(float(accuracy_gain-COST_PENALTY*ep.costs[i]))
index=int(np.argmax(gains))
if gains[index]<=1e-10:break
a=legal[index]
spent+=float(ep.costs[a]);mask|=1<<a;outcomes|=int(ep.observations[a])<<a;probes.append(a)
p=posterior_from_outcomes(ep,mask,outcomes)
return {'seed':int(ep.seed),'arm':'greedy_MAP_with_stop','truth':ep.truth,
'predicted':int(p.argmax()),'correct':int(p.argmax()==ep.truth),
'expected_correct':float(p.max()),'terminal_utility':float(p.max()-COST_PENALTY*spent),
'brier':float(np.sum((p-np.eye(N_H)[ep.truth])**2)),
'log_loss':float(-np.log(max(1e-12,p[ep.truth]))),
'cost':spent,'probes':probes,'decisions':len(probes)+1,'posterior':np.round(p,8).tolist()}


def main():
base=Path(__file__).resolve().parents[1]
out=base/'results/h_m0_02'
study='fair_stop_followup'
model=Selector();model.load_state_dict(torch.load(out/'terminal_selector.pt',weights_only=True,map_location='cpu'));model.eval()
armlist=['random','bayes_ig','terminal_policy','greedy_MAP_with_stop']
records=[]
start=time.perf_counter()
# This 500M seed range is separate from the original 300M, v2 test 400M,
# and expert-data 100M / 350M generator streams.
for j in range(1000):
ep=make_episode(500000000+j)
for arm in armlist:
r=greedy_map(ep) if arm=='greedy_MAP_with_stop' else run_existing(arm,ep,model)
records.append(r)
means={a:{key:float(np.mean([r[key] for r in records if r['arm']==a])) for key in
['correct','expected_correct','terminal_utility','brier','log_loss','cost','decisions']}
for a in armlist}
comparisons={a:{key:paired_interval(records,'terminal_policy',a,key) for key in ['correct','terminal_utility','cost']}
for a in armlist if a != 'terminal_policy'}
result={'status':'posthoc_comparator_preregistered_on_new_seed_range',
'n_fresh_worlds':1000,'seed_range':[500000000,500000999],
'mean':means,'comparisons':comparisons,
'wall_seconds':time.perf_counter()-start,
'interpretation':'myopic MAP baseline sees same known likelihoods and budget, and may stop at any time',
'note':'exact dynamic-programming expert omitted from this 1000-case comparator; it was measured on a separate 100-case subset in first evaluation'}
(out/(study+'_metrics.json')).write_text(json.dumps(result,indent=2)+'\n')
with (out/(study+'_records.jsonl')).open('w') as f:
for rec in records:f.write(json.dumps(rec)+'\n')
print(json.dumps({'accuracy':{a:round(means[a]['correct'],4) for a in armlist},
'utility':{a:round(means[a]['terminal_utility'],4) for a in armlist},
'cost':{a:round(means[a]['cost'],3) for a in armlist},
'learned_minus_greedy_MAP':comparisons['greedy_MAP_with_stop']},indent=2))

if __name__=='__main__':main()
Loading
Loading