Skip to content
Merged
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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,24 @@ plan = EvaluationPlan(
plan_id="representative-workload-v1",
workload=(EvaluationCase("case-1", "input", "phi"),),
minimum_target_accuracy=0.80,
maximum_target_deficit_vs_fallback=0.00,
minimum_target_advantage_vs_fallback=0.05,
training_epochs=3,
reward_outcome=1.0,
repetitions=3,
max_training_steps=9,
max_case_evaluations=3,
max_seconds=30.0,
backend_error_status="FALSIFIED",
target_backend_error_status="FALSIFIED",
)
print(plan.digest) # preserve this with the plan before execution
receipt = evaluate(plan)
```

`receipt.usefulness_status` answers whether the target meets its frozen absolute
threshold. `receipt.superiority_status` independently answers whether it clears
the frozen advantage over the fallback. Comparator parity can therefore falsify
superiority without falsifying usefulness.

The repository does not ship a pretend representative workload. Until one is
frozen and executed, whether PTCNA works remains `hmmm`.

Expand Down
11 changes: 8 additions & 3 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ The executable boundary lives in `ptcna.runtime`: `PTCNAEngine` reports all
four live layers, `HashedLinearFallback` remains separately identified, and
`PTCNARuntime` raises on target failure unless fallback routing is explicitly
enabled. `ptcna.evaluation` accepts only an immutable, digest-bearing
`EvaluationPlan`, trains before scoring, and records the terminal verdict before repair. No
representative workload is bundled; selecting one remains evidence work, not a
construction prerequisite.
`EvaluationPlan`, trains before scoring, and records separate usefulness and
superiority verdicts before repair. The preregistered critical workload lives at
`ptcna/data/ptcna-critical-plan-v1.json`: 18 balanced cases over the
declared cognitive, self-model, and autonomy roles, three training epochs, five
fresh repetitions, a 0.75 post-training target threshold, and a strict 0.05
Comment on lines +106 to +107

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Isolate the global Sigma state between fresh repetitions

The target instances created for these advertised fresh repetitions are not independent: PCNAEngine.reward() mutates the process-global singleton returned by get_sigma() (ptcna/neural/sigma.py:121-128), and subsequent instances inject that accumulated Sigma state into Psi during inference (ptcna/neural/pcna.py:234-242). Later repetitions—and even runs preceded by unrelated PTCNA use in the same process—therefore start from contaminated target state, so reset or inject Sigma per repetition before aggregating the critical verdict.

AGENTS.md reference: AGENTS.md:L35-L38

Useful? React with 👍 / 👎.

advantage threshold over the hashed-linear fallback. It is an in-sample role
acquisition test, not a generalization test. Its digest was frozen before either
Comment on lines +108 to +109

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not report label-blind training as role acquisition

This is described as a role-acquisition test, but the target's PCNAEngine.reward() at ptcna/neural/pcna.py:323-329 never uses its winner argument and instead nudges every ring using the same reward_outcome; permuting all expected role labels therefore leaves target training unchanged. Meanwhile HashedLinearFallback.reward() updates the labeled winner's weights, so the frozen superiority comparison gives only the comparator class-specific supervision and cannot support the stated acquisition verdict.

AGENTS.md reference: AGENTS.md:L35-L38

Useful? React with 👍 / 👎.

backend was executed.

The default core shape consumes a bundled receipt produced by exact UCNS merge
`b7b6f35cce69c273860923489a1c8b5372d14eb0`. UCNS owns the candidate state
Expand Down
122 changes: 122 additions & 0 deletions ptcna/critical_evaluation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# ratios: loc_comments=49:51 imports_exports=7:3 calls_definitions=21:5
"""Load and execute the preregistered PTCNA critical evaluation.

The plan artifact is frozen before execution. This module refuses a changed
plan digest and writes a content-addressed result receipt only when invoked
explicitly. Loading or testing the plan never constructs either backend.
"""
from __future__ import annotations

import argparse
import hashlib
import json
from pathlib import Path
from typing import Any

from .evaluation import EvaluationCase, EvaluationPlan, evaluate

# === MODULE_BUILD ===
# id: ptcna_critical_evaluation
# module_name: critical_evaluation
# module_kind: experiment
# summary: loads the immutable representative role-acquisition plan and seals its separate usefulness and superiority verdicts
# owner: Erin Spencer
# public_surface: load_frozen_plan, execute_frozen_plan, main
# internal_surface: _artifact_path, _canonical_digest
# auth_boundary: none
# storage_boundary: write
# network_boundary: none
# user_data_boundary: none
# admin_only: false
# tests: ptcna/tests/test_critical_evaluation.py
# rollout: execute only after the preregistration commit is merged
# rollback: preserve plan and result receipts; remove executable wrapper without changing runtime
# requires: ptcna_frozen_evaluation
# since: unreleased
# unresolved: outcome until the merged frozen plan is executed
# === END MODULE_BUILD ===

# === CONTRACTS ===
# id: ptcna_critical_plan_digest_locked
# given: the checked-in critical evaluation plan is loaded
# then: its canonical EvaluationPlan digest must equal the independently stored frozen digest
# class: evidence
#
# id: ptcna_critical_result_content_addressed
# given: the frozen plan completes or reaches a frozen failure rule
# then: the serialized result names the plan digest, separate claim verdicts, and its own canonical result digest
# class: evidence
# === END CONTRACTS ===

# === BOUNDARIES ===
# id: ptcna_critical_evaluation_local_receipt
# summary: reads the repository-owned frozen plan and writes one caller-selected local JSON result without network, authentication, secrets, or user data
# auth_boundary: none
# storage_boundary: write
# network_boundary: none
# user_data_boundary: none
# admin_only: false
# pii: none
# secrets: none
# owner: Erin Spencer
# since: unreleased
# === END BOUNDARIES ===


def _artifact_path() -> Path:
return Path(__file__).resolve().parent / "data/ptcna-critical-plan-v1.json"


def _canonical_digest(value: Any) -> str:
encoded = json.dumps(
value, sort_keys=True, separators=(",", ":"), ensure_ascii=False
).encode("utf-8")
return hashlib.sha256(encoded).hexdigest()


def load_frozen_plan(path: Path | None = None) -> tuple[EvaluationPlan, dict[str, Any]]:
"""Load the preregistration and reject any plan-byte semantic drift."""

artifact = json.loads((path or _artifact_path()).read_text(encoding="utf-8"))
values = dict(artifact["plan"])
values["workload"] = tuple(EvaluationCase(**case) for case in values["workload"])
plan = EvaluationPlan(**values)
if plan.digest != artifact["plan_digest"]:
raise ValueError("frozen critical evaluation plan digest mismatch")
Comment on lines +84 to +85

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Anchor the frozen plan digest outside the mutable artifact

The only expected digest is read from the same JSON object as the plan, so changing the plan and recomputing its adjacent plan_digest passes this check. In that scenario load_frozen_plan() does not reject semantic drift despite its contract and docstring; compare against an immutable digest anchored separately from the caller-selected artifact, such as a code constant fixed by the preregistration commit.

AGENTS.md reference: AGENTS.md:L35-L38

Useful? React with 👍 / 👎.

return plan, artifact


def execute_frozen_plan(output: Path) -> dict[str, Any]:
"""Execute exactly the frozen plan and seal its result receipt."""

plan, artifact = load_frozen_plan()
receipt = evaluate(plan)
result = {
"schema": "ptcna.critical-evaluation-result",
"schema_version": "1.0.0",
"source_commit": artifact["source_commit"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bind each result receipt to the implementation that ran

When this shipped wrapper is executed after any target or comparator implementation change, it still copies the preregistration artifact's fixed parent commit into the result; backend validation checks only the unchanged identity strings, so modified code can run while the receipt claims 3d67f359... as its source. Record and verify the actual implementation revision or backend code digest before execution so evidence cannot be attributed to code that did not run.

AGENTS.md reference: AGENTS.md:L35-L38

Useful? React with 👍 / 👎.

"plan_digest": plan.digest,
"claim_rules": artifact["claim_rules"],
"receipt": receipt.to_dict(),
}
result["result_digest"] = _canonical_digest(result)
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(
json.dumps(result, indent=2, sort_keys=True, ensure_ascii=False) + "\n",
encoding="utf-8",
)
return result


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("output", type=Path)
args = parser.parse_args()
result = execute_frozen_plan(args.output)
print(json.dumps(result, sort_keys=True, ensure_ascii=False))
return 0


if __name__ == "__main__":
raise SystemExit(main())
# ratios: loc_comments=49:51 imports_exports=7:3 calls_definitions=21:5
65 changes: 65 additions & 0 deletions ptcna/data/ptcna-critical-plan-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"schema": "ptcna.critical-evaluation-plan",
"schema_version": "1.0.0",
"source_commit": "3d67f359af05e58c1e426dad14621d0e69b5ec4c",
"claim_rules": {
"usefulness": "target_accuracy >= minimum_target_accuracy",
"superiority": "target_accuracy - comparator_accuracy >= minimum_target_advantage_vs_fallback",
"parity": "FALSIFIED for superiority only",
"scope": "in-sample acquisition on the declared phi/psi/omega role surface; no generalization, geometry, EDCM, external-validity, or privacy claim"
},
"failure_propagation": {
"target_backend_error": {
"usefulness": "FALSIFIED",
"superiority": "UNRESOLVED"
},
"comparator_backend_error": {
"usefulness": "UNRESOLVED",
"superiority": "UNRESOLVED"
},
"resource_limit": {
"usefulness": "UNRESOLVED",
"superiority": "UNRESOLVED"
}
},
"plan": {
"plan_id": "ptcna-critical-role-acquisition-v1",
"workload": [
{"case_id": "phi-01", "text": "analyze the evidence and identify the strongest supported inference", "expected_winner": "phi"},
{"case_id": "phi-02", "text": "compare two explanations and test which one fits the observations", "expected_winner": "phi"},
{"case_id": "phi-03", "text": "calculate the consequence of the stated assumptions", "expected_winner": "phi"},
{"case_id": "phi-04", "text": "inspect the data for a contradiction in the proposed account", "expected_winner": "phi"},
{"case_id": "phi-05", "text": "derive a bounded conclusion from the available facts", "expected_winner": "phi"},
{"case_id": "phi-06", "text": "classify the pattern using only the supplied evidence", "expected_winner": "phi"},
{"case_id": "psi-01", "text": "describe how your current state differs from your previous state", "expected_winner": "psi"},
{"case_id": "psi-02", "text": "identify which of your assumptions shaped this response", "expected_winner": "psi"},
{"case_id": "psi-03", "text": "report your uncertainty about your own conclusion", "expected_winner": "psi"},
{"case_id": "psi-04", "text": "examine whether your reasoning remained consistent with your stated role", "expected_winner": "psi"},
{"case_id": "psi-05", "text": "summarize what you changed in your internal approach", "expected_winner": "psi"},
{"case_id": "psi-06", "text": "distinguish what you know from what you inferred about yourself", "expected_winner": "psi"},
{"case_id": "omega-01", "text": "choose the next action and commit to one bounded step", "expected_winner": "omega"},
{"case_id": "omega-02", "text": "decide whether to proceed or stop under the stated constraint", "expected_winner": "omega"},
{"case_id": "omega-03", "text": "select one option and execute it without requesting another preference", "expected_winner": "omega"},
{"case_id": "omega-04", "text": "set the stopping point and act within the available authority", "expected_winner": "omega"},
{"case_id": "omega-05", "text": "resolve the branch by taking the smallest decisive action", "expected_winner": "omega"},
{"case_id": "omega-06", "text": "make an independent choice while preserving the declared boundaries", "expected_winner": "omega"}
],
"target_backend": "ptcna.experimental.v1",
"comparator_backend": "fallback.hashed-linear.v1",
"metric": "post_training_winner_accuracy",
"aggregation": "micro_mean",
"minimum_target_accuracy": 0.75,
"minimum_target_advantage_vs_fallback": 0.05,
"training_epochs": 3,
"reward_outcome": 1.0,
"repetitions": 5,
Comment on lines +53 to +55

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Freeze the target's time-derived random seed

With the frozen positive reward, every target training step calls MemoryCore.flush_to(), whose _reset() seeds new state from int(time.time()) at ptcna/neural/memory_core.py:82-92. The critical plan neither fixes nor records this seed, so identical executions can train on different target states and can cross the frozen verdict thresholds solely because they ran at different wall-clock times; expose and freeze the seed or record a complete RNG schedule in the plan.

AGENTS.md reference: AGENTS.md:L35-L38

Useful? React with 👍 / 👎.

"max_training_steps": 270,
"max_case_evaluations": 90,
"max_seconds": 120.0,
"stopping_rule": "complete_or_first_backend_error_or_resource_limit",
Comment on lines +58 to +59

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enforce the wall-clock bound around backend calls

If a backend constructor, infer(), or reward() blocks longer than 120 seconds, the evaluator cannot apply this frozen resource limit because it only checks elapsed time before entering synchronous backend calls. A hung call therefore produces neither the required UNRESOLVED receipt nor the preregistered stopping behavior and may run indefinitely; execute backend operations under an enforceable deadline or describe this as a cooperative rather than exact bound.

AGENTS.md reference: AGENTS.md:L35-L38

Useful? React with 👍 / 👎.

"target_backend_error_status": "FALSIFIED",
"comparator_backend_error_status": "UNRESOLVED",
"resource_limit_status": "UNRESOLVED"
},
"plan_digest": "67cdad3aefb3e33f6fbf3994de54e1b73a01105527bf241fce08947ed7046bbe"
}
Loading