# OpenAI4S source-analysis file · verification report

> **Object of verification**: `项目分析/OpenAI4S-源码分析.md` (v1, baseline commit `85e9fa0`) + checked against the real source `参考项目/OpenAI4S`
> **Method**: 6 parallel Explore agents, clustered by Part, file-by-file (Part I–II / III / IV / V / VI–VII + independent line-number spot-checks); each claim judged VERIFIED / WRONG / PARTIAL / UNSUPPORTED
> **Verification date**: 2026-08-04
> **Conclusion first**: this is the **highest-quality analysis in the series**—numeric claims all hit, line numbers with almost zero drift, the inference layer already labeled as inference. Problems concentrate in a **single-digit** count of factual deviations (1 WRONG + a dozen-odd PARTIAL), all already corrected in place.

---

## 1. Overall scores

| Dimension | Score | Notes |
|---|---|---|
| Line-number accuracy | ★★★★★ | Spot-check of 10 independent citations: **0 drift**; `actions.py:176-185`, `app.js:5574`, `POST /frames/{id}/message @ 9654`, `TOOL_TYPES @ 118-189`, and others exact to the starting line |
| Numeric credibility | ★★★★★ | 255 `.py` / 114k LOC / 286 tests / 34 skills / 70 TOOL_TYPES / 0 core dependencies—**all exact against source, no inflation or shrinkage** |
| Mechanism description | ★★★★☆ | Dual-plane engine, three iron rules of route_action, finalize vs submit_output attribution, ledger-first, Store single connection—**no misattribution** (except 18.1 below) |
| Inference discipline | ★★★★★ | Ch. 19–20 uniformly use the four-part “claim → evidence → what is given up → taste,” and Ch. 20 is explicitly labeled “reverse-inferred,” not packaging speculation as fact |
| Completeness | ★★★★☆ | 22 chapters cover dual-plane / Host / Kernel / Tools / Provider / Web / Skills / Compute / Security / taste / comparison; a few domain-classification tables have omissions |

**Overall: among “AI-generated source analyses,” a rare high-water mark. What needs correction is detail, not the skeleton.**

---

## 2. Where the analysis was wrong (already corrected in place)

### 🔴 WRONG (1 place, must change)

**18.1 Permission / approval-layer path misattributed**
- Original: `security/permissions.py`
- Fact: the approval broker is top-level `openai4s/permissions.py` (771 lines, opencode-style allow/deny/ask gate, `OPENAI4S_UNATTENDED_APPROVAL` at :383). The same-named `security/permissions.py` (116 lines) only manages **data-directory file permission bits** (SQLite plaintext credentials default 0644, then tightened) and has nothing to do with approval.
- Already changed: `openai4s/permissions.py` + `storage/permissions.py`, with a WRONG annotation added.
- Likewise 23.1 reading-order line 13 was corrected together.

### 🟡 PARTIAL (the key few, already changed; the rest in the appendix batch table)

| # | Location | Problem | Fix |
|---|---|---|---|
| 1 | 13.2 event-type table | Listed `cell`/`artifacts`/`permissions` as WS event `type`—none of them are; real types are `artifact_created`/`permission_resolved`/`kernel_status` and the like; `cell` is a live-buffer scope value | Table rewritten + WRONG annotation added |
| 2 | 19.3 point 2 | “dup2 / fd3·fd4” mixed two mechanisms: Python `worker.py` uses `os.dup()` anonymous high fds + `dup2(2,1)`, **no fd3/fd4 constants**; fd3/fd4 are **R-channel specific** (`r_kernel.py:12-13`) | Qualifying note added |
| 3 | 17.1 | Used `remote-compute-ssh` as a provider-shim example—it has only SKILL.md+README, **no provider.py**, a pure recipe | Noted |
| 4 | 2.2 | Quoted "Never add hard third-party import" cited as `CLAUDE.md:11`; the real line is `:90` | Changed to :90 |
| 5 | 18.3 | `egress.py:9-10` docstring claims it “does not ship an OS-level sandbox,” which **directly conflicts with and is stale relative to** `security/sandbox.py` (the real Seatbelt/bwrap implementation); the original patched this for the author but still attributed it to egress.py | Docstring marked stale |
| 6 | Choice 7 | Façade list named 6 files; CLAUDE.md:98 actually lists 7, omitting `sdk/host.py` | Added |
| 7 | 14.1 / 23.1 / 20 | Real path of `webui/app.js` is `openai4s/server/webui/app.js`; `egress.py` is top-level, not under `security/` | Unified |
| 8 | 4.1 | “State-machine body ~143 lines”—143 is the `engine.py` **file** line count; the class body (34-143) is 110 lines | See appendix |
| 9 | 12.2 | `gateway.py:6337-6447` `_loop` actually extends to ~6484 (closed 37 lines early) | See appendix |
| 10 | 10.1 | TOOL_TYPES domain table omitted the “dynamic tools” family of 6 types + `SearchCapabilitiesTool`; a reader summing the table gets only 63 | See appendix |

---

## 3. Evaluation of this analysis file (strengths)

1. **Rare numeric honesty.** Most AI analyses inflate scale; this one’s 255/114k/286/34/70/0 all recompute, and “zero third-party dependencies” was confirmed by an AST scan of all-package imports (only 7 try/except guards), not by looking at pyproject and stopping.
2. **Line numbers are “re-checkable,” not decoration.** Appendix-C-style numeric snapshots, the 23.2 symbol lookup table 15/15 hits, 14.1 lining up `send()`’s `sub()→POST→202→admissionId` timing line by line to `app.js:5640-5676`—this precision means the writer actually read the source, not an LLM hallucination.
3. **The inference layer has discipline.** Ch. 20 “ten developer choices” is explicitly reverse-inferred; the layout separates “evidence” from “taste.” That avoids the common disease of packaging the author’s speculation as source fact.
4. **Product view is in place.** 13.2’s `wait:false + sub() first` race, 14.3’s client-generated admissionId, 18.2’s approval-restart semantics—these “product-level details” are grabbed accurately, showing the analyst knows where an “agent workbench” breaks.
5. **Cross-project comparison is honest.** `22.2 honest bounds` fills many cells with “unknown / closed source,” and does not invent other-project details to make the table look complete.

---

## 4. Improvement suggestions

### A. Immediate (low cost, high return)
1. **Build a “line-number check footnote” mechanism**: every analysis that emits `file:line` should attach a `grep -n` check-script dump at the end of the document (as the Codex analysis does: “all citations re-checked with grep”). This OpenAI4S pass is already close to that standard; recommend freezing it as a template.
2. **Inject `WRONG`/`PARTIAL` marks into the document**: this pass already added `⚠️ 核查修正（2026-08-04）` blocks in the body. Recommend **every verified analysis use this format uniformly**, so a reader can tell “original conclusion” from “post-hoc errata” at a glance.
3. **Patch the appendix batch table** (below): 13 places of ±1-line drift and domain-table omissions—these come from copy-pasting a neighboring version; a batch edit is enough.

### B. Structural
4. **Add an unfalsifiable disclaimer to “other-project comparison”**: in Ch. 21’s cross-project table, OpenAI4S itself is listed as fully VERIFIED, but the other-project columns (Claude Code/OpenManus/Codex/Open Design) are cross-repo judgments this repository cannot falsify. Recommend a footnote on every comparison table: “other-project columns are public materials / author judgment, not falsifiable in this repository.”
5. **Give the dynamic-tool family its own section**: among TOOL_TYPES’s 70 subclasses, “dynamic tools” (Define/List/Promote/ListVersions/Activate/Rollback) are first-class citizens and deserve their own 10.1 subsection, rather than being buried in the “files / web / science” domains.
6. **Write the egress–sandbox relation clearly**: the stale docstring on `egress.py` will confuse readers. Recommend one sentence between 18.1 and 18.3: “egress is an application-layer domain fence; sandbox is OS-level process isolation; the two are orthogonal; egress’s docstring claim that it ‘does not ship an OS sandbox’ is an old formulation; take sandbox.py as authoritative.”

### C. Longer term
7. **Sync multiple copies of the same source**: this repository’s `OpenAI4S-源码分析.md` (root) and `项目分析/OpenAI4S-源码分析.md` are two copies of one document; they were synced in this pass. Recommend establishing a **single source of truth** (prefer `项目分析/`), leaving only a build entry at the repo root, so one edit is not missed in the other. The Codex analysis has the same dual-copy problem.
8. **Close the HTML delivery loop**: this pass found that **HTML had never been generated** for the OpenAI4S and Codex analyses (markdown only). `OpenAI4S-解析.html` and `项目分析/openai-codex-源码分析.html` have now been generated. Recommend putting “generate HTML” on each analysis’s delivery checklist.

---

## Appendix: PARTIAL list not edited one by one; recommended batch fixes

| Location | Current | Suggestion |
|---|---|---|
| 4.1 | 143 is the file line count | Change to “single file 143 lines / class body 110 lines” |
| loop.py:352-447 | Agent.run actually ends at ~461 | Change the endpoint to 461 |
| gateway.py:6337-6447 | _loop ends at ~6484 | Change the endpoint to 6484 |
| 10.1 | Domain table omits the dynamic-tool family of 6 types + SearchCapabilities | Add 7 items |
| 16.2 | skills described as a binary structure | In fact three layers: bundled > project > user |
| 17.1 | Omits the worker_runtime alias package and scrub’s name-based limits | Annotate |
| 9.2 | bwrap branch “NOT VERIFIED AT RUNTIME” not mentioned | Add the maturity difference |
| 9.4 | mermaid draws the sandbox as a bash-subprocess wrapper | The sandbox is put on at worker spawn; bash inherits the boundary |
| 19.2 | “Most agents make running code into tool Bash” | Mark as author observation (UNSUPPORTED) |
| Choice 7 | Façade list omitted sdk/host.py | Already added (see body) |

---

## Addendum: the openai-codex analysis checked along the way (bonus from a misidentified target)

The user’s spoken "openai4s" was first taken as openai-codex, so an equivalent verification was run first on `项目分析/openai-codex-源码分析.md` (commit bb1af23). That document’s line-number accuracy is equally high (spot-check 25 places, 0 drift), but **4 substantive errors** were found and already corrected in place:

1. **9.3 previous-model compact mechanism misattributed**: 1032-1040 is `capture_current_model_fallback_step_context` (only decides retry-fallback context), not a compaction switch; the real trigger is `maybe_run_previous_model_inline_compact` (1057+), which **does not check** Codex backend/OpenAI provider. The original “do not play this on a third-party provider” is wrong.
2. **15.4/15.7 Landlock/bwrap frame inverted**: the Landlock FS ruleset source itself says “currently unused / legacy”; bubblewrap is the main Linux FS sandbox implementation. The original reversed their primary/secondary roles.
3. **3.2 exec-server is not hidden**: only an `[EXPERIMENTAL]` comment, no `hide=true`; it is a public subcommand.
4. **22.1C debug_input invented**: 0 hits in the whole tree; should be `build_prompt_input` / `run_debug_prompt_input_command`.

Also corrected 5 line-number/path deviations (16.2 with_cached_approval 71-117, 11.2 built_tools path added, 11.3 CodeMode directory ownership, 20.3 rollout path prefix, 22.3 turn.rs crate path added). `项目分析/openai-codex-源码分析.html` has been generated.
