Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions .github/workflows/dg-metta12-courier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: DG-METTA-12 courier CPU contract

on:
pull_request:
paths:
- "metta_research_bench/courier_transfer/**"
- "tests/unit/test_dg_metta12_reference.py"
- ".github/workflows/dg-metta12-courier.yml"
workflow_dispatch:

permissions:
contents: read

jobs:
reference-wiring:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Check exact CPU courier reference semantics
run: python -m unittest discover -s tests/unit -p 'test_dg_metta12_*.py' -v
- name: Verify pinned split ID fingerprint and result schema
run: |
python metta_research_bench/courier_transfer/manifest_check.py
python metta_research_bench/courier_transfer/generator.py
45 changes: 45 additions & 0 deletions metta_research_bench/courier_transfer/ORACLE_CONTRACT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# DG-METTA-12 | Oracle and native courier adapter contract

The native Storyworld/MeTTa runtime is the authority for courier state transitions. A courier state is an immutable ledger containing the current location, independent witnessed-source IDs, held permits, carried parcels, and completed deliveries. Typed actions are `move(node)`, `inspect(witness)`, `permit(id)`, `pickup(id)`, `deliver(id)`, and `STOP`. Permits may require distinct independent source identities. Two aliases backed by one source count once. An episode succeeds only when every required parcel was delivered and the policy emitted a correct STOP.

## Required native adapter

Before any train or evaluation claim, fetch and pin the **full** Storyworld SHA for the locally reported courier kernel `4cfe171` and its exact Hyperon dependencies. Implement:

```python
class NativeCourierAdapter:
def initial(self, root_id: str, root_seed: int) -> object: ...
def legal(self, state: object) -> tuple[str, ...]: ...
def verify_step(self, state: object, action: str) -> tuple[bool, object, str]: ...
def delivered(self, state: object) -> frozenset[str]: ...
def required_deliveries(self, state: object) -> frozenset[str]: ...
def state_sha256(self, state: object) -> str: ...
def public_features(self, state: object) -> object: ...
def certify_macro(self, state: object, actions: tuple[str, ...]) -> tuple[bool, object, str]: ...
```

Every result must carry proof/transition receipts and an input-state digest. `verify_step` consumes a policy verifier call, including a rejected proposal. Grading checks are a separate meter. The Looped Transformer sees typed public features and the ordered allowed-action vocabulary; it never sees gold labels or the oracle value table at inference. No state mutation may occur on a failed proof.

## Exact set oracle

For remaining action horizon `h`, define a lexicographic Bellman value:

```
V(s,0) = (delivered_count(s), 0)
V(s,h) = max_lex(
(delivered_count(s), 0), # STOP
{ (V(step(s,a),h-1).deliveries, V(step(s,a),h-1).negative_steps - 1)
for a in legal(s) excluding STOP }
)
A*(s,h) = { a in legal(s) : continuation_value(s,a,h) == V(s,h) }
```

The second coordinate prefers the fewest accepted steps for the best attainable delivery count, preserving multiple shortest successful action sequences. Keep only states where a full completion is attainable for successful-action training. Recheck every oracle label against an independent replay. Canonical A uses `min(sorted(A*))`; hashed B takes SHA-256 of `root_id|seed|state|sorted(A*)` and chooses an index modulo `len(A*)`; C uses the full set loss. The three fitted arms share the identical normalized legal-action logits and verifier-call ceiling. An optimal action set may contain more than one member while still representing a single supervised state presentation.

## STOP macro contract

The learned C checkpoint is reused byte-for-byte in D. A, B, C and D all share a ceiling of five **policy verifier calls**. D reserves up to two checks until the policy proposes STOP. A macro is a bounded atomic transaction: both typed state changes are certified against the native kernel, including their joint final state, before either is committed. Failures leave the original world unchanged. A native implementation lacking transaction/rollback support blocks D; a Python simulation may validate plumbing but cannot be counted as a native MeTTa repair. Record actual verifier calls, partial-check failures, macro attempts, certified and committed macros, and paired regressions.

