From 9e15f74610dd3a5ad53df2eb9e3713a5602849a8 Mon Sep 17 00:00:00 2001 From: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com> Date: Wed, 2 Dec 2026 13:09:10 +0800 Subject: [PATCH] chore: format the repository and prune obsolete tests - Add .editorconfig, Prettier config/ignore and format / format:check scripts; reformat src, apps, tests, scripts, docs/web (frozen archives, fixtures, docs/assets and generated files are left untouched). CI runs format:check. - Move browser end-to-end tests into scripts/e2e/ (scripts/web-scenario.ts and scripts/web-ui-controls.ts stay as forwarding entries for the frozen review reproduction) and dated design notes into docs/history/. - Add test:* entries for archive-process, archive-roadmap, classic-global-trajectory and math-rendering. - Remove three browser tests that no longer exercise current behaviour: test-web-background-review, test-web-candidate-history, test-web-budget-attempt-continuity. - Add CONTRIBUTING.md (layout, commands, content that must stay byte-for-byte). - Fix the Codex sandbox when a home symlink points into /tmp: keep only the outermost hidden roots so bwrap never needs a mount point inside a hidden parent (src/runtime/codexSession.ts, with a unit test), and update the opt-in Codex-sandbox proof environment tests to the current health output. Co-Authored-By: Claude Opus 5.5 --- .editorconfig | 27 + .github/workflows/verify.yml | 11 +- .prettierignore | 24 + .prettierrc.json | 6 + CONTRIBUTING.md | 83 + README.md | 1 + apps/web/admission.ts | 16 +- apps/web/agentActions.ts | 983 ++- apps/web/auth.ts | 331 +- apps/web/candidateTargetCheck.ts | 47 +- apps/web/client/CommunityBoard.tsx | 1394 +++- apps/web/client/ResearchPractice.tsx | 703 +- apps/web/client/ShareReadingView.tsx | 371 +- apps/web/client/ShareReceiverActions.tsx | 412 +- apps/web/client/activityReader.tsx | 340 +- apps/web/client/agentActivity.ts | 74 +- apps/web/client/agentRoute.ts | 150 +- apps/web/client/app.ts | 6365 +++++++++++++---- apps/web/client/automaticExplanation.ts | 12 +- apps/web/client/backgroundReview.tsx | 122 +- apps/web/client/browserRunNotifications.ts | 46 +- apps/web/client/chatAnswer.ts | 159 +- apps/web/client/chatArtifactNavigation.ts | 58 +- apps/web/client/chatDraft.ts | 274 +- apps/web/client/chatMathematics.ts | 67 +- apps/web/client/chatReadingPosition.ts | 121 +- apps/web/client/chatReference.ts | 86 +- apps/web/client/chatSession.ts | 2349 ++++-- apps/web/client/classicPreparation.ts | 55 +- apps/web/client/collaborationFlow.css | 318 +- apps/web/client/collaborationFlow.tsx | 1731 ++++- .../client/collaborationMessageSummary.tsx | 74 +- apps/web/client/collaborationNavigation.tsx | 186 +- apps/web/client/collaborationUi.ts | 74 +- apps/web/client/collaborationView.tsx | 1726 ++++- apps/web/client/community.css | 971 ++- apps/web/client/community.ts | 12 +- apps/web/client/correspondence.tsx | 342 +- apps/web/client/decisionFlow.css | 233 +- apps/web/client/decisionSummary.tsx | 314 +- apps/web/client/decisionSummaryModel.ts | 168 +- apps/web/client/detailLevel.ts | 16 +- apps/web/client/downloadLean.ts | 7 +- apps/web/client/draft.ts | 222 +- apps/web/client/draftRecovery.ts | 92 +- apps/web/client/editorNavigation.ts | 255 +- apps/web/client/editorReview.ts | 132 +- apps/web/client/explain.ts | 800 ++- apps/web/client/explainSolutionRoute.ts | 277 +- apps/web/client/explainText.ts | 406 +- apps/web/client/explainView.tsx | 1385 +++- apps/web/client/explanationState.ts | 41 +- apps/web/client/feedback.ts | 39 +- .../client/firstResearchBudgetValidation.ts | 41 +- apps/web/client/firstResearchModel.ts | 14 +- apps/web/client/formalization.ts | 104 +- apps/web/client/formalizationActivityStore.ts | 69 +- apps/web/client/formalizationView.tsx | 436 +- apps/web/client/formalize.css | 829 ++- apps/web/client/formalize.ts | 827 ++- apps/web/client/frozenTaskView.tsx | 132 +- apps/web/client/glossary.ts | 154 +- apps/web/client/guidanceComposer.tsx | 435 +- apps/web/client/guidanceOutcome.tsx | 199 +- apps/web/client/guidanceOutcomeModel.ts | 76 +- apps/web/client/history.ts | 36 +- apps/web/client/historyPreference.ts | 4 +- apps/web/client/installedLibraryReference.ts | 31 +- .../client/installedLibraryReferenceValue.ts | 29 +- apps/web/client/keyMemory.ts | 30 +- apps/web/client/knowledgeView.tsx | 415 +- apps/web/client/leanMessages.ts | 67 +- apps/web/client/leanOutline.ts | 77 +- apps/web/client/leanPane.ts | 70 +- apps/web/client/leanTheoremType.ts | 40 +- apps/web/client/libraryEntry.ts | 45 +- apps/web/client/login.ts | 348 +- apps/web/client/mathAssets.ts | 58 +- apps/web/client/mathematicalChangesView.tsx | 628 +- apps/web/client/modulePlanEditor.ts | 350 +- apps/web/client/modulePlanLibrary.ts | 94 +- apps/web/client/modulePlanLibraryView.ts | 203 +- apps/web/client/moduleView.tsx | 696 +- apps/web/client/motion.ts | 351 +- apps/web/client/ownedDrafts.ts | 33 +- apps/web/client/paper.css | 433 +- apps/web/client/paper.tsx | 540 +- apps/web/client/personalApprovalStore.ts | 60 +- apps/web/client/personalGuidanceStore.ts | 64 +- apps/web/client/practice.ts | 12 +- apps/web/client/problemDraftLifecycle.ts | 194 +- apps/web/client/problemDrafts.tsx | 529 +- apps/web/client/productFlow.css | 180 +- apps/web/client/productFlow.ts | 193 +- apps/web/client/productFlowView.tsx | 259 +- apps/web/client/productStatus.tsx | 169 +- apps/web/client/proofMap.css | 1155 ++- apps/web/client/proofMapModel.ts | 842 ++- apps/web/client/readableExplanation.ts | 53 +- apps/web/client/research-conversation.css | 5771 ++++++++++++--- apps/web/client/research-overview.css | 333 +- apps/web/client/research.css | 3193 +++++++-- apps/web/client/researchAnnotations.tsx | 787 +- apps/web/client/researchAssetEditor.tsx | 912 ++- apps/web/client/researchBriefExport.ts | 108 +- apps/web/client/researchBriefFonts.ts | 117 +- apps/web/client/researchBudget.css | 134 +- apps/web/client/researchBudget.tsx | 323 +- apps/web/client/researchBudgetAttempt.tsx | 177 +- apps/web/client/researchBudgetAttemptModel.ts | 5 +- apps/web/client/researchBudgetContinuity.tsx | 78 +- apps/web/client/researchBudgetDraft.tsx | 125 +- apps/web/client/researchBudgetEditor.ts | 24 +- .../client/researchCandidateContinuity.css | 57 +- apps/web/client/researchCandidateHistory.tsx | 80 +- apps/web/client/researchCandidateReview.tsx | 301 +- apps/web/client/researchCheckDetails.tsx | 399 +- apps/web/client/researchCollections.css | 108 +- apps/web/client/researchCollections.tsx | 743 +- apps/web/client/researchCostModel.ts | 14 +- apps/web/client/researchDiscussionContext.tsx | 39 +- apps/web/client/researchDiscussionDraft.ts | 24 +- .../web/client/researchDiscussionGuidance.tsx | 496 +- apps/web/client/researchDraftStore.ts | 80 +- apps/web/client/researchDrafts.tsx | 642 +- apps/web/client/researchEntry.ts | 42 +- apps/web/client/researchEvolution.tsx | 95 +- apps/web/client/researchFeedback.tsx | 944 ++- apps/web/client/researchFeedbackModel.ts | 112 +- apps/web/client/researchHandoffComposer.tsx | 206 +- apps/web/client/researchHandoffDraft.ts | 41 +- apps/web/client/researchHistory.tsx | 90 +- apps/web/client/researchInlineActions.css | 178 +- apps/web/client/researchInlineActions.tsx | 364 +- apps/web/client/researchInputDraft.ts | 44 +- apps/web/client/researchInstalledLibrary.tsx | 951 ++- apps/web/client/researchInvite.tsx | 394 +- apps/web/client/researchIssueExecution.tsx | 52 +- .../web/client/researchIssueExecutionDraft.ts | 23 +- apps/web/client/researchIssueReplyDraft.ts | 15 +- apps/web/client/researchJourney.css | 411 +- apps/web/client/researchJourney.tsx | 1160 ++- apps/web/client/researchLibrary.tsx | 2107 +++++- apps/web/client/researchLibraryCandidate.tsx | 95 +- apps/web/client/researchLibraryDiscovery.tsx | 117 +- .../client/researchLibraryDiscoveryModel.ts | 80 +- apps/web/client/researchLibraryNavigation.ts | 31 +- apps/web/client/researchLibraryProposal.tsx | 378 +- .../client/researchLibraryProposalAttempt.tsx | 209 +- .../researchLibraryProposalAttemptModel.ts | 21 +- .../client/researchLibraryProposalDraft.ts | 46 +- apps/web/client/researchLibraryTrial.tsx | 661 +- apps/web/client/researchLibraryTrialDraft.ts | 86 +- .../client/researchLibraryTrialHistory.tsx | 286 +- apps/web/client/researchLibraryTrials.css | 241 +- apps/web/client/researchMathUsage.tsx | 89 +- apps/web/client/researchMathUsageEditor.tsx | 178 +- apps/web/client/researchMembers.ts | 20 +- apps/web/client/researchOpenAIProblems.tsx | 332 +- apps/web/client/researchOrganizationDraft.ts | 54 +- apps/web/client/researchOutcomeDelivery.tsx | 192 +- apps/web/client/researchOverview.tsx | 672 +- apps/web/client/researchOverviewModel.ts | 165 +- apps/web/client/researchPeople.tsx | 907 ++- apps/web/client/researchPeopleReturn.ts | 7 +- apps/web/client/researchPersonal.css | 236 +- apps/web/client/researchPersonal.tsx | 516 +- apps/web/client/researchPersonalApproval.tsx | 269 +- apps/web/client/researchPlanApproval.tsx | 282 +- apps/web/client/researchPractice.css | 519 +- apps/web/client/researchPracticeModel.ts | 131 +- apps/web/client/researchProblem.css | 854 ++- apps/web/client/researchProblem.tsx | 1515 +++- apps/web/client/researchProblemDraft.ts | 265 +- .../client/researchProblemEvidenceView.tsx | 397 +- apps/web/client/researchProblemModel.ts | 510 +- apps/web/client/researchProblemNavigation.ts | 32 +- apps/web/client/researchProgressView.tsx | 746 +- apps/web/client/researchProjectDraft.ts | 162 +- apps/web/client/researchProjectStart.tsx | 67 +- apps/web/client/researchReleaseComparison.tsx | 510 +- apps/web/client/researchReview.tsx | 500 +- apps/web/client/researchReviewerNavigation.ts | 16 +- apps/web/client/researchRoadmap.ts | 443 +- apps/web/client/researchRunNotifications.tsx | 37 +- apps/web/client/researchRunStatus.tsx | 101 +- apps/web/client/researchSelection.ts | 258 +- apps/web/client/researchShared.tsx | 559 +- apps/web/client/researchStageReference.tsx | 171 +- apps/web/client/researchStartCost.tsx | 269 +- apps/web/client/researchTheorems.tsx | 2935 ++++++-- apps/web/client/researchViews.tsx | 266 +- apps/web/client/researchWorkImpact.tsx | 359 +- apps/web/client/researchWorkspace.css | 581 +- apps/web/client/researchWorkspace.tsx | 1342 +++- apps/web/client/reviewView.tsx | 518 +- apps/web/client/richText.tsx | 132 +- apps/web/client/runAwareness.ts | 42 +- apps/web/client/runGuidanceFeedback.ts | 21 +- apps/web/client/runSnapshot.ts | 34 +- apps/web/client/runUpdates.ts | 21 +- apps/web/client/serverModulePlans.tsx | 342 +- apps/web/client/share.ts | 287 +- apps/web/client/shareContinuation.css | 93 +- apps/web/client/shareContinuation.ts | 36 +- apps/web/client/shareSolutionRoute.ts | 119 +- apps/web/client/solutionRoute.ts | 461 +- apps/web/client/solveProcess.ts | 1066 ++- apps/web/client/sourceCheck.tsx | 243 +- apps/web/client/sourceDiff.ts | 72 +- apps/web/client/sourceFile.ts | 12 +- apps/web/client/sourceIndent.ts | 25 +- apps/web/client/sourceReader.tsx | 410 +- apps/web/client/sourceReplace.ts | 33 +- apps/web/client/sourceText.ts | 90 +- apps/web/client/submission.ts | 51 +- apps/web/client/submissionIdentity.ts | 51 +- apps/web/client/taskGraphLayout.ts | 260 +- apps/web/client/taskPlanEditor.tsx | 1051 ++- apps/web/client/taskSourceComparison.tsx | 239 +- apps/web/client/teamProfilePicker.tsx | 221 +- apps/web/client/termHints.ts | 142 +- apps/web/client/themePreference.ts | 26 +- apps/web/client/thinkingProcess.ts | 453 +- apps/web/client/trajectory.ts | 543 +- apps/web/client/trajectoryView.tsx | 2765 +++++-- apps/web/client/typesetProse.tsx | 20 +- apps/web/client/ui/AdminPanel.tsx | 293 +- apps/web/client/ui/AgentCards.tsx | 111 +- apps/web/client/ui/AgentRoute.tsx | 1233 +++- apps/web/client/ui/ChatMathematicalWork.tsx | 582 +- apps/web/client/ui/ChatMessageContent.tsx | 310 +- apps/web/client/ui/ChatWorkspace.tsx | 3020 ++++++-- apps/web/client/ui/CollaborationNow.tsx | 73 +- apps/web/client/ui/CollaborationSurface.tsx | 262 +- apps/web/client/ui/CommandPalette.tsx | 153 +- apps/web/client/ui/Controls.tsx | 105 +- apps/web/client/ui/Conversation.tsx | 134 +- apps/web/client/ui/DetailPanel.tsx | 1535 +++- apps/web/client/ui/DraftPreview.tsx | 135 +- apps/web/client/ui/FirstResearchStart.tsx | 127 +- apps/web/client/ui/FormalizationProgress.tsx | 158 +- apps/web/client/ui/Icon.tsx | 211 +- apps/web/client/ui/LiveWorkspace.tsx | 622 +- apps/web/client/ui/MathFormula.tsx | 81 +- apps/web/client/ui/ProgressSummary.tsx | 106 +- apps/web/client/ui/ProofMap.tsx | 932 ++- apps/web/client/ui/ResearchConversation.tsx | 122 +- apps/web/client/ui/ResearchProblemDraft.tsx | 125 +- apps/web/client/ui/ResearchRoadmap.tsx | 615 +- apps/web/client/ui/RunHeader.tsx | 557 +- apps/web/client/ui/RunMonitor.tsx | 65 +- apps/web/client/ui/Section.tsx | 163 +- apps/web/client/ui/SideViewer.tsx | 85 +- apps/web/client/ui/SolutionRouteGraph.tsx | 40 +- apps/web/client/ui/SolveProcess.tsx | 356 +- apps/web/client/ui/TaskBoard.tsx | 230 +- apps/web/client/ui/TaskInspector.tsx | 186 +- apps/web/client/ui/TermHint.tsx | 13 +- apps/web/client/ui/ThinkingProcess.tsx | 1356 +++- apps/web/client/ui/Topbar.tsx | 290 +- apps/web/client/usePersonalGuidance.ts | 153 +- apps/web/collaboration.ts | 661 +- apps/web/collaborationValidation.ts | 99 +- apps/web/community.ts | 640 +- apps/web/communityTypes.ts | 75 +- apps/web/completionMail.ts | 183 +- apps/web/config.ts | 340 +- apps/web/conversationTypes.ts | 26 +- apps/web/conversations.ts | 556 +- apps/web/declarationArtifacts.ts | 67 +- apps/web/environment.ts | 3 +- apps/web/explain.ts | 182 +- apps/web/explanation.ts | 340 +- apps/web/explanationCheckpoint.ts | 99 +- apps/web/explanationWorker.ts | 310 +- apps/web/explanations.ts | 300 +- apps/web/failure.ts | 35 +- apps/web/formalizationActivity.ts | 492 +- apps/web/formalizationActivityValidation.ts | 109 +- apps/web/formalizationAuditTypes.ts | 9 +- apps/web/formalizationReasons.ts | 36 +- apps/web/formalizationReport.ts | 242 +- apps/web/formalizationSeed.ts | 107 +- apps/web/formalizationTypes.ts | 204 +- apps/web/formalizationWorker.ts | 336 +- apps/web/formalizations.ts | 894 ++- apps/web/frozenLibrary.ts | 48 +- apps/web/funnel.ts | 24 +- apps/web/harness.ts | 182 +- apps/web/i18n.ts | 113 +- apps/web/i18n/admin.ts | 166 +- apps/web/i18n/app.ts | 1830 ++--- apps/web/i18n/collaboration.ts | 1415 ++-- apps/web/i18n/common.ts | 574 +- apps/web/i18n/editor.ts | 366 +- apps/web/i18n/en.ts | 19 +- apps/web/i18n/errors.ts | 859 ++- apps/web/i18n/explain.ts | 556 +- apps/web/i18n/formalize.ts | 366 +- apps/web/i18n/guide.ts | 213 +- apps/web/i18n/legal.ts | 176 +- apps/web/i18n/libraryTrials.ts | 39 +- apps/web/i18n/modules.ts | 425 +- apps/web/i18n/pages.ts | 553 +- apps/web/i18n/process.ts | 217 +- apps/web/i18n/release.ts | 243 +- apps/web/i18n/server.ts | 462 +- apps/web/i18nLocale.ts | 11 +- apps/web/installedLibrary.ts | 173 +- apps/web/installedLibraryDefinitions.ts | 40 +- apps/web/installedLibraryInterfaceSearch.ts | 55 +- apps/web/installedLibraryLabels.ts | 495 +- apps/web/installedLibraryMathematics.ts | 401 +- apps/web/installedLibrarySearch.ts | 123 +- apps/web/installedLibraryTypes.ts | 7 +- apps/web/jobs.ts | 637 +- apps/web/keyVault.ts | 23 +- apps/web/knowledgeService.ts | 176 +- apps/web/libraryResearch.ts | 269 +- apps/web/libraryUsage.ts | 122 +- apps/web/math.css | 63 +- apps/web/moduleRegistry.ts | 203 +- apps/web/moduleTelemetry.ts | 198 +- apps/web/nativeTeamObservation.ts | 331 +- apps/web/nativeTeamProfiles.ts | 9 +- apps/web/observationChecks.ts | 26 +- apps/web/observationSources.ts | 78 +- apps/web/operations.ts | 26 +- apps/web/paperDrafts.ts | 99 +- apps/web/paperPdf.ts | 29 +- apps/web/precheck.ts | 186 +- apps/web/presentation.ts | 470 +- apps/web/preview/preview.css | 179 +- apps/web/preview/preview.tsx | 635 +- apps/web/problemDraftSubmission.ts | 85 +- apps/web/problemDraftTypes.ts | 6 +- apps/web/problemExamples.ts | 69 +- apps/web/productStatus.ts | 45 +- apps/web/productStatusTypes.ts | 15 +- apps/web/progress.ts | 333 +- apps/web/proofJournal.ts | 45 +- apps/web/providerCheck.ts | 40 +- apps/web/quota.ts | 118 +- apps/web/report.ts | 487 +- apps/web/researchAnnotationsApi.ts | 42 +- apps/web/researchApi.ts | 800 ++- apps/web/researchAssetPrefill.ts | 242 +- apps/web/researchAssetTypes.ts | 114 +- apps/web/researchAssets.ts | 947 ++- apps/web/researchBudgetTypes.ts | 28 +- apps/web/researchBudgets.ts | 241 +- apps/web/researchCandidateScope.ts | 79 +- apps/web/researchCollaborationApi.ts | 62 +- apps/web/researchCollaborationTypes.ts | 131 +- apps/web/researchCollectionTypes.ts | 29 +- apps/web/researchCollections.ts | 372 +- apps/web/researchHistory.ts | 251 +- apps/web/researchJourney.ts | 859 ++- apps/web/researchJourneyTypes.ts | 108 +- apps/web/researchLibraryDiscoveryTypes.ts | 12 +- apps/web/researchLibraryProposalOrigin.ts | 5 +- apps/web/researchLibraryProvenance.ts | 53 +- apps/web/researchLibraryTrialTypes.ts | 117 +- apps/web/researchLibraryTrials.ts | 1036 ++- apps/web/researchLibraryUsage.ts | 129 +- apps/web/researchMathExamples.ts | 72 +- apps/web/researchMathematics.ts | 250 +- apps/web/researchMode.ts | 71 +- apps/web/researchOverview.ts | 52 +- apps/web/researchOverviewTypes.ts | 39 +- apps/web/researchPersonal.ts | 1012 ++- apps/web/researchPersonalTypes.ts | 134 +- apps/web/researchProblemEvidence.ts | 310 +- apps/web/researchProblemStatus.ts | 31 +- apps/web/researchProblemTypes.ts | 55 +- apps/web/researchProblems.ts | 229 +- apps/web/researchProjectStart.ts | 56 +- apps/web/researchProjectTypes.ts | 420 +- apps/web/researchProjects.ts | 4062 ++++++++--- apps/web/researchReleaseComparison.ts | 146 +- apps/web/researchWorkspace.ts | 658 +- apps/web/researchWorkspaceTypes.ts | 165 +- apps/web/runner.ts | 1192 ++- apps/web/sample.ts | 125 +- apps/web/server.ts | 2193 ++++-- apps/web/share.ts | 70 +- apps/web/shareReading.ts | 163 +- apps/web/shareReadingTypes.ts | 24 +- apps/web/shareTypes.ts | 35 +- apps/web/shared.ts | 791 +- apps/web/sharedProofTypes.ts | 19 +- apps/web/sharedProofs.ts | 61 +- apps/web/solutionRoute.css | 1415 +++- apps/web/solutionRoute.ts | 89 +- apps/web/solutionRouteView.ts | 1149 ++- apps/web/staticFiles.ts | 67 +- apps/web/staticReport.ts | 50 +- apps/web/storage.ts | 408 +- apps/web/trajectory.ts | 728 +- apps/web/verificationKit.ts | 131 +- apps/web/worker-command.ts | 14 +- apps/web/worker.ts | 661 +- apps/web/workerBridge.ts | 701 +- apps/web/workerDisconnect.ts | 9 +- bin/math.ts | 14 +- bun.lock | 219 +- docs/README.md | 6 +- docs/collaborative-research-implementation.md | 6 +- docs/feedback.css | 481 +- docs/history/README.md | 51 + .../evaluation-improvement-plan-2026-11-01.md | 2 +- .../{ => history}/frontend-function-review.md | 22 +- .../frontend-problem-workspace-20261110.md | 0 .../frontend-product-continuity-20261110.md | 0 .../frontend-product-flow-20261110.md | 0 ...ntend-product-state-continuity-20261111.md | 0 .../frontend-release-20261109.md | 0 .../frontend-research-closure-20261110.md | 0 .../frontend-research-completion-20261110.md | 0 .../frontend-research-continuity-20261110.md | 0 .../frontend-research-depth-20261110.md | 0 ...rontend-research-followthrough-20261110.md | 0 .../frontend-research-lifecycle-20261110.md | 0 ...nd-research-product-continuity-20261111.md | 0 .../frontend-round10-release-20261110.md | 0 .../{ => history}/frontend-round3-20261109.md | 0 .../{ => history}/frontend-round4-20261109.md | 0 .../{ => history}/frontend-round5-20261109.md | 0 .../{ => history}/frontend-round6-20261109.md | 0 .../frontend-round7-fixes-20261109.md | 0 .../frontend-round7-release-20261109.md | 0 ...langfuse-evaluation-insights-2026-11-01.md | 26 +- .../library-original-uses-20261109.md | 0 .../product-flow-release-20261110.md | 0 .../research-round4-fixes-20261109.md | 0 .../research-round5-fixes-20261109.md | 0 docs/landing.css | 3155 ++++++-- docs/legal.css | 193 +- docs/process.css | 5081 ++++++++++--- docs/replay.css | 561 +- docs/research-space.md | 4 +- docs/site.css | 2566 ++++++- docs/web-operations.md | 6 +- docs/web-release-status.md | 20 +- docs/web-workbench.md | 12 +- docs/web/app.ts | 1263 +++- docs/web/archiveDestination.ts | 14 +- docs/web/archiveSolutionRoute.ts | 619 +- docs/web/archiveSourceRoute.ts | 141 +- docs/web/campaignCatalog.ts | 119 +- docs/web/catalog.ts | 532 +- docs/web/feedback.ts | 154 +- docs/web/feedbackDraft.ts | 34 +- docs/web/generatedProofExplanation.ts | 92 +- docs/web/globalTrajectory.ts | 178 +- docs/web/humanDecision.ts | 10 +- docs/web/landing.ts | 375 +- docs/web/presentation.ts | 176 +- docs/web/process.ts | 647 +- docs/web/processRoadmap.ts | 769 +- docs/web/processText.ts | 21 +- docs/web/proofAcceptance.ts | 10 +- docs/web/proofConvexFigure.ts | 75 +- docs/web/proofCoverFigure.ts | 141 +- docs/web/proofFigures.ts | 82 +- docs/web/proofHadamardFigure.ts | 78 +- docs/web/proofReading.ts | 356 +- docs/web/proofReadingContext.ts | 88 +- docs/web/proofReadingLocation.ts | 64 +- docs/web/proofRoute.ts | 49 +- docs/web/proofSeparationFigure.ts | 54 +- docs/web/proofSnakyFigure.ts | 244 +- docs/web/proofSolution.ts | 53 +- docs/web/proofSourceMathematics.ts | 257 +- docs/web/proofTriangleFigure.ts | 73 +- docs/web/proofTruffetFigure.ts | 149 +- docs/web/proofWalkthrough.ts | 136 +- docs/web/proofWalkthroughAdditional.ts | 90 +- docs/web/proofWalkthroughAnalysis.ts | 1454 +++- docs/web/proofWalkthroughCatalog.ts | 98 +- docs/web/proofWalkthroughCore.ts | 2291 ++++-- docs/web/proofWalkthroughFoundations.ts | 2439 +++++-- docs/web/proofWalkthroughGeometry.ts | 1359 +++- docs/web/proofWalkthroughTypes.ts | 10 +- docs/web/replay.ts | 90 +- docs/web/roadmapLabels.ts | 75 +- docs/web/selectionIndicator.ts | 7 +- docs/web/site.ts | 11 +- docs/web/solutionRouteClient.ts | 81 +- docs/web/solutionRouteRuntime.ts | 75 +- docs/web/sourceLocation.ts | 87 +- docs/web/types.ts | 84 +- docs/web/virtual.d.ts | 5 +- docs/web/workflowNotes.ts | 2 +- package.json | 211 +- scripts/archive-replay-checks.mjs | 108 +- scripts/build-agent-tools.ts | 43 +- scripts/build-pantograph.ts | 82 +- scripts/build-proof-environment-seed.ts | 24 +- scripts/build-site.ts | 93 +- scripts/build-web-preview.ts | 27 +- scripts/build-web-sample.ts | 51 +- scripts/build-web.ts | 236 +- scripts/build-workbench-classics.ts | 94 +- scripts/build.ts | 38 +- scripts/campaign-explanations.ts | 117 +- scripts/capture-advanced-previews.ts | 458 +- scripts/capture-archive.mjs | 20 +- scripts/capture-natural-entry.ts | 135 +- scripts/capture-promo.mjs | 18 +- scripts/capture-site-assets.mjs | 27 +- scripts/capture-workbench.mjs | 126 +- scripts/e2e/test-archive-process.ts | 567 ++ scripts/e2e/test-archive-roadmap.ts | 492 ++ scripts/e2e/test-classic-global-trajectory.ts | 2279 ++++++ scripts/{ => e2e}/test-feedback.mjs | 207 +- scripts/e2e/test-frontend-audit-layout.ts | 394 + scripts/{ => e2e}/test-i18n.mjs | 412 +- scripts/e2e/test-landing-motion.mjs | 242 + scripts/{ => e2e}/test-landing.mjs | 380 +- scripts/e2e/test-math-rendering.ts | 807 +++ scripts/e2e/test-proof-reading-navigation.mjs | 294 + scripts/e2e/test-site-feedback-drafts.mjs | 228 + scripts/{ => e2e}/test-site-product-flow.mjs | 79 +- scripts/e2e/test-site-research-entry.mjs | 108 + scripts/{ => e2e}/test-site.mjs | 215 +- scripts/e2e/test-universal-solution-route.ts | 1216 ++++ scripts/{ => e2e}/test-web-a11y.ts | 290 +- scripts/e2e/test-web-activity.ts | 804 +++ scripts/{ => e2e}/test-web-admin.ts | 179 +- scripts/{ => e2e}/test-web-agent-route.ts | 483 +- scripts/e2e/test-web-audit-library.ts | 360 + scripts/e2e/test-web-audit-workbench.ts | 256 + .../e2e/test-web-automatic-explanations.ts | 348 + .../e2e/test-web-brief-export-continuity.ts | 330 + scripts/e2e/test-web-budget-live-refresh.ts | 365 + .../e2e/test-web-budget-post-continuity.ts | 293 + .../e2e/test-web-budget-save-continuity.ts | 362 + scripts/e2e/test-web-candidate-continuity.ts | 507 ++ scripts/e2e/test-web-cantor-bernstein-demo.ts | 624 ++ scripts/e2e/test-web-capacity.ts | 557 ++ scripts/{ => e2e}/test-web-chat-artifacts.ts | 386 +- .../test-web-chat-cancel-recovery.ts | 109 +- scripts/e2e/test-web-chat-mathematics.ts | 2011 ++++++ scripts/e2e/test-web-chat-recovery.ts | 448 ++ scripts/e2e/test-web-chat-session.ts | 1861 +++++ scripts/e2e/test-web-classic-preparation.ts | 251 + scripts/{ => e2e}/test-web-classics.ts | 454 +- scripts/e2e/test-web-collaboration-actions.ts | 665 ++ .../e2e/test-web-collaboration-continuity.ts | 730 ++ ...est-web-collaboration-entry-permissions.ts | 213 + scripts/e2e/test-web-collaboration-layers.ts | 556 ++ .../e2e/test-web-collaboration-post-state.ts | 859 +++ scripts/e2e/test-web-collaboration.ts | 829 +++ scripts/e2e/test-web-collections-lifecycle.ts | 376 + scripts/{ => e2e}/test-web-community.ts | 211 +- scripts/e2e/test-web-continuation-archive.ts | 320 + scripts/e2e/test-web-discovery-invites.ts | 453 ++ scripts/e2e/test-web-discussion-guidance.ts | 811 +++ scripts/e2e/test-web-draft-recovery.ts | 951 +++ scripts/e2e/test-web-drafts.ts | 710 ++ scripts/e2e/test-web-editor-navigation.ts | 843 +++ scripts/e2e/test-web-editor-post-state.ts | 439 ++ scripts/e2e/test-web-editor-replace.ts | 852 +++ scripts/e2e/test-web-editor-review.ts | 1342 ++++ scripts/e2e/test-web-entry-post-lifecycle.ts | 508 ++ scripts/e2e/test-web-explain-recovery.ts | 369 + scripts/{ => e2e}/test-web-explain.ts | 1216 +++- scripts/{ => e2e}/test-web-failures.ts | 149 +- .../e2e/test-web-first-budget-corrections.ts | 239 + .../test-web-first-research-sharing.ts | 393 +- .../test-web-formalization-completion.ts | 152 +- .../e2e/test-web-formalization-progress.ts | 1097 +++ scripts/{ => e2e}/test-web-formalize.ts | 475 +- scripts/e2e/test-web-guidance-recovery.ts | 799 +++ scripts/{ => e2e}/test-web-guide.ts | 125 +- scripts/e2e/test-web-history.ts | 931 +++ scripts/e2e/test-web-human-decisions.ts | 911 +++ scripts/{ => e2e}/test-web-i18n.ts | 207 +- scripts/e2e/test-web-inline-annotations.ts | 536 ++ scripts/e2e/test-web-installed-library.ts | 1733 +++++ scripts/e2e/test-web-interaction-flow.ts | 766 ++ .../e2e/test-web-issue-action-continuity.ts | 664 ++ .../test-web-journey-project-navigation.ts | 474 ++ scripts/e2e/test-web-key-memory.ts | 332 + scripts/e2e/test-web-knowledge-context.ts | 553 ++ scripts/e2e/test-web-library-followthrough.ts | 502 ++ scripts/e2e/test-web-library-navigation.ts | 249 + .../test-web-library-personal-continuity.ts | 464 ++ .../e2e/test-web-library-post-continuity.ts | 620 ++ scripts/e2e/test-web-library-post-state.ts | 549 ++ scripts/e2e/test-web-library-product-gaps.ts | 382 + .../test-web-library-proposal-continuity.ts | 629 ++ scripts/e2e/test-web-library-reference.ts | 857 +++ scripts/e2e/test-web-live-source-actions.ts | 562 ++ scripts/e2e/test-web-live-sync.ts | 913 +++ scripts/{ => e2e}/test-web-load.ts | 176 +- scripts/{ => e2e}/test-web-login.ts | 282 +- scripts/{ => e2e}/test-web-long-run.ts | 125 +- scripts/e2e/test-web-mathematical-changes.ts | 775 ++ .../e2e/test-web-message-stage-continuity.ts | 393 + scripts/e2e/test-web-module-plan.ts | 2032 ++++++ scripts/e2e/test-web-modules.ts | 1108 +++ scripts/e2e/test-web-motion.ts | 741 ++ scripts/{ => e2e}/test-web-native-team.ts | 338 +- scripts/{ => e2e}/test-web-natural-first.ts | 332 +- .../test-web-onboarding-post-continuity.ts | 356 + scripts/{ => e2e}/test-web-onboarding.ts | 235 +- scripts/e2e/test-web-openai-problems.ts | 1698 +++++ .../e2e/test-web-overview-post-continuity.ts | 578 ++ scripts/{ => e2e}/test-web-paper.ts | 175 +- scripts/{ => e2e}/test-web-performance.ts | 494 +- .../test-web-personal-approval-continuity.ts | 462 ++ scripts/{ => e2e}/test-web-plan-approval.ts | 543 +- scripts/e2e/test-web-plan-structure.ts | 810 +++ scripts/e2e/test-web-practice.ts | 213 + scripts/{ => e2e}/test-web-precheck.ts | 171 +- scripts/e2e/test-web-preparation.ts | 1156 +++ scripts/e2e/test-web-preview.ts | 147 + scripts/e2e/test-web-problem-demo.ts | 553 ++ scripts/e2e/test-web-problem-drafts.ts | 454 ++ scripts/e2e/test-web-problem-lifecycle.ts | 454 ++ scripts/{ => e2e}/test-web-product-flow.ts | 649 +- scripts/e2e/test-web-project-attempt-reuse.ts | 305 + scripts/e2e/test-web-project-drafts.ts | 647 ++ scripts/e2e/test-web-project-participation.ts | 509 ++ scripts/{ => e2e}/test-web-proof-map.ts | 473 +- scripts/e2e/test-web-proof-thinking.ts | 3530 +++++++++ scripts/{ => e2e}/test-web-rate-limit.ts | 238 +- scripts/e2e/test-web-readable-results.ts | 911 +++ scripts/e2e/test-web-recovery-context.ts | 382 + .../e2e/test-web-recovery-library-context.ts | 512 ++ scripts/{ => e2e}/test-web-recovery.ts | 379 +- scripts/{ => e2e}/test-web-report.ts | 694 +- scripts/e2e/test-web-research-collections.ts | 372 + scripts/e2e/test-web-research-completion.ts | 276 + ...st-web-research-decisions-followthrough.ts | 495 ++ .../test-web-research-decisions-lifecycle.ts | 556 ++ scripts/e2e/test-web-research-depth.ts | 303 + .../e2e/test-web-research-draft-lifecycle.ts | 436 ++ scripts/e2e/test-web-research-entry.ts | 327 + scripts/e2e/test-web-research-information.ts | 1127 +++ scripts/e2e/test-web-research-journey.ts | 359 + scripts/e2e/test-web-research-lean.ts | 158 + .../e2e/test-web-research-library-trials.ts | 811 +++ .../e2e/test-web-research-login-navigation.ts | 602 ++ .../e2e/test-web-research-notifications.ts | 263 + scripts/e2e/test-web-research-personal.ts | 429 ++ scripts/e2e/test-web-research-problem.ts | 584 ++ scripts/e2e/test-web-research-progress.ts | 907 +++ .../e2e/test-web-research-run-continuity.ts | 393 + scripts/e2e/test-web-research-space.ts | 960 +++ .../e2e/test-web-research-start-planning.ts | 242 + scripts/e2e/test-web-research-workspace.ts | 553 ++ scripts/e2e/test-web-results.ts | 911 +++ .../e2e/test-web-review-product-continuity.ts | 675 ++ .../{ => e2e}/test-web-review-regressions.ts | 374 +- scripts/e2e/test-web-reviews.ts | 933 +++ scripts/{ => e2e}/test-web-roadmap.ts | 468 +- scripts/e2e/test-web-round10-math.ts | 318 + scripts/e2e/test-web-round10-routes.ts | 309 + scripts/e2e/test-web-round10-workbench.ts | 654 ++ scripts/e2e/test-web-round2-collaboration.ts | 573 ++ scripts/{ => e2e}/test-web-round2-login.ts | 179 +- scripts/e2e/test-web-round2-routes.ts | 392 + scripts/e2e/test-web-round2-workbench.ts | 371 + scripts/e2e/test-web-round3-approval.ts | 690 ++ scripts/e2e/test-web-round3-collaboration.ts | 607 ++ scripts/e2e/test-web-round3-library.ts | 239 + scripts/e2e/test-web-round3-routes.ts | 326 + scripts/e2e/test-web-round3-workbench.ts | 272 + scripts/e2e/test-web-round4-library.ts | 426 ++ scripts/e2e/test-web-round4-sharing.ts | 445 ++ scripts/e2e/test-web-round5-collaboration.ts | 477 ++ scripts/e2e/test-web-round5-library.ts | 458 ++ scripts/e2e/test-web-round5-people.ts | 465 ++ scripts/e2e/test-web-round5-workbench.ts | 373 + scripts/e2e/test-web-round6-collaboration.ts | 673 ++ scripts/e2e/test-web-round6-library.ts | 390 + scripts/e2e/test-web-round6-people.ts | 435 ++ scripts/e2e/test-web-round6-routes.ts | 184 + scripts/e2e/test-web-round7-library.ts | 357 + scripts/e2e/test-web-round7-people.ts | 472 ++ scripts/e2e/test-web-round7-routes.ts | 293 + scripts/e2e/test-web-round7-session.ts | 374 + scripts/e2e/test-web-round8-approval.ts | 545 ++ scripts/{ => e2e}/test-web-round8-budget.ts | 195 +- scripts/e2e/test-web-round8-keys.ts | 324 + scripts/e2e/test-web-round8-routes.ts | 318 + scripts/e2e/test-web-round9-availability.ts | 227 + scripts/e2e/test-web-round9-mobile.ts | 433 ++ scripts/e2e/test-web-round9-routes.ts | 330 + scripts/e2e/test-web-run-monitor.ts | 858 +++ scripts/e2e/test-web-runtime.ts | 607 ++ scripts/{ => e2e}/test-web-saved-key.ts | 285 +- scripts/e2e/test-web-schur-demo.ts | 519 ++ scripts/e2e/test-web-server-plans.ts | 319 + scripts/e2e/test-web-share-bookmark-notes.ts | 298 + scripts/e2e/test-web-share-continuity.ts | 356 + scripts/{ => e2e}/test-web-share.ts | 169 +- scripts/e2e/test-web-simple-workbench.ts | 679 ++ scripts/e2e/test-web-skill-research.ts | 284 + scripts/{ => e2e}/test-web-solve-process.ts | 376 +- scripts/e2e/test-web-source-diff.ts | 599 ++ scripts/e2e/test-web-source-handoff.ts | 923 +++ scripts/e2e/test-web-source-reader.ts | 953 +++ scripts/e2e/test-web-task-browser.ts | 879 +++ scripts/e2e/test-web-task-source.ts | 519 ++ scripts/e2e/test-web-team-continuity.ts | 547 ++ scripts/{ => e2e}/test-web-theme.ts | 263 +- scripts/{ => e2e}/test-web-trajectory.ts | 779 +- scripts/{ => e2e}/test-web-ui.ts | 490 +- scripts/e2e/test-web-workbench-ux.ts | 989 +++ .../test-web-workspace-post-lifecycle.ts | 219 +- scripts/e2e/web-a11y.ts | 145 + scripts/e2e/web-agent-action-fixture.ts | 369 + scripts/{ => e2e}/web-contrast.ts | 51 +- scripts/{ => e2e}/web-cooperative-fixture.ts | 18 +- scripts/{ => e2e}/web-i18n-fixture.ts | 35 +- scripts/{ => e2e}/web-print.ts | 53 +- scripts/e2e/web-scenario.ts | 275 + scripts/e2e/web-trajectory-fixture.ts | 148 + scripts/e2e/web-ui-controls.ts | 444 ++ scripts/enrich-archive-process.ts | 200 +- scripts/export-site-repo.ts | 57 +- scripts/fixtures/cantorBernsteinDemo.ts | 366 +- scripts/fixtures/schurDemo.ts | 194 +- scripts/generate-web-library-search.ts | 37 +- scripts/import-math-campaign.ts | 552 +- scripts/math-tools/make-profile.ts | 31 +- scripts/mathematics/agentTools.ts | 16 +- scripts/mathematics/arguments.ts | 21 +- scripts/mathematics/autoLibrary.ts | 340 +- scripts/mathematics/autoLibraryHostReplay.ts | 247 +- scripts/mathematics/autoLibraryReplay.ts | 395 +- scripts/mathematics/benchmarkTheoremSearch.ts | 695 +- scripts/mathematics/bootstrapImo2026.ts | 10 +- .../mathematics/bootstrapLeanEvalHeldOut.ts | 35 +- scripts/mathematics/checkFinite.ts | 29 +- scripts/mathematics/checkLean.ts | 212 +- scripts/mathematics/checkRunStates.ts | 18 +- scripts/mathematics/checkWestlakeProtocol.ts | 520 +- scripts/mathematics/checkpoint.ts | 19 +- scripts/mathematics/compareMathRuns.ts | 1215 +++- scripts/mathematics/component.ts | 47 +- scripts/mathematics/doctor.ts | 32 +- scripts/mathematics/editMathRun.ts | 28 +- scripts/mathematics/evaluateFormalization.ts | 265 +- scripts/mathematics/experimentKnowledge.ts | 75 +- scripts/mathematics/firstProof.ts | 621 +- scripts/mathematics/formalize.ts | 469 +- .../mathematics/freezeMathRetrievalCorpus.ts | 12 +- scripts/mathematics/huggingMath.ts | 88 +- scripts/mathematics/informalize.ts | 362 +- scripts/mathematics/inspectMathRun.ts | 19 +- scripts/mathematics/kernelCertificate.ts | 77 +- scripts/mathematics/library.ts | 30 +- scripts/mathematics/libraryCatalog.ts | 80 +- scripts/mathematics/libraryPack.ts | 76 +- scripts/mathematics/listLeanEval.ts | 63 +- scripts/mathematics/moduleExperiment.ts | 163 +- scripts/mathematics/nativeSkillComparison.ts | 284 +- scripts/mathematics/packMathlibAdditive.ts | 6 +- scripts/mathematics/planCommand.ts | 34 +- scripts/mathematics/prepareCampaignLibrary.ts | 43 +- .../mathematics/prepareLibraryKnowledge.ts | 20 +- .../prepareNativeSkillComparison.ts | 138 +- scripts/mathematics/readContinuation.ts | 62 +- scripts/mathematics/readDeclarations.ts | 27 +- scripts/mathematics/recoverMathSnapshot.ts | 60 +- .../reportNativeSkillComparison.ts | 154 +- scripts/mathematics/runExample.ts | 197 +- scripts/mathematics/runGoalsFirst.ts | 9 +- scripts/mathematics/runMathBatch.ts | 213 +- scripts/mathematics/runMathProof.ts | 17 +- scripts/mathematics/runNativeSkillBaseline.ts | 416 +- scripts/mathematics/samplePutnamRuns.ts | 370 +- scripts/mathematics/searchLean.ts | 50 +- scripts/mathematics/seedContinuation.ts | 34 +- scripts/mathematics/summarizeMathProofRuns.ts | 35 +- scripts/mathematics/theoremKnowledge.ts | 232 +- scripts/mathematics/validateSkillProvider.ts | 307 +- .../mathematics/verifyFirstProofOffline.ts | 172 +- scripts/mathematics/workflowHarness.ts | 19 +- scripts/prepare-web-library.ts | 70 +- scripts/prepare-web-mathlib.ts | 24 +- scripts/run-web-cantor-bernstein-real.ts | 614 +- scripts/site-archive.ts | 146 +- scripts/smoke-web-first-use.ts | 552 +- scripts/smoke-web-precheck.ts | 58 +- scripts/test-archive-process.ts | 312 - scripts/test-archive-roadmap.ts | 278 - scripts/test-classic-global-trajectory.ts | 1198 ---- scripts/test-codex-backend-delivery.ts | 752 +- scripts/test-codex-backend.ts | 782 +- scripts/test-formalization.ts | 70 +- scripts/test-frontend-audit-layout.ts | 229 - scripts/test-landing-motion.mjs | 192 - scripts/test-math-rendering.ts | 472 -- scripts/test-proof-reading-navigation.mjs | 186 - scripts/test-site-feedback-drafts.mjs | 67 - scripts/test-site-research-entry.mjs | 64 - scripts/test-universal-solution-route.ts | 592 -- scripts/test-web-activity.ts | 415 -- scripts/test-web-audit-library.ts | 191 - scripts/test-web-audit-workbench.ts | 164 - scripts/test-web-automatic-explanations.ts | 203 - scripts/test-web-background-review.ts | 210 - scripts/test-web-brief-export-continuity.ts | 163 - scripts/test-web-budget-attempt-continuity.ts | 180 - scripts/test-web-budget-live-refresh.ts | 158 - scripts/test-web-budget-post-continuity.ts | 154 - scripts/test-web-budget-save-continuity.ts | 153 - scripts/test-web-candidate-continuity.ts | 190 - scripts/test-web-candidate-history.ts | 226 - scripts/test-web-cantor-bernstein-demo.ts | 286 - scripts/test-web-capacity.ts | 235 - scripts/test-web-chat-mathematics.ts | 962 --- scripts/test-web-chat-recovery.ts | 250 - scripts/test-web-chat-session.ts | 1047 --- scripts/test-web-classic-preparation.ts | 131 - scripts/test-web-collaboration-actions.ts | 226 - scripts/test-web-collaboration-continuity.ts | 241 - ...est-web-collaboration-entry-permissions.ts | 80 - scripts/test-web-collaboration-layers.ts | 233 - scripts/test-web-collaboration-post-state.ts | 232 - scripts/test-web-collaboration.ts | 144 - scripts/test-web-collections-lifecycle.ts | 131 - scripts/test-web-continuation-archive.ts | 200 - scripts/test-web-discovery-invites.ts | 192 - scripts/test-web-discussion-guidance.ts | 353 - scripts/test-web-draft-recovery.ts | 518 -- scripts/test-web-drafts.ts | 452 -- scripts/test-web-editor-navigation.ts | 449 -- scripts/test-web-editor-post-state.ts | 200 - scripts/test-web-editor-replace.ts | 418 -- scripts/test-web-editor-review.ts | 602 -- scripts/test-web-entry-post-lifecycle.ts | 203 - scripts/test-web-explain-recovery.ts | 218 - scripts/test-web-first-budget-corrections.ts | 114 - scripts/test-web-formalization-progress.ts | 561 -- scripts/test-web-guidance-recovery.ts | 358 - scripts/test-web-history.ts | 476 -- scripts/test-web-human-decisions.ts | 475 -- scripts/test-web-inline-annotations.ts | 184 - scripts/test-web-installed-library.ts | 796 --- scripts/test-web-interaction-flow.ts | 318 - scripts/test-web-issue-action-continuity.ts | 219 - .../test-web-journey-project-navigation.ts | 160 - scripts/test-web-key-memory.ts | 209 - scripts/test-web-knowledge-context.ts | 225 - scripts/test-web-library-followthrough.ts | 196 - scripts/test-web-library-navigation.ts | 134 - .../test-web-library-personal-continuity.ts | 157 - scripts/test-web-library-post-continuity.ts | 253 - scripts/test-web-library-post-state.ts | 241 - scripts/test-web-library-product-gaps.ts | 165 - .../test-web-library-proposal-continuity.ts | 204 - scripts/test-web-library-reference.ts | 402 -- scripts/test-web-live-source-actions.ts | 299 - scripts/test-web-live-sync.ts | 473 -- scripts/test-web-mathematical-changes.ts | 347 - scripts/test-web-message-stage-continuity.ts | 150 - scripts/test-web-module-plan.ts | 1133 --- scripts/test-web-modules.ts | 560 -- scripts/test-web-motion.ts | 435 -- .../test-web-onboarding-post-continuity.ts | 114 - scripts/test-web-openai-problems.ts | 757 -- scripts/test-web-overview-post-continuity.ts | 192 - .../test-web-personal-approval-continuity.ts | 217 - scripts/test-web-plan-structure.ts | 307 - scripts/test-web-practice.ts | 126 - scripts/test-web-preparation.ts | 782 -- scripts/test-web-preview.ts | 89 - scripts/test-web-problem-demo.ts | 237 - scripts/test-web-problem-drafts.ts | 243 - scripts/test-web-problem-lifecycle.ts | 115 - scripts/test-web-project-attempt-reuse.ts | 138 - scripts/test-web-project-drafts.ts | 262 - scripts/test-web-project-participation.ts | 241 - scripts/test-web-proof-thinking.ts | 1666 ----- scripts/test-web-readable-results.ts | 363 - scripts/test-web-recovery-context.ts | 172 - scripts/test-web-recovery-library-context.ts | 167 - scripts/test-web-research-collections.ts | 195 - scripts/test-web-research-completion.ts | 110 - ...st-web-research-decisions-followthrough.ts | 199 - .../test-web-research-decisions-lifecycle.ts | 203 - scripts/test-web-research-depth.ts | 133 - scripts/test-web-research-draft-lifecycle.ts | 162 - scripts/test-web-research-entry.ts | 186 - scripts/test-web-research-information.ts | 483 -- scripts/test-web-research-journey.ts | 157 - scripts/test-web-research-lean.ts | 78 - scripts/test-web-research-library-trials.ts | 328 - scripts/test-web-research-login-navigation.ts | 316 - scripts/test-web-research-notifications.ts | 124 - scripts/test-web-research-personal.ts | 192 - scripts/test-web-research-problem.ts | 246 - scripts/test-web-research-progress.ts | 348 - scripts/test-web-research-run-continuity.ts | 175 - scripts/test-web-research-space.ts | 367 - scripts/test-web-research-start-planning.ts | 132 - scripts/test-web-research-workspace.ts | 239 - scripts/test-web-results.ts | 594 -- scripts/test-web-review-product-continuity.ts | 169 - scripts/test-web-reviews.ts | 385 - scripts/test-web-round10-math.ts | 139 - scripts/test-web-round10-routes.ts | 168 - scripts/test-web-round10-workbench.ts | 275 - scripts/test-web-round2-collaboration.ts | 211 - scripts/test-web-round2-routes.ts | 217 - scripts/test-web-round2-workbench.ts | 226 - scripts/test-web-round3-approval.ts | 255 - scripts/test-web-round3-collaboration.ts | 209 - scripts/test-web-round3-library.ts | 122 - scripts/test-web-round3-routes.ts | 152 - scripts/test-web-round3-workbench.ts | 162 - scripts/test-web-round4-library.ts | 214 - scripts/test-web-round4-sharing.ts | 180 - scripts/test-web-round5-collaboration.ts | 211 - scripts/test-web-round5-library.ts | 222 - scripts/test-web-round5-people.ts | 259 - scripts/test-web-round5-workbench.ts | 143 - scripts/test-web-round6-collaboration.ts | 297 - scripts/test-web-round6-library.ts | 217 - scripts/test-web-round6-people.ts | 237 - scripts/test-web-round6-routes.ts | 91 - scripts/test-web-round7-library.ts | 162 - scripts/test-web-round7-people.ts | 229 - scripts/test-web-round7-routes.ts | 171 - scripts/test-web-round7-session.ts | 183 - scripts/test-web-round8-approval.ts | 191 - scripts/test-web-round8-keys.ts | 169 - scripts/test-web-round8-routes.ts | 152 - scripts/test-web-round9-availability.ts | 121 - scripts/test-web-round9-mobile.ts | 213 - scripts/test-web-round9-routes.ts | 153 - scripts/test-web-run-monitor.ts | 400 -- scripts/test-web-runtime.ts | 322 - scripts/test-web-schur-demo.ts | 234 - scripts/test-web-server-plans.ts | 183 - scripts/test-web-share-bookmark-notes.ts | 141 - scripts/test-web-share-continuity.ts | 174 - scripts/test-web-simple-workbench.ts | 355 - scripts/test-web-skill-research.ts | 137 - scripts/test-web-source-diff.ts | 360 - scripts/test-web-source-handoff.ts | 451 -- scripts/test-web-source-reader.ts | 522 -- scripts/test-web-task-browser.ts | 346 - scripts/test-web-task-source.ts | 171 - scripts/test-web-team-continuity.ts | 199 - scripts/test-web-workbench-ux.ts | 418 -- scripts/web-a11y.ts | 100 - scripts/web-agent-action-fixture.ts | 125 - scripts/web-funnel.ts | 63 +- scripts/web-i18n.ts | 336 +- scripts/web-operations-monitor.ts | 323 +- scripts/web-operations-scheduled.ts | 236 +- scripts/web-operations.ts | 429 +- scripts/web-sample-actions.ts | 98 +- scripts/web-scenario.ts | 182 +- scripts/web-trajectory-fixture.ts | 69 - scripts/web-ui-controls.ts | 348 +- src/math/agentHarnessIdentity.ts | 14 +- src/math/autoLibrary.ts | 647 +- src/math/autoLibraryHost.ts | 19 +- src/math/autoLibraryPlanner.ts | 236 +- src/math/certificateSlots.ts | 12 +- src/math/concurrency.ts | 27 +- src/math/contracts.ts | 36 +- src/math/doctor.ts | 386 +- src/math/finiteBooleanCheck.ts | 124 +- src/math/firstProof.ts | 356 +- src/math/formalization.ts | 1350 +++- src/math/formalizationAdjudication.ts | 81 +- src/math/formalizationAudit.ts | 114 +- src/math/formalizationAuditProtocol.ts | 86 +- src/math/formalizationClaimShape.ts | 46 +- src/math/formalizationEvaluation.ts | 631 +- src/math/formalizationExemplars.ts | 98 +- src/math/formalizationFidelity.ts | 113 +- src/math/formalizationFiniteFamilyProgram.ts | 3 +- src/math/formalizationLibrary.ts | 76 +- src/math/formalizationNameCompatibility.ts | 115 +- src/math/formalizationPlan.ts | 205 +- src/math/formalizationReference.ts | 878 ++- src/math/formalizationReferenceProgram.ts | 1014 +-- src/math/formalizationReferenceV2.ts | 398 +- src/math/formalizationReferenceV3.ts | 468 +- src/math/formalizationReferenceV3Program.ts | 401 +- src/math/formalizationReferenceV4.ts | 491 +- src/math/formalizationReferenceV4Program.ts | 572 +- src/math/formalizationRefutation.ts | 210 +- src/math/formalizationRetrieval.ts | 468 +- src/math/formalizationReview.ts | 118 +- src/math/formalizationReviewV2.ts | 188 +- src/math/formalizationRoleContract.ts | 116 +- src/math/formalizationSemanticReview.ts | 423 +- src/math/formalizationSource.ts | 124 +- src/math/formalizationWorkflow.ts | 132 +- src/math/frozenLibraryQuery.ts | 81 +- src/math/frozenLibrarySearchTypes.ts | 5 +- src/math/huggingMathBundle.ts | 816 ++- src/math/huggingMathClient.ts | 213 +- src/math/huggingMathImports.ts | 132 +- src/math/imo2026Adapter.ts | 47 +- src/math/informalization.ts | 1508 +++- src/math/informalizationAlignment.ts | 202 +- src/math/informalizationExtraction.ts | 520 +- src/math/installedPackageSearch.ts | 66 +- src/math/kernelCertificate.ts | 392 +- src/math/leanCompilationCache.ts | 240 +- src/math/leanDiagnosticMessages.ts | 115 +- src/math/leanDiagnostics.ts | 586 +- src/math/leanEnvironmentHealth.ts | 104 +- src/math/leanEvalAdapter.ts | 84 +- src/math/leanEvalBenchmark.ts | 54 +- src/math/leanEvalBootstrap.ts | 617 +- src/math/leanEvalCatalogAdapter.ts | 74 +- src/math/leanEvalHeldOutEvaluation.ts | 4 +- src/math/leanEvalSubmission.ts | 45 +- src/math/leanGoalPremises.ts | 85 +- src/math/leanGoalSpecialization.ts | 16 +- src/math/leanKnowledgeEnrichment.ts | 570 +- src/math/leanLibrarySymbols.ts | 290 +- src/math/leanLibrarySymbolsProgram.ts | 252 +- src/math/leanModuleBuild.ts | 215 +- src/math/leanProbeSnapshot.ts | 20 +- src/math/leanProofSearch.ts | 681 +- src/math/leanReferences.ts | 215 +- src/math/leanResidualGoals.ts | 217 +- src/math/leanSearchProjection.ts | 184 +- src/math/leanSource.ts | 232 +- src/math/leanStatementContext.ts | 512 +- src/math/leanStatementSemantic.ts | 333 +- src/math/leanSyntax.ts | 104 +- src/math/leanTask.ts | 428 +- src/math/leanTaskEnvironment.ts | 391 +- src/math/leanToolchainReadiness.ts | 29 +- src/math/leanTypeDiagnostics.ts | 244 +- src/math/leanTypes.ts | 16 +- src/math/libraryEffectivePack.ts | 125 +- src/math/libraryHostConfig.ts | 350 +- src/math/libraryLegacyBinding.ts | 228 +- src/math/libraryPacks.ts | 435 +- src/math/libraryRelease.ts | 491 +- src/math/localExample.ts | 115 +- src/math/mathBuildManifest.ts | 89 +- src/math/mathConstructionSources.ts | 69 +- src/math/mathGit.ts | 38 +- src/math/mathModelSlot.ts | 59 +- src/math/mathProcess.ts | 143 +- src/math/mathProofEnvironment.ts | 300 +- src/math/mathProofEnvironmentCache.ts | 11 +- src/math/mathProofEnvironmentSeed.ts | 219 +- src/math/mathProofRunReport.ts | 76 +- src/math/mathProofSourcePolicy.ts | 4 +- src/math/mathRetrievalCorpus.ts | 783 +- src/math/mathRuntimeEnvironment.ts | 42 +- src/math/mathRuntimeIo.ts | 105 +- src/math/mathSearchConcepts.ts | 85 +- src/math/mathTimers.ts | 21 +- src/math/mathTools.ts | 151 +- src/math/mathlibAdditiveIndex.ts | 16 +- src/math/mathlibTheoremAliases.ts | 89 +- src/math/pantographSession.ts | 212 +- src/math/paperDraft.ts | 14 +- src/math/paths.ts | 10 +- src/math/proofSearchCheckpointPath.ts | 8 +- src/math/putnamBench.ts | 255 +- src/math/receiptAttestation.ts | 10 +- src/math/receiptKey.ts | 6 +- src/math/resources.d.ts | 10 +- src/math/theoryModules.ts | 14 +- src/math/upstreamPackageSearch.ts | 8 +- src/math/verifier.ts | 1546 ++-- src/math/verifierCheckout.ts | 28 +- src/runtime/codexSession.ts | 5 +- src/solver/agentTeam.ts | 2084 ++++-- src/solver/agentTeamBudget.ts | 40 +- src/solver/agentTeamContext.ts | 95 +- src/solver/agentTeamContributions.ts | 225 +- src/solver/agentTeamEvidenceRef.ts | 15 +- src/solver/agentTeamForwarding.ts | 48 +- src/solver/agentTeamNative.ts | 385 +- src/solver/agentTeamOperations.ts | 4 +- src/solver/agentTeamProfiles.ts | 288 +- src/solver/agentTeamProof.ts | 751 +- src/solver/agentTeamResearch.ts | 182 +- src/solver/agentTeamState.ts | 573 +- src/solver/agentTeamTool.ts | 141 +- src/solver/agentTeamViews.ts | 537 +- src/solver/agentTeamWorkspace.ts | 68 +- src/solver/archive.ts | 1325 +++- src/solver/autoLibrary.ts | 1373 +++- src/solver/autoLibraryApplication.ts | 126 +- src/solver/autoLibraryDemand.ts | 129 +- src/solver/automaticExplanations.ts | 147 +- src/solver/campaignLibrary.ts | 453 +- src/solver/capacityExploration.ts | 272 +- src/solver/componentTemplate.ts | 49 +- src/solver/conditionalProjection.ts | 43 +- src/solver/contextCheckpoint.ts | 62 +- src/solver/contextCompiler.ts | 1512 +++- src/solver/continuationHistory.ts | 97 +- src/solver/continuationInput.ts | 255 +- src/solver/continuationSearch.ts | 294 +- src/solver/continuationSeed.ts | 161 +- src/solver/contributionFlow.ts | 627 +- src/solver/cooperationShared.ts | 379 +- src/solver/cooperativeProof.ts | 1933 +++-- src/solver/declarationArtifacts.ts | 547 +- src/solver/declarationIndex.ts | 69 +- src/solver/declarationSearch.ts | 116 +- src/solver/definitionContractChecks.ts | 209 +- src/solver/deliveries.ts | 225 +- src/solver/deliveryArtifacts.ts | 147 +- src/solver/deliveryReceipts.ts | 102 +- src/solver/environment.ts | 14 +- src/solver/evaluation.ts | 116 +- src/solver/feedback.ts | 136 +- src/solver/formalization.ts | 3133 +++++--- src/solver/formalizationAudit.ts | 486 +- src/solver/formalizationContext.ts | 110 +- src/solver/formalizationElaboration.ts | 215 +- src/solver/formalizationFidelity.ts | 45 +- src/solver/formalizationReference.ts | 202 +- src/solver/formalizationRefutation.ts | 95 +- src/solver/formalizationReview.ts | 632 +- src/solver/formalizationReviewIsolation.ts | 73 +- src/solver/formalizationReviewV2.ts | 1283 ++-- src/solver/goalPathDecisions.ts | 255 +- src/solver/goalPathReview.ts | 399 +- src/solver/goalProgress.ts | 609 +- src/solver/humanEdit.ts | 207 +- src/solver/humanGuidance.ts | 562 +- src/solver/incrementalHelpers.ts | 279 +- src/solver/informalization.ts | 1075 ++- src/solver/informalizationExtraction.ts | 118 +- src/solver/inspection.ts | 1554 +++- src/solver/installedLibraryContext.ts | 312 +- src/solver/knowledgeApplications.ts | 299 +- src/solver/knowledgeContext.ts | 529 +- src/solver/knowledgeFunnel.ts | 272 +- src/solver/knowledgeUsage.ts | 160 +- src/solver/knowledgeUsageContract.ts | 58 +- src/solver/leadInbox.ts | 163 +- src/solver/leadWakes.ts | 63 +- src/solver/libraryAccess.ts | 193 +- src/solver/libraryApplication.ts | 249 +- src/solver/libraryCatalog.ts | 526 +- src/solver/libraryKnowledgeApplications.ts | 172 +- src/solver/libraryKnowledgeCandidates.ts | 58 +- src/solver/mathematicalGapContract.ts | 55 +- src/solver/mathematicalGaps.ts | 301 +- src/solver/modules/context.ts | 1695 +++-- src/solver/modules/contracts.ts | 154 +- src/solver/modules/custom.ts | 36 +- src/solver/modules/evidence.ts | 337 +- src/solver/modules/execution.ts | 49 +- src/solver/modules/index.ts | 63 +- src/solver/modules/moduleIdentity.ts | 105 +- src/solver/modules/organization.ts | 290 +- src/solver/modules/policy.ts | 88 +- src/solver/modules/search.ts | 735 +- src/solver/nextCheckContract.ts | 95 +- src/solver/nextChecks.ts | 496 +- src/solver/obligationProgress.ts | 487 +- src/solver/paperDraft.ts | 29 +- src/solver/personalExpertSchema.ts | 19 +- src/solver/personalExperts.ts | 15 +- src/solver/planApproval.ts | 179 +- src/solver/planDiagnostics.ts | 8 +- src/solver/planPatch.ts | 192 +- src/solver/planTool.ts | 81 +- src/solver/planningEvidence.ts | 384 +- src/solver/portfolioExploration.ts | 101 +- src/solver/problem.ts | 511 +- src/solver/progress.ts | 352 +- src/solver/projectionDependencyHints.ts | 110 +- src/solver/projectionDependencyReview.ts | 103 +- src/solver/projectionNotation.ts | 133 +- src/solver/proofImportRecord.ts | 49 +- src/solver/proofReady.ts | 99 +- src/solver/proofReferences.ts | 137 +- src/solver/proofReuse.ts | 88 +- src/solver/proofRoutes.ts | 323 +- src/solver/proofSearchRecords.ts | 367 +- src/solver/proofSearchTool.ts | 147 +- src/solver/proofWriter.ts | 19 +- src/solver/recovery.ts | 467 +- src/solver/research.ts | 1082 ++- src/solver/researchAdmission.ts | 192 +- src/solver/researchCheckpoints.ts | 243 +- src/solver/researchDecisions.ts | 128 +- src/solver/researchEvidence.ts | 105 +- src/solver/researchGuidance.ts | 276 +- src/solver/researchPublication.ts | 29 +- src/solver/researchRecords.ts | 311 +- src/solver/researchReferences.ts | 83 +- src/solver/researchRetirement.ts | 28 +- src/solver/researchSkill.ts | 21 +- src/solver/researchSources.ts | 65 +- src/solver/researchToolGuide.ts | 210 +- src/solver/researchToolHelp.ts | 9 +- src/solver/researchUsage.ts | 183 +- src/solver/routeControl.ts | 386 +- src/solver/routePriority.ts | 190 +- src/solver/run.ts | 1107 ++- src/solver/singleContinuationSeed.ts | 842 ++- src/solver/singleSolverProofHandoff.ts | 75 +- src/solver/skillProofLifecycle.ts | 170 +- src/solver/skillResearchContext.ts | 256 +- src/solver/softSlice.ts | 35 +- src/solver/sourceContext.ts | 69 +- src/solver/stateInvariants.ts | 111 +- src/solver/statementReview.ts | 365 +- src/solver/storedRunInspection.ts | 342 +- src/solver/tacticBattery.ts | 291 +- src/solver/tacticBatteryFailureCache.ts | 226 +- src/solver/taskConnections.ts | 278 +- src/solver/taskConsumers.ts | 57 +- src/solver/taskFamilies.ts | 132 +- src/solver/taskLifecycle.ts | 23 +- src/solver/taskProjection.ts | 98 +- src/solver/taskProofCache.ts | 53 +- src/solver/taskProposals.ts | 51 +- src/solver/taskQuestions.ts | 69 +- src/solver/taskReferenceAttribution.ts | 27 +- src/solver/taskTypeContract.ts | 18 +- src/solver/taskTypePreflight.ts | 490 +- src/solver/tasks.ts | 756 +- src/solver/textPage.ts | 33 +- src/solver/theoremKnowledge.ts | 415 +- src/solver/theoremKnowledgeAccepted.ts | 247 +- .../theoremKnowledgeApplicationHints.ts | 39 +- src/solver/theoremKnowledgeAuthorization.ts | 121 +- src/solver/theoremKnowledgeConsumers.ts | 159 +- src/solver/theoremKnowledgeDependencies.ts | 132 +- src/solver/theoremKnowledgeEnrichment.ts | 732 +- src/solver/theoremKnowledgeFindings.ts | 476 +- src/solver/theoremKnowledgeGoal.ts | 315 +- src/solver/theoremKnowledgeLibrary.ts | 128 +- src/solver/theoremKnowledgeMetadata.ts | 155 +- src/solver/theoremKnowledgeRelations.ts | 82 +- src/solver/theoremKnowledgeRuns.ts | 686 +- src/solver/theoremKnowledgeSearch.ts | 986 ++- src/solver/theoremKnowledgeSource.ts | 90 +- src/solver/theoremKnowledgeStore.ts | 156 +- src/solver/usageBudget.ts | 282 +- src/solver/verificationCheckpoint.ts | 115 +- src/solver/verifierFailure.ts | 95 +- src/solver/workerProject.ts | 18 +- src/solver/workflowOutput.ts | 13 +- src/solver/workflowSession.ts | 76 +- tests/advisoryScheduling.test.ts | 172 +- tests/agentRoute.test.ts | 240 +- tests/agentSessionPlan.test.ts | 121 +- tests/agentTeamBudget.test.ts | 119 +- tests/agentTeamContext.test.ts | 131 +- tests/agentTeamContextContract.test.ts | 274 +- tests/agentTeamHandoffs.test.ts | 187 +- tests/agentTeamNativeControl.test.ts | 492 +- tests/agentTeamNativeLifecycle.test.ts | 1447 +++- tests/agentTeamNativeTools.test.ts | 2135 ++++-- tests/agentTeamProfiles.test.ts | 74 +- tests/agentTeamProof.test.ts | 1121 ++- tests/agentTeamResearch.test.ts | 173 +- tests/agentTeamRouteSummary.test.ts | 230 +- tests/agentTeamSolver.test.ts | 145 +- tests/agentTeamSourceRecovery.test.ts | 1543 ++-- tests/agentTeamTool.test.ts | 121 +- tests/agentTeamTools.test.ts | 292 +- tests/agentTeamTransportFallback.test.ts | 463 +- tests/agentTeamViews.test.ts | 244 +- tests/agentTeamWorkspace.test.ts | 64 +- tests/agentTools.test.ts | 141 +- tests/archiveAssetVersions.test.ts | 11 +- tests/archiveProcessEvidence.test.ts | 328 +- tests/archiveRecordNavigation.test.ts | 288 +- tests/archiveRoadmap.test.ts | 241 +- tests/archiveSolutionRoute.test.ts | 444 +- tests/archiveSourceLocation.test.ts | 124 +- tests/autoLibrary.test.ts | 642 +- tests/autoLibraryApplication.test.ts | 117 +- tests/autoLibraryCli.test.ts | 336 +- tests/autoLibraryDemand.test.ts | 143 +- tests/autoLibraryHost.test.ts | 436 +- tests/autoLibraryUsage.test.ts | 122 +- tests/blueprintFields.test.ts | 77 +- tests/campaignCatalog.test.ts | 61 +- tests/campaignExplanations.test.ts | 283 +- tests/campaignLibrary.test.ts | 274 +- tests/campaignLibraryNative.test.ts | 242 +- tests/campaignProcess.test.ts | 121 +- tests/campaignReference.test.ts | 6 +- tests/capacityExploration.test.ts | 449 +- tests/certificateSlots.test.ts | 301 +- tests/chatCompletionsBridge.test.ts | 947 ++- tests/chatSessionWorkspace.test.ts | 105 +- tests/claudeCodeSession.test.ts | 732 +- tests/cliConfiguration.test.ts | 147 +- tests/cliSession.test.ts | 585 +- tests/codexCompletedResponse.test.ts | 56 +- tests/codexConnectivity.test.ts | 31 +- tests/codexNativeNotifications.test.ts | 422 +- tests/codexNativeShellFeedback.test.ts | 400 +- tests/codexSession.test.ts | 1366 +++- tests/codexSessionAgentControl.test.ts | 500 +- tests/codexSessionCheckpoint.test.ts | 201 +- tests/codexSessionFileWatch.test.ts | 108 +- tests/codexSessionInstructions.test.ts | 306 +- tests/codexSessionLifecycle.test.ts | 312 +- tests/codexSessionNativeMailbox.test.ts | 402 +- tests/codexSessionNotifications.test.ts | 960 ++- tests/codexSkills.test.ts | 209 +- tests/codexStreamIdle.test.ts | 152 +- tests/commonResearchGuidance.test.ts | 262 +- tests/comparison.test.ts | 985 ++- tests/comparisonHarness.test.ts | 198 +- tests/comparisonLeanTask.test.ts | 303 +- tests/comparisonReportSnapshot.test.ts | 350 +- tests/comparisonSkillBaseline.test.ts | 335 +- tests/componentTemplate.test.ts | 65 +- tests/concurrency.test.ts | 27 +- tests/conditionalLibraryImports.test.ts | 141 +- tests/conditionalProjection.test.ts | 156 +- tests/conditionalProjectionElaborator.test.ts | 214 +- tests/connectionCheckpointScheduling.test.ts | 95 +- tests/consumerConnections.test.ts | 269 +- tests/contextBudgetConvergence.test.ts | 57 +- tests/contextCheckpoint.test.ts | 55 +- tests/contextCompiler.test.ts | 2300 ++++-- tests/contextDeclarationOrder.test.ts | 193 +- tests/contextDispatchBudget.test.ts | 516 +- tests/continuationContext.test.ts | 212 +- tests/continuationInput.test.ts | 328 +- tests/continuationSearch.test.ts | 431 +- tests/contributionFlow.test.ts | 795 +- tests/customSolverModules.test.ts | 371 +- tests/decisionSummaryModel.test.ts | 97 +- tests/declarationArtifacts.test.ts | 726 +- tests/declarationIndex.test.ts | 95 +- tests/declarationSearch.test.ts | 105 +- tests/deepseek.test.ts | 51 +- tests/definitionContractChecks.test.ts | 186 +- tests/definitionTasks.test.ts | 145 +- tests/deliveryArtifacts.test.ts | 168 +- tests/deliveryReceipts.test.ts | 67 +- tests/directFormalizationEvidence.test.ts | 159 +- tests/directFormalizationWorkflow.test.ts | 669 +- tests/doctor.test.ts | 158 +- tests/earlyRouteChecks.test.ts | 325 +- tests/evaluatorExecution.test.ts | 108 +- tests/evaluatorRun.test.ts | 119 +- tests/exactSourceIntegration.test.ts | 130 +- tests/executionDeadline.test.ts | 14 +- tests/finalCandidateReadiness.test.ts | 84 +- tests/finiteBooleanCheck.test.ts | 199 +- tests/firstProof.test.ts | 234 +- tests/firstProofAutomation.test.ts | 729 +- tests/firstProofCli.test.ts | 388 +- tests/firstResearchBudgetValidation.test.ts | 53 +- tests/firstResearchModel.test.ts | 23 +- tests/formalBatch.test.ts | 173 +- tests/formalization.test.ts | 951 ++- tests/formalizationAdjudication.test.ts | 220 +- tests/formalizationAudit.test.ts | 953 ++- tests/formalizationCardinality.test.ts | 475 +- tests/formalizationClaimShape.test.ts | 62 +- tests/formalizationCompiledCandidate.test.ts | 120 +- tests/formalizationContext.test.ts | 305 +- tests/formalizationCoverage.test.ts | 114 +- tests/formalizationElaboration.test.ts | 268 +- tests/formalizationEvaluation.test.ts | 609 +- tests/formalizationExemplars.test.ts | 95 +- tests/formalizationFidelity.test.ts | 150 +- tests/formalizationFidelityEvaluation.test.ts | 421 +- tests/formalizationFidelityRecovery.test.ts | 252 +- tests/formalizationFidelityReference.test.ts | 763 +- tests/formalizationFidelityWorkflow.test.ts | 512 +- tests/formalizationFiniteFamily.test.ts | 461 +- tests/formalizationGroupCenter.test.ts | 120 +- tests/formalizationIdentityFallback.test.ts | 124 +- tests/formalizationIdentityReference.test.ts | 327 +- tests/formalizationLibrary.test.ts | 56 +- ...alizationLibraryEnvironment.native.test.ts | 206 +- tests/formalizationLibraryEnvironment.test.ts | 174 +- ...ormalizationLibrarySymbolsWorkflow.test.ts | 812 ++- tests/formalizationLimits.test.ts | 283 +- tests/formalizationNameCompatibility.test.ts | 149 +- tests/formalizationPackagesWarmup.test.ts | 83 +- tests/formalizationPlan.test.ts | 594 +- tests/formalizationRecovery.test.ts | 452 +- tests/formalizationReference.test.ts | 370 +- tests/formalizationReferenceLibrary.test.ts | 136 +- ...malizationReferenceV4Compatibility.test.ts | 39 +- tests/formalizationRefutation.test.ts | 175 +- tests/formalizationRelay.test.ts | 2130 ++++-- tests/formalizationRepresentation.test.ts | 312 +- tests/formalizationResolvedQueries.test.ts | 315 +- tests/formalizationRetrieval.test.ts | 265 +- tests/formalizationRetrievalWorkflow.test.ts | 420 +- tests/formalizationReview.test.ts | 545 +- tests/formalizationReviewCli.test.ts | 669 +- tests/formalizationReviewIsolation.test.ts | 85 +- tests/formalizationReviewV2.test.ts | 693 +- tests/formalizationReviewV2Runner.test.ts | 1463 ++-- tests/formalizationRoleContract.test.ts | 246 +- tests/formalizationSandbox.test.ts | 1240 ++-- tests/formalizationSource.test.ts | 82 +- tests/formalizationWorkflow.test.ts | 2347 ++++-- tests/formalizeCli.test.ts | 715 +- tests/frontierPriority.test.ts | 206 +- tests/frontierPriorityContext.test.ts | 223 +- tests/fullSkillWorkflow.test.ts | 228 +- tests/genericCliSolver.test.ts | 165 +- tests/globalTrajectory.test.ts | 299 +- tests/goalPathDecisions.test.ts | 312 +- tests/goalPathReview.test.ts | 168 +- tests/goalProgress.test.ts | 321 +- tests/goalProgressResearch.test.ts | 202 +- tests/guidanceOutcomeModel.test.ts | 150 +- tests/harnessProcess.test.ts | 489 +- tests/harnessProofAcceptance.test.ts | 202 +- tests/helpers/approvedFormalizationFixture.ts | 120 +- tests/helpers/async.ts | 5 +- tests/helpers/conditionalProjection.ts | 10 +- tests/helpers/formalizationAuditFixture.ts | 61 +- tests/helpers/formalizationFixture.ts | 304 +- tests/helpers/formalizationLibraryFixture.ts | 75 +- tests/helpers/informalizationFixture.ts | 200 +- tests/helpers/lean.ts | 19 +- tests/helpers/leanCompletion.ts | 30 +- tests/helpers/libraryHostFixture.ts | 73 +- tests/helpers/longTurn.ts | 27 +- tests/helpers/shareReadingFixture.ts | 180 +- tests/helpers/solver.ts | 40 +- tests/helpers/taskProof.ts | 52 +- tests/helpers/verifier.ts | 118 +- tests/helpers/webCheckedLeanFixture.ts | 26 +- tests/helpers/webExplanationFixture.ts | 275 +- tests/helpers/webFormalizationFixture.ts | 282 +- tests/helpers/webWorkerBridge.ts | 220 +- tests/helpers/workflowHarnessFixture.ts | 66 +- tests/huggingMathBundle.test.ts | 334 +- tests/huggingMathClient.test.ts | 274 +- tests/huggingMathImports.test.ts | 275 +- tests/humanGuidance.test.ts | 438 +- tests/informalization.test.ts | 2446 +++++-- tests/informalizationAlignment.test.ts | 169 +- tests/informalizationExtraction.test.ts | 228 +- tests/informalizationLean.test.ts | 40 +- tests/informalizeCli.test.ts | 342 +- tests/inspection.test.ts | 1269 +++- tests/installedLibraryContext.test.ts | 1066 ++- tests/kernelCertificate.test.ts | 277 +- tests/knowledgeApplications.test.ts | 246 +- tests/knowledgeContext.test.ts | 1067 ++- tests/knowledgeFunnel.test.ts | 398 +- tests/knowledgeRelevance.test.ts | 379 +- tests/knowledgeResidualViews.test.ts | 43 +- tests/knowledgeUsage.test.ts | 118 +- tests/knowledgeUsageObservation.test.ts | 261 +- tests/largeChallenge.test.ts | 154 +- tests/leadInbox.test.ts | 377 +- tests/leadPlanRejectionFeedback.test.ts | 138 +- tests/leanDeclarationIdentity.test.ts | 329 +- tests/leanDiagnosticCapture.test.ts | 72 +- tests/leanDiagnostics.test.ts | 405 +- tests/leanEnvironmentHealth.test.ts | 406 +- tests/leanEvalBenchmark.test.ts | 59 +- tests/leanEvalBootstrap.test.ts | 715 +- tests/leanEvalCatalog.test.ts | 33 +- tests/leanEvalHistoricalBootstrap.test.ts | 75 +- tests/leanKnowledgeEnrichment.test.ts | 299 +- tests/leanLibraryCache.test.ts | 236 +- tests/leanLibrarySymbols.test.ts | 308 +- tests/leanLocalDependencies.test.ts | 232 +- tests/leanModuleBuild.test.ts | 268 +- tests/leanPlanNames.test.ts | 87 +- tests/leanProbeSnapshot.test.ts | 91 +- tests/leanProofSearch.test.ts | 252 +- tests/leanReferences.test.ts | 305 +- tests/leanResidualGoals.test.ts | 304 +- tests/leanSearchProjection.test.ts | 174 +- tests/leanSource.test.ts | 177 +- tests/leanStatementContext.test.ts | 334 +- tests/leanStatementSemantic.test.ts | 275 +- tests/leanStatementStructures.test.ts | 325 +- tests/leanSyntax.test.ts | 91 +- tests/leanTask.test.ts | 563 +- tests/leanTaskEnvironment.test.ts | 60 +- tests/leanTestEnvironment.test.ts | 12 +- tests/leanToolchainReadiness.test.ts | 42 +- tests/leanTypeDiagnostics.test.ts | 530 +- tests/leanTypeDiagnosticsEnvironment.test.ts | 84 +- tests/leanTypeDiagnosticsSealed.test.ts | 78 +- tests/libraryAccess.test.ts | 508 +- tests/libraryApplication.test.ts | 889 ++- tests/libraryCatalog.test.ts | 543 +- tests/libraryEffectivePack.test.ts | 261 +- tests/libraryHostConfig.test.ts | 111 +- tests/libraryKnowledgeDocumentation.test.ts | 74 +- tests/libraryKnowledgeFeedback.test.ts | 542 +- tests/libraryLegacyBinding.test.ts | 148 +- tests/libraryPacks.test.ts | 849 ++- tests/localExample.test.ts | 30 +- tests/mathBatch.test.ts | 133 +- tests/mathGit.test.ts | 85 +- tests/mathModelSlot.test.ts | 68 +- tests/mathProcess.test.ts | 363 +- tests/mathProofEnvironment.test.ts | 258 +- tests/mathProofEnvironmentSeed.test.ts | 858 ++- tests/mathProofLease.test.ts | 93 +- tests/mathProofRunReport.test.ts | 117 +- tests/mathRetrievalCorpus.test.ts | 1072 ++- tests/mathRuntimeEnvironment.test.ts | 333 +- tests/mathRuntimeLease.test.ts | 59 +- tests/mathRuntimeLeaseProcess.test.ts | 74 +- tests/mathTimers.test.ts | 18 +- tests/mathTools.test.ts | 246 +- tests/mathematicalGaps.test.ts | 230 +- tests/moduleExperiment.test.ts | 439 +- tests/nativeSkillComparison.test.ts | 325 +- tests/nativeTurnUsage.test.ts | 108 +- tests/nextCheckExecution.test.ts | 315 +- tests/nextCheckNegativeDecisions.test.ts | 272 +- tests/obligationArchive.test.ts | 124 +- tests/obligationProgress.test.ts | 381 +- tests/openCodeSession.test.ts | 234 +- tests/pantographSession.test.ts | 90 +- tests/personalApprovalStore.test.ts | 164 +- tests/planPatch.test.ts | 412 +- tests/planResearchConnections.test.ts | 58 +- tests/planningEvidence.test.ts | 272 +- tests/projectionDependencyHints.test.ts | 325 +- tests/projectionDependencyReview.test.ts | 176 +- tests/projectionNotation.test.ts | 112 +- tests/proofFigures.test.ts | 392 +- tests/proofMapModel.test.ts | 554 +- tests/proofReferenceOwnership.test.ts | 144 +- tests/proofReuseEnvironment.test.ts | 243 +- tests/proofRoutes.test.ts | 302 +- tests/proofSearchRecords.test.ts | 211 +- tests/proofSearchRuntime.test.ts | 723 +- tests/proofSearchTool.test.ts | 321 +- tests/proofWalkthrough.test.ts | 503 +- tests/proofWriter.test.ts | 18 +- tests/putnamBench.test.ts | 180 +- tests/putnamSample.test.ts | 931 ++- tests/qualifiedInputRegression.test.ts | 28 +- tests/reasoningCheckpointContext.test.ts | 159 +- tests/receiptKey.test.ts | 80 +- tests/recovery.test.ts | 780 +- tests/researchAdmission.test.ts | 263 +- tests/researchAdvance.test.ts | 140 +- tests/researchArchive.test.ts | 166 +- tests/researchBudgetEditor.test.ts | 46 +- tests/researchClosureNavigation.test.ts | 35 +- tests/researchCollaboration.test.ts | 2248 +++++- tests/researchCredentialRelay.test.ts | 326 +- tests/researchDecisionRecovery.test.ts | 159 +- tests/researchDecisions.test.ts | 116 +- tests/researchDraftStore.test.ts | 179 +- tests/researchEntry.test.ts | 81 +- tests/researchEvidence.test.ts | 46 +- tests/researchFeedbackModel.test.ts | 171 +- tests/researchHarness.test.ts | 124 +- tests/researchIssueExecutionDraft.test.ts | 41 +- tests/researchLibraryTrialDraft.test.ts | 81 +- tests/researchOrganizationDraft.test.ts | 51 +- tests/researchOverviewModel.test.ts | 297 +- tests/researchOverviewVerifiedRuns.test.ts | 113 +- tests/researchPlanApproval.test.ts | 23 +- tests/researchPractice.test.ts | 48 +- tests/researchRecords.test.ts | 317 +- tests/researchReferences.test.ts | 127 +- tests/researchRoadmap.test.ts | 475 +- tests/researchSources.test.ts | 182 +- tests/researchStartCost.test.ts | 28 +- tests/researchToolGuide.test.ts | 45 +- tests/researchUsage.test.ts | 468 +- tests/reviewedEnvironmentIdentity.test.ts | 6 +- tests/routeControl.test.ts | 504 +- tests/routePriority.test.ts | 258 +- tests/routePriorityContext.test.ts | 96 +- tests/routeScheduling.test.ts | 323 +- tests/runLeaseSafety.test.ts | 95 +- tests/sealedHarness.test.ts | 750 +- tests/setup/cacheCleanup.ts | 4 +- tests/shareContinuation.test.ts | 87 +- tests/shareReading.test.ts | 68 +- tests/singleContinuationSeed.test.ts | 700 +- tests/singleSolverProofHandoff.test.ts | 49 +- tests/siteCatalog.test.ts | 202 +- tests/siteFeedbackDraft.test.ts | 25 +- tests/skillContextContinuation.test.ts | 490 +- tests/skillKnowledgeConsumer.test.ts | 246 +- tests/skillProcessRecovery.test.ts | 310 +- tests/skillProviderValidation.test.ts | 105 +- tests/skillResearchRuntime.test.ts | 1598 +++-- tests/skillRunInspection.test.ts | 416 +- tests/skillSolver.test.ts | 653 +- tests/solutionRouteLayout.test.ts | 78 +- tests/solver.test.ts | 4958 +++++++++---- tests/solverAtomicPlanApply.test.ts | 82 +- tests/solverAutomaticExplanations.test.ts | 124 +- tests/solverBatchAttribution.test.ts | 574 +- tests/solverCapacityCli.test.ts | 197 +- tests/solverCompactProjection.test.ts | 157 +- tests/solverContext.test.ts | 871 ++- tests/solverEnvironment.test.ts | 79 +- tests/solverEvidenceReuse.test.ts | 100 +- tests/solverFeedback.test.ts | 100 +- tests/solverInputs.test.ts | 90 +- tests/solverLibraryRequest.test.ts | 155 +- tests/solverMathematicalContext.test.ts | 46 +- tests/solverOrganization.test.ts | 275 +- tests/solverPlanResponse.test.ts | 79 +- tests/solverPreflightArchive.test.ts | 202 +- tests/solverProgress.test.ts | 273 +- tests/solverProverRoles.test.ts | 155 +- tests/solverRouteRetirement.test.ts | 250 +- tests/solverSchedulerFairness.test.ts | 66 +- tests/solverScratchOwnership.test.ts | 436 +- tests/solverSingleProofHandoff.test.ts | 203 +- tests/solverSoftSliceCompaction.test.ts | 298 +- tests/solverSourceRecovery.test.ts | 119 +- tests/solverUsageReceipts.test.ts | 534 +- tests/sourceContextComments.test.ts | 29 +- tests/standalone.test.ts | 56 +- tests/stateInvariants.test.ts | 158 +- tests/statementContextScopes.test.ts | 116 +- tests/statementProjectionDiagnostics.test.ts | 117 +- tests/statementReviewIdentity.test.ts | 143 +- tests/staticReport.test.ts | 206 +- tests/storedRunInspection.test.ts | 351 +- tests/tacticBattery.test.ts | 133 +- tests/tacticBatteryCacheIsolation.test.ts | 297 +- tests/tacticBatteryFailureCache.test.ts | 317 +- tests/tacticBatteryTestIsolation.test.ts | 54 +- tests/taskConditionalUniverses.test.ts | 123 +- tests/taskConsumerInterfaces.test.ts | 259 +- tests/taskFamilies.test.ts | 378 +- tests/taskPlanEditorAccess.test.ts | 81 +- tests/taskProofCache.test.ts | 494 +- tests/taskProposals.test.ts | 58 +- tests/taskQuestions.test.ts | 31 +- tests/taskReadiness.test.ts | 150 +- tests/taskReferenceAttribution.test.ts | 148 +- tests/taskResponsibility.test.ts | 192 +- tests/taskSourceConditionalContext.test.ts | 138 +- tests/taskSourceImplicitInstances.test.ts | 207 +- tests/taskSourceMacroProjection.test.ts | 173 +- tests/taskSourceNotationContext.test.ts | 225 +- tests/taskSourceNotationHints.test.ts | 176 +- tests/taskSourceProjection.test.ts | 984 ++- tests/taskTypeContract.test.ts | 40 +- tests/taskTypePreflight.test.ts | 721 +- tests/theoremKnowledge.test.ts | 192 +- tests/theoremKnowledgeAccepted.test.ts | 267 +- tests/theoremKnowledgeAuthorization.test.ts | 152 +- tests/theoremKnowledgeConsumers.test.ts | 398 +- tests/theoremKnowledgeDependencies.test.ts | 114 +- tests/theoremKnowledgeEnrichment.test.ts | 1052 ++- tests/theoremKnowledgeEnrichmentCli.test.ts | 117 +- tests/theoremKnowledgeFindings.test.ts | 894 ++- tests/theoremKnowledgeGoal.test.ts | 87 +- tests/theoremKnowledgeLibrary.test.ts | 200 +- tests/theoremKnowledgeMetadata.test.ts | 377 +- tests/theoremKnowledgeRelations.test.ts | 248 +- tests/theoremKnowledgeRuns.test.ts | 449 +- tests/theoremKnowledgeSearch.test.ts | 593 +- tests/theoremKnowledgeSearchIndex.test.ts | 306 +- tests/theoremKnowledgeSource.test.ts | 201 +- tests/theoremKnowledgeStore.test.ts | 225 +- tests/theoryModules.test.ts | 257 +- tests/usageBudget.test.ts | 240 +- tests/verificationCheckpoint.test.ts | 187 +- tests/verifierCheckout.test.ts | 143 +- tests/verifierFailure.test.ts | 49 +- tests/verifierLeaseTimeout.test.ts | 223 +- tests/verifierModuleBuild.test.ts | 104 +- tests/verifierOfficialManifest.test.ts | 366 +- tests/verifierSealedEnvironmentCache.test.ts | 95 +- tests/verifierToolIdentity.test.ts | 65 +- tests/webAdmin.test.ts | 110 +- tests/webAdminKey.test.ts | 136 +- tests/webAdmission.test.ts | 12 +- tests/webAdmissionRace.test.ts | 143 +- tests/webAgentActions.test.ts | 1132 ++- tests/webArtifact.test.ts | 185 +- tests/webAuth.test.ts | 421 +- tests/webAuthPolicy.test.ts | 184 +- tests/webBackgroundReview.test.ts | 78 +- tests/webBackgroundReviewWorkflow.test.ts | 413 +- tests/webBrowserRunNotifications.test.ts | 79 +- tests/webBudgetAttempt.test.ts | 254 +- tests/webBudgetContinuity.test.ts | 223 +- tests/webChatAnswer.test.ts | 580 +- tests/webChatDraft.test.ts | 336 +- tests/webChatMathematics.test.ts | 282 +- tests/webClassicPreparation.test.ts | 54 +- tests/webClient.test.ts | 147 +- tests/webClientIp.test.ts | 50 +- tests/webClientMarkup.test.ts | 12 +- tests/webCollaboration.test.ts | 1110 ++- tests/webCommunity.test.ts | 237 +- tests/webCompletionMail.test.ts | 337 +- tests/webConfig.test.ts | 52 +- tests/webContinuation.test.ts | 51 +- tests/webContinuationIdentity.test.ts | 193 +- tests/webConversations.test.ts | 1534 +++- tests/webCreation.test.ts | 57 +- tests/webDraft.test.ts | 464 +- tests/webDraftRecovery.test.ts | 220 +- tests/webExplain.test.ts | 300 +- tests/webExplainText.test.ts | 558 +- tests/webExplanation.test.ts | 837 ++- tests/webExplanationServer.test.ts | 506 +- tests/webFailure.test.ts | 219 +- tests/webFonts.test.ts | 30 +- tests/webFormalizationActivity.test.ts | 816 ++- tests/webFormalizationAuditWorker.test.ts | 231 +- .../webFormalizationBackgroundReview.test.ts | 277 +- tests/webFormalizationCreation.test.ts | 60 +- tests/webFormalizationProgress.test.ts | 60 +- tests/webFormalizationReport.test.ts | 126 +- tests/webFormalizationSeed.test.ts | 187 +- tests/webFormalizationWorker.test.ts | 456 +- tests/webFormalizations.test.ts | 1666 +++-- tests/webFrozenLibrary.test.ts | 675 +- tests/webFunnel.test.ts | 9 +- tests/webHarness.test.ts | 351 +- tests/webHistoryPreference.test.ts | 12 +- tests/webI18n.test.ts | 177 +- tests/webI18nScanner.test.ts | 17 +- tests/webInstalledLibrary.test.ts | 448 +- tests/webJobs.test.ts | 696 +- tests/webKeyMemory.test.ts | 40 +- tests/webKeyVault.test.ts | 203 +- tests/webKnowledgeApi.test.ts | 276 +- tests/webLeanMessages.test.ts | 81 +- tests/webLeanOutline.test.ts | 23 +- tests/webLeanTheoremType.test.ts | 17 +- tests/webLibraryCompatibleDiscovery.test.ts | 188 +- tests/webLibraryFollowthrough.test.ts | 195 +- tests/webLibraryNative.test.ts | 297 +- tests/webLibraryProposalContinuity.test.ts | 91 +- tests/webLibraryResearch.test.ts | 671 +- tests/webLibraryUsage.test.ts | 460 +- tests/webLifecyclePersistence.test.ts | 637 +- tests/webLoginReturn.test.ts | 125 +- tests/webLongRun.test.ts | 206 +- tests/webModuleIdentity.test.ts | 49 +- tests/webModulePlan.test.ts | 152 +- tests/webModulePlanLibrary.test.ts | 143 +- tests/webModuleTelemetry.test.ts | 511 +- tests/webModuleView.test.ts | 113 +- tests/webOperations.test.ts | 313 +- tests/webOperationsApi.test.ts | 220 +- tests/webOperationsMonitor.test.ts | 340 +- tests/webOperationsScheduled.test.ts | 124 +- tests/webOwnedDrafts.test.ts | 89 +- tests/webPersistence.test.ts | 465 +- tests/webPersonalExpertHandoff.test.ts | 49 +- tests/webPrecheck.test.ts | 175 +- tests/webPresentation.test.ts | 359 +- tests/webProblemDrafts.test.ts | 455 +- tests/webProductFlow.test.ts | 80 +- tests/webProofSearchEnvironment.test.ts | 27 +- tests/webProviderCheck.test.ts | 79 +- tests/webProviderContainer.test.ts | 121 +- tests/webProviderFixture.test.ts | 198 +- tests/webQuota.test.ts | 65 +- tests/webReadableExplanation.test.ts | 30 +- tests/webReport.test.ts | 880 ++- tests/webResearchApi.test.ts | 1726 ++++- tests/webResearchAssetPrefill.test.ts | 340 +- tests/webResearchAssets.test.ts | 787 +- tests/webResearchBriefFonts.test.ts | 78 +- tests/webResearchCandidateScope.test.ts | 132 +- tests/webResearchCollections.test.ts | 416 +- tests/webResearchCompletion.test.ts | 122 +- tests/webResearchDepth.test.ts | 277 +- tests/webResearchDiscoveryInvites.test.ts | 291 +- tests/webResearchJourney.test.ts | 426 +- tests/webResearchLibraryTrials.test.ts | 1176 ++- tests/webResearchLibraryUsage.test.ts | 199 +- tests/webResearchMathExamples.test.ts | 285 +- tests/webResearchMathematics.test.ts | 443 +- tests/webResearchPeopleReturn.test.ts | 36 +- tests/webResearchPersonal.test.ts | 1048 ++- tests/webResearchProblemDraft.test.ts | 421 +- tests/webResearchProblems.test.ts | 838 ++- tests/webResearchProjectDraft.test.ts | 68 +- tests/webResearchProjects.test.ts | 1984 ++++- tests/webResearchReleaseComparison.test.ts | 231 +- tests/webResearchRunContinuity.test.ts | 246 +- tests/webResearchSession.test.ts | 162 +- tests/webResearchTeamContinuity.test.ts | 269 +- tests/webResearchWorkspace.test.ts | 508 +- tests/webRichProse.test.ts | 20 +- tests/webRunSnapshot.test.ts | 101 +- tests/webRunStream.test.ts | 240 +- tests/webRunner.test.ts | 1063 ++- tests/webSample.test.ts | 47 +- tests/webServer.test.ts | 857 ++- tests/webSessionCookies.test.ts | 195 +- tests/webShare.test.ts | 249 +- tests/webSharedProofs.test.ts | 168 +- tests/webSignup.test.ts | 150 +- tests/webSkillDeclarationArtifacts.test.ts | 129 +- tests/webSkillDeclarationBounds.test.ts | 30 +- tests/webSkillResearch.test.ts | 354 +- tests/webSolutionRoute.test.ts | 813 ++- tests/webSolveProcess.test.ts | 412 +- tests/webSourceDiff.test.ts | 210 +- tests/webSourceIndent.test.ts | 111 +- tests/webSourceReplace.test.ts | 38 +- tests/webSourceText.test.ts | 82 +- tests/webStaticFiles.test.ts | 82 +- tests/webTaskGraphLayout.test.ts | 66 +- tests/webThemePreference.test.ts | 31 +- tests/webThinkingProcess.test.ts | 556 +- tests/webTrajectory.test.ts | 497 +- tests/webVerificationKit.test.ts | 582 +- tests/webWorkerBridge.test.ts | 823 ++- tests/westlake.test.ts | 57 +- tests/workerProject.test.ts | 58 +- tests/workerRecovery.test.ts | 881 ++- tests/workflowHarness.test.ts | 137 +- tests/workflowOutput.test.ts | 37 +- vitest.config.ts | 9 +- 1837 files changed, 457322 insertions(+), 161736 deletions(-) create mode 100644 .editorconfig create mode 100644 .prettierignore create mode 100644 .prettierrc.json create mode 100644 CONTRIBUTING.md create mode 100644 docs/history/README.md rename docs/{ => history}/evaluation-improvement-plan-2026-11-01.md (96%) rename docs/{ => history}/frontend-function-review.md (93%) rename docs/{ => history}/frontend-problem-workspace-20261110.md (100%) rename docs/{ => history}/frontend-product-continuity-20261110.md (100%) rename docs/{ => history}/frontend-product-flow-20261110.md (100%) rename docs/{ => history}/frontend-product-state-continuity-20261111.md (100%) rename docs/{ => history}/frontend-release-20261109.md (100%) rename docs/{ => history}/frontend-research-closure-20261110.md (100%) rename docs/{ => history}/frontend-research-completion-20261110.md (100%) rename docs/{ => history}/frontend-research-continuity-20261110.md (100%) rename docs/{ => history}/frontend-research-depth-20261110.md (100%) rename docs/{ => history}/frontend-research-followthrough-20261110.md (100%) rename docs/{ => history}/frontend-research-lifecycle-20261110.md (100%) rename docs/{ => history}/frontend-research-product-continuity-20261111.md (100%) rename docs/{ => history}/frontend-round10-release-20261110.md (100%) rename docs/{ => history}/frontend-round3-20261109.md (100%) rename docs/{ => history}/frontend-round4-20261109.md (100%) rename docs/{ => history}/frontend-round5-20261109.md (100%) rename docs/{ => history}/frontend-round6-20261109.md (100%) rename docs/{ => history}/frontend-round7-fixes-20261109.md (100%) rename docs/{ => history}/frontend-round7-release-20261109.md (100%) rename docs/{ => history}/langfuse-evaluation-insights-2026-11-01.md (94%) rename docs/{ => history}/library-original-uses-20261109.md (100%) rename docs/{ => history}/product-flow-release-20261110.md (100%) rename docs/{ => history}/research-round4-fixes-20261109.md (100%) rename docs/{ => history}/research-round5-fixes-20261109.md (100%) create mode 100644 scripts/e2e/test-archive-process.ts create mode 100644 scripts/e2e/test-archive-roadmap.ts create mode 100644 scripts/e2e/test-classic-global-trajectory.ts rename scripts/{ => e2e}/test-feedback.mjs (72%) create mode 100644 scripts/e2e/test-frontend-audit-layout.ts rename scripts/{ => e2e}/test-i18n.mjs (66%) create mode 100644 scripts/e2e/test-landing-motion.mjs rename scripts/{ => e2e}/test-landing.mjs (71%) create mode 100644 scripts/e2e/test-math-rendering.ts create mode 100644 scripts/e2e/test-proof-reading-navigation.mjs create mode 100644 scripts/e2e/test-site-feedback-drafts.mjs rename scripts/{ => e2e}/test-site-product-flow.mjs (76%) create mode 100644 scripts/e2e/test-site-research-entry.mjs rename scripts/{ => e2e}/test-site.mjs (68%) create mode 100644 scripts/e2e/test-universal-solution-route.ts rename scripts/{ => e2e}/test-web-a11y.ts (59%) create mode 100644 scripts/e2e/test-web-activity.ts rename scripts/{ => e2e}/test-web-admin.ts (66%) rename scripts/{ => e2e}/test-web-agent-route.ts (56%) create mode 100644 scripts/e2e/test-web-audit-library.ts create mode 100644 scripts/e2e/test-web-audit-workbench.ts create mode 100644 scripts/e2e/test-web-automatic-explanations.ts create mode 100644 scripts/e2e/test-web-brief-export-continuity.ts create mode 100644 scripts/e2e/test-web-budget-live-refresh.ts create mode 100644 scripts/e2e/test-web-budget-post-continuity.ts create mode 100644 scripts/e2e/test-web-budget-save-continuity.ts create mode 100644 scripts/e2e/test-web-candidate-continuity.ts create mode 100644 scripts/e2e/test-web-cantor-bernstein-demo.ts create mode 100644 scripts/e2e/test-web-capacity.ts rename scripts/{ => e2e}/test-web-chat-artifacts.ts (54%) rename scripts/{ => e2e}/test-web-chat-cancel-recovery.ts (57%) create mode 100644 scripts/e2e/test-web-chat-mathematics.ts create mode 100644 scripts/e2e/test-web-chat-recovery.ts create mode 100644 scripts/e2e/test-web-chat-session.ts create mode 100644 scripts/e2e/test-web-classic-preparation.ts rename scripts/{ => e2e}/test-web-classics.ts (61%) create mode 100644 scripts/e2e/test-web-collaboration-actions.ts create mode 100644 scripts/e2e/test-web-collaboration-continuity.ts create mode 100644 scripts/e2e/test-web-collaboration-entry-permissions.ts create mode 100644 scripts/e2e/test-web-collaboration-layers.ts create mode 100644 scripts/e2e/test-web-collaboration-post-state.ts create mode 100644 scripts/e2e/test-web-collaboration.ts create mode 100644 scripts/e2e/test-web-collections-lifecycle.ts rename scripts/{ => e2e}/test-web-community.ts (57%) create mode 100644 scripts/e2e/test-web-continuation-archive.ts create mode 100644 scripts/e2e/test-web-discovery-invites.ts create mode 100644 scripts/e2e/test-web-discussion-guidance.ts create mode 100644 scripts/e2e/test-web-draft-recovery.ts create mode 100644 scripts/e2e/test-web-drafts.ts create mode 100644 scripts/e2e/test-web-editor-navigation.ts create mode 100644 scripts/e2e/test-web-editor-post-state.ts create mode 100644 scripts/e2e/test-web-editor-replace.ts create mode 100644 scripts/e2e/test-web-editor-review.ts create mode 100644 scripts/e2e/test-web-entry-post-lifecycle.ts create mode 100644 scripts/e2e/test-web-explain-recovery.ts rename scripts/{ => e2e}/test-web-explain.ts (59%) rename scripts/{ => e2e}/test-web-failures.ts (71%) create mode 100644 scripts/e2e/test-web-first-budget-corrections.ts rename scripts/{ => e2e}/test-web-first-research-sharing.ts (56%) rename scripts/{ => e2e}/test-web-formalization-completion.ts (62%) create mode 100644 scripts/e2e/test-web-formalization-progress.ts rename scripts/{ => e2e}/test-web-formalize.ts (57%) create mode 100644 scripts/e2e/test-web-guidance-recovery.ts rename scripts/{ => e2e}/test-web-guide.ts (63%) create mode 100644 scripts/e2e/test-web-history.ts create mode 100644 scripts/e2e/test-web-human-decisions.ts rename scripts/{ => e2e}/test-web-i18n.ts (70%) create mode 100644 scripts/e2e/test-web-inline-annotations.ts create mode 100644 scripts/e2e/test-web-installed-library.ts create mode 100644 scripts/e2e/test-web-interaction-flow.ts create mode 100644 scripts/e2e/test-web-issue-action-continuity.ts create mode 100644 scripts/e2e/test-web-journey-project-navigation.ts create mode 100644 scripts/e2e/test-web-key-memory.ts create mode 100644 scripts/e2e/test-web-knowledge-context.ts create mode 100644 scripts/e2e/test-web-library-followthrough.ts create mode 100644 scripts/e2e/test-web-library-navigation.ts create mode 100644 scripts/e2e/test-web-library-personal-continuity.ts create mode 100644 scripts/e2e/test-web-library-post-continuity.ts create mode 100644 scripts/e2e/test-web-library-post-state.ts create mode 100644 scripts/e2e/test-web-library-product-gaps.ts create mode 100644 scripts/e2e/test-web-library-proposal-continuity.ts create mode 100644 scripts/e2e/test-web-library-reference.ts create mode 100644 scripts/e2e/test-web-live-source-actions.ts create mode 100644 scripts/e2e/test-web-live-sync.ts rename scripts/{ => e2e}/test-web-load.ts (65%) rename scripts/{ => e2e}/test-web-login.ts (67%) rename scripts/{ => e2e}/test-web-long-run.ts (61%) create mode 100644 scripts/e2e/test-web-mathematical-changes.ts create mode 100644 scripts/e2e/test-web-message-stage-continuity.ts create mode 100644 scripts/e2e/test-web-module-plan.ts create mode 100644 scripts/e2e/test-web-modules.ts create mode 100644 scripts/e2e/test-web-motion.ts rename scripts/{ => e2e}/test-web-native-team.ts (56%) rename scripts/{ => e2e}/test-web-natural-first.ts (54%) create mode 100644 scripts/e2e/test-web-onboarding-post-continuity.ts rename scripts/{ => e2e}/test-web-onboarding.ts (70%) create mode 100644 scripts/e2e/test-web-openai-problems.ts create mode 100644 scripts/e2e/test-web-overview-post-continuity.ts rename scripts/{ => e2e}/test-web-paper.ts (55%) rename scripts/{ => e2e}/test-web-performance.ts (53%) create mode 100644 scripts/e2e/test-web-personal-approval-continuity.ts rename scripts/{ => e2e}/test-web-plan-approval.ts (57%) create mode 100644 scripts/e2e/test-web-plan-structure.ts create mode 100644 scripts/e2e/test-web-practice.ts rename scripts/{ => e2e}/test-web-precheck.ts (64%) create mode 100644 scripts/e2e/test-web-preparation.ts create mode 100644 scripts/e2e/test-web-preview.ts create mode 100644 scripts/e2e/test-web-problem-demo.ts create mode 100644 scripts/e2e/test-web-problem-drafts.ts create mode 100644 scripts/e2e/test-web-problem-lifecycle.ts rename scripts/{ => e2e}/test-web-product-flow.ts (50%) create mode 100644 scripts/e2e/test-web-project-attempt-reuse.ts create mode 100644 scripts/e2e/test-web-project-drafts.ts create mode 100644 scripts/e2e/test-web-project-participation.ts rename scripts/{ => e2e}/test-web-proof-map.ts (66%) create mode 100644 scripts/e2e/test-web-proof-thinking.ts rename scripts/{ => e2e}/test-web-rate-limit.ts (56%) create mode 100644 scripts/e2e/test-web-readable-results.ts create mode 100644 scripts/e2e/test-web-recovery-context.ts create mode 100644 scripts/e2e/test-web-recovery-library-context.ts rename scripts/{ => e2e}/test-web-recovery.ts (52%) rename scripts/{ => e2e}/test-web-report.ts (61%) create mode 100644 scripts/e2e/test-web-research-collections.ts create mode 100644 scripts/e2e/test-web-research-completion.ts create mode 100644 scripts/e2e/test-web-research-decisions-followthrough.ts create mode 100644 scripts/e2e/test-web-research-decisions-lifecycle.ts create mode 100644 scripts/e2e/test-web-research-depth.ts create mode 100644 scripts/e2e/test-web-research-draft-lifecycle.ts create mode 100644 scripts/e2e/test-web-research-entry.ts create mode 100644 scripts/e2e/test-web-research-information.ts create mode 100644 scripts/e2e/test-web-research-journey.ts create mode 100644 scripts/e2e/test-web-research-lean.ts create mode 100644 scripts/e2e/test-web-research-library-trials.ts create mode 100644 scripts/e2e/test-web-research-login-navigation.ts create mode 100644 scripts/e2e/test-web-research-notifications.ts create mode 100644 scripts/e2e/test-web-research-personal.ts create mode 100644 scripts/e2e/test-web-research-problem.ts create mode 100644 scripts/e2e/test-web-research-progress.ts create mode 100644 scripts/e2e/test-web-research-run-continuity.ts create mode 100644 scripts/e2e/test-web-research-space.ts create mode 100644 scripts/e2e/test-web-research-start-planning.ts create mode 100644 scripts/e2e/test-web-research-workspace.ts create mode 100644 scripts/e2e/test-web-results.ts create mode 100644 scripts/e2e/test-web-review-product-continuity.ts rename scripts/{ => e2e}/test-web-review-regressions.ts (60%) create mode 100644 scripts/e2e/test-web-reviews.ts rename scripts/{ => e2e}/test-web-roadmap.ts (51%) create mode 100644 scripts/e2e/test-web-round10-math.ts create mode 100644 scripts/e2e/test-web-round10-routes.ts create mode 100644 scripts/e2e/test-web-round10-workbench.ts create mode 100644 scripts/e2e/test-web-round2-collaboration.ts rename scripts/{ => e2e}/test-web-round2-login.ts (56%) create mode 100644 scripts/e2e/test-web-round2-routes.ts create mode 100644 scripts/e2e/test-web-round2-workbench.ts create mode 100644 scripts/e2e/test-web-round3-approval.ts create mode 100644 scripts/e2e/test-web-round3-collaboration.ts create mode 100644 scripts/e2e/test-web-round3-library.ts create mode 100644 scripts/e2e/test-web-round3-routes.ts create mode 100644 scripts/e2e/test-web-round3-workbench.ts create mode 100644 scripts/e2e/test-web-round4-library.ts create mode 100644 scripts/e2e/test-web-round4-sharing.ts create mode 100644 scripts/e2e/test-web-round5-collaboration.ts create mode 100644 scripts/e2e/test-web-round5-library.ts create mode 100644 scripts/e2e/test-web-round5-people.ts create mode 100644 scripts/e2e/test-web-round5-workbench.ts create mode 100644 scripts/e2e/test-web-round6-collaboration.ts create mode 100644 scripts/e2e/test-web-round6-library.ts create mode 100644 scripts/e2e/test-web-round6-people.ts create mode 100644 scripts/e2e/test-web-round6-routes.ts create mode 100644 scripts/e2e/test-web-round7-library.ts create mode 100644 scripts/e2e/test-web-round7-people.ts create mode 100644 scripts/e2e/test-web-round7-routes.ts create mode 100644 scripts/e2e/test-web-round7-session.ts create mode 100644 scripts/e2e/test-web-round8-approval.ts rename scripts/{ => e2e}/test-web-round8-budget.ts (52%) create mode 100644 scripts/e2e/test-web-round8-keys.ts create mode 100644 scripts/e2e/test-web-round8-routes.ts create mode 100644 scripts/e2e/test-web-round9-availability.ts create mode 100644 scripts/e2e/test-web-round9-mobile.ts create mode 100644 scripts/e2e/test-web-round9-routes.ts create mode 100644 scripts/e2e/test-web-run-monitor.ts create mode 100644 scripts/e2e/test-web-runtime.ts rename scripts/{ => e2e}/test-web-saved-key.ts (61%) create mode 100644 scripts/e2e/test-web-schur-demo.ts create mode 100644 scripts/e2e/test-web-server-plans.ts create mode 100644 scripts/e2e/test-web-share-bookmark-notes.ts create mode 100644 scripts/e2e/test-web-share-continuity.ts rename scripts/{ => e2e}/test-web-share.ts (61%) create mode 100644 scripts/e2e/test-web-simple-workbench.ts create mode 100644 scripts/e2e/test-web-skill-research.ts rename scripts/{ => e2e}/test-web-solve-process.ts (59%) create mode 100644 scripts/e2e/test-web-source-diff.ts create mode 100644 scripts/e2e/test-web-source-handoff.ts create mode 100644 scripts/e2e/test-web-source-reader.ts create mode 100644 scripts/e2e/test-web-task-browser.ts create mode 100644 scripts/e2e/test-web-task-source.ts create mode 100644 scripts/e2e/test-web-team-continuity.ts rename scripts/{ => e2e}/test-web-theme.ts (52%) rename scripts/{ => e2e}/test-web-trajectory.ts (57%) rename scripts/{ => e2e}/test-web-ui.ts (71%) create mode 100644 scripts/e2e/test-web-workbench-ux.ts rename scripts/{ => e2e}/test-web-workspace-post-lifecycle.ts (52%) create mode 100644 scripts/e2e/web-a11y.ts create mode 100644 scripts/e2e/web-agent-action-fixture.ts rename scripts/{ => e2e}/web-contrast.ts (60%) rename scripts/{ => e2e}/web-cooperative-fixture.ts (68%) rename scripts/{ => e2e}/web-i18n-fixture.ts (58%) rename scripts/{ => e2e}/web-print.ts (57%) create mode 100644 scripts/e2e/web-scenario.ts create mode 100644 scripts/e2e/web-trajectory-fixture.ts create mode 100644 scripts/e2e/web-ui-controls.ts delete mode 100644 scripts/test-archive-process.ts delete mode 100644 scripts/test-archive-roadmap.ts delete mode 100644 scripts/test-classic-global-trajectory.ts delete mode 100644 scripts/test-frontend-audit-layout.ts delete mode 100644 scripts/test-landing-motion.mjs delete mode 100644 scripts/test-math-rendering.ts delete mode 100644 scripts/test-proof-reading-navigation.mjs delete mode 100644 scripts/test-site-feedback-drafts.mjs delete mode 100644 scripts/test-site-research-entry.mjs delete mode 100644 scripts/test-universal-solution-route.ts delete mode 100644 scripts/test-web-activity.ts delete mode 100644 scripts/test-web-audit-library.ts delete mode 100644 scripts/test-web-audit-workbench.ts delete mode 100644 scripts/test-web-automatic-explanations.ts delete mode 100644 scripts/test-web-background-review.ts delete mode 100644 scripts/test-web-brief-export-continuity.ts delete mode 100644 scripts/test-web-budget-attempt-continuity.ts delete mode 100644 scripts/test-web-budget-live-refresh.ts delete mode 100644 scripts/test-web-budget-post-continuity.ts delete mode 100644 scripts/test-web-budget-save-continuity.ts delete mode 100644 scripts/test-web-candidate-continuity.ts delete mode 100644 scripts/test-web-candidate-history.ts delete mode 100644 scripts/test-web-cantor-bernstein-demo.ts delete mode 100644 scripts/test-web-capacity.ts delete mode 100644 scripts/test-web-chat-mathematics.ts delete mode 100644 scripts/test-web-chat-recovery.ts delete mode 100644 scripts/test-web-chat-session.ts delete mode 100644 scripts/test-web-classic-preparation.ts delete mode 100644 scripts/test-web-collaboration-actions.ts delete mode 100644 scripts/test-web-collaboration-continuity.ts delete mode 100644 scripts/test-web-collaboration-entry-permissions.ts delete mode 100644 scripts/test-web-collaboration-layers.ts delete mode 100644 scripts/test-web-collaboration-post-state.ts delete mode 100644 scripts/test-web-collaboration.ts delete mode 100644 scripts/test-web-collections-lifecycle.ts delete mode 100644 scripts/test-web-continuation-archive.ts delete mode 100644 scripts/test-web-discovery-invites.ts delete mode 100644 scripts/test-web-discussion-guidance.ts delete mode 100644 scripts/test-web-draft-recovery.ts delete mode 100644 scripts/test-web-drafts.ts delete mode 100644 scripts/test-web-editor-navigation.ts delete mode 100644 scripts/test-web-editor-post-state.ts delete mode 100644 scripts/test-web-editor-replace.ts delete mode 100644 scripts/test-web-editor-review.ts delete mode 100644 scripts/test-web-entry-post-lifecycle.ts delete mode 100644 scripts/test-web-explain-recovery.ts delete mode 100644 scripts/test-web-first-budget-corrections.ts delete mode 100644 scripts/test-web-formalization-progress.ts delete mode 100644 scripts/test-web-guidance-recovery.ts delete mode 100644 scripts/test-web-history.ts delete mode 100644 scripts/test-web-human-decisions.ts delete mode 100644 scripts/test-web-inline-annotations.ts delete mode 100644 scripts/test-web-installed-library.ts delete mode 100644 scripts/test-web-interaction-flow.ts delete mode 100644 scripts/test-web-issue-action-continuity.ts delete mode 100644 scripts/test-web-journey-project-navigation.ts delete mode 100644 scripts/test-web-key-memory.ts delete mode 100644 scripts/test-web-knowledge-context.ts delete mode 100644 scripts/test-web-library-followthrough.ts delete mode 100644 scripts/test-web-library-navigation.ts delete mode 100644 scripts/test-web-library-personal-continuity.ts delete mode 100644 scripts/test-web-library-post-continuity.ts delete mode 100644 scripts/test-web-library-post-state.ts delete mode 100644 scripts/test-web-library-product-gaps.ts delete mode 100644 scripts/test-web-library-proposal-continuity.ts delete mode 100644 scripts/test-web-library-reference.ts delete mode 100644 scripts/test-web-live-source-actions.ts delete mode 100644 scripts/test-web-live-sync.ts delete mode 100644 scripts/test-web-mathematical-changes.ts delete mode 100644 scripts/test-web-message-stage-continuity.ts delete mode 100644 scripts/test-web-module-plan.ts delete mode 100644 scripts/test-web-modules.ts delete mode 100644 scripts/test-web-motion.ts delete mode 100644 scripts/test-web-onboarding-post-continuity.ts delete mode 100644 scripts/test-web-openai-problems.ts delete mode 100644 scripts/test-web-overview-post-continuity.ts delete mode 100644 scripts/test-web-personal-approval-continuity.ts delete mode 100644 scripts/test-web-plan-structure.ts delete mode 100644 scripts/test-web-practice.ts delete mode 100644 scripts/test-web-preparation.ts delete mode 100644 scripts/test-web-preview.ts delete mode 100644 scripts/test-web-problem-demo.ts delete mode 100644 scripts/test-web-problem-drafts.ts delete mode 100644 scripts/test-web-problem-lifecycle.ts delete mode 100644 scripts/test-web-project-attempt-reuse.ts delete mode 100644 scripts/test-web-project-drafts.ts delete mode 100644 scripts/test-web-project-participation.ts delete mode 100644 scripts/test-web-proof-thinking.ts delete mode 100644 scripts/test-web-readable-results.ts delete mode 100644 scripts/test-web-recovery-context.ts delete mode 100644 scripts/test-web-recovery-library-context.ts delete mode 100644 scripts/test-web-research-collections.ts delete mode 100644 scripts/test-web-research-completion.ts delete mode 100644 scripts/test-web-research-decisions-followthrough.ts delete mode 100644 scripts/test-web-research-decisions-lifecycle.ts delete mode 100644 scripts/test-web-research-depth.ts delete mode 100644 scripts/test-web-research-draft-lifecycle.ts delete mode 100644 scripts/test-web-research-entry.ts delete mode 100644 scripts/test-web-research-information.ts delete mode 100644 scripts/test-web-research-journey.ts delete mode 100644 scripts/test-web-research-lean.ts delete mode 100644 scripts/test-web-research-library-trials.ts delete mode 100644 scripts/test-web-research-login-navigation.ts delete mode 100644 scripts/test-web-research-notifications.ts delete mode 100644 scripts/test-web-research-personal.ts delete mode 100644 scripts/test-web-research-problem.ts delete mode 100644 scripts/test-web-research-progress.ts delete mode 100644 scripts/test-web-research-run-continuity.ts delete mode 100644 scripts/test-web-research-space.ts delete mode 100644 scripts/test-web-research-start-planning.ts delete mode 100644 scripts/test-web-research-workspace.ts delete mode 100644 scripts/test-web-results.ts delete mode 100644 scripts/test-web-review-product-continuity.ts delete mode 100644 scripts/test-web-reviews.ts delete mode 100644 scripts/test-web-round10-math.ts delete mode 100644 scripts/test-web-round10-routes.ts delete mode 100644 scripts/test-web-round10-workbench.ts delete mode 100644 scripts/test-web-round2-collaboration.ts delete mode 100644 scripts/test-web-round2-routes.ts delete mode 100644 scripts/test-web-round2-workbench.ts delete mode 100644 scripts/test-web-round3-approval.ts delete mode 100644 scripts/test-web-round3-collaboration.ts delete mode 100644 scripts/test-web-round3-library.ts delete mode 100644 scripts/test-web-round3-routes.ts delete mode 100644 scripts/test-web-round3-workbench.ts delete mode 100644 scripts/test-web-round4-library.ts delete mode 100644 scripts/test-web-round4-sharing.ts delete mode 100644 scripts/test-web-round5-collaboration.ts delete mode 100644 scripts/test-web-round5-library.ts delete mode 100644 scripts/test-web-round5-people.ts delete mode 100644 scripts/test-web-round5-workbench.ts delete mode 100644 scripts/test-web-round6-collaboration.ts delete mode 100644 scripts/test-web-round6-library.ts delete mode 100644 scripts/test-web-round6-people.ts delete mode 100644 scripts/test-web-round6-routes.ts delete mode 100644 scripts/test-web-round7-library.ts delete mode 100644 scripts/test-web-round7-people.ts delete mode 100644 scripts/test-web-round7-routes.ts delete mode 100644 scripts/test-web-round7-session.ts delete mode 100644 scripts/test-web-round8-approval.ts delete mode 100644 scripts/test-web-round8-keys.ts delete mode 100644 scripts/test-web-round8-routes.ts delete mode 100644 scripts/test-web-round9-availability.ts delete mode 100644 scripts/test-web-round9-mobile.ts delete mode 100644 scripts/test-web-round9-routes.ts delete mode 100644 scripts/test-web-run-monitor.ts delete mode 100644 scripts/test-web-runtime.ts delete mode 100644 scripts/test-web-schur-demo.ts delete mode 100644 scripts/test-web-server-plans.ts delete mode 100644 scripts/test-web-share-bookmark-notes.ts delete mode 100644 scripts/test-web-share-continuity.ts delete mode 100644 scripts/test-web-simple-workbench.ts delete mode 100644 scripts/test-web-skill-research.ts delete mode 100644 scripts/test-web-source-diff.ts delete mode 100644 scripts/test-web-source-handoff.ts delete mode 100644 scripts/test-web-source-reader.ts delete mode 100644 scripts/test-web-task-browser.ts delete mode 100644 scripts/test-web-task-source.ts delete mode 100644 scripts/test-web-team-continuity.ts delete mode 100644 scripts/test-web-workbench-ux.ts delete mode 100644 scripts/web-a11y.ts delete mode 100644 scripts/web-agent-action-fixture.ts delete mode 100644 scripts/web-trajectory-fixture.ts diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..55a0ad4d --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index bbd0a75a..8ff95be9 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -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 @@ -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 @@ -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 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..e5831c07 --- /dev/null +++ b/.prettierignore @@ -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 diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..437568fb --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "printWidth": 120, + "singleQuote": true, + "semi": true, + "arrowParens": "avoid" +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..43135e34 --- /dev/null +++ b/CONTRIBUTING.md @@ -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/.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-.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 配置,不为验证本地改动调用真实模型。 +- 维护工作不得直接干预具体题目的求解过程(指导投递、改证明或进度、替题目提交);问题应通过调度、上下文、工具、检索等通用机制修复。 diff --git a/README.md b/README.md index 96dba19c..4b8a4042 100644 --- a/README.md +++ b/README.md @@ -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 & 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 & Archive Architecture](./docs/website.md) · [Release Trial Notes](./docs/web-release-trial.md) · [v0.1.0 Release Notes](./docs/releases/v0.1.0.md)
diff --git a/apps/web/admission.ts b/apps/web/admission.ts index b83d193f..7bf1e232 100644 --- a/apps/web/admission.ts +++ b/apps/web/admission.ts @@ -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 { @@ -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; diff --git a/apps/web/agentActions.ts b/apps/web/agentActions.ts index 6d64968b..e6787266 100644 --- a/apps/web/agentActions.ts +++ b/apps/web/agentActions.ts @@ -3,9 +3,19 @@ import { assertMathCanonicalPath, repositoryRelativePath } from '../../src/math/ import { mathDigest, readMathFile, readMathText } from '../../src/math/mathRuntimeIo'; import { currentWorkerProject } from '../../src/solver/workerProject'; import { teamEvidenceRefSchema } from '../../src/solver/agentTeamEvidenceRef'; -import { webAgentActionKinds, webAgentActionLimits as limits, webLeanClassifications, type WebAgentActionBody, - type WebAgentActionIntent, type WebAgentFileChange, type WebAgentLeanCheck, type WebLeanMessage, - type WebAgentLeanSearch, type WebAgentLibraryAction, type WebAgentLibraryDeclaration } from './shared'; +import { + webAgentActionKinds, + webAgentActionLimits as limits, + webLeanClassifications, + type WebAgentActionBody, + type WebAgentActionIntent, + type WebAgentFileChange, + type WebAgentLeanCheck, + type WebLeanMessage, + type WebAgentLeanSearch, + type WebAgentLibraryAction, + type WebAgentLibraryDeclaration, +} from './shared'; type Item = Record; export type AgentActionContext = { @@ -24,9 +34,11 @@ const escape = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&'); const notName = '(?![A-Za-z0-9._-])'; const ansi = /\u001b\[[0-9;?]*[ -/]*[@-~]/gu; const lockLine = /^\{"event":"lean_lock_(?:waiting|acquired)"[^\n]*\}\n?/gmu; -const string = (value: unknown) => typeof value === 'string' ? value : undefined; -const object = (value: unknown): Item | undefined => value && typeof value === 'object' && !Array.isArray(value) ? value as Item : undefined; -const count = (value: unknown) => typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined; +const string = (value: unknown) => (typeof value === 'string' ? value : undefined); +const object = (value: unknown): Item | undefined => + value && typeof value === 'object' && !Array.isArray(value) ? (value as Item) : undefined; +const count = (value: unknown) => + typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value : undefined; function clip(value: string, limit: number) { if (value.length <= limit) return { text: value, clipped: false }; @@ -35,7 +47,10 @@ function clip(value: string, limit: number) { /** The start and the end of a long output; the middle is what a reader skips. */ function clipOutput(value: string) { if (value.length <= limits.output) return { text: value, clipped: false }; - return { text: `${value.slice(0, limits.outputHead)}\n…\n${value.slice(value.length - (limits.output - limits.outputHead - 3))}`, clipped: true }; + return { + text: `${value.slice(0, limits.outputHead)}\n…\n${value.slice(value.length - (limits.output - limits.outputHead - 3))}`, + clipped: true, + }; } /** `bash -lc '…'` as the command inside it. */ export function unwrapShell(command: string) { @@ -47,50 +62,96 @@ export function unwrapShell(command: string) { /** Replaces the Agent's workspace with "." and every host directory with "…"; `hidden` says whether one appeared. */ export function createAgentPathMask(context: AgentActionContext) { const rules: RegExp[] = []; - const tool = context.tool ? new RegExp(String.raw`\bbun\s+'?${escape(path.resolve(context.tool))}'?`, 'gu') : undefined; + const tool = context.tool + ? new RegExp(String.raw`\bbun\s+'?${escape(path.resolve(context.tool))}'?`, 'gu') + : undefined; const own = new RegExp(escape(path.resolve(context.worktree)) + notName, 'gu'); for (const root of [...new Set(context.hidden.map(item => path.resolve(item)))].sort((a, b) => b.length - a.length)) - rules.push(new RegExp(escape(root) + notName + "(?:/[^\\s'\"`;|&)\\]}]*)?", 'gu')); + rules.push(new RegExp(escape(root) + notName + '(?:/[^\\s\'"`;|&)\\]}]*)?', 'gu')); return (value: string) => { let text = context.apiKey && context.apiKey.length >= 8 ? value.replaceAll(context.apiKey, '[REDACTED]') : value; if (tool) text = text.replace(tool, 'math'); text = text.replace(own, '.'); let hidden = false; - for (const rule of rules) text = text.replace(rule, () => { hidden = true; return '…'; }); + for (const rule of rules) + text = text.replace(rule, () => { + hidden = true; + return '…'; + }); return { text, hidden }; }; } -const statuses: Record = { inProgress: 'running', completed: 'done', failed: 'failed', declined: 'declined' }; +const statuses: Record = { + inProgress: 'running', + completed: 'done', + failed: 'failed', + declined: 'declined', +}; // Streaming items start empty; only those that run for a while are worth a "running" row. -const startedKinds = new Set(['commandExecution', 'webSearch', 'mcpToolCall', 'dynamicToolCall', 'reasoning', 'agentMessage', 'collabAgentToolCall']); +const startedKinds = new Set([ + 'commandExecution', + 'webSearch', + 'mcpToolCall', + 'dynamicToolCall', + 'reasoning', + 'agentMessage', + 'collabAgentToolCall', +]); const collaborationTools = new Map([ - ['spawnAgent', 'spawn_agent'], ['sendInput', 'send_input'], ['resumeAgent', 'resume_agent'], ['wait', 'wait_agent'], - ['closeAgent', 'close_agent'], ['sendMessage', 'send_message'], ['followupTask', 'followup_task'], - ['interruptAgent', 'interrupt_agent'], ['listAgents', 'list_agents'], + ['spawnAgent', 'spawn_agent'], + ['sendInput', 'send_input'], + ['resumeAgent', 'resume_agent'], + ['wait', 'wait_agent'], + ['closeAgent', 'close_agent'], + ['sendMessage', 'send_message'], + ['followupTask', 'followup_task'], + ['interruptAgent', 'interrupt_agent'], + ['listAgents', 'list_agents'], ]); const subAgentActivities = new Map([ - ['started', 'agent_started'], ['interacted', 'agent_contacted'], ['interrupted', 'agent_interrupted'], ['completed', 'agent_turn_completed'], + ['started', 'agent_started'], + ['interacted', 'agent_contacted'], + ['interrupted', 'agent_interrupted'], + ['completed', 'agent_turn_completed'], ]); /** The last JSON object a command printed; the Agent's tools end with their result on one line. */ function lastJson(output: string): Item | undefined { - const line = output.trimEnd().split('\n').reverse().find(value => value.startsWith('{')); - try { return line ? object(JSON.parse(line)) : undefined; } catch { return; } + const line = output + .trimEnd() + .split('\n') + .reverse() + .find(value => value.startsWith('{')); + try { + return line ? object(JSON.parse(line)) : undefined; + } catch { + return; + } } const digest = (value: unknown): value is string => typeof value === 'string' && /^[a-f0-9]{64}$/u.test(value); const classification = (value: unknown) => webLeanClassifications.find(item => item === value); export function sanitizeAgentLeanCheck(result: Item, mask: (value: string) => string): WebAgentLeanCheck | undefined { const classified = classification(result.classification); - if (typeof result.timedOut !== 'boolean' || !Array.isArray(result.messages) && !classified) return; + if (typeof result.timedOut !== 'boolean' || (!Array.isArray(result.messages) && !classified)) return; const messageView = (value: unknown): WebLeanMessage | undefined => { - const message = object(value), severity = message?.severity, text = string(message?.message); + const message = object(value), + severity = message?.severity, + text = string(message?.message); if (!message || !text || (severity !== 'error' && severity !== 'warning' && severity !== 'info')) return; - const file = string(message.file), line = count(message.line), column = count(message.column), goalText = string(message.goalText); - return { severity, ...(file ? { file: clip(mask(file), 1_000).text } : {}), ...(line !== undefined ? { line } : {}), - ...(column !== undefined ? { column } : {}), text: clip(mask(text).trim(), limits.leanMessage).text, - ...(goalText && { goalText: clip(mask(goalText), limits.leanMessage).text }) }; + const file = string(message.file), + line = count(message.line), + column = count(message.column), + goalText = string(message.goalText); + return { + severity, + ...(file ? { file: clip(mask(file), 1_000).text } : {}), + ...(line !== undefined ? { line } : {}), + ...(column !== undefined ? { column } : {}), + text: clip(mask(text).trim(), limits.leanMessage).text, + ...(goalText && { goalText: clip(mask(goalText), limits.leanMessage).text }), + }; }; const all = (Array.isArray(result.messages) ? result.messages : []).flatMap(value => { const message = messageView(value); @@ -103,32 +164,64 @@ export function sanitizeAgentLeanCheck(result: Item, mask: (value: string) => st } const firstBlocking = messageView(result.firstBlocking); // Errors first: a reader wants what blocks the proof before its warnings. - const ordered = [...all.filter(message => message.severity === 'error'), ...all.filter(message => message.severity !== 'error')]; + const ordered = [ + ...all.filter(message => message.severity === 'error'), + ...all.filter(message => message.severity !== 'error'), + ]; const messages = ordered.slice(0, limits.leanMessages); - const artifacts = (Array.isArray(result.diagnosticArtifacts) ? result.diagnosticArtifacts : []).flatMap(value => { - const ref = object(value), file = string(ref?.path); - if (!ref || !file || !repositoryRelativePath(file) || !file.startsWith('.lake/') || file.length > 1_000 || - !digest(ref.digest) || !digest(ref.sourceDigest) || !digest(ref.environmentDigest)) return []; - return [{ path: file, digest: ref.digest, sourceDigest: ref.sourceDigest, environmentDigest: ref.environmentDigest }]; - }).slice(-limits.leanArtifacts); + const artifacts = (Array.isArray(result.diagnosticArtifacts) ? result.diagnosticArtifacts : []) + .flatMap(value => { + const ref = object(value), + file = string(ref?.path); + if ( + !ref || + !file || + !repositoryRelativePath(file) || + !file.startsWith('.lake/') || + file.length > 1_000 || + !digest(ref.digest) || + !digest(ref.sourceDigest) || + !digest(ref.environmentDigest) + ) + return []; + return [ + { path: file, digest: ref.digest, sourceDigest: ref.sourceDigest, environmentDigest: ref.environmentDigest }, + ]; + }) + .slice(-limits.leanArtifacts); const omitted = all.length - messages.length + (count(result.omittedMessages) ?? 0); - return { passed: result.exitCode === 0 && !result.timedOut, ...(result.timedOut ? { timedOut: true } : {}), messages, - ...(omitted ? { omittedMessages: omitted } : {}), ...(firstBlocking && { firstBlocking }), - ...(classified && { classification: classified }), ...(digest(result.sourceDigest) && { sourceDigest: result.sourceDigest }), + return { + passed: result.exitCode === 0 && !result.timedOut, + ...(result.timedOut ? { timedOut: true } : {}), + messages, + ...(omitted ? { omittedMessages: omitted } : {}), + ...(firstBlocking && { firstBlocking }), + ...(classified && { classification: classified }), + ...(digest(result.sourceDigest) && { sourceDigest: result.sourceDigest }), ...(digest(result.environmentDigest) && { environmentDigest: result.environmentDigest }), - ...(artifacts.length && { artifacts }) }; + ...(artifacts.length && { artifacts }), + }; } /** Copy a bounded source only while its exact bytes still match the saved diagnostic artifact. */ -function checkedLeanSource(lean: WebAgentLeanCheck, result: Item, context: AgentActionContext, - mask: (value: string) => string): WebAgentLeanCheck['checkedSource'] { - if (!lean.artifacts?.length || !lean.sourceDigest || !lean.environmentDigest || - lean.classification !== 'lean' && lean.classification !== 'success') return; +function checkedLeanSource( + lean: WebAgentLeanCheck, + result: Item, + context: AgentActionContext, + mask: (value: string) => string, +): WebAgentLeanCheck['checkedSource'] { + if ( + !lean.artifacts?.length || + !lean.sourceDigest || + !lean.environmentDigest || + (lean.classification !== 'lean' && lean.classification !== 'success') + ) + return; try { const project = currentWorkerProject(context.worktree); const projectPrefix = mask(project).replace(/\/$/u, '') + '/'; - const localPath = (file?: string) => file?.startsWith(projectPrefix) - ? file.slice(projectPrefix.length) : file?.replace(/^\.\//u, ''); + const localPath = (file?: string) => + file?.startsWith(projectPrefix) ? file.slice(projectPrefix.length) : file?.replace(/^\.\//u, ''); const blocking = localPath(lean.firstBlocking?.file); for (const ref of lean.artifacts.toReversed()) { if (ref.sourceDigest !== lean.sourceDigest || ref.environmentDigest !== lean.environmentDigest) continue; @@ -136,15 +229,26 @@ function checkedLeanSource(lean: WebAgentLeanCheck, result: Item, context: Agent assertMathCanonicalPath(artifact); const text = readMathText(artifact, 10 * 1024 * 1024); if (mathDigest(text) !== ref.digest) continue; - const record = object(JSON.parse(text)), file = string(record?.file); - if (!record || record.schema !== 'theoremos.lean-diagnostics.v1' || record.sourceCurrent !== true || - record.sourceDigest !== lean.sourceDigest || record.environmentDigest !== lean.environmentDigest || - record.exitCode !== result.exitCode || !file || !file.endsWith('.lean') || !repositoryRelativePath(file) || - blocking && blocking !== file) continue; + const record = object(JSON.parse(text)), + file = string(record?.file); + if ( + !record || + record.schema !== 'theoremos.lean-diagnostics.v1' || + record.sourceCurrent !== true || + record.sourceDigest !== lean.sourceDigest || + record.environmentDigest !== lean.environmentDigest || + record.exitCode !== result.exitCode || + !file || + !file.endsWith('.lean') || + !repositoryRelativePath(file) || + (blocking && blocking !== file) + ) + continue; const suffix = '.lake/diagnostic-artifacts/' + ref.digest + '.json'; if (!ref.path.endsWith(suffix)) continue; const root = path.join(project, ref.path.slice(0, -suffix.length)); - const identity = Array.isArray(record.sourceFiles) && record.sourceFiles.map(object).find(source => source?.file === file); + const identity = + Array.isArray(record.sourceFiles) && record.sourceFiles.map(object).find(source => source?.file === file); if (!identity || !digest(identity.digest)) continue; const absolute = path.join(root, file); assertMathCanonicalPath(absolute); @@ -156,58 +260,129 @@ function checkedLeanSource(lean: WebAgentLeanCheck, result: Item, context: Agent if (localPath(message.file) === file) message.file = file; return { file, digest: identity.digest, text: source, artifact: ref.digest }; } - } catch { /* The diagnostic remains readable when the source is gone, moved or changed. */ } + } catch { + /* The diagnostic remains readable when the source is gone, moved or changed. */ + } } function leanSearch(result: Item, mask: (value: string) => string): WebAgentLeanSearch | undefined { - const queries = Array.isArray(result.queries) ? result.queries : string(result.query) !== undefined ? [result] : undefined; + const queries = Array.isArray(result.queries) + ? result.queries + : string(result.query) !== undefined + ? [result] + : undefined; if (!queries) return; const found = queries.slice(0, limits.queries).flatMap(value => { - const entry = object(value), query = string(entry?.query); + const entry = object(value), + query = string(entry?.query); if (!entry || query === undefined || !Array.isArray(entry.results)) return []; - const names = entry.results.flatMap(match => { - const name = string(object(match)?.qualifiedName) ?? string(object(match)?.name); - return name ? [clip(name, limits.name).text] : []; - }).slice(0, limits.names); - return [{ query: clip(mask(query), limits.query).text, total: count(entry.totalMatches) ?? entry.results.length, names }]; + const names = entry.results + .flatMap(match => { + const name = string(object(match)?.qualifiedName) ?? string(object(match)?.name); + return name ? [clip(name, limits.name).text] : []; + }) + .slice(0, limits.names); + return [ + { query: clip(mask(query), limits.query).text, total: count(entry.totalMatches) ?? entry.results.length, names }, + ]; }); return found.length ? found : undefined; } -function libraryAction(result: Item, command: string, mask: (value: string) => string): WebAgentLibraryAction | undefined { +function libraryAction( + result: Item, + command: string, + mask: (value: string) => string, +): WebAgentLibraryAction | undefined { const operation = /\blibrary\s+(search|get|request)\b/u.exec(command)?.[1]; - const schema = operation === 'search' ? 'theorem-os.library-search.v1' : operation === 'get' ? 'theorem-os.library-source.v1' - : operation === 'request' ? 'theorem-os.library-request-result.v1' : undefined; - const identity = object(result.library), id = string(identity?.id), revision = string(identity?.revision), catalogDigest = string(identity?.catalogDigest); - if (!schema || result.schema !== schema || !id || !revision || !catalogDigest || !/^[a-f0-9]{64}$/u.test(catalogDigest)) return; - const library = { id: clip(mask(id), limits.name).text, revision: clip(mask(revision), limits.name).text, catalogDigest }; + const schema = + operation === 'search' + ? 'theorem-os.library-search.v1' + : operation === 'get' + ? 'theorem-os.library-source.v1' + : operation === 'request' + ? 'theorem-os.library-request-result.v1' + : undefined; + const identity = object(result.library), + id = string(identity?.id), + revision = string(identity?.revision), + catalogDigest = string(identity?.catalogDigest); + if ( + !schema || + result.schema !== schema || + !id || + !revision || + !catalogDigest || + !/^[a-f0-9]{64}$/u.test(catalogDigest) + ) + return; + const library = { + id: clip(mask(id), limits.name).text, + revision: clip(mask(revision), limits.name).text, + catalogDigest, + }; const declaration = (value: unknown): WebAgentLibraryDeclaration | undefined => { - const entry = object(value), name = string(entry?.name), installation = entry?.installation; - if (!name || installation !== 'installed-frozen' && installation !== 'not-installed') return; + const entry = object(value), + name = string(entry?.name), + installation = entry?.installation; + if (!name || (installation !== 'installed-frozen' && installation !== 'not-installed')) return; return { name: clip(mask(name), limits.name).text, installation }; }; const declarations = (value: unknown) => { if (!Array.isArray(value)) return; const entries = value.map(declaration); if (entries.some(entry => !entry)) return; - return { entries: (entries as WebAgentLibraryDeclaration[]).slice(0, limits.names), omitted: Math.max(0, entries.length - limits.names) }; + return { + entries: (entries as WebAgentLibraryDeclaration[]).slice(0, limits.names), + omitted: Math.max(0, entries.length - limits.names), + }; }; if (operation === 'search') { - const query = string(result.query), goal = string(result.goal), hits = declarations(result.hits), references = declarations(result.namedReferences); + const query = string(result.query), + goal = string(result.goal), + hits = declarations(result.hits), + references = declarations(result.namedReferences); if (query === undefined || !hits || !references) return; - return { library, operation, query: clip(mask(query), limits.query).text, ...(goal ? { goal: clip(mask(goal), limits.query).text } : {}), - hits: hits.entries, namedReferences: references.entries, ...(hits.omitted ? { omittedHits: hits.omitted } : {}), - ...(references.omitted ? { omittedReferences: references.omitted } : {}) }; + return { + library, + operation, + query: clip(mask(query), limits.query).text, + ...(goal ? { goal: clip(mask(goal), limits.query).text } : {}), + hits: hits.entries, + namedReferences: references.entries, + ...(hits.omitted ? { omittedHits: hits.omitted } : {}), + ...(references.omitted ? { omittedReferences: references.omitted } : {}), + }; } if (operation === 'get') { - const source = object(result.source), offset = count(source?.offset), nextOffset = source?.nextOffset, complete = source?.complete; + const source = object(result.source), + offset = count(source?.offset), + nextOffset = source?.nextOffset, + complete = source?.complete; const entry = declaration({ ...object(result.declaration), installation: result.installation }); - if (!entry || offset === undefined || typeof complete !== 'boolean' || - (complete ? nextOffset !== null : count(nextOffset) === undefined || (nextOffset as number) <= offset)) return; - return { library, operation, declaration: entry, source: { offset, nextOffset: nextOffset as number | null, complete } }; + if ( + !entry || + offset === undefined || + typeof complete !== 'boolean' || + (complete ? nextOffset !== null : count(nextOffset) === undefined || (nextOffset as number) <= offset) + ) + return; + return { + library, + operation, + declaration: entry, + source: { offset, nextOffset: nextOffset as number | null, complete }, + }; } if (operation === 'request') { - const entries = declarations(result.declarations), status = result.status; - if (!entries?.entries.length || status !== 'queued' && status !== 'already-installed') return; - return { library, operation, status, declarations: entries.entries, ...(entries.omitted ? { omittedDeclarations: entries.omitted } : {}) }; + const entries = declarations(result.declarations), + status = result.status; + if (!entries?.entries.length || (status !== 'queued' && status !== 'already-installed')) return; + return { + library, + operation, + status, + declarations: entries.entries, + ...(entries.omitted ? { omittedDeclarations: entries.omitted } : {}), + }; } } @@ -215,21 +390,40 @@ function libraryAction(result: Item, command: string, mask: (value: string) => s * One Codex thread item as the run's owner may see it, or undefined for items that are the host's own words * (its prompts and context) or that carry nothing to show. */ -export function sanitizeAgentItem(phase: 'started' | 'completed', item: Item, context: AgentActionContext): WebAgentActionBody | undefined { - const type = string(item.type), itemId = string(item.id); +export function sanitizeAgentItem( + phase: 'started' | 'completed', + item: Item, + context: AgentActionContext, +): WebAgentActionBody | undefined { + const type = string(item.type), + itemId = string(item.id); if (!type || !itemId || itemId.length > 200 || (phase === 'started' && !startedKinds.has(type))) return; - const mask = createAgentPathMask(context), shown = (value: string) => mask(value.replace(ansi, '')).text; + const mask = createAgentPathMask(context), + shown = (value: string) => mask(value.replace(ansi, '')).text; const base = { workerId: context.workerId, itemId, phase }; - const status = (fallback: WebAgentActionBody['status']) => statuses[string(item.status) ?? ''] ?? (phase === 'started' ? 'running' : fallback); - const text = (value: string | undefined, kind: WebAgentActionBody['kind'], fallback: WebAgentActionBody['status'] = 'done'): WebAgentActionBody => { + const status = (fallback: WebAgentActionBody['status']) => + statuses[string(item.status) ?? ''] ?? (phase === 'started' ? 'running' : fallback); + const text = ( + value: string | undefined, + kind: WebAgentActionBody['kind'], + fallback: WebAgentActionBody['status'] = 'done', + ): WebAgentActionBody => { const clipped = clip(shown(value ?? '').trim(), limits.text); - return { ...base, kind, status: phase === 'started' ? 'running' : fallback, ...(clipped.text ? { text: clipped.text } : {}), ...(clipped.clipped ? { textClipped: true } : {}) }; + return { + ...base, + kind, + status: phase === 'started' ? 'running' : fallback, + ...(clipped.text ? { text: clipped.text } : {}), + ...(clipped.clipped ? { textClipped: true } : {}), + }; }; switch (type) { case 'commandExecution': { const raw = unwrapShell(string(item.command) ?? ''); - const command = mask(raw.replace(ansi, '')), cwd = string(item.cwd); - const outsideCwd = cwd !== undefined && path.relative(path.resolve(context.worktree), path.resolve(cwd)).startsWith('..'); + const command = mask(raw.replace(ansi, '')), + cwd = string(item.cwd); + const outsideCwd = + cwd !== undefined && path.relative(path.resolve(context.worktree), path.resolve(cwd)).startsWith('..'); const rawOutput = (string(item.aggregatedOutput) ?? '').replace(ansi, '').replace(lockLine, ''); const output = mask(rawOutput); // Completed mathematics tools read as bounded reports, their JSON only the carrier. The fields shown are masked; @@ -237,166 +431,412 @@ export function sanitizeAgentItem(phase: 'started' | 'completed', item: Item, co const result = !command.hidden && !outsideCwd && phase === 'completed' ? lastJson(output.text) : undefined; const masked = (value: string) => mask(value).text; const library = result ? libraryAction(result, command.text, masked) : undefined; - const lean = result && !library && /\bcheck-lean\b/u.test(command.text) ? sanitizeAgentLeanCheck(result, masked) : undefined; + const lean = + result && !library && /\bcheck-lean\b/u.test(command.text) ? sanitizeAgentLeanCheck(result, masked) : undefined; if (lean && result) { const source = checkedLeanSource(lean, result, context, masked); if (source) lean.checkedSource = source; - const work = object(result.candidate), candidate = teamEvidenceRefSchema.safeParse(work?.ref); + const work = object(result.candidate), + candidate = teamEvidenceRefSchema.safeParse(work?.ref); // Only a saved source and its check can substantiate a trial, including a Lean failure. - if (lean.checkedSource && work?.file === lean.checkedSource.file && context.solverRunId && candidate.success && raw.includes(candidate.data)) - lean.candidate = { ref: candidate.data, solverRunId: context.solverRunId, ...(context.nativeRole && { nativeRole: context.nativeRole }) }; + if ( + lean.checkedSource && + work?.file === lean.checkedSource.file && + context.solverRunId && + candidate.success && + raw.includes(candidate.data) + ) + lean.candidate = { + ref: candidate.data, + solverRunId: context.solverRunId, + ...(context.nativeRole && { nativeRole: context.nativeRole }), + }; } - const found = result && !library && !lean && /\bsearch-lean\b/u.test(command.text) ? leanSearch(result, masked) : undefined; + const found = + result && !library && !lean && /\bsearch-lean\b/u.test(command.text) ? leanSearch(result, masked) : undefined; const withheld = !library && !lean && !found && (command.hidden || output.hidden || outsideCwd); const shownCommand = clip(command.text.replace(/\b([a-f0-9]{12})[a-f0-9]{52}\b/gu, '$1…'), limits.command); - const intents = (Array.isArray(item.commandActions) ? item.commandActions : []).flatMap((value): WebAgentActionIntent[] => { - const action = object(value), kind = string(action?.type); - const type = kind === 'read' ? 'read' : kind === 'listFiles' ? 'list' : kind === 'search' ? 'search' : undefined; - if (!action || !type) return []; - const where = string(action.path), query = string(action.query); - return [{ type, ...(where ? { path: clip(mask(where).text, 1_000).text } : {}), ...(query ? { query: clip(shown(query), limits.query).text } : {}) }]; - }).slice(0, limits.intents); + const intents = (Array.isArray(item.commandActions) ? item.commandActions : []) + .flatMap((value): WebAgentActionIntent[] => { + const action = object(value), + kind = string(action?.type); + const type = + kind === 'read' ? 'read' : kind === 'listFiles' ? 'list' : kind === 'search' ? 'search' : undefined; + if (!action || !type) return []; + const where = string(action.path), + query = string(action.query); + return [ + { + type, + ...(where ? { path: clip(mask(where).text, 1_000).text } : {}), + ...(query ? { query: clip(shown(query), limits.query).text } : {}), + }, + ]; + }) + .slice(0, limits.intents); const tail = clipOutput(output.text.replace(/\s+$/u, '')); - const exitCode = typeof item.exitCode === 'number' && Number.isSafeInteger(item.exitCode) ? item.exitCode : undefined; + const exitCode = + typeof item.exitCode === 'number' && Number.isSafeInteger(item.exitCode) ? item.exitCode : undefined; // Whatever Codex calls it, a command that exited nonzero failed. const state = status('done'); - return { ...base, kind: 'command', status: state === 'done' && exitCode ? 'failed' : state, command: shownCommand.text, + return { + ...base, + kind: 'command', + status: state === 'done' && exitCode ? 'failed' : state, + command: shownCommand.text, ...(intents.length ? { intents } : {}), - ...(withheld ? { withheld: true } : library ? { library } : lean ? { lean } : found ? { found } : tail.text ? { output: tail.text, ...(tail.clipped ? { outputClipped: true } : {}) } : {}), - ...(exitCode !== undefined ? { exitCode } : {}), ...(count(item.durationMs) !== undefined ? { durationMs: count(item.durationMs) } : {}) }; + ...(withheld + ? { withheld: true } + : library + ? { library } + : lean + ? { lean } + : found + ? { found } + : tail.text + ? { output: tail.text, ...(tail.clipped ? { outputClipped: true } : {}) } + : {}), + ...(exitCode !== undefined ? { exitCode } : {}), + ...(count(item.durationMs) !== undefined ? { durationMs: count(item.durationMs) } : {}), + }; } case 'fileChange': { const all = Array.isArray(item.changes) ? item.changes : []; let budget = limits.diffs; const changes = all.slice(0, limits.changes).flatMap((value): WebAgentFileChange[] => { - const change = object(value), file = string(change?.path); + const change = object(value), + file = string(change?.path); if (!change || !file) return []; - const kind = string(object(change.kind)?.type), where = mask(file), moved = string(object(change.kind)?.move_path); - const diff = where.hidden ? undefined : clip(shown(string(change.diff) ?? ''), Math.min(limits.diff, Math.max(0, budget))); + const kind = string(object(change.kind)?.type), + where = mask(file), + moved = string(object(change.kind)?.move_path); + const diff = where.hidden + ? undefined + : clip(shown(string(change.diff) ?? ''), Math.min(limits.diff, Math.max(0, budget))); if (diff) budget -= diff.text.length; - return [{ path: clip(where.text, 1_000).text, change: kind === 'add' || kind === 'delete' ? kind : 'update', - ...(moved ? { movedTo: clip(mask(moved).text, 1_000).text } : {}), - ...(diff?.text ? { diff: diff.text } : {}), ...(diff?.clipped || (where.hidden && string(change.diff)) ? { clipped: true } : {}) }]; + return [ + { + path: clip(where.text, 1_000).text, + change: kind === 'add' || kind === 'delete' ? kind : 'update', + ...(moved ? { movedTo: clip(mask(moved).text, 1_000).text } : {}), + ...(diff?.text ? { diff: diff.text } : {}), + ...(diff?.clipped || (where.hidden && string(change.diff)) ? { clipped: true } : {}), + }, + ]; }); - return { ...base, kind: 'edit', status: status('done'), changes, ...(all.length > changes.length ? { omittedChanges: all.length - changes.length } : {}) }; + return { + ...base, + kind: 'edit', + status: status('done'), + changes, + ...(all.length > changes.length ? { omittedChanges: all.length - changes.length } : {}), + }; } case 'reasoning': { - const parts = (value: unknown) => Array.isArray(value) ? value.filter((part): part is string => typeof part === 'string' && part.trim() !== '') : []; + const parts = (value: unknown) => + Array.isArray(value) + ? value.filter((part): part is string => typeof part === 'string' && part.trim() !== '') + : []; const summary = parts(item.summary); if (!summary.length) return; return { ...text(summary.join('\n\n'), 'reasoning'), textSource: 'summary' }; } case 'agentMessage': { if (phase === 'started' && (item.phase !== 'commentary' || !string(item.text)?.trim())) return; - return { ...text(string(item.text), 'message'), ...(item.phase === 'commentary' ? { textSource: 'commentary' as const } : {}) }; + return { + ...text(string(item.text), 'message'), + ...(item.phase === 'commentary' ? { textSource: 'commentary' as const } : {}), + }; } - case 'plan': return text(string(item.text), 'plan'); + case 'plan': + return text(string(item.text), 'plan'); case 'webSearch': { - const action = object(item.action), query = string(item.query) ?? string(action?.query), url = string(action?.url); - return { ...base, kind: 'search', status: status('done'), ...(query ? { query: clip(shown(query), limits.query).text } : {}), - ...(url ? { url: clip(url, limits.query).text } : {}) }; + const action = object(item.action), + query = string(item.query) ?? string(action?.query), + url = string(action?.url); + return { + ...base, + kind: 'search', + status: status('done'), + ...(query ? { query: clip(shown(query), limits.query).text } : {}), + ...(url ? { url: clip(url, limits.query).text } : {}), + }; } - case 'mcpToolCall': case 'dynamicToolCall': { - const server = string(item.server) ?? string(item.namespace), name = string(item.tool) ?? 'tool'; - const args = item.arguments === undefined ? '' : clip(shown(JSON.stringify(item.arguments) ?? ''), limits.arguments).text; + case 'mcpToolCall': + case 'dynamicToolCall': { + const server = string(item.server) ?? string(item.namespace), + name = string(item.tool) ?? 'tool'; + const args = + item.arguments === undefined ? '' : clip(shown(JSON.stringify(item.arguments) ?? ''), limits.arguments).text; const failed = item.success === false || item.error; - return { ...base, kind: 'tool', status: status(failed ? 'failed' : 'done'), tool: clip(server ? `${server}.${name}` : name, 200).text, - ...(args && args !== '{}' && args !== 'null' ? { arguments: args } : {}), ...(count(item.durationMs) !== undefined ? { durationMs: count(item.durationMs) } : {}) }; + return { + ...base, + kind: 'tool', + status: status(failed ? 'failed' : 'done'), + tool: clip(server ? `${server}.${name}` : name, 200).text, + ...(args && args !== '{}' && args !== 'null' ? { arguments: args } : {}), + ...(count(item.durationMs) !== undefined ? { durationMs: count(item.durationMs) } : {}), + }; } case 'collabAgentToolCall': { const tool = collaborationTools.get(string(item.tool) ?? ''); if (!tool) return; // Native thread ids and raw tool prompts are unnecessary for displaying the action. - return { ...base, kind: 'tool', tool: 'collaboration.' + tool, - status: item.status === 'interrupted' ? 'failed' : status('done') }; + return { + ...base, + kind: 'tool', + tool: 'collaboration.' + tool, + status: item.status === 'interrupted' ? 'failed' : status('done'), + }; } case 'subAgentActivity': { - const activity = subAgentActivities.get(string(item.kind) ?? ''), agent = string(item.agentPath); + const activity = subAgentActivities.get(string(item.kind) ?? ''), + agent = string(item.agentPath); if (!activity) return; // This is a lifecycle observation, with proof acceptance reported separately by Lean. - return { ...base, kind: 'tool', tool: 'collaboration.' + activity, status: 'done', - ...(agent ? { arguments: clip(shown(agent), limits.arguments).text } : {}) }; + return { + ...base, + kind: 'tool', + tool: 'collaboration.' + activity, + status: 'done', + ...(agent ? { arguments: clip(shown(agent), limits.arguments).text } : {}), + }; } - case 'imageView': return { ...base, kind: 'tool', status: 'done', tool: 'view_image', arguments: clip(mask(string(item.path) ?? '').text, limits.arguments).text }; - case 'contextCompaction': return { ...base, kind: 'compaction', status: 'done' }; + case 'imageView': + return { + ...base, + kind: 'tool', + status: 'done', + tool: 'view_image', + arguments: clip(mask(string(item.path) ?? '').text, limits.arguments).text, + }; + case 'contextCompaction': + return { ...base, kind: 'compaction', status: 'done' }; // User messages and hook prompts are the host's instructions to the Agent, not something the Agent did. - default: return; + default: + return; } } -const keys = new Set(['workerId', 'itemId', 'phase', 'kind', 'status', 'command', 'intents', 'output', 'outputClipped', 'withheld', 'exitCode', - 'durationMs', 'lean', 'found', 'library', 'changes', 'omittedChanges', 'text', 'textClipped', 'textSource', 'query', 'url', 'tool', 'arguments']); -const short = (value: unknown, limit: number) => value === undefined || typeof value === 'string' && value.length <= limit; +const keys = new Set([ + 'workerId', + 'itemId', + 'phase', + 'kind', + 'status', + 'command', + 'intents', + 'output', + 'outputClipped', + 'withheld', + 'exitCode', + 'durationMs', + 'lean', + 'found', + 'library', + 'changes', + 'omittedChanges', + 'text', + 'textClipped', + 'textSource', + 'query', + 'url', + 'tool', + 'arguments', +]); +const short = (value: unknown, limit: number) => + value === undefined || (typeof value === 'string' && value.length <= limit); const flag = (value: unknown) => value === undefined || value === true; -const integer = (value: unknown) => value === undefined || typeof value === 'number' && Number.isSafeInteger(value); +const integer = (value: unknown) => value === undefined || (typeof value === 'number' && Number.isSafeInteger(value)); const only = (item: Item, allowed: readonly string[]) => Object.keys(item).every(key => allowed.includes(key)); export function isWebAgentLeanCheck(value: unknown): value is WebAgentLeanCheck { const lean = object(value); const diagnostic = (entry: unknown) => { - const message = object(entry); - return !!message && only(message, ['severity', 'file', 'line', 'column', 'text', 'goalText']) && - ['error', 'warning', 'info'].includes(message.severity as string) && short(message.file, 1_000) && - integer(message.line) && integer(message.column) && typeof message.text === 'string' && - short(message.text, limits.leanMessage) && short(message.goalText, limits.leanMessage); + const message = object(entry); + return ( + !!message && + only(message, ['severity', 'file', 'line', 'column', 'text', 'goalText']) && + ['error', 'warning', 'info'].includes(message.severity as string) && + short(message.file, 1_000) && + integer(message.line) && + integer(message.column) && + typeof message.text === 'string' && + short(message.text, limits.leanMessage) && + short(message.goalText, limits.leanMessage) + ); }; - if (!lean || !only(lean, ['passed', 'timedOut', 'messages', 'omittedMessages', 'firstBlocking', 'classification', - 'sourceDigest', 'environmentDigest', 'artifacts', 'checkedSource', 'candidate']) || typeof lean.passed !== 'boolean' || - !flag(lean.timedOut) || !integer(lean.omittedMessages) || - lean.classification !== undefined && !classification(lean.classification) || - lean.firstBlocking !== undefined && !diagnostic(lean.firstBlocking) || - lean.sourceDigest !== undefined && !digest(lean.sourceDigest) || lean.environmentDigest !== undefined && !digest(lean.environmentDigest) || - !Array.isArray(lean.messages) || lean.messages.length > limits.leanMessages || !lean.messages.every(diagnostic)) return false; - if (lean.artifacts !== undefined && (!Array.isArray(lean.artifacts) || lean.artifacts.length > limits.leanArtifacts || - !lean.artifacts.every(value => { - const ref = object(value); - return ref && only(ref, ['path', 'digest', 'sourceDigest', 'environmentDigest']) && typeof ref.path === 'string' && - short(ref.path, 1_000) && repositoryRelativePath(ref.path) && digest(ref.digest) && digest(ref.sourceDigest) && digest(ref.environmentDigest); - }))) return false; + if ( + !lean || + !only(lean, [ + 'passed', + 'timedOut', + 'messages', + 'omittedMessages', + 'firstBlocking', + 'classification', + 'sourceDigest', + 'environmentDigest', + 'artifacts', + 'checkedSource', + 'candidate', + ]) || + typeof lean.passed !== 'boolean' || + !flag(lean.timedOut) || + !integer(lean.omittedMessages) || + (lean.classification !== undefined && !classification(lean.classification)) || + (lean.firstBlocking !== undefined && !diagnostic(lean.firstBlocking)) || + (lean.sourceDigest !== undefined && !digest(lean.sourceDigest)) || + (lean.environmentDigest !== undefined && !digest(lean.environmentDigest)) || + !Array.isArray(lean.messages) || + lean.messages.length > limits.leanMessages || + !lean.messages.every(diagnostic) + ) + return false; + if ( + lean.artifacts !== undefined && + (!Array.isArray(lean.artifacts) || + lean.artifacts.length > limits.leanArtifacts || + !lean.artifacts.every(value => { + const ref = object(value); + return ( + ref && + only(ref, ['path', 'digest', 'sourceDigest', 'environmentDigest']) && + typeof ref.path === 'string' && + short(ref.path, 1_000) && + repositoryRelativePath(ref.path) && + digest(ref.digest) && + digest(ref.sourceDigest) && + digest(ref.environmentDigest) + ); + })) + ) + return false; const checked = object(lean.checkedSource); - if (lean.checkedSource !== undefined && (!checked || !only(checked, ['file', 'digest', 'text', 'artifact']) || - typeof checked.file !== 'string' || !short(checked.file, 1_000) || !repositoryRelativePath(checked.file) || - typeof checked.text !== 'string' || Buffer.byteLength(checked.text) > limits.leanSource || mathDigest(checked.text) !== checked.digest || - !Array.isArray(lean.artifacts) || !lean.artifacts.some(ref => ref.digest === checked.artifact && - ref.sourceDigest === lean.sourceDigest && ref.environmentDigest === lean.environmentDigest))) return false; + if ( + lean.checkedSource !== undefined && + (!checked || + !only(checked, ['file', 'digest', 'text', 'artifact']) || + typeof checked.file !== 'string' || + !short(checked.file, 1_000) || + !repositoryRelativePath(checked.file) || + typeof checked.text !== 'string' || + Buffer.byteLength(checked.text) > limits.leanSource || + mathDigest(checked.text) !== checked.digest || + !Array.isArray(lean.artifacts) || + !lean.artifacts.some( + ref => + ref.digest === checked.artifact && + ref.sourceDigest === lean.sourceDigest && + ref.environmentDigest === lean.environmentDigest, + )) + ) + return false; const candidate = object(lean.candidate); - return lean.candidate === undefined || Boolean(checked && candidate && only(candidate, ['ref', 'solverRunId', 'nativeRole']) && - (candidate.nativeRole === undefined || candidate.nativeRole === 'lead' || candidate.nativeRole === 'member') && - teamEvidenceRefSchema.safeParse(candidate.ref).success && typeof candidate.solverRunId === 'string' && - candidate.solverRunId.length > 0 && candidate.solverRunId.length <= 128); + return ( + lean.candidate === undefined || + Boolean( + checked && + candidate && + only(candidate, ['ref', 'solverRunId', 'nativeRole']) && + (candidate.nativeRole === undefined || candidate.nativeRole === 'lead' || candidate.nativeRole === 'member') && + teamEvidenceRefSchema.safeParse(candidate.ref).success && + typeof candidate.solverRunId === 'string' && + candidate.solverRunId.length > 0 && + candidate.solverRunId.length <= 128, + ) + ); } function isLeanSearch(value: unknown) { - return Array.isArray(value) && value.length >= 1 && value.length <= limits.queries && value.every(entry => { - const query = object(entry); - return !!query && only(query, ['query', 'total', 'names']) && typeof query.query === 'string' && short(query.query, limits.query) && - typeof query.total === 'number' && Number.isSafeInteger(query.total) && query.total >= 0 && Array.isArray(query.names) && - query.names.length <= limits.names && query.names.every(name => typeof name === 'string' && name.length <= limits.name); - }); + return ( + Array.isArray(value) && + value.length >= 1 && + value.length <= limits.queries && + value.every(entry => { + const query = object(entry); + return ( + !!query && + only(query, ['query', 'total', 'names']) && + typeof query.query === 'string' && + short(query.query, limits.query) && + typeof query.total === 'number' && + Number.isSafeInteger(query.total) && + query.total >= 0 && + Array.isArray(query.names) && + query.names.length <= limits.names && + query.names.every(name => typeof name === 'string' && name.length <= limits.name) + ); + }) + ); } function isLibraryAction(value: unknown) { - const action = object(value), identity = object(action?.library); + const action = object(value), + identity = object(action?.library); const requiredText = (value: unknown) => typeof value === 'string' && value.length > 0 && short(value, limits.name); const omitted = (value: unknown) => value === undefined || count(value) !== undefined; const declaration = (value: unknown) => { const item = object(value); - return !!item && only(item, ['name', 'installation']) && requiredText(item.name) && - ['installed-frozen', 'not-installed'].includes(item.installation as string); + return ( + !!item && + only(item, ['name', 'installation']) && + requiredText(item.name) && + ['installed-frozen', 'not-installed'].includes(item.installation as string) + ); }; - const declarations = (value: unknown) => Array.isArray(value) && value.length <= limits.names && value.every(declaration); - if (!action || !identity || !only(identity, ['id', 'revision', 'catalogDigest']) || !requiredText(identity.id) || !requiredText(identity.revision) || - typeof identity.catalogDigest !== 'string' || !/^[a-f0-9]{64}$/u.test(identity.catalogDigest)) return false; - if (action.operation === 'search') return only(action, ['library', 'operation', 'query', 'goal', 'hits', 'namedReferences', 'omittedHits', 'omittedReferences']) && - typeof action.query === 'string' && short(action.query, limits.query) && short(action.goal, limits.query) && declarations(action.hits) && - declarations(action.namedReferences) && omitted(action.omittedHits) && omitted(action.omittedReferences); + const declarations = (value: unknown) => + Array.isArray(value) && value.length <= limits.names && value.every(declaration); + if ( + !action || + !identity || + !only(identity, ['id', 'revision', 'catalogDigest']) || + !requiredText(identity.id) || + !requiredText(identity.revision) || + typeof identity.catalogDigest !== 'string' || + !/^[a-f0-9]{64}$/u.test(identity.catalogDigest) + ) + return false; + if (action.operation === 'search') + return ( + only(action, [ + 'library', + 'operation', + 'query', + 'goal', + 'hits', + 'namedReferences', + 'omittedHits', + 'omittedReferences', + ]) && + typeof action.query === 'string' && + short(action.query, limits.query) && + short(action.goal, limits.query) && + declarations(action.hits) && + declarations(action.namedReferences) && + omitted(action.omittedHits) && + omitted(action.omittedReferences) + ); if (action.operation === 'get') { const source = object(action.source); - return only(action, ['library', 'operation', 'declaration', 'source']) && declaration(action.declaration) && !!source && - only(source, ['offset', 'nextOffset', 'complete']) && count(source.offset) !== undefined && typeof source.complete === 'boolean' && - (source.complete ? source.nextOffset === null : count(source.nextOffset) !== undefined && (source.nextOffset as number) > (source.offset as number)); + return ( + only(action, ['library', 'operation', 'declaration', 'source']) && + declaration(action.declaration) && + !!source && + only(source, ['offset', 'nextOffset', 'complete']) && + count(source.offset) !== undefined && + typeof source.complete === 'boolean' && + (source.complete + ? source.nextOffset === null + : count(source.nextOffset) !== undefined && (source.nextOffset as number) > (source.offset as number)) + ); } - return action.operation === 'request' && only(action, ['library', 'operation', 'status', 'declarations', 'omittedDeclarations']) && - ['queued', 'already-installed'].includes(action.status as string) && declarations(action.declarations) && - (action.declarations as unknown[]).length > 0 && omitted(action.omittedDeclarations); + return ( + action.operation === 'request' && + only(action, ['library', 'operation', 'status', 'declarations', 'omittedDeclarations']) && + ['queued', 'already-installed'].includes(action.status as string) && + declarations(action.declarations) && + (action.declarations as unknown[]).length > 0 && + omitted(action.omittedDeclarations) + ); } /** The shape and limits sanitizeAgentItem produces; the server accepts nothing else from a worker. */ @@ -405,83 +845,192 @@ export function isWebAgentActionBody(value: unknown): value is WebAgentActionBod if (!action || Object.keys(action).some(key => !keys.has(key))) return false; if (typeof action.workerId !== 'string' || !/^[a-zA-Z0-9_-]{1,64}$/u.test(action.workerId)) return false; if (typeof action.itemId !== 'string' || !action.itemId || action.itemId.length > 200) return false; - if (!['started', 'completed'].includes(action.phase as string) || !(webAgentActionKinds as readonly unknown[]).includes(action.kind)) return false; + if ( + !['started', 'completed'].includes(action.phase as string) || + !(webAgentActionKinds as readonly unknown[]).includes(action.kind) + ) + return false; if (!['running', 'done', 'failed', 'declined'].includes(action.status as string)) return false; - if (action.textSource !== undefined && !(action.textSource === 'summary' && action.kind === 'reasoning' - || action.textSource === 'commentary' && action.kind === 'message')) return false; - if (!short(action.command, limits.command) || !short(action.output, limits.output) || !short(action.text, limits.text) || - !short(action.query, limits.query) || !short(action.url, limits.query) || !short(action.tool, 200) || !short(action.arguments, limits.arguments)) return false; - if (![action.outputClipped, action.withheld, action.textClipped].every(flag) || ![action.exitCode, action.durationMs, action.omittedChanges].every(integer)) return false; - if ((action.lean !== undefined && !isWebAgentLeanCheck(action.lean)) || (action.found !== undefined && !isLeanSearch(action.found))) return false; - if (action.library !== undefined && (action.kind !== 'command' || action.phase !== 'completed' || !isLibraryAction(action.library) || - [action.lean, action.found, action.output, action.outputClipped, action.withheld].some(value => value !== undefined))) return false; - if (action.intents !== undefined && (!Array.isArray(action.intents) || action.intents.length > limits.intents || !action.intents.every(intent => { - const item = object(intent); - return item && Object.keys(item).every(key => ['type', 'path', 'query'].includes(key)) && ['read', 'list', 'search'].includes(item.type as string) && - short(item.path, 1_000) && short(item.query, limits.query); - }))) return false; - if (action.changes !== undefined && (!Array.isArray(action.changes) || action.changes.length > limits.changes || !action.changes.every(change => { - const item = object(change); - return item && Object.keys(item).every(key => ['path', 'change', 'movedTo', 'diff', 'clipped'].includes(key)) && typeof item.path === 'string' && - short(item.path, 1_000) && ['add', 'delete', 'update'].includes(item.change as string) && short(item.movedTo, 1_000) && short(item.diff, limits.diff) && flag(item.clipped); - }))) return false; + if ( + action.textSource !== undefined && + !( + (action.textSource === 'summary' && action.kind === 'reasoning') || + (action.textSource === 'commentary' && action.kind === 'message') + ) + ) + return false; + if ( + !short(action.command, limits.command) || + !short(action.output, limits.output) || + !short(action.text, limits.text) || + !short(action.query, limits.query) || + !short(action.url, limits.query) || + !short(action.tool, 200) || + !short(action.arguments, limits.arguments) + ) + return false; + if ( + ![action.outputClipped, action.withheld, action.textClipped].every(flag) || + ![action.exitCode, action.durationMs, action.omittedChanges].every(integer) + ) + return false; + if ( + (action.lean !== undefined && !isWebAgentLeanCheck(action.lean)) || + (action.found !== undefined && !isLeanSearch(action.found)) + ) + return false; + if ( + action.library !== undefined && + (action.kind !== 'command' || + action.phase !== 'completed' || + !isLibraryAction(action.library) || + [action.lean, action.found, action.output, action.outputClipped, action.withheld].some( + value => value !== undefined, + )) + ) + return false; + if ( + action.intents !== undefined && + (!Array.isArray(action.intents) || + action.intents.length > limits.intents || + !action.intents.every(intent => { + const item = object(intent); + return ( + item && + Object.keys(item).every(key => ['type', 'path', 'query'].includes(key)) && + ['read', 'list', 'search'].includes(item.type as string) && + short(item.path, 1_000) && + short(item.query, limits.query) + ); + })) + ) + return false; + if ( + action.changes !== undefined && + (!Array.isArray(action.changes) || + action.changes.length > limits.changes || + !action.changes.every(change => { + const item = object(change); + return ( + item && + Object.keys(item).every(key => ['path', 'change', 'movedTo', 'diff', 'clipped'].includes(key)) && + typeof item.path === 'string' && + short(item.path, 1_000) && + ['add', 'delete', 'update'].includes(item.change as string) && + short(item.movedTo, 1_000) && + short(item.diff, limits.diff) && + flag(item.clipped) + ); + })) + ) + return false; return JSON.stringify(action).length <= limits.encoded; } /** Coalesce only sanitized public text snapshots; lifecycle reports and tool actions remain immediate. */ export function createAgentActionStream(send: (action: WebAgentActionBody) => void) { - const reasoningIntervalMs = 4_000, reasoningPreviewBytes = 2_048; + const reasoningIntervalMs = 4_000, + reasoningPreviewBytes = 2_048; const runningPreview = (action: WebAgentActionBody) => { - if (action.kind !== 'reasoning' || !action.text || Buffer.byteLength(action.text) <= reasoningPreviewBytes) return action; + if (action.kind !== 'reasoning' || !action.text || Buffer.byteLength(action.text) <= reasoningPreviewBytes) + return action; const bytes = Buffer.from(action.text); let start = bytes.length - reasoningPreviewBytes + Buffer.byteLength('…'); while ((bytes[start]! & 0xc0) === 0x80) start++; return { ...action, text: '…' + bytes.toString('utf8', start), textClipped: true }; }; - type Entry = { sentAt?: number; signature?: string; latest?: WebAgentActionBody; pending?: WebAgentActionBody; - timer?: ReturnType; completed?: boolean }; + type Entry = { + sentAt?: number; + signature?: string; + latest?: WebAgentActionBody; + pending?: WebAgentActionBody; + timer?: ReturnType; + completed?: boolean; + }; const entries = new Map(); let accepting = true; - const deliver = (action: WebAgentActionBody) => { try { send(action); } catch { /* Observation never changes the run. */ } }; - const signature = (action: WebAgentActionBody) => JSON.stringify([action.kind, action.textSource, action.text, action.textClipped]); + const deliver = (action: WebAgentActionBody) => { + try { + send(action); + } catch { + /* Observation never changes the run. */ + } + }; + const signature = (action: WebAgentActionBody) => + JSON.stringify([action.kind, action.textSource, action.text, action.textClipped]); const emit = (entry: Entry, action: WebAgentActionBody) => { - entry.pending = undefined; entry.sentAt = Date.now(); entry.signature = signature(action); + entry.pending = undefined; + entry.sentAt = Date.now(); + entry.signature = signature(action); deliver(action); }; const stop = () => { accepting = false; - for (const entry of entries.values()) { clearTimeout(entry.timer); entry.timer = undefined; entry.pending = undefined; } + for (const entry of entries.values()) { + clearTimeout(entry.timer); + entry.timer = undefined; + entry.pending = undefined; + } }; return { - reset() { stop(); entries.clear(); accepting = true; }, + reset() { + stop(); + entries.clear(); + accepting = true; + }, stop, write(phase: 'started' | 'completed', itemId: string, action?: WebAgentActionBody, incremental = false) { let entry = entries.get(itemId); if (phase === 'completed') { if (entry?.completed) return; - if (!entry) { entry = {}; entries.set(itemId, entry); } - clearTimeout(entry.timer); entry.timer = undefined; entry.pending = undefined; entry.completed = true; + if (!entry) { + entry = {}; + entries.set(itemId, entry); + } + clearTimeout(entry.timer); + entry.timer = undefined; + entry.pending = undefined; + entry.completed = true; // Some clients omit text in the final lifecycle item. Preserve only an already sanitized public snapshot. - const retained = entry.latest ? { ...entry.latest, phase: 'completed' as const, status: 'done' as const } : undefined; - const final = action?.text === undefined && retained && (!action || action.textSource === retained.textSource) - ? { ...retained, ...action } : action; + const retained = entry.latest + ? { ...entry.latest, phase: 'completed' as const, status: 'done' as const } + : undefined; + const final = + action?.text === undefined && retained && (!action || action.textSource === retained.textSource) + ? { ...retained, ...action } + : action; if (final) deliver(final); return; } - if (!action || entry?.completed || incremental && (!accepting || !action.textSource || !action.text)) return; - if (!action.textSource) { if (!incremental) deliver(action); return; } - if (!entry) { entry = {}; entries.set(itemId, entry); } + if (!action || entry?.completed || (incremental && (!accepting || !action.textSource || !action.text))) return; + if (!action.textSource) { + if (!incremental) deliver(action); + return; + } + if (!entry) { + entry = {}; + entries.set(itemId, entry); + } entry.latest = action; const preview = runningPreview(action); - if (!incremental) { emit(entry, preview); return; } + if (!incremental) { + emit(entry, preview); + return; + } if (entry.signature === signature(preview)) { - clearTimeout(entry.timer); entry.timer = undefined; entry.pending = undefined; return; + clearTimeout(entry.timer); + entry.timer = undefined; + entry.pending = undefined; + return; } entry.pending = preview; const interval = action.kind === 'reasoning' ? reasoningIntervalMs : 1_000; const remaining = entry.sentAt === undefined ? 0 : Math.max(0, interval - (Date.now() - entry.sentAt)); - if (!remaining) { clearTimeout(entry.timer); entry.timer = undefined; emit(entry, preview); } - else if (!entry.timer) { + if (!remaining) { + clearTimeout(entry.timer); + entry.timer = undefined; + emit(entry, preview); + } else if (!entry.timer) { entry.timer = setTimeout(() => { entry!.timer = undefined; if (accepting && !entry!.completed && entry!.pending) emit(entry!, entry!.pending); diff --git a/apps/web/auth.ts b/apps/web/auth.ts index 65d0b4c6..6e81f858 100644 --- a/apps/web/auth.ts +++ b/apps/web/auth.ts @@ -10,8 +10,15 @@ import { accountLogin, type WebAccountIdentity } from './shared'; * `signup: 'open'` admits every valid email that can receive a code; the allowlist then only marks how an address * arrived. `termsVersion` names the terms an account has to accept when it first signs in. */ -export type WebAuthConfig = { smtpUrl: string; from: string; allowlist: string[]; allowlistFile?: string; admins?: string[]; - signup?: WebSignupMode; termsVersion?: string }; +export type WebAuthConfig = { + smtpUrl: string; + from: string; + allowlist: string[]; + allowlistFile?: string; + admins?: string[]; + signup?: WebSignupMode; + termsVersion?: string; +}; export type WebSignupMode = 'allowlist' | 'open'; /** Where an address is admitted from: only `file` entries can be removed in the workbench. */ export type WebAllowlistEntry = { email: string; source: 'admin' | 'config' | 'file' }; @@ -20,24 +27,44 @@ export type WebAllowlistEntry = { email: string; source: 'admin' | 'config' | 'f * acceptance; scripts/web-funnel.ts reports them only as totals, and they go with the account when it is deleted. * `completionEmail: false` turns off the mail sent when a run ends; absent means on. */ -export type WebAccount = WebAccountIdentity & { id: string; createdAt: string; firstLoginAt?: string; firstRunAt?: string; firstAcceptedAt?: string; completionEmail?: boolean; +export type WebAccount = WebAccountIdentity & { + id: string; + createdAt: string; + firstLoginAt?: string; + firstRunAt?: string; + firstAcceptedAt?: string; + completionEmail?: boolean; /** When this account accepted the terms, and which version; an open signup records it before the account exists. */ - termsAt?: string; termsVersion?: string; suspendedAt?: string }; + termsAt?: string; + termsVersion?: string; + suspendedAt?: string; +}; export type WebMilestone = 'firstRunAt' | 'firstAcceptedAt'; export type WebMailer = (message: { to: string; subject: string; text: string }) => Promise; export class WebAuthError extends Error { - constructor(readonly status: number, message: string) { super(message); } + constructor( + readonly status: number, + message: string, + ) { + super(message); + } } -const codeTtlMs = 10 * 60_000, captchaTtlMs = 5 * 60_000, resendAfterMs = 60_000; +const codeTtlMs = 10 * 60_000, + captchaTtlMs = 5 * 60_000, + resendAfterMs = 60_000; type PasswordRecord = { algorithm: 'scrypt'; salt: string; digest: string }; const samePasswordRecord = (a?: PasswordRecord, b?: PasswordRecord) => a?.salt === b?.salt && a?.digest === b?.digest; -const derivePassword = (password: string, salt: Buffer) => new Promise((resolve, reject) => - crypto.scrypt(password, salt, 64, { N: 1 << 15, r: 8, p: 1, maxmem: 64 * 1024 * 1024 }, - (error, key) => error ? reject(error) : resolve(key))); +const derivePassword = (password: string, salt: Buffer) => + new Promise((resolve, reject) => + crypto.scrypt(password, salt, 64, { N: 1 << 15, r: 8, p: 1, maxmem: 64 * 1024 * 1024 }, (error, key) => + error ? reject(error) : resolve(key), + ), + ); const validPassword = (value: unknown): value is string => typeof value === 'string' && value.length >= 12 && Buffer.byteLength(value, 'utf8') <= 256; -const emailPattern = /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/u; +const emailPattern = + /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/u; export const normalizeEmail = (value: unknown) => { const email = typeof value === 'string' ? value.trim().toLowerCase() : ''; if (email.length > 254 || !emailPattern.test(email)) throw new WebAuthError(400, '请输入有效的邮箱地址。'); @@ -53,30 +80,56 @@ export const normalizeLogin = (value: unknown): string => { /** Seven-segment strokes on a 20×36 cell; jitter and noise keep the answer out of the markup. */ const segments: Record = { - a: [[2, 2, 18, 2]], b: [[18, 2, 18, 18]], c: [[18, 18, 18, 34]], d: [[2, 34, 18, 34]], e: [[2, 18, 2, 34]], f: [[2, 2, 2, 18]], g: [[2, 18, 18, 18]], + a: [[2, 2, 18, 2]], + b: [[18, 2, 18, 18]], + c: [[18, 18, 18, 34]], + d: [[2, 34, 18, 34]], + e: [[2, 18, 2, 34]], + f: [[2, 2, 2, 18]], + g: [[2, 18, 18, 18]], }; const digits = ['abcdef', 'bc', 'abged', 'abgcd', 'fgbc', 'afgcd', 'afgedc', 'abc', 'abcdefg', 'abcdfg']; -const random = (min: number, max: number) => min + crypto.randomInt(0, 10_000) / 10_000 * (max - min); +const random = (min: number, max: number) => min + (crypto.randomInt(0, 10_000) / 10_000) * (max - min); export function captchaImage(answer: string): string { - const width = 36 + answer.length * 30, height = 56, parts: string[] = []; + const width = 36 + answer.length * 30, + height = 56, + parts: string[] = []; for (let line = 0; line < 4; line++) - parts.push(``); + parts.push( + ``, + ); [...answer].forEach((digit, index) => { - const x = 20 + index * 30 + random(-3, 3), y = 10 + random(-3, 3), angle = random(-14, 14).toFixed(1); - const strokes = [...digits[Number(digit)]!].flatMap(name => segments[name]!).map(([x1, y1, x2, y2]) => - `M${(x1 + random(-1.6, 1.6)).toFixed(1)} ${(y1 + random(-1.6, 1.6)).toFixed(1)}L${(x2 + random(-1.6, 1.6)).toFixed(1)} ${(y2 + random(-1.6, 1.6)).toFixed(1)}`).join(''); - parts.push(``); + const x = 20 + index * 30 + random(-3, 3), + y = 10 + random(-3, 3), + angle = random(-14, 14).toFixed(1); + const strokes = [...digits[Number(digit)]!] + .flatMap(name => segments[name]!) + .map( + ([x1, y1, x2, y2]) => + `M${(x1 + random(-1.6, 1.6)).toFixed(1)} ${(y1 + random(-1.6, 1.6)).toFixed(1)}L${(x2 + random(-1.6, 1.6)).toFixed(1)} ${(y2 + random(-1.6, 1.6)).toFixed(1)}`, + ) + .join(''); + parts.push( + ``, + ); }); for (let dot = 0; dot < 24; dot++) - parts.push(``); + parts.push( + ``, + ); return `${parts.join('')}`; } export function smtpMailer(config: WebAuthConfig): WebMailer { // A loopback-only development transport: the code goes to the server log instead of an inbox. - if (config.smtpUrl === 'log:') return async message => { console.error(`[login code] ${message.to}: ${message.text.match(/\b\d{6}\b/u)?.[0]}`); }; + if (config.smtpUrl === 'log:') + return async message => { + console.error(`[login code] ${message.to}: ${message.text.match(/\b\d{6}\b/u)?.[0]}`); + }; const transport = nodemailer.createTransport(config.smtpUrl); - return async message => { await transport.sendMail({ from: config.from, ...message }); }; + return async message => { + await transport.sendMail({ from: config.from, ...message }); + }; } type Limit = { times: number[] }; @@ -86,23 +139,35 @@ export class WebAuth { private readonly codes = new Map(); private readonly limits = new Map(); - constructor(private readonly config: WebAuthConfig, private readonly storage: WebStorage, + constructor( + private readonly config: WebAuthConfig, + private readonly storage: WebStorage, private readonly mailer: WebMailer = smtpMailer(config), - private readonly answer: () => string = () => String(crypto.randomInt(0, 100_000)).padStart(5, '0')) {} + private readonly answer: () => string = () => String(crypto.randomInt(0, 100_000)).padStart(5, '0'), + ) {} /** Sliding-window counter; returns false once `max` events already fall inside `windowMs`. */ private allow(key: string, max: number, windowMs: number): boolean { - const now = Date.now(), limit = this.limits.get(key) ?? { times: [] }; + const now = Date.now(), + limit = this.limits.get(key) ?? { times: [] }; limit.times = limit.times.filter(time => now - time < windowMs); - if (limit.times.length >= max) { this.limits.set(key, limit); return false; } - limit.times.push(now); this.limits.set(key, limit); return true; + if (limit.times.length >= max) { + this.limits.set(key, limit); + return false; + } + limit.times.push(now); + this.limits.set(key, limit); + return true; + } + private digest(email: string, code: string) { + return crypto.createHmac('sha256', this.secret).update(`${email}\n${code}`).digest(); } - private digest(email: string, code: string) { return crypto.createHmac('sha256', this.secret).update(`${email}\n${code}`).digest(); } prune() { const now = Date.now(); for (const [id, captcha] of this.captchas) if (captcha.expiresAt <= now) this.captchas.delete(id); for (const [email, code] of this.codes) if (code.expiresAt <= now) this.codes.delete(email); - for (const [key, limit] of this.limits) if (limit.times.every(time => now - time > 60 * 60_000)) this.limits.delete(key); + for (const [key, limit] of this.limits) + if (limit.times.every(time => now - time > 60 * 60_000)) this.limits.delete(key); } /** Allowlisted addresses from the environment and the allowlist file, which is read on every call. */ @@ -117,12 +182,20 @@ export class WebAuth { if (!login.includes('@')) return Boolean(account?.username); return this.config.signup === 'open' || this.allowlist().has(login); } - admins(): Set { return new Set(this.config.admins ?? []); } - isAdmin(email: string): boolean { return this.admins().has(email); } + admins(): Set { + return new Set(this.config.admins ?? []); + } + isAdmin(email: string): boolean { + return this.admins().has(email); + } /** `open` when anyone may register; the login page says so. */ - signup(): WebSignupMode { return this.config.signup ?? 'allowlist'; } + signup(): WebSignupMode { + return this.config.signup ?? 'allowlist'; + } /** The terms version a new account accepts; absent when the service does not ask. */ - get termsVersion(): string | undefined { return this.config.termsVersion; } + get termsVersion(): string | undefined { + return this.config.termsVersion; + } needsTerms(email: string): boolean { return Boolean(this.termsVersion && this.getAccount(email)?.termsVersion !== this.termsVersion); } @@ -142,7 +215,8 @@ export class WebAuth { } /** Suspension keeps records for restoration, blocks both login methods and invalidates admission on the next request. */ setSuspended(value: unknown, suspended: boolean): WebAccount { - const login = normalizeLogin(value), account = this.getAccount(login); + const login = normalizeLogin(value), + account = this.getAccount(login); if (!account) throw new WebAuthError(404, '账号不存在。'); if (this.isAdmin(login) && suspended) throw new WebAuthError(400, '管理员账号不能暂停。'); const { suspendedAt: _previous, ...rest } = account; @@ -157,7 +231,11 @@ export class WebAuth { while (lines.length && !lines.at(-1)!.trim()) lines.pop(); return lines; } - private fileEntries(): string[] { return this.fileLines().map(line => line.replace(/#.*/u, '').trim().toLowerCase()).filter(Boolean); } + private fileEntries(): string[] { + return this.fileLines() + .map(line => line.replace(/#.*/u, '').trim().toLowerCase()) + .filter(Boolean); + } /** Each admitted address once, with the most fixed source: an admin, then the environment, then the file. */ allowlistEntries(): WebAllowlistEntry[] { const entries = new Map(); @@ -168,7 +246,8 @@ export class WebAuth { } /** Appends an address to the allowlist file; comments and other lines are kept as written. */ addToAllowlist(value: unknown): WebAllowlistEntry { - const email = normalizeEmail(value), file = this.writableFile(); + const email = normalizeEmail(value), + file = this.writableFile(); const existing = this.allowlistEntries().find(entry => entry.email === email); if (existing) return existing; this.writeFile(file, [...this.fileLines(), email]); @@ -176,14 +255,20 @@ export class WebAuth { } /** Removes every file line for the address; an admin or environment entry cannot be removed here. */ removeFromAllowlist(value: unknown) { - const email = normalizeEmail(value), file = this.writableFile(); + const email = normalizeEmail(value), + file = this.writableFile(); const source = this.allowlistEntries().find(entry => entry.email === email)?.source; if (!source) throw new WebAuthError(404, '这个邮箱不在白名单中。'); if (source !== 'file') throw new WebAuthError(409, '这个邮箱由服务配置加入,需要在部署配置中移除。'); - this.writeFile(file, this.fileLines().filter(line => line.replace(/#.*/u, '').trim().toLowerCase() !== email)); + this.writeFile( + file, + this.fileLines().filter(line => line.replace(/#.*/u, '').trim().toLowerCase() !== email), + ); this.codes.delete(email); } - allowlistWritable(): boolean { return Boolean(this.config.allowlistFile); } + allowlistWritable(): boolean { + return Boolean(this.config.allowlistFile); + } private writableFile(): string { if (!this.config.allowlistFile) throw new WebAuthError(409, '服务没有配置白名单文件,无法在线修改。'); return this.config.allowlistFile; @@ -197,8 +282,10 @@ export class WebAuth { } captcha(ip: string): { id: string; image: string } { - if (!this.allow(`captcha:${ip}`, 30, 10 * 60_000) || this.captchas.size >= 5_000) throw new WebAuthError(429, '请求过于频繁,请稍后重试。'); - const id = crypto.randomUUID(), answer = this.answer(); + if (!this.allow(`captcha:${ip}`, 30, 10 * 60_000) || this.captchas.size >= 5_000) + throw new WebAuthError(429, '请求过于频繁,请稍后重试。'); + const id = crypto.randomUUID(), + answer = this.answer(); this.captchas.set(id, { answer, expiresAt: Date.now() + captchaTtlMs }); return { id, image: `data:image/svg+xml;base64,${Buffer.from(captchaImage(answer)).toString('base64')}` }; } @@ -210,27 +297,48 @@ export class WebAuth { if (!captcha || captcha.expiresAt <= Date.now() || String(body.captcha ?? '').trim() !== captcha.answer) throw new WebAuthError(400, '图形验证码不正确或已过期,请换一张重试。'); const email = normalizeEmail(body.email); - if (!this.allowed(email)) throw new WebAuthError(403, this.getAccount(email)?.suspendedAt - ? '这个账号目前无法使用,请联系支持。' : '这个邮箱还没有内测资格。请先申请内测,通过后再登录。'); + if (!this.allowed(email)) + throw new WebAuthError( + 403, + this.getAccount(email)?.suspendedAt + ? '这个账号目前无法使用,请联系支持。' + : '这个邮箱还没有内测资格。请先申请内测,通过后再登录。', + ); const previous = this.codes.get(email); - if (previous && Date.now() - previous.sentAt < resendAfterMs) throw new WebAuthError(429, '验证码刚刚发送过,请稍后再试。'); - if (!this.allow(`code-email:${email}`, 5, 60 * 60_000)) throw new WebAuthError(429, '这个邮箱的验证码请求过多,请一小时后再试。'); + if (previous && Date.now() - previous.sentAt < resendAfterMs) + throw new WebAuthError(429, '验证码刚刚发送过,请稍后再试。'); + if (!this.allow(`code-email:${email}`, 5, 60 * 60_000)) + throw new WebAuthError(429, '这个邮箱的验证码请求过多,请一小时后再试。'); const code = String(crypto.randomInt(0, 1_000_000)).padStart(6, '0'); try { - await this.mailer({ to: email, subject: `TheoremOS 登录验证码 ${code}`, - text: `你的 TheoremOS 登录验证码是 ${code},10 分钟内有效。\n如果不是你本人操作,请忽略这封邮件。\n\nYour TheoremOS login code is ${code}. It expires in 10 minutes.\n` }); - } catch { throw new WebAuthError(502, '验证码邮件发送失败,请稍后重试。'); } - this.codes.set(email, { digest: this.digest(email, code), expiresAt: Date.now() + codeTtlMs, attempts: 0, sentAt: Date.now() }); + await this.mailer({ + to: email, + subject: `TheoremOS 登录验证码 ${code}`, + text: `你的 TheoremOS 登录验证码是 ${code},10 分钟内有效。\n如果不是你本人操作,请忽略这封邮件。\n\nYour TheoremOS login code is ${code}. It expires in 10 minutes.\n`, + }); + } catch { + throw new WebAuthError(502, '验证码邮件发送失败,请稍后重试。'); + } + this.codes.set(email, { + digest: this.digest(email, code), + expiresAt: Date.now() + codeTtlMs, + attempts: 0, + sentAt: Date.now(), + }); return { email, expiresInSeconds: codeTtlMs / 1000, resendAfterSeconds: resendAfterMs / 1000 }; } /** `terms` is the signup form's checkbox; an open signup requires it before the account exists. */ verifyCode(body: { email?: unknown; code?: unknown; terms?: unknown; termsVersion?: unknown }): WebAccount { - const email = normalizeEmail(body.email), pending = this.codes.get(email); + const email = normalizeEmail(body.email), + pending = this.codes.get(email); if (!pending || pending.expiresAt <= Date.now()) throw new WebAuthError(400, '验证码已过期,请重新获取。'); const code = String(body.code ?? '').trim(); if (!/^\d{6}$/u.test(code) || !crypto.timingSafeEqual(pending.digest, this.digest(email, code))) { - if (++pending.attempts >= 5) { this.codes.delete(email); throw new WebAuthError(400, '验证码错误次数过多,请重新获取。'); } + if (++pending.attempts >= 5) { + this.codes.delete(email); + throw new WebAuthError(400, '验证码错误次数过多,请重新获取。'); + } throw new WebAuthError(400, '验证码不正确。'); } this.codes.delete(email); @@ -240,7 +348,9 @@ export class WebAuth { return this.account(email, this.checkTerms(body, this.getAccount(email))); } - private accountPath(login: string) { return ['accounts', `${crypto.createHash('sha256').update(login).digest('hex')}.json`]; } + private accountPath(login: string) { + return ['accounts', `${crypto.createHash('sha256').update(login).digest('hex')}.json`]; + } private recordTerms(account: WebAccount, termsVersion?: string): WebAccount { if (!termsVersion || account.termsVersion === termsVersion) return account; const updated = { ...account, termsAt: new Date().toISOString(), termsVersion }; @@ -251,8 +361,12 @@ export class WebAuth { const existing = this.storage.getRecord(this.accountPath(email)); // An account that signed in before the terms existed records them at its next code login. if (existing) return this.recordTerms(existing, termsVersion); - const account = { id: crypto.randomUUID(), email, createdAt: new Date().toISOString(), - ...(termsVersion ? { termsAt: new Date().toISOString(), termsVersion } : {}) }; + const account = { + id: crypto.randomUUID(), + email, + createdAt: new Date().toISOString(), + ...(termsVersion ? { termsAt: new Date().toISOString(), termsVersion } : {}), + }; this.storage.saveRecord(this.accountPath(email), account); return account; } @@ -262,45 +376,87 @@ export class WebAuth { if (username.includes('@')) throw new WebAuthError(400, '请输入用户名,不要使用邮箱地址。'); if (!validPassword(password)) throw new WebAuthError(400, '密码至少 12 位且不超过 256 字节。'); if (this.getAccount(username)) throw new WebAuthError(409, '这个用户名已存在。'); - const salt = crypto.randomBytes(16), digest = await derivePassword(password, salt); - const account: WebAccount = { id: crypto.randomUUID(), username, createdAt: new Date().toISOString(), completionEmail: false }; + const salt = crypto.randomBytes(16), + digest = await derivePassword(password, salt); + const account: WebAccount = { + id: crypto.randomUUID(), + username, + createdAt: new Date().toISOString(), + completionEmail: false, + }; const passwordPath = this.passwordPath(username); - if (!this.storage.createRecord(passwordPath, { algorithm: 'scrypt', salt: salt.toString('hex'), digest: digest.toString('hex') } satisfies PasswordRecord)) + if ( + !this.storage.createRecord(passwordPath, { + algorithm: 'scrypt', + salt: salt.toString('hex'), + digest: digest.toString('hex'), + } satisfies PasswordRecord) + ) throw new WebAuthError(409, '这个用户名已存在。'); try { - if (!this.storage.createRecord(this.accountPath(username), account)) throw new WebAuthError(409, '这个用户名已存在。'); + if (!this.storage.createRecord(this.accountPath(username), account)) + throw new WebAuthError(409, '这个用户名已存在。'); } catch (error) { this.storage.deleteRecord(passwordPath); throw error; } return account; } - getAccount(login: string): WebAccount | undefined { return this.storage.getRecord(this.accountPath(login)); } - private passwordPath(login: string) { return ['passwords', this.accountPath(login)[1]!]; } + getAccount(login: string): WebAccount | undefined { + return this.storage.getRecord(this.accountPath(login)); + } + private passwordPath(login: string) { + return ['passwords', this.accountPath(login)[1]!]; + } private passwordRecord(login: string): PasswordRecord | undefined { const record = this.storage.getRecord(this.passwordPath(login)); - return record?.algorithm === 'scrypt' && /^[a-f0-9]{32}$/u.test(record.salt) && /^[a-f0-9]{128}$/u.test(record.digest) - ? record : undefined; + return record?.algorithm === 'scrypt' && + /^[a-f0-9]{32}$/u.test(record.salt) && + /^[a-f0-9]{128}$/u.test(record.digest) + ? record + : undefined; + } + hasPassword(login: string): boolean { + return Boolean(this.passwordRecord(login)); } - hasPassword(login: string): boolean { return Boolean(this.passwordRecord(login)); } private async matchesPassword(value: string, record?: PasswordRecord): Promise { const salt = record ? Buffer.from(record.salt, 'hex') : Buffer.alloc(16); const expected = record ? Buffer.from(record.digest, 'hex') : Buffer.alloc(64); const actual = await derivePassword(value, salt); return Boolean(record) && crypto.timingSafeEqual(actual, expected); } - async loginPassword(ip: string, body: { login?: unknown; username?: unknown; email?: unknown; password?: unknown; terms?: unknown; termsVersion?: unknown }, authorize?: () => void): Promise { + async loginPassword( + ip: string, + body: { + login?: unknown; + username?: unknown; + email?: unknown; + password?: unknown; + terms?: unknown; + termsVersion?: unknown; + }, + authorize?: () => void, + ): Promise { const login = normalizeLogin(body.login ?? body.username ?? body.email); if (!this.allow('password-ip:' + ip, 20, 60 * 60_000) || !this.allow('password-email:' + login, 5, 60 * 60_000)) - throw new WebAuthError(429, login.includes('@') ? '密码尝试过多,请一小时后再试,或使用邮箱验证码登录。' : '密码尝试过多,请一小时后再试。'); + throw new WebAuthError( + 429, + login.includes('@') ? '密码尝试过多,请一小时后再试,或使用邮箱验证码登录。' : '密码尝试过多,请一小时后再试。', + ); if (typeof body.password !== 'string' || Buffer.byteLength(body.password, 'utf8') > 256) throw new WebAuthError(401, login.includes('@') ? '邮箱或密码不正确。' : '账号或密码不正确。'); - const initialAccount = this.getAccount(login), record = this.passwordRecord(login); + const initialAccount = this.getAccount(login), + record = this.passwordRecord(login); const matches = await this.matchesPassword(body.password, record); authorize?.(); const account = this.getAccount(login); - if (!matches || !account || account.id !== initialAccount?.id || !this.allowed(login) - || !samePasswordRecord(record, this.passwordRecord(login))) + if ( + !matches || + !account || + account.id !== initialAccount?.id || + !this.allowed(login) || + !samePasswordRecord(record, this.passwordRecord(login)) + ) throw new WebAuthError(401, login.includes('@') ? '邮箱或密码不正确。' : '账号或密码不正确。'); const version = this.checkTerms(body, account); const admitted = this.recordTerms(account, version); @@ -315,33 +471,52 @@ export class WebAuth { const account = this.getAccount(login); if (!account) throw new WebAuthError(404, '账号不存在。'); if (!validPassword(next)) throw new WebAuthError(400, '密码至少 12 位且不超过 256 字节。'); - if (!this.allow('password-change:' + login, 5, 60 * 60_000)) throw new WebAuthError(429, '密码修改过于频繁,请一小时后再试。'); + if (!this.allow('password-change:' + login, 5, 60 * 60_000)) + throw new WebAuthError(429, '密码修改过于频繁,请一小时后再试。'); const record = this.passwordRecord(login); - if (!(verifiedByEmail && account.email) && (!record || typeof current !== 'string' || !(await this.matchesPassword(current, record)))) - throw new WebAuthError(403, account.email ? '请输入当前密码;忘记密码请用邮箱验证码重新登录后设置。' : '请输入当前密码;忘记密码请联系管理员。'); + if ( + !(verifiedByEmail && account.email) && + (!record || typeof current !== 'string' || !(await this.matchesPassword(current, record))) + ) + throw new WebAuthError( + 403, + account.email + ? '请输入当前密码;忘记密码请用邮箱验证码重新登录后设置。' + : '请输入当前密码;忘记密码请联系管理员。', + ); const salt = crypto.randomBytes(16); const digest = await derivePassword(next, salt); // Derivation yields; deletion, recreation or suspension must not leave a password written by the old session. authorize?.(); if (this.getAccount(login)?.id !== account.id) throw new WebAuthError(404, '账号不存在。'); if (!this.allowed(login)) throw new WebAuthError(403, '这个账号目前无法使用,请联系支持。'); - if (!samePasswordRecord(record, this.passwordRecord(login))) throw new WebAuthError(409, '密码已变更,请刷新页面后重试。'); - this.storage.saveRecord(this.passwordPath(login), { algorithm: 'scrypt', salt: salt.toString('hex'), digest: digest.toString('hex') } satisfies PasswordRecord); + if (!samePasswordRecord(record, this.passwordRecord(login))) + throw new WebAuthError(409, '密码已变更,请刷新页面后重试。'); + this.storage.saveRecord(this.passwordPath(login), { + algorithm: 'scrypt', + salt: salt.toString('hex'), + digest: digest.toString('hex'), + } satisfies PasswordRecord); } /** Every account record; the funnel report and run milestones read these (a closed beta keeps the list short). */ listAccounts(): WebAccount[] { - return this.storage.listRecords(['accounts']).filter(file => /^[a-f0-9]{64}\.json$/u.test(file)) + return this.storage + .listRecords(['accounts']) + .filter(file => /^[a-f0-9]{64}\.json$/u.test(file)) .flatMap(file => this.storage.getRecord(['accounts', file]) ?? []); } /** Stamps a milestone the first time it happens; later runs leave the first time unchanged. */ markMilestone(accountId: string, milestone: WebMilestone, at = new Date().toISOString()) { const account = this.listAccounts().find(item => item.id === accountId); - if (account && !account[milestone]) this.storage.saveRecord(this.accountPath(accountLogin(account)), { ...account, [milestone]: at }); + if (account && !account[milestone]) + this.storage.saveRecord(this.accountPath(accountLogin(account)), { ...account, [milestone]: at }); } /** The address to tell when a run ends, unless the account turned the mail off or lost its allowlist entry. */ completionRecipient(accountId: string): string | undefined { const account = this.listAccounts().find(item => item.id === accountId); - return account?.email && account.completionEmail !== false && this.allowed(account.email) ? account.email : undefined; + return account?.email && account.completionEmail !== false && this.allowed(account.email) + ? account.email + : undefined; } setCompletionEmail(login: string, enabled: boolean) { const account = this.getAccount(login); @@ -350,7 +525,9 @@ export class WebAuth { const { completionEmail: _previous, ...rest } = account; this.storage.saveRecord(this.accountPath(login), enabled ? rest : { ...rest, completionEmail: false }); } - async sendCompletion(to: string, message: { subject: string; text: string }) { await this.mailer({ to, ...message }); } + async sendCompletion(to: string, message: { subject: string; text: string }) { + await this.mailer({ to, ...message }); + } deleteAccount(login: string) { // Keep the account retryable if credential deletion fails; a recreated account must never inherit its password. this.storage.deleteRecord(this.passwordPath(login)); @@ -359,4 +536,4 @@ export class WebAuth { } } -export const allowlistFile = (dataRoot?: string) => dataRoot ? path.join(dataRoot, 'allowlist.txt') : undefined; +export const allowlistFile = (dataRoot?: string) => (dataRoot ? path.join(dataRoot, 'allowlist.txt') : undefined); diff --git a/apps/web/candidateTargetCheck.ts b/apps/web/candidateTargetCheck.ts index 81b1bd55..a6840e22 100644 --- a/apps/web/candidateTargetCheck.ts +++ b/apps/web/candidateTargetCheck.ts @@ -2,26 +2,33 @@ import { leanDeclarationContextCommands } from '../../src/math/leanSource'; /** Runs in a separate host-written module after the candidate compiles. Other original goals may remain open; * the selected declaration must have a value, the requested type and no admitted or additional axioms. */ -export function candidateTargetQuery(sourceModule: string, source: string, - target: { name: string; expectedType?: string }, marker: string): string { +export function candidateTargetQuery( + sourceModule: string, + source: string, + target: { name: string; expectedType?: string }, + marker: string, +): string { const context = leanDeclarationContextCommands(source, target.name); return [ - 'import Lean', `import ${sourceModule}`, - ...(target.expectedType ? [ - ...context.before, - 'run_cmd Lean.Elab.Command.liftTermElabM do', - ` let parsedType ← match Lean.Parser.runParserCategory (← Lean.getEnv) (Lean.Name.mkSimple "term") ${JSON.stringify(target.expectedType)} with`, - ' | .ok stx => pure stx', - ' | .error message => throwError "{message}"', - ' let expected ← Lean.Elab.Term.elabType parsedType', - ' Lean.Elab.Term.synthesizeSyntheticMVarsNoPostponing', - ' let expected ← Lean.instantiateMVars expected', - ' if expected.hasMVar || expected.hasFVar then throwError "Candidate expected type must be closed"', - ` let declaration ← Lean.Meta.mkConstWithFreshMVarLevels (${JSON.stringify(target.name)}.toName)`, - ' let actual ← Lean.Meta.inferType declaration', - ' unless (← Lean.Meta.isDefEq actual expected) do throwError "Candidate declaration has a different type or additional assumptions"', - ...context.after, - ] : []), + 'import Lean', + `import ${sourceModule}`, + ...(target.expectedType + ? [ + ...context.before, + 'run_cmd Lean.Elab.Command.liftTermElabM do', + ` let parsedType ← match Lean.Parser.runParserCategory (← Lean.getEnv) (Lean.Name.mkSimple "term") ${JSON.stringify(target.expectedType)} with`, + ' | .ok stx => pure stx', + ' | .error message => throwError "{message}"', + ' let expected ← Lean.Elab.Term.elabType parsedType', + ' Lean.Elab.Term.synthesizeSyntheticMVarsNoPostponing', + ' let expected ← Lean.instantiateMVars expected', + ' if expected.hasMVar || expected.hasFVar then throwError "Candidate expected type must be closed"', + ` let declaration ← Lean.Meta.mkConstWithFreshMVarLevels (${JSON.stringify(target.name)}.toName)`, + ' let actual ← Lean.Meta.inferType declaration', + ' unless (← Lean.Meta.isDefEq actual expected) do throwError "Candidate declaration has a different type or additional assumptions"', + ...context.after, + ] + : []), 'run_cmd do', ` let target := ${JSON.stringify(target.name)}.toName`, ' let some info := (← Lean.getEnv).find? target | throwError "Candidate target is missing"', @@ -40,6 +47,8 @@ export function candidateTargetWasChecked(output: string, marker: string): boole try { const item = JSON.parse(line); return item.severity === 'information' && item.data === marker; - } catch { return false; } + } catch { + return false; + } }); } diff --git a/apps/web/client/CommunityBoard.tsx b/apps/web/client/CommunityBoard.tsx index 96ca7c18..76ca8369 100644 --- a/apps/web/client/CommunityBoard.tsx +++ b/apps/web/client/CommunityBoard.tsx @@ -4,19 +4,33 @@ import { loginHref, type WebSession } from '../shared'; import { localizeMessage } from '../i18n'; type Tx = (zh: string, en: string) => string; -type Me = { profile: { handle: string; token: boolean; tokenCreatedAt?: string } | null; admin: boolean; - claims: { taskId: string; title: string; expiresAt: string }[]; submissions: Omit[]; - limits: { claimsPerPerson: number; claimHours: number; submissionsLeft: number; pointsIntervalSeconds: number } }; -type Detail = { task: CommunityPublicTask; claimants: { who?: string; claimedAt: string; expiresAt: string }[]; +type Me = { + profile: { handle: string; token: boolean; tokenCreatedAt?: string } | null; + admin: boolean; + claims: { taskId: string; title: string; expiresAt: string }[]; + submissions: Omit[]; + limits: { claimsPerPerson: number; claimHours: number; submissionsLeft: number; pointsIntervalSeconds: number }; +}; +type Detail = { + task: CommunityPublicTask; + claimants: { who?: string; claimedAt: string; expiresAt: string }[]; submissions: (Omit & { who?: string })[]; - solution?: { id: string; who?: string; source: string; model: string; harness: string } }; + solution?: { id: string; who?: string; source: string; model: string; harness: string }; +}; type Tab = 'tasks' | 'boards' | 'activity' | 'join'; let csrf = ''; async function call(route: string, body?: unknown): Promise { - const response = await fetch(route, { method: body === undefined ? 'GET' : 'POST', credentials: 'same-origin', cache: 'no-store', - headers: { Accept: 'application/json', ...(body === undefined ? {} : { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf }) }, - body: body === undefined ? undefined : JSON.stringify(body) }); + const response = await fetch(route, { + method: body === undefined ? 'GET' : 'POST', + credentials: 'same-origin', + cache: 'no-store', + headers: { + Accept: 'application/json', + ...(body === undefined ? {} : { 'Content-Type': 'application/json', 'X-CSRF-Token': csrf }), + }, + body: body === undefined ? undefined : JSON.stringify(body), + }); const value = await response.json().catch(() => ({})); if (!response.ok) throw new Error(typeof value.error === 'string' ? value.error : `HTTP ${response.status}`); return value as T; @@ -24,376 +38,1168 @@ async function call(route: string, body?: unknown): Promise { /** Moves focus to a status line when the control that started the action has gone, so focus never falls back to the page top. */ function useStatusFocus(text: string | undefined) { const ref = useRef(null); - useEffect(() => { if (text && (!document.activeElement || document.activeElement === document.body)) ref.current?.focus({ preventScroll: true }); }, [text]); + useEffect(() => { + if (text && (!document.activeElement || document.activeElement === document.body)) + ref.current?.focus({ preventScroll: true }); + }, [text]); return ref; } type Filter = 'open' | 'solved' | 'all'; const route = () => { const task = /^#task-(T\d+)$/u.exec(location.hash)?.[1]; - return { tab: task ? 'tasks' : (['tasks', 'boards', 'activity', 'join'] as Tab[]).find(item => location.hash === `#${item}`) ?? 'tasks', open: task }; + return { + tab: task + ? 'tasks' + : ((['tasks', 'boards', 'activity', 'join'] as Tab[]).find(item => location.hash === `#${item}`) ?? 'tasks'), + open: task, + }; }; const oneLine = (text: string) => text.replace(/\s+/gu, ' ').trim(); -const when = (iso: string, language: string) => new Date(iso).toLocaleString(language === 'en' ? 'en' : 'zh-CN', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }); +const when = (iso: string, language: string) => + new Date(iso).toLocaleString(language === 'en' ? 'en' : 'zh-CN', { + month: 'short', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + }); export function CommunityBoard({ language }: { language: 'zh' | 'en' }) { - const tx: Tx = (zh, en) => language === 'en' ? en : zh; + const tx: Tx = (zh, en) => (language === 'en' ? en : zh); const [overview, setOverview] = useState(); const [session, setSession] = useState(); const [me, setMe] = useState(); const [{ tab, open }, setRoute] = useState(route); const [filter, setFilter] = useState('open'); - const tabs = useRef(null), came = useRef(), moved = useRef(false); + const tabs = useRef(null), + came = useRef(), + moved = useRef(false); const [error, setError] = useState(''); const refresh = async () => { try { - const [board, current] = await Promise.all([call('/api/community/overview'), call('/api/session')]); - csrf = current.csrfToken; setOverview(board); setSession(current); - setMe(current.account ? await call('/api/community/me') : undefined); setError(''); - } catch (failure) { setError(localizeMessage((failure as Error).message)); } + const [board, current] = await Promise.all([ + call('/api/community/overview'), + call('/api/session'), + ]); + csrf = current.csrfToken; + setOverview(board); + setSession(current); + setMe(current.account ? await call('/api/community/me') : undefined); + setError(''); + } catch (failure) { + setError(localizeMessage((failure as Error).message)); + } }; - useEffect(() => { void refresh(); const timer = setInterval(() => { if (!document.hidden) void refresh(); }, 15_000); return () => clearInterval(timer); }, []); + useEffect(() => { + void refresh(); + const timer = setInterval(() => { + if (!document.hidden) void refresh(); + }, 15_000); + return () => clearInterval(timer); + }, []); useEffect(() => { const follow = () => { - const next = route(); moved.current = true; - setRoute(previous => { if (previous.open && !next.open) came.current = previous.open; return next; }); + const next = route(); + moved.current = true; + setRoute(previous => { + if (previous.open && !next.open) came.current = previous.open; + return next; + }); if ((tabs.current?.getBoundingClientRect().top ?? 0) < 0) tabs.current?.scrollIntoView(); }; - addEventListener('hashchange', follow); return () => removeEventListener('hashchange', follow); + addEventListener('hashchange', follow); + return () => removeEventListener('hashchange', follow); }, []); useEffect(() => { if (tab !== 'tasks' || open || !came.current) return; - document.querySelector(`[data-task="${came.current}"]`)?.focus({ preventScroll: true }); came.current = undefined; + document.querySelector(`[data-task="${came.current}"]`)?.focus({ preventScroll: true }); + came.current = undefined; }, [tab, open]); - const go = (next: Tab) => { location.hash = next; }; + const go = (next: Tab) => { + location.hash = next; + }; const show = (id?: string) => { const task = id && overview?.tasks.find(item => item.id === id); if (task && filter !== 'all' && task.status !== filter) setFilter('all'); location.hash = id ? `task-${id}` : 'tasks'; }; - const names: [Tab, string][] = [['tasks', tx('题目', 'Problems')], ['boards', tx('排行榜', 'Leaderboards')], ['activity', tx('动态', 'Activity')], ['join', tx('参与', 'Join')]]; + const names: [Tab, string][] = [ + ['tasks', tx('题目', 'Problems')], + ['boards', tx('排行榜', 'Leaderboards')], + ['activity', tx('动态', 'Activity')], + ['join', tx('参与', 'Join')], + ]; const keys = (event: KeyboardEvent) => { - const buttons = [...tabs.current?.querySelectorAll('[role=tab]') ?? []], last = buttons.length - 1; + const buttons = [...(tabs.current?.querySelectorAll('[role=tab]') ?? [])], + last = buttons.length - 1; const at = buttons.indexOf(event.target as HTMLElement); // the focused tab, since the route updates only after hashchange - const next = at < 0 ? undefined : { ArrowRight: at === last ? 0 : at + 1, ArrowLeft: at === 0 ? last : at - 1, Home: 0, End: last }[event.key]; + const next = + at < 0 + ? undefined + : { ArrowRight: at === last ? 0 : at + 1, ArrowLeft: at === 0 ? last : at - 1, Home: 0, End: last }[event.key]; if (next === undefined) return; - event.preventDefault(); go(names[next]![0]); buttons[next]?.focus(); + event.preventDefault(); + go(names[next]![0]); + buttons[next]?.focus(); }; - if (!overview) return
{error || tx('正在读取社区题目…', 'Loading community problems…')}
; - const signedIn = Boolean(session?.account), { totals } = overview; - const latest = overview.activity.find(item => item.kind === 'accepted' || item.kind === 'rejected' || item.kind === 'late'); - const browse = () => { setFilter('open'); location.hash = 'tasks'; }; - return
-
-
-

{tx('社区开放解题', 'Community open problems')}

-

{tx('管理员发布冻结的 Lean 目标,任何人或其 Agent 都可以认领、提交证明。服务器在隔离沙箱里独立编译并检查公理,第一份通过的证明获得提交那一刻锁定的分数。', - 'Admins publish frozen Lean goals; anyone, or their agent, can claim one and submit a proof. The server compiles it in an isolated sandbox and checks its axioms; the first accepted proof earns the points locked when it was sent.')}

+ if (!overview) + return ( +
+ {error || tx('正在读取社区题目…', 'Loading community problems…')} +
+ ); + const signedIn = Boolean(session?.account), + { totals } = overview; + const latest = overview.activity.find( + item => item.kind === 'accepted' || item.kind === 'rejected' || item.kind === 'late', + ); + const browse = () => { + setFilter('open'); + location.hash = 'tasks'; + }; + return ( +
+
+
+

{tx('社区开放解题', 'Community open problems')}

+

+ {tx( + '管理员发布冻结的 Lean 目标,任何人或其 Agent 都可以认领、提交证明。服务器在隔离沙箱里独立编译并检查公理,第一份通过的证明获得提交那一刻锁定的分数。', + 'Admins publish frozen Lean goals; anyone, or their agent, can claim one and submit a proof. The server compiles it in an isolated sandbox and checks its axioms; the first accepted proof earns the points locked when it was sent.', + )} +

+
+
+
+
{tx('开放', 'Open')}
+
{overview.totals.open}
+
+
+
{tx('已解出', 'Solved')}
+
{overview.totals.solved}
+
+
+
{tx('提交', 'Submissions')}
+
{overview.totals.submissions}
+
+
+
{tx('解题者', 'Solvers')}
+
{overview.totals.people}
+
+
+
+
+
+ + + + {totals.solved} / {totals.tasks} + +
+ +