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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.py]
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab

# Proof records, evidence and byte-compared fixtures keep their exact bytes.
[{accepted,submitted,in-progress,results,theoremos-review,tests/fixtures,docs/assets}/**]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
11 changes: 6 additions & 5 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
with:
bun-version: 1.4.0
- run: bun install --frozen-lockfile
- run: bun run format:check
- run: bun run typecheck && bun run typecheck:web && bun run typecheck:site
- name: Verify account, job, persistence and operations boundaries without models
run: bunx vitest run --maxWorkers=4 tests/webAuth.test.ts tests/webSignup.test.ts tests/webAuthPolicy.test.ts tests/webQuota.test.ts tests/webAdmission.test.ts tests/webAdmissionRace.test.ts tests/webProviderCheck.test.ts tests/webI18n.test.ts tests/webFonts.test.ts tests/webKeyVault.test.ts tests/webJobs.test.ts tests/webLifecyclePersistence.test.ts tests/webCollaboration.test.ts tests/webConversations.test.ts tests/webExplain.test.ts tests/webPersistence.test.ts tests/webFormalizations.test.ts tests/webExplanation.test.ts tests/webExplanationServer.test.ts tests/webServer.test.ts tests/webRunStream.test.ts tests/webRunner.test.ts tests/webPrecheck.test.ts tests/webOperations.test.ts tests/webOperationsApi.test.ts tests/webOperationsScheduled.test.ts tests/webOperationsMonitor.test.ts
Expand All @@ -46,15 +47,15 @@ jobs:
- 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
run: bun scripts/e2e/test-web-proof-thinking.ts --simple-reading
- 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
run: bun scripts/e2e/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
run: bun scripts/e2e/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
run: bun scripts/e2e/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
Expand All @@ -78,7 +79,7 @@ jobs:
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
run: bun scripts/e2e/test-web-proof-thinking.ts

verify-research-workflows:
runs-on: ubuntu-24.04
Expand Down
24 changes: 24 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
node_modules/
out/
coverage/
runtime/
.state/
**/*.runtime/

# Proof records, evidence and byte-compared fixtures keep their exact bytes.
accepted/
submitted/
in-progress/
results/
theoremos-review/
tests/fixtures/
docs/assets/

bun.lock
*.lean

# Generated by scripts/generate-web-library-search.ts.
src/math/frozenLibrarySearchData.ts

# Font faces are generated and matched byte-for-byte by tests/webFonts.test.ts.
apps/web/client/app.css
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"singleQuote": true,
"semi": true,
"arrowParens": "avoid"
}
83 changes: 83 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 开发约定

本文说明仓库的目录分工、常用命令和必须保持原样的内容。产品介绍与快速上手见 [README](README.md),文档导航见 [docs/README.md](docs/README.md),运行时边界见 [AGENTS.md](AGENTS.md)。

## 环境

- 包管理与运行:`bun@1.4.0`(`package.json` 的 `packageManager`),安装用 `bun install --frozen-lockfile`。
- 证明检查需要 Lean 工具链,可用 `scripts/install-elan.sh` 安装。
- 编辑器按 `.editorconfig` 统一缩进与换行;代码格式由 Prettier(`.prettierrc.json`)决定。

## 目录

| 目录 | 内容 |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `bin/` | CLI 入口 `math.ts`(`bun run math`) |
| `src/math/` | 数学服务:检索、库、形式化与检查 |
| `src/solver/` | 求解运行、研究会话、协作、归档与最终验收 |
| `src/runtime/` | 与 Codex 等模型运行时的连接 |
| `apps/web/` | 可选的网页工作台(服务端与 `client/`),不得成为 CLI 的依赖 |
| `docs/web/` | 官网源码,`bun run build:site` 构建到 `out/site` |
| `tests/` | vitest 单元与集成测试;`tests/fixtures/` 为逐字节比对的夹具 |
| `scripts/` | 构建、导入、部署与运维脚本 |
| `scripts/e2e/` | 浏览器端到端测试及其共用模块 |
| `scripts/mathematics/`、`scripts/math-tools/` | 数学库构建、回放与外部数学工具脚本 |
| `ops/systemd/` | 备份、监控与快照保留的 systemd 单元 |
| `resources/` | Lean/Mathlib 固定配置、CLI harness 配置、库与题目支持材料 |
| `skills/` | Lead 使用的固定研究 Skill |
| `research/` | 研究协议、决策记录与题目研究材料 |
| `examples/` | 可复验的示例与基准适配 |
| `docs/` | 使用与设计文档;`docs/history/`、`docs/releases/`、`docs/execution/`、`docs/maintenance/` 为带日期的历史记录 |
| `reports/` | 研究报告 |
| `third_party/`、`LICENSES/` | 第三方与本项目许可 |

## 保持原样的内容

以下内容是证据或被逐字节比对,不做格式化、重命名或改写:

- 归档目录:`accepted/`、`submitted/`、`in-progress/`、`results/`、`theoremos-review/`。路径与公开归档链接一致。
- `tests/fixtures/`、`docs/assets/`。
- `examples/knowledge-reuse/` 的证据记录(不在格式化范围内)。
- 生成文件:`src/math/frozenLibrarySearchData.ts`(由 `scripts/generate-web-library-search.ts` 生成)、`apps/web/client/app.css`(字体声明由 `tests/webFonts.test.ts` 比对)。
- 历史文档里的路径与版本号代表当时状态,不随代码搬迁更新。
- 已有证明、研究笔记与运行记录作为历史证据保留。

`scripts/web-scenario.ts` 与 `scripts/web-ui-controls.ts` 只是转发到 `scripts/e2e/` 的兼容入口,供冻结的 `theoremos-review/web-main/reproduce.ts` 使用,不要删除。

