Skip to content

chore(codex): enforce complete native replacements#3

Draft
johannhartmann wants to merge 22 commits into
mainfrom
agent/enforce-native-replacement
Draft

chore(codex): enforce complete native replacements#3
johannhartmann wants to merge 22 commits into
mainfrom
agent/enforce-native-replacement

Conversation

@johannhartmann

@johannhartmann johannhartmann commented Jul 20, 2026

Copy link
Copy Markdown
Member

Why

Performance architecture tasks could still be satisfied by preserving the old production route behind a wrapper, fallback, bridge, or dual dispatch. The repository also told the performance ratchet to implement the smallest local fix, which conflicted with complete Cranelift cutovers.

This change makes externally observable PHP 8.5 behavior the compatibility boundary for explicit architecture replacements. Internal compatibility with a retired VM/JIT/runtime route is no longer an acceptance goal.

What changed

  • Add repository-local Codex developer_instructions for complete Cranelift production replacements.
  • Add UserPromptSubmit and Stop hooks. Replacement prompts activate a per-session hard mode; Codex cannot finish the turn while the replacement guard is red.
  • Add an auditable JSON replacement-contract format with workflow documentation.
  • Default contracts to zero semantic slow paths and zero diff allowlist entries. A task must add and justify each genuine PHP-semantic exception; the schema never forces one to exist.
  • Add a deterministic guard that:
    • proves named removal symbols and paths existed at the comparison base;
    • proves those targets are absent from the final production source;
    • rejects changed production paths outside the declared scope;
    • rejects newly added fallback, compatibility, wrapper, bridge, safety-path, and interpreter-reentry machinery;
    • permits only narrow, explicitly justified PHP-semantic slow paths;
    • rejects broad allowlists such as fallback.
  • Change the performance prompt ratchet from “implement the smallest fix” to the smallest complete vertical architecture replacement.
  • Treat only a correctness regression introduced by the current change as a correctness blocker; known unrelated failures no longer redirect architecture work.
  • Add a dedicated GitHub Actions policy workflow for the hooks, contract schema, ratchet, and diff guard.
  • Document the same contract in AGENTS.md so non-Codex agents receive it as well.

Operator behavior

  • [native-replacement] activates replacement mode explicitly.
  • Any prompt combining an explicit removal/replacement verb with a fallback, wrapper, adapter, bridge, legacy route, interpreter route, generic binder, or comparable old execution path activates it automatically. The exact phrase “Eliminiere endlich alle Fallbacks” is covered by the hook self-test.
  • [native-replacement:off] is available for discussion or analysis that does not request a production cutover.
  • A real replacement tranche must add one concrete contract under docs/performance/native-replacement-contracts/ and pass its own correctness, application, structural-counter, and clean-latency commands.

Validation

The dedicated native replacement policy workflow performs:

  • Python bytecode compilation for all new policy and hook modules;
  • JSON validation for .codex/hooks.json;
  • TOML parsing for .codex/config.toml;
  • replacement guard self-tests, including valid/invalid contracts, wrapper rejection, narrow semantic allowlisting, broad fallback-allowlist rejection, comment exclusion, test-module exclusion, and validation of the checked-in zero-exception template;
  • prompt-hook and Stop-hook self-tests;
  • performance ratchet self-tests, including known-failure versus new-regression classification;
  • pull-request diff-policy enforcement against the real base and head commits.

Additional temporary-Git integration tests covered a complete deletion contract, rejection of a new compatibility wrapper, rejection of hard mode without a changed contract, successful Stop-state cleanup, and bounded repeated Stop failure without an infinite loop.

Full Nix/Rust workspace gates were not run locally because the branch was written through the GitHub connector rather than a runnable full repository checkout. The repository’s general CI workflow runs separately on the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant