Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
verify:
if: (github.event_name == 'push' && !github.event.deleted) || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
uses: ./.github/workflows/verify.yml
with:
full: true

publish:
needs: verify
Expand Down
35 changes: 28 additions & 7 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
branches: [main]
workflow_dispatch:
workflow_call:
inputs:
full:
description: Run the extended browser suites
type: boolean
default: false

permissions:
contents: read
Expand Down Expand Up @@ -35,31 +40,45 @@ jobs:
run: bunx vitest run --maxWorkers=4 tests/webRunSnapshot.test.ts tests/webResearchProjects.test.ts tests/webResearchApi.test.ts tests/webResearchAssets.test.ts tests/webResearchMathematics.test.ts tests/libraryPacks.test.ts tests/leanSource.test.ts
- name: Verify direct formalization and independent background review without models
run: bunx vitest run --maxWorkers=4 tests/directFormalizationEvidence.test.ts tests/directFormalizationWorkflow.test.ts tests/formalizationCoverage.test.ts tests/formalizationAudit.test.ts tests/formalizationContext.test.ts tests/formalizationPackagesWarmup.test.ts tests/mathProofEnvironmentSeed.test.ts tests/webFormalizationAuditWorker.test.ts tests/webFormalizationBackgroundReview.test.ts tests/webBackgroundReview.test.ts tests/webFormalizationProgress.test.ts tests/webThinkingProcess.test.ts tests/codexSessionInstructions.test.ts
- name: Verify session, draft, budget and archive recovery without models
run: bunx vitest run --maxWorkers=4 tests/webSessionCookies.test.ts tests/webResearchSession.test.ts tests/webDraft.test.ts tests/webLongRun.test.ts tests/researchPlanApproval.test.ts tests/archiveRecordNavigation.test.ts tests/globalTrajectory.test.ts tests/webChatDraft.test.ts tests/archiveSourceLocation.test.ts tests/taskPlanEditorAccess.test.ts
- run: bun run build && bun run build:web
- run: bunx playwright install --with-deps chromium
- name: Verify proof progress in the default simple reading
timeout-minutes: 5
run: bun scripts/test-web-proof-thinking.ts --simple-reading
- name: Verify the browser's login and research flows with local fixtures
run: bun run test:web-login && bun run test:web-natural-first && bun run test:web-chat-session && bun run test:web-chat-cancel-recovery && bun run test:web-key-memory && bun run test:web-saved-key && bun run test:web-solve-process && bun run test:web-review-regressions && bun run test:web-explain && bun run test:web-explain-recovery
- name: Verify login and the first research flow with local fixtures
run: bun run test:web-login && bun run test:web-natural-first
- name: Verify native team creation, approval and library continuation with local fixtures
run: bun scripts/test-web-native-team.ts && bun run test:web-plan-approval && bunx vitest run tests/webLibraryResearch.test.ts
- name: Verify paper drafting and download with local fixtures
run: bun scripts/test-web-paper.ts
- name: Verify formalization progress and background review in the browser
run: bun scripts/test-web-formalization-progress.ts && bunx vitest run tests/webBackgroundReviewWorkflow.test.ts
- name: Verify chat, saved keys, proof runs and explanations in the browser
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:web-chat-session && bun run test:web-chat-cancel-recovery && bun run test:web-key-memory && bun run test:web-saved-key && bun run test:web-solve-process && bun run test:web-review-regressions && bun run test:web-explain && bun run test:web-explain-recovery
- name: Verify research account switching and interrupted frontend operations
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-round5
- name: Verify session renewal, candidate review and route evidence readers
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-round6
- name: Verify delayed session responses and draft recovery
run: bunx vitest run --maxWorkers=4 tests/webSessionCookies.test.ts tests/webResearchSession.test.ts && bun run test:frontend-round7
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-round7
- name: Verify archive budgets, saved keys, plan approvals and historical record navigation
run: bunx vitest run --maxWorkers=4 tests/webDraft.test.ts tests/webLongRun.test.ts tests/researchPlanApproval.test.ts tests/archiveRecordNavigation.test.ts tests/globalTrajectory.test.ts && bun run test:frontend-round8
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-round8
- name: Verify historical guidance, mobile controls and native route search input
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-round9
- name: Verify recovered guidance, message receipts, math readers and source links
run: bunx vitest run --maxWorkers=4 tests/webChatDraft.test.ts tests/webConversations.test.ts tests/archiveSourceLocation.test.ts tests/taskPlanEditorAccess.test.ts && bun run test:frontend-round10
- name: Verify formalization progress and proof thinking in the browser
run: bun scripts/test-web-formalization-progress.ts && bun scripts/test-web-proof-thinking.ts && bunx vitest run tests/webBackgroundReviewWorkflow.test.ts
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-round10
- name: Verify the complete proof thinking workflow in the browser
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun scripts/test-web-proof-thinking.ts

