打开文档导航

Pysolate implementation source-owner map

当前导航对象:agent-python-runtime target 94fab78cb3f44d14f86d293287269b704b11d383,tree a4291f77e59d680f5ef1bd21e39b323afd5c5ecf。1–12 节保留旧基线的核心 owner 导航;13–14 节记录随后新增的 Prepared Family 与 source-bound pass architecture。

读图规则

  • 路径均相对 target repository;symbol 比行号稳定,目录/包名是第一导航键。
  • owner 指拥有该状态、authority、资源关闭或 evidence 投影责任的源码 seam;不等于调用者。
  • 文档列是 reader-facing explained 文档:先读对应单文档,再回到 target symbol;不要把相邻 research seam 自动串接。

生命周期 source owners

1. 入口与 run admission

  • Source owner: cmd/apyrun/main.go (main, execute, runIdentity, capabilityPlan, BrokerFactory);cmd/apyrun/config.go (operatorConfig.resolve)。
  • Key symbols: runtime/request.go: DecodeRunRequestruntime/config.go: RunConfig, DefaultRunConfig, RunConfig.Validateruntime/outcome.go: AdmitRunRequirements, NewUnsupportedOutcome
  • 职责: Host 配置、bounded JSON、compatibility/requirements 与 deterministic admission;request 不携带 capability、credential、mount 或 budget。
  • Reader → explained: 01-execution-core.md(入口/顺序/失败矩阵);需要 authority 关系再读 02-authority-spine.md

2. Guest construction

  • Source owner: runtime/engine/wazero/engine.goFactory.New, newEngine, runWithPrepares, AnalyzeSemantic, PrepareSemanticRuntimeruntime/engine/runner.goRunner/Properties
  • Key symbols: takePreparedEngine.Run/RunStream seam、projectHostEvidenceguest/include/agent_runtime_v1.hguest/src/runtime.cruntime_init, runtime_validate_source, runtime_prepare, execute
  • 职责: fresh module、WASI/import 安装、ABI framing、source validation、trusted prepare 与 close;prepared slot 不是 served Guest pool。
  • Reader → explained: 01-execution-core.md;streamed Guest 细节转 03-streaming-and-source-binding.md,COW 转 08c-private-cow-and-prepared-runtime.md

3. Capability / authority

  • Source owner: runtime/capability/registry.go (Spec, Registry.Register, Registry.Seal, Plan/Present);grant.go (Grant, NewGrant)。
  • Key symbols: runtime/capability/broker.go: NewBroker, Call/CallStreaming, Finalizeruntime/approval/controller.go: Authorize, BeginDispatch, Complete, AbortApproved
  • Bridge symbols: Wazero instantiateCapabilityHost, hostCall;native runtime/capabilityrpc/registry.go: Open, Check, Dispatch
  • 职责: Host 封存 Spec + Grant → Plan,Broker 是唯一 admission/handler dispatch seam;presentation、approval、RPC 都不能铸造第二套 authority。
  • Reader → explained: 02-authority-spine.md

4. Semantic / streaming

  • Source owner: runtime/semantic/analyzer.go (Analyze, AnalyzeVerified);contract.go/legality.go (Analysis, QualifiedCall, CanPreissue*)。
  • Key symbols: runtime/semantic/prefix_execution.go: GenerateVerifiedSourceWithPreDispatch, ExecuteGeneratedSourceObservedstreaming_predispatch.go: StreamingPrefixAdmission, StreamingSemanticPreDispatch, SealFinalSource
  • Streaming symbols: runtime/streaming/source.go: SourceStream, SourceSeal, BindObservationruntime/streaming/observation.goguest/bootstrap/agent_runtime/__init__.py: _StreamingSession
  • 职责: exact Guest facts → Host qualification → one-shot staged physical work → final-source gate → unchanged dynamic claim;candidate/AST 不是 authority。
  • Reader → explained: 03-streaming-and-source-binding.md(三条 source lane);04-semantic-predispatch.md(qualification/claim ledger)。

5. Receipts / effect truth

  • Source owner: runtime/receipt/receipt.go (NewAuthorized, BindSource, ValidIdentity);runtime/capability/transcript.go (TransportEvidence, TranscriptEntry)。
  • Key symbols: runtime/response.goDecodeAndValidateRunResponse、receipt/workspace validation;runtime/observe/observe.go: Session.Append, Incomplete
  • Terminal owners: Wazero observationLifecycle.start/capabilityPlan/capabilityCalls/complete/failcmd/apyrun/workspace_binding.go: prepareDisposition, stageExport, publish, discard
  • 职责: Host 生成/投影 receipt、plan、call metrics、workspace disposition;这些是 bounded identity/evidence,不是 provider 或外部世界真值,也不是 rollback。
  • Reader → explained: 01-execution-core.md(response/observation);02-authority-spine.md(receipt/effect);workspace 收尾读 08a-workspace-lineage.md

