Skip to content

feat(apex): bootstrap ApexCode safety and evaluation foundation - #1

Merged
kratosboom merged 13 commits into
mainfrom
apex/bootstrap-v2
Aug 22, 2026
Merged

feat(apex): bootstrap ApexCode safety and evaluation foundation#1
kratosboom merged 13 commits into
mainfrom
apex/bootstrap-v2

Conversation

@kratosboom

@kratosboomkratosboom commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Bootstrap ApexCode as an upstream-friendly, independent extension of OpenAI Codex.

This PR intentionally avoids changing the upstream Codex runtime. It establishes the first isolated ApexCode implementation slice and public project identity.

What changes

  • identify ApexCode clearly in README.md while retaining the upstream Codex quickstart/content
  • extend SECURITY.md with separate upstream-vs-ApexCode reporting guidance and safety invariants
  • add dependency-free apexcode/apex-policy Rust crate
  • define R0-R5 risk levels and default policy decisions
  • fail closed for unknown operation risk
  • add five focused unit tests for the initial policy mapping
  • add benchmarks/APEXBENCH.md for reproducible high-complexity evaluation

Already established on main

During bootstrap, three additive documentation files were written directly to main before branch targeting was corrected:

  • UPSTREAM.md
  • ARCHITECTURE.md
  • ROADMAP.md

No Codex runtime code was changed by those direct documentation commits. History was not rewritten or force-reset. This PR is based on that documented main state.

Safety

  • no production infrastructure changes
  • no secrets or proprietary GPRO source included
  • no Codex runtime behavior changed
  • no dependency added to the upstream Codex workspace
  • no merge requested as part of this bootstrap

Validation

The apex-policy crate is dependency-free and includes five unit tests.

Local execution was not completed because the available execution environment has neither outbound GitHub DNS access nor a Rust/Cargo toolchain. Tests must therefore be treated as UNVERIFIED until CI or a Rust-enabled environment executes them.

Suggested focused verification:

cargo fmt --manifest-path apexcode/apex-policy/Cargo.toml -- --check
cargo test --manifest-path apexcode/apex-policy/Cargo.toml

Review gate

Keep this PR in draft until:

  1. focused Rust formatting/test evidence is green,
  2. licensing/provenance is reviewed,
  3. security wording is reviewed,
  4. the isolation strategy is accepted.

Do not merge automatically.

ApexCode foundation update

Implemented:

  • apex-policy
  • apex-task-state
  • apex-evidence

Verification:

  • cargo fmt --manifest-path apexcode/Cargo.toml -- --check — Cargo does not support target discovery for this virtual workspace without --all; the equivalent new-crate rustfmt --edition 2024 --check passed.
  • cargo test --manifest-path apexcode/Cargo.toml --workspace — PASS with the local GNU-linker workaround RUSTFLAGS=-Clinker=rust-lld; 29 tests total: apex-policy 5, apex-task-state 11, apex-evidence 13.
  • cargo clippy --manifest-path apexcode/Cargo.toml --workspace --all-targets -- -D warnings — PASS with the same linker workaround.
  • git diff --check — PASS.

NO CODEX RUNTIME INTEGRATION YET
NO PRODUCTION CHANGE
NO MERGE

Verification command correction

For the isolated virtual workspace, the exact formatting command is cargo fmt --manifest-path apexcode/Cargo.toml --all -- --check. The formatting-only closure commit makes this foundation PR fmt-clean.

@kratosboom
kratosboom marked this pull request as ready for review August 22, 2026 06:37

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:9ae17e784d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapexcode/apex-evidence/src/lib.rs Outdated
Comment threadapexcode/apex-task-state/src/lib.rs Outdated
Comment threadapexcode/Cargo.toml
@@ -0,0 +1,7 @@
[workspace]

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 Exercise the Apex workspace in CI