verify-research-workflows:
runs-on: ubuntu-24.04
Expand All @@ -82,8 +101,10 @@ jobs:
- name: Verify single-step proof reading in the website and workbench archives
run: bun run test:proof-reading-navigation
- name: Verify the problem workspace, collaboration, library trials and public reading with disposable fixtures
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-product-continuity
- name: Verify installed libraries, archived problems, mathematical reading and login returns with disposable fixtures
if: github.event_name == 'workflow_dispatch' || inputs.full
run: bun run test:frontend-research-redesign && bun run test:site-research-entry

verify-solver:
Expand Down
3 changes: 2 additions & 1 deletion apps/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM docker:29-cli AS docker-cli
# require a newer glibc even when the Codex source and architecture match.
FROM rust:1.99.1-bookworm AS codex-backend
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 cmake pkg-config libssl-dev libcap-dev libasound2-dev \
python3 curl cmake pkg-config libssl-dev libcap-dev libasound2-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
COPY scripts/build-codex-backend.sh scripts/build-codex-backend.sh
Expand Down Expand Up @@ -105,6 +105,7 @@ ARG THEOREMOS_SOURCE_COMMIT=unknown
LABEL org.opencontainers.image.revision=$THEOREMOS_SOURCE_COMMIT
ENV THEOREMOS_SOURCE_COMMIT=$THEOREMOS_SOURCE_COMMIT
COPY --from=codex-backend /build/artifacts/bin/codex /opt/theoremos-codex-backend/codex
COPY --from=codex-backend /build/artifacts/bin/codex-code-mode-host /opt/theoremos-codex-backend/codex-code-mode-host
ENV THEOREMOS_CODEX_BACKEND_EXECUTABLE=/opt/theoremos-codex-backend/codex
USER 10001:10001
RUN timeout 30s python3 scripts/codex-backend/check-capabilities.py "$THEOREMOS_CODEX_BACKEND_EXECUTABLE"
Expand Down
4 changes: 2 additions & 2 deletions docs/web-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

## 发布镜像

`Verify TheoremOS` 在面向 `main` 的 pull request 和 `main` 推送上运行,也可手动运行。它以只读仓库权限执行 TypeScript 检查、运行时与网页构建、离线浏览器回归,以及 Lean 4.33.0 和 4.34.1 上的求解器回归。验证和镜像发布均使用 Ubuntu 24.04。
`Verify TheoremOS` 在面向 `main` 的 pull request 和 `main` 推送上运行。日常验证包含 TypeScript 检查、运行时和网页构建、单测、Lean 4.33.0 和 4.34.1 上的求解器回归,以及登录、原生团队、计划审批、形式化和归档阅读的浏览器测试。手动运行 `gh workflow run verify.yml --ref <分支>` 会加跑完整的浏览器回归。验证和镜像发布均使用 Ubuntu 24.04。