6. Workspace

  • Source owner: runtime/workspace/manager.go (Manager, Create, Acquire, Lease, NewTemporary);fs.go/capture.go 负责 rooted FS 与 bounded capture。
  • Lineage symbols: branch_root.go: ForkBranch, Seal, SelectRoot, BindImportedRootattempt.go: ForkAttempt, Publish, Discard
  • Direct callers: cmd/apyrun/workspace_binding.go 的 mount/initial-final snapshot/stage-publish;runtime/streaming/run.go 的 success-publish/failure-discard;runtime/subagent/orchestrator.go 的 branch selection。
  • 职责: Host-owned Ref/Lease、普通文件 copy、immutable Root lineage 与 private Attempt;Publish 不等于 Seal,workspace copy 不等于 filesystem COW。
  • Reader → explained: 08a-workspace-lineage.md

7. Workflow / suspension

  • Source owner: runtime/workflow/evaluator.go: Graph.Validate, State.Validate, Start, Resume, evaluate, refreshObservations
  • Suspension owners: approval 仍由 runtime/approval/controller.go + runtime/capability/broker.go 管;cold I/O 由 runtime/engine/wazero/cold_io.gocold_io_linux.go (wait, resume, finish) 管。
  • 职责: workflow 到 Wait 后销毁 Guest,以显式 State + fresh Guest resume;approval/cold 是受限同一调用/slot 等待;普通 cancel/timeout 没有通用 resume token。
  • Reader → explained: 08b-suspension-and-resume.md

8. Prepared-data

  • Source owner: runtime/prepareddataset/decision.go: Decide, PreparationDecision.Claimcontract.goHostPreparedDataDeclaration/NewPreparedDataContract
  • Object owners: research/prepareddataset/staged.go: NewStagedObject, IssueRead, VerifySource, Decode, Seal, ClaimBoundMaterialization, Orphan, Cancel, Reject
  • Claim owners: research/prepareddataset/claim_guard.go: NewPreparedDataClaimGuard, ClaimPreparedRegionruntime/preparedregion/table.goClaim/Closecmd/prepared-data-authority-probecmd/prepared-data-claim-probe 是 fixed probe seams。
  • 职责: declaration/Plan/context/facts join → bounded typed staging → exact final occurrence/object-bound one-shot claim;当前是 fixed NumPy copy bridge,不是 generic object ABI/cache。
  • Reader → explained: 06-prepared-data.md;机制分类和与 COW/cache 的边界读 05-reuse-taxonomy.md

9. Wazero COW

  • Source owner: runtime/engine/wazero/cow_memory_linux.go (newCOWImageWithMaximum, mapPrivate, restoreBaselineBeforeServe);非 Linux 是 cow_runtime_stub.go
  • Runtime owners: cow_runtime_linux.go (newCOWPreparedRuntimeWithTrustedSource, prepare, derive, sealCOWPreparedRuntime);engine.goensurePreparedWithResultAndTrustedSource, acquireCOWRuntime, closeCOWRuntime
  • 职责: sealed memfd + MAP_PRIVATE 的线性内存 baseline、active lease 和 fresh consumer;不保存 Python frame/heap/WASI/Broker state,页级共享也不等于全链路 zero-copy。
  • Reader → explained: 08c-private-cow-and-prepared-runtime.md;reuse owner 对照读 05-reuse-taxonomy.md

10. Native backend

  • Source owner: runtime/engine/native/backend.go: ExecuteWithEvidence, validateConfig, reconcileRunscoci.go: writeOCIBundlerootfs.go: VerifyOCIImageConfig, RootFSIdentity
  • Capability bridge: runtime/capabilityrpc/registry.go/http.gonative/python/_agent_runtime_host.pyrunner.pyruntime/verification/native.go: VerifyNative, VerifyNativeAttempt
  • 职责: image/rootfs preflight → OCI/runsc → invocation-bound Unix HTTP Broker → response/evidence → delete/cgroup/unmount/workspace cleanup;native evidence 是独立 aggregate seam。
  • Reader → explained: 07-backends-package-profiles-and-placement.md(backend/placement);01-execution-core.md02-authority-spine.md(native boundary/RPC authority)。

11. Placement / package profiles

  • Source owner: runtime/placement/placement.go: Analyze, makeDecision, Orchestrator.Executeruntime/profile.go: NewExecutionProfile, BindVerifiedArtifact, EvaluateRunCompatibility
  • Artifact/profile owners: runtime/artifact.goruntime/execution_contract.goguest/build/package_profile.py (validate_registry, resolve_profile, source_lock_projection);guest/build/verify-artifact.py/write-manifest.py
  • 职责: Host 以 state/import/requirements/profile/shard 做保守选择;当前 router 实际消费 plain/base,attrs-770 与 numpy-core 的 build/verifier support 不等于 generic multi-shard placement。
  • Promotion boundary: 只有 Host-authored UnsupportedRunError 且 workspace/effect 均 not_started 才允许 native child;普通 Guest error 不 replay。
  • Reader → explained: 07-backends-package-profiles-and-placement.md