Adding this separate workspace does not make any existing PR job build or test it: .github/workflows/rust-ci.yml:43-47 only marks codex-rs/*, tooling, or workflow changes as relevant, and its Rust jobs run from codex-rs at lines 64-67. Consequently an Apex-only follow-up can merge with compilation, formatting, and all 29 tests skipped; add an Apex path detector and a job that checks this workspace.

Useful? React with 👍 / 👎.

Comment threadapexcode/Cargo.toml
@@ -0,0 +1,7 @@
[workspace]

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 Ignore the Apex Cargo target directory

Running Cargo in the newly added workspace creates an untracked apexcode/target/ tree. A repository-wide search shows only codex-rs/.gitignore entries for that workspace's own /target/, so the documented Apex build workflow dirties the worktree and risks generated artifacts being committed; add an ignore rule scoped to apexcode/target/.

Useful? React with 👍 / 👎.

Comment on lines +236 to +237
#[cfg(test)]
mod tests {

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 Move evidence tests into a sibling module

This is a newly introduced inline test module, whereas the repository requires new test modules to live in a descriptive sibling *_tests.rs file and be attached with an explicit #[path = "..."]; move these tests out of the implementation module.

AGENTS.md reference: AGENTS.md:L169-L178

Useful? React with 👍 / 👎.

Comment on lines +352 to +353
#[cfg(test)]
mod tests {

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 Move task-state tests into a sibling module

This newly introduced inline test module should be placed in a descriptive sibling *_tests.rs file and referenced through an explicit #[path = "..."], as required for all new test modules in this repository.

AGENTS.md reference: AGENTS.md:L169-L178

Useful? React with 👍 / 👎.

Comment threadapexcode/Cargo.toml
Comment on lines +2 to +5
members = [
"apex-policy",
"apex-task-state",
"apex-evidence",

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 Split the independent foundation crates into stages

This non-mechanical commit changes 1,225 lines and combines three dependency-free crates with identity, security, fixture, and benchmark documentation, exceeding the repository's 800-line review limit. Land the smallest coherent stage first—such as the workspace plus apex-policy—then add task state, evidence, and documentation separately so their independent contracts remain reviewable.

AGENTS.md reference: AGENTS.md:L125-L131

Useful? React with 👍 / 👎.

Comment threadapexcode/apex-evidence/src/lib.rs
Comment on lines +253 to +257
let constraint_count = reader.u32().ok_or(SnapshotError::InvalidFormat)? as usize;
if constraint_count > reader.remaining() {
return Err(SnapshotError::InvalidFormat);
}
let mut constraints = Vec::with_capacity(constraint_count);

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 Bound constraint allocation before reserving

For malformed or corrupted snapshots, comparing constraint_count directly with the remaining byte count is insufficient because every constraint requires at least a four-byte length prefix and the snapshot also needs its status and revision. A roughly 100 MB input claiming 100 million constraints passes this check and Vec::with_capacity attempts about 2.4 GB of allocation before parsing fails, allowing recovery data to terminate the process through memory exhaustion; enforce the minimum encoded size and a hard count cap before reserving.

Useful? React with 👍 / 👎.

Comment on lines +155 to +158
let revision = self.revision.checked_add(1).ok_or(TransitionError {
from: self.status,
to: next,
})?;

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 Report revision exhaustion instead of an invalid transition

A structurally valid snapshot may decode with revision == u64::MAX, after which an otherwise allowed transition such as Planned -> Running fails here with TransitionError { Planned, Running } and is reported as an invalid state-machine edge. The dedicated TaskStateError::RevisionOverflow variant is never surfaced, so recovery code cannot distinguish revision exhaustion from an actually forbidden transition and the resumed task remains permanently stuck; return a distinct overflow error while preserving the state.

Useful? React with 👍 / 👎.

@kratosboom
kratosboom marked this pull request as draft August 22, 2026 07:09
@kratosboom
kratosboom merged commit 67fdb80 into mainAug 22, 2026
2 checks passed
Sign up for freeto 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

@kratosboom