-
Notifications
You must be signed in to change notification settings - Fork 0
experiment: freeze critical PTCNA evaluation #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is described as a role-acquisition test, but the target's 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 | ||
|
|
||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The only expected digest is read from the same JSON object as the plan, so changing the plan and recomputing its adjacent 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"], | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 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 | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With the frozen positive reward, every target training step calls 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a backend constructor, 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" | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target instances created for these advertised fresh repetitions are not independent:
PCNAEngine.reward()mutates the process-global singleton returned byget_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 👍 / 👎.