12. Evidence commands / docs

  • Runtime evidence owners: runtime/observe(bounded Host events,无 storage/policy);runtime/verification(identity/cleanup validator);runtime/playback(bundle identity/transport seam)。
  • Reader-facing commands: cmd/pysolate-acceptance(live/playback acceptance report);cmd/composable-acceptance-report(corpus/report revalidation);cmd/pysolate-research(inspect/compare/branch/store/lab projection)。
  • Research-only owners: research/* campaign/report packages、cmd/*probecmd/*campaign;它们生产 bounded report/projection,不改变 Runtime authority,也不是默认 production call chain。
  • Reader → explained: 先读 01-execution-core.md 的 evidence boundary,再按主题读 02-authority-spine.md06-prepared-data.md07-backends-package-profiles-and-placement.md;不要把 historical JSON/report 当 target fresh run。

13. Prepared Family

  • Input/image owners: runtime/engine/wazero/prepared_input.go (PreparedNumpyInput, NewPreparedNumpyInput);prepared_family.go (PreparedFamily, PrepareNumpyFamily)。
  • Member owners: prepared_family_runner.go (NewRunner, PreparedFamily.Close, preparedFamilyRunner.Run, PreparedMemberRecord);prepared_lifecycle.goprepared_family_subagent.go (PreparedFamilyRunnerFactory)。
  • Guest transfer: prepared_guest_transfer.goguest/src/runtime.c: runtime_prepare_numpy_ndarrayguest/bootstrap/agent_runtime/__init__.py: _prepare_numpy_ndarray
  • 职责: 一个 immutable bounded NumPy input,有限个 fresh single-use member;private-copy 逐 Guest prepare,Linux private-COW 可共享 sealed image/page lineage。Invocation/workspace/terminal record 逐 member 私有,需要 capability 时再使用自己的 Plan/Broker。Family 不 schedule、retry、select 或 publish。
  • Reader → explained: 09-prepared-family.md;substrate 对照 08c-private-cow-and-prepared-runtime.md

14. Source-bound pass architecture

  • Registration/outcome owners: runtime/passregistration/registration.goruntime/passpipeline/pipeline.go
  • Existing adapters: runtime/semantic/pass_outcome.go 提供 semantic terminal-state projection adapter 和单测,但当前没有 production caller;prepared pure-region 有 static adapter/registration,保留既有 execution-patch owner,并无 equivalent outcome projection adapter。
  • Static plugin/patch owners: runtime/passplugin/registry.goruntime/sourcepatch/sourcepatch.goruntime/engine/wazero/engine.go: RunSourcePatchDerivedsemantic_session.go: TransformSourcePassguest/bootstrap/agent_runtime/source_pass.py
  • 职责: pass identity、stage、consumer、binding、开关,以及可复用的 bounded body-free outcome contract;pipeline 不执行 transform/Agent Python,不接管 Broker/workspace,也不决定 post-effect fallback。Scalar registry 当前不自动向 pipeline 写 whole-program record。
  • Current passes: semantic_pre_dispatchprepared_pure_regionpure_scalar_csepure_scalar_fold。两个 scalar pass 是 closed bool/int64 whole-program rewrite;不是 generic optimizer。
  • Reader → explained: 10-source-bound-pass-pipeline.md

独立 seam:不要串成一条 production call chain

  • runtime/streaming.SourceStream 是可测试的 S1 Host protocol;target 中未见它直接驱动 Engine.RunStream。实际 streamed preparation 是另一条 Engine.RunStream + Guest _StreamingSession seam。
  • semantic analyzer Guest、Host staged pre-dispatch 与 final fresh Guest 是三段相邻生命周期;不是 analyzer-to-final 的 same-Guest continuation。
  • runtime/workflow 的 State resume、approval suspension、cold-I/O continuation 语义不同;不能合并成通用 checkpoint/restore。
  • runtime/prepareddataset contract/decision 与 research/prepareddataset object/claim probe 是窄 research lane;不等于 runtime/engine/wazero COW,也不等于 runtime/agentfunction whole-Run cache/single-flight。
  • Prepared Family 是显式 multi-consumer owner,但仍不等于 runtime/prepareddataset 的 predicted numpy.load occurrence/object-claim lane;二者输入来源、logical claim 和 lifecycle 不同。
  • passpipeline 统一 registration/outcome vocabulary,不把 semantic overlay、prepared region 与 pure source patch 合并成一条 transform/execution lifecycle。
  • runtime/workspace 的 filesystem lineage 与 runtime/capability/workspace.go 的内存 typed-tool workspace 是两个 package seam;前者不证明后者,反之亦然。
  • Wazero 与 native 各有执行、receipt/evidence、cleanup owner;native RPC completed-response replay 不是 Guest/Run replay,WASM/native 也没有字节级 response 等价证明。
  • package profile registry/lock、artifact verifier、runtime profile 与 placement consumer 是四个接入点;存在 profile 不代表 router 已接通该 shard。
  • cmd/*acceptancecmd/*researchresearch/*campaign 只消费或投影 evidence;它们不能反向成为 authority issuer。本文未运行 campaign。