## Reproducibility and release gates

Check split ID/seed disjointness and both oracle value and tie-set correctness. Require independent witness-source handling, permit ordering, graph topology, STOP, and atomicity tests. Pin the generator, MeTTa rule hashes, full native commit, tokenizer, protocol, source and training data hashes, initial-model hashes, checkpoint hashes, optimizer budget and the development report before any frozen run. Abort on changed inputs or attempts to tune on frozen labels. Frozen primary runs once per locked fitting cohort. `reference_wiring` is never conflated with `native` results.
44 changes: 44 additions & 0 deletions metta_research_bench/courier_transfer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# DG-METTA-12 | Storyworld courier action-set transfer

**Status: CPU reference wiring (2026-11-23).** The reported native Storyworld courier commit `4cfe171` could not be resolved on the remote `MoralityLabAI/metta-storyworld` repository; its main tree currently has no courier kernel. The local three-test native report and uncommitted DataGoblin comparison could not be audited here. Native transfer remains gated.

## Preregistered question

Does teaching the Looped Transformer to assign probability to **all equally good actions** improve verified completion when the actions are courier navigation, evidence collection, permit acquisition, pickup, delivery, and STOP?

| Arm | Training objective | Inference |
| --- | --- | --- |
| A | Lexicographically first action among all exact optima | Looped Transformer |
| B | SHA-256 hashed singleton from the exact same optimal set | Looped Transformer |
| C | Full optimal-action-set log-sum-exp objective | Looped Transformer |
| D | Exactly C's frozen checkpoint | Transformer plus certified MeTTa STOP macro |
| E | No training | Exact bounded oracle reference |

The **primary confirmation** is C minus B on full verified deliveries followed by a correct STOP. A is the additional canonical-label control. All learned arms A/B/C/D share the same five-call verifier ceiling, so the primary C-B comparison is budget-matched. D minus C is the separate inference comparison. Prior MeTTa curation and docket gains motivate this test and are not courier outcomes.

## Split firewall

`roots_manifest.json` freezes 520 deterministic root IDs, root-seed derivation, and a SHA-256 fingerprint of the complete ordered ID list. Train/development/frozen use distinct roots from four families; transfer uses withheld family names.

| Split | Families | Roots each |
| --- | --- | ---: |
| Train | route_ties, permit_gate, multi_drop, evidence_ledger | 48 |
| Development | same four | 12 |
| Frozen primary | same four with fresh roots | 40 |
| Transfer | permit_chain, evidence_collision, unseen_topology | 40 |

For each seed 1101, 1102, 1103, use the same initial weights, public state features, valid-action vocabulary, state presentations, batch indices, 600 AdamW updates and 48 examples per update. Choose B by the documented stable hash. C uses `-log(sum_{a in A*(s,h)} softmax(z)[a])`. Count one training presentation per state regardless of tie multiplicity.

Every generated root must have a completed path with at most five charged primitive checks. A root qualifies for successful-action training only when the exact bounded oracle can finish all deliveries. Root-local and seed-local effects are preserved. Frozen primary is held closed until the source, data and checkpoint SHA-256 receipts and the development report are locked. Paired 95% root-clustered bootstrap retains all model seeds within each resampled root. The prespecified C-B success gate is an interval lower bound above zero. Always report every seed and transfer result, including failures.

## Gates and reproduction

1. Run `python metta_research_bench/courier_transfer/generator.py`, `python -m unittest discover -s tests/unit -p test_dg_metta12_reference.py -v` and `python metta_research_bench/courier_transfer/manifest_check.py` on CPU. This independently implemented courier model only establishes a wiring gate.
2. Push the complete native courier commit to Storyworld, pin its full SHA and runtime, run the three original targeted tests, then implement the adapter specified in `ORACLE_CONTRACT.md`. Differentially replay small shared states against the Python reference and inspect all disagreements.
3. Train A/B/C using native verified oracle action sets; pin the upstream LoopedDecoderLM revision stated in `protocol.json`. Lock source and checkpoints before opening frozen roots.
4. Evaluate D with a native two-check atomic macro only when C's model proposes STOP and at least two checks remain. Compare C and D with the same five-call ceiling, reporting actual calls, calls per success, vetoes, false stops and paired regressions. Abort if no native rollback/macro transition exists.
5. Emit one `RESULT_SCHEMA.json`-valid receipt per root, arm and seed. Distinguish grading checks from budgeted policy checks, persist proof identities, and label any Python-only record `reference_wiring`.