推送 `v*` 标签或运行 `gh workflow run images.yml --ref main` 会触发 `Publish workbench images`。发布流程在同一提交上调用上述验证,通过后分别构建和推送 web、worker、tex。三个镜像都使用完整源码 SHA 作为 GHCR 标签,并写入 OCI revision。Web 和 worker 还设置 `THEOREMOS_SOURCE_COMMIT`,Web 前端的 `build-info.json` 也记录这个 SHA。三张镜像均推送成功后,流程才上传 `image-release-<SHA>`,其中 `image-release.json` 记录提交及三个 registry digest。
推送 `v*` 标签或运行 `gh workflow run images.yml --ref main` 会触发 `Publish workbench images`。发布流程在同一提交上运行完整验证,通过后分别构建和推送 web、worker、tex。三个镜像都使用完整源码 SHA 作为 GHCR 标签,并写入 OCI revision。Web 和 worker 还设置 `THEOREMOS_SOURCE_COMMIT`,Web 前端的 `build-info.json` 也记录这个 SHA。三张镜像均推送成功后,流程才上传 `image-release-<SHA>`,其中 `image-release.json` 记录提交及三个 registry digest。

本地可执行同一组无模型求解器回归。Linux CI 与 Worker 构建使用 `scripts/install-elan.sh` 安装固定的 elan 4.2.4,校验官方发布包 SHA-256,并通过 Lean 的发布 JSON 获取工具链。先安装相应工具链,再显式选择版本。