## 常用命令

```bash
bun run check # 格式检查 + 三套类型检查 + vitest,提交前运行
bun run format # 按 Prettier 改写源码
bun run typecheck # CLI 与运行时
bun run typecheck:web # 网页工作台
bun run typecheck:site # 官网
bun run build # CLI bundle
bun run build:web # 工作台
bun run build:site # 官网
bunx vitest run tests/<name>.test.ts # 单个测试文件
```

格式化范围是 `src`、`apps`、`tests`、`scripts`、`docs/web` 下的脚本与样式,加上 `docs/*.css`、`bin/math.ts`、`vitest.config.ts`。CI(`.github/workflows/verify.yml`)会执行 `format:check`。

## 浏览器测试

浏览器测试在 `scripts/e2e/`,用 Playwright 驱动,大多在 `package.json` 里有对应的 `test:*` 脚本。一律从仓库根目录运行:

```bash
bun scripts/e2e/test-web-<name>.ts
```

新增浏览器测试放进 `scripts/e2e/`,复用 `web-scenario.ts`、`web-ui-controls.ts` 等共用模块,并在 `package.json` 里补一个 `test:*` 脚本。

## 资源再生成

- 工作台标题字体:`scripts/subset-workbench-heading.py`(需要 FontTools)从 `docs/assets/fonts/` 的 `NotoSerifSC-ui*.woff2` 截取空白工作台标题用到的字(“想证明什么?”“今天”),重新生成 `TheoremOSWorkbenchHeading.woff2`;改标题文字时同步修改脚本里的字表,`scripts/build-web.ts` 把它复制进构建产物,`apps/web/client/research-conversation.css` 引用它。目前没有测试覆盖这个字体,改完后用 `bun run build:web` 构建,在空白工作台页面上确认标题显示正常。
- 官网与工作台截图:`scripts/capture-*.{ts,mjs}`,用法见 [docs/website.md](docs/website.md)。
- 自动库宿主回放:`scripts/mathematics/autoLibraryHostReplay.ts`,见 [docs/LIBRARY-HOST-CONFIG.md](docs/LIBRARY-HOST-CONFIG.md)。

## 提交

- 做最小的必要改动;修改运行时边界时跑相关测试和 `bun run build`。
- 不提交凭据,不改全局 Codex 配置,不为验证本地改动调用真实模型。
- 维护工作不得直接干预具体题目的求解过程(指导投递、改证明或进度、替题目提交);问题应通过调度、上下文、工具、检索等通用机制修复。
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ TheoremOS separates research decisions from proof verification. The table includ

- **IMO 2026 Public Comparison (`6/6` problems / `15/15` goals)**: Verified on aligned AxiomMath formal statements (`TheoremOS + GPT-5.6` total **285.55 min**, local Lean verification `official: false`); methodology, timing definitions, and complete proofs are in [`examples/imo2026/RESULTS.md`](./examples/imo2026/RESULTS.md) and the [IMO2026 Guide](./examples/imo2026/README.md).
- **Lean-Eval &amp; Extended Benchmarks**: Frozen archive provenance in [`accepted/accepted.json`](./accepted/accepted.json) and [`submitted/README.md`](./submitted/README.md), alongside [PutnamBench](./examples/putnambench/README.md) and [First Proof](./examples/first-proof/README.md) adapters. Browse all 29 interactive trajectories at [**theoremos.top/en/archive.html**](https://theoremos.top/en/archive.html) or [**HuggingMath/TheoremOS**](https://github.com/HuggingMath/TheoremOS).
- **Archive Folders** (kept byte-for-byte; paths match the public archive links): [`accepted/`](./accepted/README.md) officially accepted Lean-Eval packages · [`submitted/`](./submitted/README.md) packages from submission #2144, also accepted · [`in-progress/`](./in-progress/README.md) research snapshots from 2026-10-15 · [`results/`](./results/README.md) other solved results with local verification evidence · [`theoremos-review/`](./theoremos-review/) web workbench review records.
- **Technical Documentation**: [Formalization](./docs/formalization.md) · [Informalization](./docs/informalization.md) · [Website &amp; Archive Architecture](./docs/website.md) · [Release Trial Notes](./docs/web-release-trial.md) · [v0.1.0 Release Notes](./docs/releases/v0.1.0.md)

<details>
Expand Down
16 changes: 13 additions & 3 deletions apps/web/admission.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
/** Login-page sessions cost a slot even before authentication. Bound new sessions per visitor, independently of API reads. */
type Session = { id: string; touchedAt: number; account?: unknown };
const windowMs = 10 * 60_000, perIp = 30, anonymousLimit = 200, sessionLimit = 2_000;
const windowMs = 10 * 60_000,
perIp = 30,
anonymousLimit = 200,
sessionLimit = 2_000;

export class WebAdmissionError extends Error {
constructor(readonly status: number, message: string) { super(message); }
constructor(
readonly status: number,
message: string,
) {
super(message);
}
}

export class WebSessionAdmission {
Expand All @@ -21,7 +29,9 @@ export class WebSessionAdmission {
const visitor = this.visitors.get(ip);
if (visitor && visitor.count >= perIp) throw new WebAdmissionError(429, '登录页面打开过于频繁,请十分钟后重试。');
if (!visitor && this.visitors.size >= 2_000) throw new WebAdmissionError(429, '请求较多,请稍后重试。');
let total = 0, anonymous = 0, oldest: Session | undefined;
let total = 0,
anonymous = 0,
oldest: Session | undefined;
for (const session of sessions) {
total++;
if (session.account) continue;
Expand Down
Loading
Loading