A green wiring workflow cannot be reported as native-domain transfer or as a trained Looped Transformer result.

Files: `protocol.json` preregisters all arms and metrics; `roots_manifest.json` freezes the cohort allocation; `ORACLE_CONTRACT.md` defines admissibility, Bellman ties and transaction semantics; `RESULT_SCHEMA.json` defines receipts; `reference.py` and the unit tests are CPU controls.
169 changes: 169 additions & 0 deletions metta_research_bench/courier_transfer/RESULT_SCHEMA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/MoralityLabAI/DataGoblin/blob/master/metta_research_bench/courier_transfer/RESULT_SCHEMA.json",
"title": "DG-METTA-12 per-root, per-seed, per-arm receipt",
"type": "object",
"additionalProperties": false,
"required": [
"schema_version",
"mode",
"experiment_id",
"split",
"family",
"root_id",
"root_seed",
"arm",
"model_seed",
"source_sha256",
"protocol_sha256",
"native_kernel_sha",
"checkpoint_sha256",
"complete",
"stopped",
"verifier_calls",
"actions",
"proof_receipts",
"macro"
],
"properties": {
"schema_version": {
"const": "dg-metta12-result-v1"
},
"mode": {
"enum": [
"reference_wiring",
"native"
]
},
"experiment_id": {
"const": "DG-METTA-12"
},
"split": {
"enum": [
"train",
"development",
"frozen",
"transfer"
]
},
"family": {
"type": "string",
"minLength": 1
},
"root_id": {
"type": "string",
"minLength": 1
},
"root_seed": {
"type": "integer",
"minimum": 0
},
"arm": {
"enum": [
"A",
"B",
"C",
"D",
"E"
]
},
"model_seed": {
"type": "integer"
},
"source_sha256": {
"$ref": "#/$defs/sha256"
},
"protocol_sha256": {
"$ref": "#/$defs/sha256"
},
"native_kernel_sha": {
"type": [
"string",
"null"
],
"pattern": "^[0-9a-f]{40}$"
},
"checkpoint_sha256": {
"type": [
"string",
"null"
],
"pattern": "^[0-9a-f]{64}$"
},
"complete": {
"type": "boolean"
},
"stopped": {
"type": "boolean"
},
"verifier_calls": {
"type": "integer",
"minimum": 0
},
"grading_calls": {
"type": "integer",
"minimum": 0
},
"invalid_proposals": {
"type": "integer",
"minimum": 0
},
"premature_stop": {
"type": "boolean"
},
"accepted_action_count": {
"type": "integer",
"minimum": 0
},
"actions": {
"type": "array",
"items": {
"type": "string"
}
},
"proof_receipts": {
"type": "array",
"items": {
"type": "string"
}
},
"macro": {
"type": "object",
"additionalProperties": false,
"required": [
"attempted",
"certified",
"committed",
"verifier_calls"
],
"properties": {
"attempted": {
"type": "boolean"
},
"certified": {
"type": "boolean"
},
"committed": {
"type": "boolean"
},
"verifier_calls": {
"type": "integer",
"minimum": 0
},
"final_state_sha256": {
"type": [
"string",
"null"
],
"pattern": "^[0-9a-f]{64}$"
}
}
}
},
"$defs": {
"sha256": {
"type": "string",
"pattern": "^[0-9a-f]{64}$"
}
}
}
1 change: 1 addition & 0 deletions metta_research_bench/courier_transfer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""DG-METTA-12 native courier transfer contract and CPU reference oracle."""
Loading
Loading