Expand Down
60 changes: 49 additions & 11 deletions scripts/build-codex-backend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ usage() {
Usage: scripts/build-codex-backend.sh --source DIR --downloads DIR --output DIR [--jobs N] [--host-tools DIR] [--prepare-only]

Fetch the pinned official Codex release, apply the checked-in build patches,
and build codex-cli with its locked dependencies and an explicitly selected Rust.
All target files, logs, the executable and its provenance stay under --output.
and build Codex and its Code Mode host with locked dependencies and pinned Rust.
All target files, logs, both executables and their provenance stay under --output.
--prepare-only verifies the upstream identity without applying the patch.
--host-tools uses an extracted Debian sysroot for build-only native dependencies.
No global Codex profile or default Rust toolchain is changed.
Expand Down Expand Up @@ -61,6 +61,7 @@ lock_patch_digest=$(pin lockPatchSha256)
patch_file=$script_dir/codex-backend/$(pin patch)
package=$(pin package)
binary=$(pin binary)
code_mode_host=codex-code-mode-host
profile=$(pin profile)

mkdir -p -- "$downloads_dir" "$output_dir" "$(dirname -- "$source_dir")"
Expand Down Expand Up @@ -108,14 +109,15 @@ if ! git -C "$source_dir" apply --reverse --check "$patch_file" 2>/dev/null; the
fi
# Build precisely the reviewable patch. Extra edits are preserved and rejected,
# so re-running this script never resets a developer's source worktree.
git -C "$source_dir" diff --binary --no-ext-diff HEAD -- . ':(exclude)codex-rs/Cargo.lock' > "$output_dir/agent-control-source.patch"
git -C "$source_dir" diff --binary --no-ext-diff HEAD -- codex-rs/Cargo.lock > "$output_dir/derived-lock-source.patch"
# Match the checked-in index width even when a shallow clone uses shorter IDs.
git -C "$source_dir" diff --binary --abbrev=8 --no-ext-diff HEAD -- . ':(exclude)codex-rs/Cargo.lock' > "$output_dir/agent-control-source.patch"
git -C "$source_dir" diff --binary --abbrev=8 --no-ext-diff HEAD -- codex-rs/Cargo.lock > "$output_dir/derived-lock-source.patch"
if ! cmp -s "$patch_file" "$output_dir/agent-control-source.patch" ||
! cmp -s "$lock_patch_file" "$output_dir/derived-lock-source.patch" ||
[[ -n $(git -C "$source_dir" ls-files --others --exclude-standard) ]]; then
echo 'Source worktree differs from the checked-in build patches.' >&2; exit 1
fi
git -C "$source_dir" diff --binary --no-ext-diff HEAD > "$output_dir/source.patch"
git -C "$source_dir" diff --binary --abbrev=8 --no-ext-diff HEAD > "$output_dir/source.patch"

export CARGO_TARGET_DIR=$output_dir/target
export CARGO_PROFILE_DEV_DEBUG=$(pin devDebug)
Expand Down Expand Up @@ -169,24 +171,59 @@ export THEOREMOS_BUILD_SUBMODULE_PINS=$output_dir/submodule-pins.json
ln -sfn -- "$script_dir/codex-backend/git-fetch-pinned.py" "$build_tools/git"
export PATH="$build_tools:$PATH"
export CARGO_NET_GIT_FETCH_WITH_CLI=true

# Build the Code Mode host with the same V8 release pair as upstream Cargo CI.
# The crate's default download site does not publish this pair.
v8_version=$(python3 "$source_dir/.github/scripts/rusty_v8_bazel.py" resolved-v8-crate-version)
rust_target=$(rustup run "$toolchain" rustc -vV | awk '$1 == "host:" {print $2}')
v8_dir=$downloads_dir/codex-rusty-v8-$v8_version
v8_checksums=$source_dir/third_party/v8/rusty_v8_${v8_version//./_}.sha256
v8_archive=librusty_v8_ptrcomp_sandbox_release_$rust_target.a.gz
v8_binding=src_binding_ptrcomp_sandbox_release_$rust_target.rs
mkdir -p -- "$v8_dir"
for artifact in "$v8_archive" "$v8_binding"; do
expected=$(awk -v name="$artifact" '$2 == name {print $1}' "$v8_checksums")
if [[ ! $expected =~ ^[0-9a-f]{64}$ ]]; then
echo "No pinned V8 asset: $artifact" >&2; exit 1
fi
if [[ ! -f $v8_dir/$artifact ]] || ! sha256sum --check --status <<< "$expected $v8_dir/$artifact"; then
download_file=$(mktemp "$v8_dir/$artifact.XXXXXX")
if ! curl --fail --silent --show-error --location --retry 3 \
"https://github.com/openai/codex/releases/download/rusty-v8-v$v8_version/$artifact" --output "$download_file" ||
! sha256sum --check --status <<< "$expected $download_file"; then
rm -f -- "$download_file"
echo "Could not fetch the pinned V8 asset: $artifact" >&2; exit 1
fi
mv -f -- "$download_file" "$v8_dir/$artifact"
fi
done
export RUSTY_V8_ARCHIVE=$v8_dir/$v8_archive
export RUSTY_V8_SRC_BINDING_PATH=$v8_dir/$v8_binding

build_log=$output_dir/build.log
echo "Building $package/$binary; log: $build_log"
echo "Building $package/$binary and $code_mode_host; log: $build_log"
if ! (cd -- "$source_dir/codex-rs" && rustup run "$toolchain" cargo build --locked \
--profile "$profile" -p "$package" --bin "$binary" --jobs "$jobs") > "$build_log" 2>&1; then
--profile "$profile" -p "$package" --bin "$binary" \
-p "$code_mode_host" --bin "$code_mode_host" --jobs "$jobs") > "$build_log" 2>&1; then
tail -n 60 "$build_log" >&2
exit 1
fi
mkdir -p -- "$output_dir/bin"
install -m 755 "$CARGO_TARGET_DIR/debug/$binary" "$output_dir/bin/$binary.new"
mv -f -- "$output_dir/bin/$binary.new" "$output_dir/bin/$binary"
# Codex resolves its companion next to the real executable, including when
# started through the runtime symlink.
for artifact in "$code_mode_host" "$binary"; do
install -m 755 "$CARGO_TARGET_DIR/debug/$artifact" "$output_dir/bin/$artifact.new"
mv -f -- "$output_dir/bin/$artifact.new" "$output_dir/bin/$artifact"
done
runtime_link=$script_dir/../out/codex-backend/codex
mkdir -p -- "$(dirname -- "$runtime_link")"
ln -sfn -- "$output_dir/bin/$binary" "$runtime_link"
python3 - "$pin_file" "$source_dir" "$output_dir" "$patch_file" "$jobs" "$runtime_link" "$host_tools" <<'PY'
python3 - "$pin_file" "$source_dir" "$output_dir" "$patch_file" "$jobs" "$runtime_link" "$host_tools" "$code_mode_host" <<'PY'
import datetime, hashlib, json, pathlib, subprocess, sys
pin_file, source, output, patch_file, jobs, runtime_link, host_tools = sys.argv[1:]
pin_file, source, output, patch_file, jobs, runtime_link, host_tools, code_mode_host = sys.argv[1:]
pin = json.loads(pathlib.Path(pin_file).read_text())
artifact = pathlib.Path(output, "bin", pin["binary"])
companion = artifact.with_name(code_mode_host)
digest = lambda file: hashlib.file_digest(pathlib.Path(file).open("rb"), "sha256").hexdigest()
version = lambda command: subprocess.check_output(["rustup", "run", pin["toolchain"], *command], text=True).strip()
record = {
Expand All @@ -198,6 +235,7 @@ record = {
"lockPatchSha256": digest(pathlib.Path(pin_file).parent / pin["lockPatch"]),
"sourcePatchSha256": digest(pathlib.Path(output, "source.patch")),
"executable": str(artifact), "executableSha256": digest(artifact),
"codeModeHost": str(companion), "codeModeHostSha256": digest(companion),
"rustc": version(["rustc", "--version", "--verbose"]), "cargo": version(["cargo", "--version"]),
"jobs": int(jobs), "targetDirectory": str(pathlib.Path(output, "target")),
"log": str(pathlib.Path(output, "build.log")),
Expand Down
27 changes: 14 additions & 13 deletions scripts/codex-backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ and `libssl3t64` version `3.0.13-0ubuntu3.16`.
Large asynchronous core tests require `RUST_MIN_STACK=8388608`, matching the
upstream Bazel test configuration. Set it only on the test subprocess.

All Cargo targets, logs and binaries stay under `--output`. On success,
`backend-build.json` records the source, patch, lockfile and executable digests;
`out/codex-backend/codex` points to the built executable. Existing sessions are
not restarted. Source edits beyond the checked-in patches are preserved and
rejected, so freeze the adapter patch before running a final build.
All Cargo targets, logs and binaries stay under `--output`. The build installs
`codex` and `codex-code-mode-host` together in `bin/` and records both digests in
`backend-build.json`. Keep the pair together when moving the backend. The local
`out/codex-backend/codex` link points to the built CLI. Existing sessions are not
restarted. Source edits beyond the checked-in patches are preserved and rejected,
so freeze the adapter patch before running a final build.

New team runs pin the executable's real path and digest and record
`agentTeam.transport: native-agent-control`. Startup failures are reported
Expand Down Expand Up @@ -80,19 +81,19 @@ returns a tool error and Lead can retry with `fork_turns: "none"`. Pass
profile, including metered requests before and after Lead cold resume.

The built runtime link installs this backend for new local CLI team runs.
The Web worker Dockerfile builds the same pinned source on Debian Bookworm
and installs a separate binary at `/opt/theoremos-codex-backend/codex`.
Ordinary runs keep the stock Codex binary. The worker build probes the native
app-server's capabilities as the worker user before labeling the image
The Web worker Dockerfile builds the same pinned source on Debian Bookworm and
installs both executables in `/opt/theoremos-codex-backend/`. Ordinary runs keep
the stock Codex binary. The worker build probes AgentControl and executes a Code
Mode call as the worker user with fixed loopback responses before labeling the image
`org.theoremos.native-agent-control=v1`. The Web service also checks
`org.theoremos.native-team-workflow=v1`, which identifies support for native
team scheduling and initial route approval. It launches the image by its
verified ID. Rebuild both Web and worker images to roll out this workflow.

Cargo resolves V8 host manifests even though the CLI does not link that runtime.
The build-local Git helper fetches the exact locked submodule commits without
downloading unrelated Chromium branch histories. Their official gitlink pins
are recorded in `submodule-pins.json`.
The Code Mode host uses the V8 archive and Rust bindings from the matching Codex
release. The build verifies them against the pinned checkout's checksums. The
build-local Git helper fetches the exact locked submodule commits and records
their official gitlink pins in `submodule-pins.json`.

If downloads fail with `Proxy CONNECT aborted`, check the configured proxy. A
confirmed direct connection can be used for this build by invoking the script
Expand Down
Loading
Loading