Purge selfPatch JSON from role results
This commit is contained in:
parent
0060cbbe4f
commit
bd71f1e6dc
8 changed files with 236 additions and 371 deletions
72
notes/codex-auth-spine-inventory.md
Normal file
72
notes/codex-auth-spine-inventory.md
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# Codex Auth Spine Inventory
|
||||
|
||||
Objective: keep only the Codex organ that proves OpenAI entitlement and moves typed model-call requests to the OpenAI edge. Everything else is suspect until it earns a live invariant.
|
||||
|
||||
## Live Spine
|
||||
|
||||
Plain path:
|
||||
|
||||
1. Epiphany prepares a typed turn/request document.
|
||||
2. A small auth spine resolves OpenAI credentials.
|
||||
3. A small model transport spine serializes the typed request at the OpenAI wire edge.
|
||||
4. The OpenAI stream is decoded into typed Epiphany runtime events/results.
|
||||
5. Epiphany stores durable state as CultCache documents and exposes CultNet schemas at network edges.
|
||||
|
||||
Current Codex mechanism:
|
||||
|
||||
- `vendor/codex/codex-rs/login/src/auth/manager.rs`
|
||||
- Owns `CodexAuth`, `AuthManager`, token refresh, API-key auth, ChatGPT subscription auth, agent identity auth, and unauthorized recovery.
|
||||
- Real need: OpenAI subscription/API entitlement and refresh behavior.
|
||||
- Smell: imports app-server protocol auth modes and wider Codex protocol types. The auth organ is not cleanly independent.
|
||||
- `vendor/codex/codex-rs/codex-api/src/auth.rs`
|
||||
- Owns `AuthProvider` and `SharedAuthProvider`.
|
||||
- Real need: small async boundary that applies auth headers to transport requests.
|
||||
- Keep candidate. This is close to the shape Epiphany wants.
|
||||
- `vendor/codex/codex-rs/codex-api/src/provider.rs`
|
||||
- Owns endpoint base URL, headers, retry policy, idle timeout, and request construction.
|
||||
- Real need: OpenAI/Azure endpoint configuration.
|
||||
- Keep candidate, but only as model transport configuration.
|
||||
- `vendor/codex/codex-rs/codex-api/src/endpoint/session.rs`
|
||||
- Owns request construction, auth application, retry telemetry, and HTTP/SSE execution.
|
||||
- Real need: authenticated OpenAI HTTP/SSE execution.
|
||||
- Keep candidate if carved away from telemetry and generic endpoint spread.
|
||||
- `vendor/codex/codex-rs/codex-api/src/endpoint/responses.rs`
|
||||
- Owns Responses API request serialization and SSE request launch.
|
||||
- Real need: OpenAI wire adapter.
|
||||
- Allowed JSON: `serde_json::to_value` at this exact external wire edge.
|
||||
- `vendor/codex/codex-rs/codex-client/src/default_client.rs`
|
||||
- Owns reqwest client setup and trace header injection.
|
||||
- Real need: HTTP transport.
|
||||
- Keep candidate, but it should become a small transport dependency, not a Codex identity.
|
||||
- `vendor/codex/codex-rs/core/src/client.rs`
|
||||
- Owns the current live request path from prompt/model info through `ApiResponsesClient`.
|
||||
- Real need: some of this is model-call orchestration.
|
||||
- Smell: currently embedded in a broad Codex session core with tools, session telemetry, prompt assembly, realtime/websocket alternatives, and unauthorized retry loops.
|
||||
|
||||
## Not The Spine
|
||||
|
||||
These may remain in the vendored tree during quarantine, but they are not Epiphany organs:
|
||||
|
||||
- Apps, skills, plugins, marketplace, startup sync, connector inventory.
|
||||
- TUI/CLI/chat UI/session lifecycle except a temporary login UX if needed.
|
||||
- Multi-agent tool plumbing from Codex. Epiphany owns swarm physiology through CultNet/CultCache.
|
||||
- App-server protocol surfaces that exist to mirror Codex product features.
|
||||
- JSON-RPC shapes that expose internal accidents instead of CultNet contracts.
|
||||
- Realtime/websocket, review, guardian, cloud task, backend task, and account UI surfaces unless a specific auth entitlement dependency proves otherwise.
|
||||
|
||||
## Invariants
|
||||
|
||||
- OpenAI auth is a sealed reliquary: it may authenticate and refresh, not own Epiphany runtime shape.
|
||||
- The OpenAI API wire adapter may serialize JSON because OpenAI speaks JSON. That permission does not leak inward.
|
||||
- CultNet schemas describe network edges. CultCache documents carry live state.
|
||||
- A Codex type survives only if it protects one of these invariants: credential validity, authenticated request construction, streaming decode, or model capability/provider metadata.
|
||||
- `codex_message_processor.rs` is not allowed to be the owner of Epiphany runtime truth.
|
||||
|
||||
## Suspicious Load-Bearing Questions
|
||||
|
||||
- Can `AuthManager` be extracted without `codex_app_server_protocol`, `codex_protocol::auth`, and app-server-specific auth modes?
|
||||
- Does Epiphany need Codex websocket/realtime paths, or only Responses SSE?
|
||||
- Which model-provider metadata is genuinely required to keep subscription compatibility?
|
||||
- Can unauthorized recovery live entirely in the auth spine instead of the session/chat processor layer?
|
||||
- Can model-call input/output become one typed Epiphany document pair before the OpenAI edge serialization?
|
||||
|
||||
|
|
@ -366,23 +366,29 @@ that change what the next agent should believe.
|
|||
|
||||
Do not continue implementation automatically from a rehydrate-only request.
|
||||
|
||||
The next real move is Codex starvation, not outward bridge work. The first
|
||||
bounded slice is:
|
||||
The next real move remains Codex starvation, not outward bridge work. The
|
||||
inventory and ledger now exist:
|
||||
|
||||
1. create `notes/codex-auth-spine-inventory.md`
|
||||
2. inventory the minimum vendored Codex path required for OpenAI subscription
|
||||
auth, account/session refresh, model provider config, model request
|
||||
construction, streaming response handling, and rate/error handling
|
||||
3. create `notes/json-contamination-ledger.md`
|
||||
4. classify every Epiphany-relevant `serde_json::Value`, `json!`,
|
||||
`from_value`, and `to_value` as schema/wire descriptor, hostile ingress,
|
||||
sealed forensic artifact, quarantine experiment, or heretek internal blob
|
||||
5. choose the first typed-document replacement target, preferably `selfPatch`
|
||||
or worker launch/result cargo
|
||||
- `notes/codex-auth-spine-inventory.md` maps the minimal Codex auth/model-call
|
||||
reliquary: `login` auth/token refresh, `codex-api` auth/provider/session and
|
||||
Responses edge, `codex-client` transport, and the suspect current
|
||||
`core/src/client.rs` orchestration.
|
||||
- `notes/json-contamination-ledger.md` classifies the major Epiphany JSON
|
||||
contamination. Edge JSON is allowed only for schema/wire boundaries,
|
||||
hostile ingress before typed parse, sealed forensic artifacts, or named
|
||||
quarantine.
|
||||
- First cut landed: role-result `selfPatch` is now an internal typed
|
||||
`AgentSelfPatch` document reviewed by the same contract used by agent memory.
|
||||
The legacy app-server protocol projection serializes it back to JSON only at
|
||||
the quarantine wall.
|
||||
|
||||
Do not resume Rider, Unity, Aquarium, Face, dogfood, planning, app, skill,
|
||||
marketplace, or bridge expansion until this liberation pass has an inventory,
|
||||
ledger, and first cut. No fresh balcony on the contaminated cathedral.
|
||||
Continue with worker launch/result cargo. Replace
|
||||
`EpiphanyJobLaunchRequest.input_json` and `output_schema_json` with typed
|
||||
launch/result documents plus schema ids in `epiphany-core`, then make
|
||||
`codex_message_processor.rs` project those documents instead of assembling
|
||||
loose JSON blobs. Do not resume Rider, Unity, Aquarium, Face, dogfood,
|
||||
planning, app, skill, marketplace, or bridge expansion until this organ is
|
||||
being cut cleanly.
|
||||
|
||||
The Phase 6 freshness slice is landed. It exposes read-only
|
||||
`thread/epiphany/freshness` from live retrieval summaries plus graph
|
||||
|
|
|
|||
64
notes/json-contamination-ledger.md
Normal file
64
notes/json-contamination-ledger.md
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# JSON Contamination Ledger
|
||||
|
||||
Rule: JSON is allowed at external schema/wire boundaries. Inside Epiphany, live data should be typed CultCache documents or typed CultNet messages. A `serde_json::Value` inside core logic is guilty until it identifies its border checkpoint.
|
||||
|
||||
## Allowed Wire Or Schema JSON
|
||||
|
||||
- `vendor/codex/codex-rs/codex-api/src/endpoint/responses.rs`
|
||||
- Current mechanism: typed `ResponsesApiRequest` is serialized to JSON for the OpenAI Responses HTTP body.
|
||||
- Real need: OpenAI wire protocol.
|
||||
- Verdict: allowed edge JSON.
|
||||
- `vendor/codex/codex-rs/codex-api/src/requests/responses.rs`
|
||||
- Current mechanism: mutates serialized request JSON to attach item ids for Azure.
|
||||
- Real need: compatibility with upstream API quirks.
|
||||
- Smell: typed request loses shape before a provider-specific patch is applied.
|
||||
- Simpler architecture: provider-specific typed request rendering, then JSON emission once.
|
||||
- Schema fixtures, schema catalogs, and protocol snapshot tests.
|
||||
- Verdict: allowed if they test wire schema, not internal state.
|
||||
|
||||
## Internal JSON To Purge
|
||||
|
||||
- `vendor/codex/codex-rs/core/src/codex_thread.rs`
|
||||
- Current mechanism: `EpiphanyJobLaunchRequest.input_json` and `output_schema_json`.
|
||||
- Real need: launch role workers with structured instructions and expected response shape.
|
||||
- What breaks if deleted: current job launch path cannot carry worker input/schema to Codex runtime.
|
||||
- Essential or bad ownership: bad ownership. Worker launch intent should be a typed document plus schema id, not two loose blobs.
|
||||
- Simpler architecture: `EpiphanyWorkerLaunchDocument` in CultCache/CultNet, with typed payload and `output_contract_id`.
|
||||
- Files: `vendor/codex/codex-rs/core/src/codex_thread.rs`, `vendor/codex/codex-rs/app-server/src/codex_message_processor.rs`, `vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs`, `epiphany-core/src/runtime_spine.rs`.
|
||||
- `epiphany-core/src/surfaces/role_result.rs`
|
||||
- Current mechanism: `state_patch` and `self_patch` are `serde_json::Value`; `selfPatch` is manually revalidated here.
|
||||
- Real need: interpret worker findings and review bounded lane-local memory petitions.
|
||||
- What breaks if deleted: app-server mapping still expects JSON protocol fields.
|
||||
- Essential or bad ownership: bad ownership. `selfPatch` already has a typed `AgentSelfPatch` document in `agent_memory.rs`; role-result review duplicated the contract.
|
||||
- Simpler architecture: role interpretation stores `AgentSelfPatch`, and only the protocol projection serializes JSON for the existing app-server surface.
|
||||
- Files: `epiphany-core/src/agent_memory.rs`, `epiphany-core/src/surfaces/role_result.rs`, `vendor/codex/codex-rs/app-server/src/codex_message_processor.rs`, `vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs`.
|
||||
- `vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs`
|
||||
- Current mechanism: `ThreadEpiphanyRoleFinding.self_patch: Option<serde_json::Value>`, `ThreadEpiphanyJobLaunchRequest.input_json`, and `output_schema_json`.
|
||||
- Real need: app-server compatibility while Epiphany is still hosted inside Codex.
|
||||
- What breaks if deleted: frontend/server protocol compilation.
|
||||
- Essential or bad ownership: temporary compatibility reliquary, not a final contract.
|
||||
- Simpler architecture: CultNet schema messages generated from typed document structs.
|
||||
|
||||
## Quarantine JSON
|
||||
|
||||
- `epiphany-core/src/heartbeat_state.rs`
|
||||
- Current mechanism: heartbeat cognition stores some `serde_json::Value` fields.
|
||||
- Real need: experimental cognition payloads still changing shape.
|
||||
- Verdict: quarantine only. It must either become typed heartbeat documents or remain clearly marked as volatile cognition scratch.
|
||||
- MCP tool call arguments/results in `vendor/codex/codex-rs/core/src/mcp_tool_call.rs`.
|
||||
- Current mechanism: arbitrary MCP payloads are raw JSON.
|
||||
- Real need: MCP is an external protocol with schema-bearing tools.
|
||||
- Verdict: edge adapter. It does not belong in the Codex auth organ.
|
||||
- Simpler architecture: CultNet MCP adapter with typed request/result wrappers and raw JSON sealed at the MCP edge.
|
||||
- Unity/Rider/void-memory CLI outputs.
|
||||
- Current mechanism: JSON command output and ad hoc parsing.
|
||||
- Real need: bridge external tools while native surfaces mature.
|
||||
- Verdict: quarantine bridges; do not let them define internal contracts.
|
||||
|
||||
## Ranking
|
||||
|
||||
1. Done: purge `selfPatch` as internal JSON. Role-result interpretation now stores the typed `AgentSelfPatch` document and shares the agent-memory contract; JSON remains only at the legacy app-server projection.
|
||||
2. Replace worker launch `input_json` and `output_schema_json` with typed launch documents and schema ids.
|
||||
3. Replace role `statePatch` JSON with typed map/planning/graph patch documents.
|
||||
4. Seal MCP JSON behind a CultNet MCP adapter.
|
||||
5. Audit heartbeat cognition values and either type them or explicitly expire them.
|
||||
Reference in a new issue