diff --git a/README.md b/README.md index f549d34..e61ad55 100644 --- a/README.md +++ b/README.md @@ -38,28 +38,34 @@ can receive images and results while those files remain on the GPU host. ## Supported asset sources -The public preview registers **7 sources: 5 enabled and 2 audited**. Three are -searched by default. Optional sources require explicit selection. +This table is generated from the +[development registry](src/simscene/catalog/data/sources.yaml). The public +preview tag has its own +[source list](https://github.com/ros-claw/simscene/blob/v0.2.0-dev.1/docs/assets/SOURCES.md). -| Resource | Source ID | Availability | Supported route and recorded scope | + + +| Source ID | State | Default | Formats | | --- | --- | --- | --- | -| [NVIDIA USD Search](https://search.simready.omniverse.nvidia.com) | `nvidia-usd-search` | Default · enabled | Natural-language metadata search and selected native USD acquisition. The recorded workbench uses visual geometry with an explicit support proxy; its unresolved individual license blocks the newer preparation route. | -| [ABO GLB](https://huggingface.co/datasets/codepawl/abo-glb) | `abo-glb` | Default · enabled | Community-converted Amazon Berkeley Objects: metadata search and selected standard GLB preparation. A notebook has recorded rigid-body fall, contact, and settling checks. | -| [GSO GLB](https://huggingface.co/datasets/codepawl/scanned-objects-glb) | `gso-glb` | Default · enabled | Community-converted Google Scanned Objects: metadata search and selected standard GLB preparation. A scanned box has a real drop test and missing-support control. | -| [NVIDIA USDCraft-10K](https://huggingface.co/datasets/nvidia/USDCraft-10K) | `usdcraft` | Optional · enabled | Manifest search and selected native USD dependencies. The recorded `ds_R021_02` cabinet preserves a two-link, single-hinge articulation; arbitrary multi-DOF imports are outside this public profile. | -| [Poly Haven](https://polyhaven.com) | `polyhaven` | Optional · enabled | Configured HDRI/material IDs and selected resolutions. A 1k HDRI has light-only USD preparation and rendering evidence; material-map acquisition does not imply geometry preparation. | -| [NVIDIA SimReady Central](https://huggingface.co/spaces/nvidia/simready-central) | `simready-central` | Optional · audited | Literal filename filtering through its HTTP service. Returns metadata locators; this adapter does not directly acquire or prepare the returned assets. | -| [ProjectSim SimReady packages](https://huggingface.co/datasets/projectsim/simready-assets) | `projectsim-public` | Optional · audited | The selected `industrial_pipe_valve` BOM package has acquisition, visual-only preparation, texture rendering, and cache-restore evidence. Its original dynamics and joints are not qualified. | - -**Enabled** means an adapter has a finite integration example. **Audited** is a -limited admission state, not full-source support. Search availability, preparation, -and physical success are separate results; each recorded check applies to its -listed asset, parameters, and runtime. - -For the current development checkout, the -[packaged registry](src/simscene/catalog/data/sources.yaml) is authoritative. -Its generated [full source list](docs/assets/SOURCES.md) records revisions, -license scope, examples, and limitations. See also +| [nvidia-usd-search](https://search.simready.omniverse.nvidia.com) | enabled | yes | USD | +| [abo-glb](https://huggingface.co/datasets/codepawl/abo-glb) | enabled | yes | GLB | +| [gso-glb](https://huggingface.co/datasets/codepawl/scanned-objects-glb) | enabled | yes | GLB | +| [usdcraft](https://huggingface.co/datasets/nvidia/USDCraft-10K) | enabled | no | USD | +| [artvip](https://huggingface.co/datasets/X-Humanoid/ArtVIP) | audited | no | USD | +| [polyhaven](https://polyhaven.com) | enabled | no | HDRI / material maps (selected IDs) | +| [simready-central](https://nvidia-simready-central.hf.space) | audited | no | USD locators (metadata only) | +| [projectsim-public](https://huggingface.co/datasets/projectsim/simready-assets) | audited | no | USD | + + + +Default sources participate in a search without a source filter. Select an +optional source explicitly. **Enabled** sources have a finite integration +example. **Audited** sources have a limited admission scope. Search, +preparation, and physical verification have separate evidence for each asset +and configuration. + +The generated [full source list](docs/assets/SOURCES.md) documents access, +formats, licensing scope, and the recorded examples. See [measured capabilities](docs/validation/catalog-capabilities.md) and [adding a source](docs/assets/ADDING_A_SOURCE.md). @@ -84,7 +90,7 @@ it does not execute arbitrary code returned by search. ## Get started -### Development branch +### First delivery on the development branch Build and install the current dev2 portable package using [the package guide](docs/packaging.md). Then run the @@ -93,8 +99,7 @@ pinned GSO scan, drop it onto an editable worktop, verify the run and export a four-second native video. See the [integration results](docs/validation/integration-release-matrix.md) for tested cases and client qualification scope. - -### 1. Search metadata first +### 1. Search metadata in the public preview Use **Python 3.10+** and pin the public preview. These catalog commands do not start Isaac Sim or require the optional GLB decoder: @@ -117,7 +122,7 @@ model library. For a prebuilt installation, the includes a Python wheel and a **Linux x86_64 / Python 3.10** client bundle; see [installation and relocation](docs/packaging.md). -### 2. Prepare one object and run a small physical test +### 2. Run a physical example in the public preview | Operation | Additional requirements | | --- | --- | @@ -144,7 +149,7 @@ to configure the decoder and probe the runtime before GLB physics. `doctor` checks configuration; `asset probe` starts the preparation runtime and records its capabilities. -**Recommended first experiment:** the +The public preview includes the [cross-catalog gravity cell](examples/catalog_gravity_cell/README.md). Its reproduction starts with a pinned ABO notebook and an NVIDIA table, then checks fall, contact, and settling before expanding to several notebook diff --git a/docs/assets/ADDING_A_SOURCE.md b/docs/assets/ADDING_A_SOURCE.md index 0447eb7..442cb65 100644 --- a/docs/assets/ADDING_A_SOURCE.md +++ b/docs/assets/ADDING_A_SOURCE.md @@ -9,7 +9,7 @@ Use the curated YAML registry as the single production source inventory. Dynamic 5. Implement and test the adapter boundary. Search may read bounded metadata; model, texture, archive and preview payloads require their own authorized acquisition paths. Do not use whole-repository downloads to complete a selected object. If a model is hidden in an archive, report the archive's real cost and leave range/member access unverified until measured. 6. Obtain a selected sample through a frozen acquisition plan, retain licensing and a complete hashed dependency closure, prepare its declared role, and test restoration after cache eviction. Confirm codec support in the actual converter environment. A static schema check is not a runtime test. 7. Record an actual acceptance example with its exact asset revision, preparation parameters, engine/toolchain, case, input/evidence locks and result. Include a meaningful negative control. Source admission requires implemented code and a finite integration example; it never certifies every object, variant or physics task in the source. -8. Edit the packaged registry explicitly, keep evidence scoped, and regenerate `SOURCES.md`. Do not copy the research inventory or discovery results into the enabled set wholesale. +8. Edit the packaged registry explicitly, keep evidence scoped, and regenerate the README source table and `SOURCES.md`. Do not copy the research inventory or discovery results into the enabled set wholesale. The Python maintenance interfaces are: @@ -23,10 +23,21 @@ for candidate in page.candidates: # Inspect audit.to_dict(); no registry change occurs. ``` -Regenerate the public list from the registry, then run its drift test: +From the checkout root, regenerate both documents using the packaged registry. +The drift tests run without network access or model downloads. ```bash -python -c "from simscene.catalog.audit import build_source_list; print(build_source_list(), end='')" > docs/assets/SOURCES.md +python - <<'PYTHON' +from pathlib import Path +from simscene.catalog.audit import build_source_list, update_readme_sources +from simscene.catalog.registry import load_registry + +registry = load_registry() +readme = Path("README.md") +updated = update_readme_sources(readme.read_text(encoding="utf8"), registry) +readme.write_text(updated, encoding="utf8") +Path("docs/assets/SOURCES.md").write_text(build_source_list(registry), encoding="utf8") +PYTHON python -m unittest discover -s tests -p 'test_catalog_audit.py' ``` diff --git a/docs/packaging.md b/docs/packaging.md index 5cd8134..fa72e8b 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -120,14 +120,22 @@ The evaluator forwards these names to both packages. On the tested host, this resolved a case where a direct metadata request worked while the MCP request timed out. Other clients need their corresponding environment-forwarding setup. -The DeepSeek root contains `cordis.patch.yml` with the absolute build location. -After moving it, generate a new overlay at a new path: +The DeepSeek development package includes an overlay generator. Move or +extract the package to its final location, then run these commands with the +local Python version that matches the package. ```sh -python3 plugins/deepseek_patch.py --plugin-root /absolute/path/to/moved/deepseek/simscene --output /absolute/path/to/new-cordis.patch.yml -dsh web --patch /absolute/path/to/new-cordis.patch.yml +cd "/absolute/path/to/deepseek/simscene" +python3 deepseek_patch.py +dsh web --patch "$(pwd)/cordis.patch.yml" ``` +The generator uses the package's vendored YAML library and records the selected +local interpreter, launcher and working directory. After another move, use +`python3 deepseek_patch.py --output cordis-local.patch.yml` to write a fresh +overlay at an unused path, then pass that path to `dsh web --patch`. Use +`--python /path/to/python` to select a different interpreter for the server. + Add the package's `skills` directory to the host's existing skill directories, or install project skills separately. The overlay adds an MCP client; it does not install a skill or replace a host profile. @@ -136,7 +144,7 @@ not install a skill or replace a host profile. | --- | --- | | Portable/Codex | Final release transport: stdio, resources, cached metadata, isolated registration/readback, and two authenticated Codex tasks passed. The tasks independently checked native video/physics and real GLB preparation/physics. No desktop marketplace installation is claimed. | | Claude Code | Packaged stdio is tested. Existing host evidence covers skill/MCP loading; no authenticated Claude model task is claimed. | -| DeepSeek Harness | Packaged stdio is tested. Existing host evidence covers overlay loading and ListTools; no authenticated DeepSeek model task is claimed. | +| DeepSeek Harness | Packaged stdio is tested with an overlay generated after relocation. Existing host evidence covers overlay loading and ListTools; no authenticated DeepSeek model task is claimed. | `tests/agent/test_package.py` clears `PYTHONPATH`, changes working directory, and uses a new virtual environment without host site-packages for resources, cached diff --git a/docs/validation/integration-release-matrix.md b/docs/validation/integration-release-matrix.md index c71ba7a..db3ff07 100644 --- a/docs/validation/integration-release-matrix.md +++ b/docs/validation/integration-release-matrix.md @@ -27,7 +27,7 @@ runs, not to every object from the named sources: | `integration_workspace` | The pinned USDCraft `ds_R022_02` two-drawer cabinet carried one independent GSO box in the lower drawer. The matched control removed only lower-drawer commands; the upper drawer still moved. Actual contact and relative poses were recorded. Drives were scheduled, and the observed contact data are not a general penetration certification. | | Motion keepouts | The supplied hinge and two-slider profiles cover their inspected native geometry and stated joint ranges. Unknown geometry is not assessed. Layout feasibility remains a geometric precheck, not a physics result. | | ArtVIP and SDK examples | The pinned door and guide-plate pair retain their previous limited checks. They do not qualify arbitrary ArtVIP objects or SDK-generated assets. | -| Client use | Both historical QI1 attempts failed to submit. The first reached its token limit before physics. The retry passed physics and began synchronous export, which was interrupted during submission reserve. The durable export path has its own engineering checks and awaits a fresh client qualification. | +| Client use | Both historical QI1 attempts failed to submit. The first reached its token limit before physics. The retry passed physics and began synchronous export, which was interrupted during submission reserve. The fixed GSO first delivery qualified with durable export, as recorded below. A cabinet-specific qualification remains open. | | Showcase video | An independently captured, source-mapped candidate exists; its visual review is `change_needed`. Video acceptance and physical acceptance are separate. | The development helper starts video export as a durable job. A client can save @@ -47,6 +47,28 @@ each new run. Hashes support integrity comparisons; they are not signatures. See [catalog capabilities](catalog-capabilities.md) for per-source conditions. +## Historical QI1 usage audit + +The retained Codex session records contain 16 completed model responses for +the first attempt and 22 for the retry. Their summed usage reconciles with +the host's totals. + +| Attempt | Total input and output tokens | Cached input tokens included in total | Tokens after reserve began | +| --- | ---: | ---: | ---: | +| First attempt | 1,047,317 | 955,904 | 295,405 | +| Retry | 1,016,231 | 951,552 | 314,460 | + +During the retry's background workflow, 13 responses completed between the +physics request and the host observing its terminal job status. Those responses +accounted for 598,944 tokens. The session shows repeated progress checks and +growing context across responses. The logs provide completion timestamps and +aggregate input usage. They give no per-component token breakdown or HTTP +request start times. + +The first-delivery host runs the long engineering workflow between model +turns. Its reported usage is scoped to the observed turns and the pinned +first-delivery case. + ## Independent first delivery On 2026-11-25, the new host-assisted first-delivery qualification submitted diff --git "a/docs/\345\277\253\351\200\237\345\274\200\345\247\213.md" "b/docs/\345\277\253\351\200\237\345\274\200\345\247\213.md" index 99a7d99..ea50db5 100644 --- "a/docs/\345\277\253\351\200\237\345\274\200\345\247\213.md" +++ "b/docs/\345\277\253\351\200\237\345\274\200\345\247\213.md" @@ -3,12 +3,18 @@ SimScene 为智能体提供在线资产检索、可编辑 USD 场景、Isaac Sim 运行和原生视频交付工具。 可以先查看资源与搜索元数据,再配置仿真主机;不需要预下载完整资产库。 -开发分支可运行[单物体首次交付](../examples/first_delivery/README.md),使用自建台面,完成 -选定模型获取、物理检查和 4 秒原生录像。安装方式见[插件打包与安装](packaging.md)。 +## 开发分支首次交付 -下文的公开版命令固定使用预览版 **v0.2.0-dev.1**。支持来源见 -[README 资源表](../README.md#supported-asset-sources)和 -[完整来源清单](assets/SOURCES.md)。来源可检索、模型能准备、物理实验通过是不同结果。 +按[插件打包与安装](packaging.md)安装开发包,再运行[单物体首次交付](../examples/first_delivery/README.md)。 +这个例子使用锁定的 GSO 扫描物体和项目自建台面,完成选定资产获取、跌落与稳定检查、 +4 秒原生视频及来源映射。 + +## 公开预览版入门 + +下文的公开版命令固定使用 **v0.2.0-dev.1**。该版本的注册范围见 +[公开预览版来源清单](https://github.com/ros-claw/simscene/blob/v0.2.0-dev.1/docs/assets/SOURCES.md)。 +当前开发分支的来源见 [README 资源表](../README.md#supported-asset-sources)。 +来源可检索、模型能准备、物理实验通过是不同结果。 ## 1. 安装基础包,先搜索元数据 @@ -63,7 +69,7 @@ simscene doctor 机器人 IK 的附加依赖可通过 `python -m pip install -e '.[ik]'` 安装;普通元数据搜索不需要它。 预构建客户端包为 Linux x86_64/Python 3.10,对应 wheel 和迁移方法见[插件安装说明](packaging.md)。 -## 3. 先复现一个小实验 +## 3. 复现预览版物理示例 [跨目录重力单元](../examples/catalog_gravity_cell/README.md)包含固定 ABO 笔记本道具的 单物体检查和四实例场景。它保存资产身份、准备参数和物理 case,适合先检查跌落、接触与稳定。 @@ -92,10 +98,10 @@ Isaac 路径、GLB 解码器和缓存配置应在实际启动 MCP 的环境中 安装包和客户端的验证范围见[客户端表](../README.md#connect-your-agent); Claude/DeepSeek 的加载检查不等于真实模型已经完成端到端场景任务。 -第一条提示可以使用: +在开发分支可用这条提示完成首次交付。 -> 复现 gravity-cell 示例,使用锁定的 ABO 笔记本道具和文档说明的 NVIDIA 工作台获取路径, -> 检查真实跌落、接触和稳定结果。明确启用原生录像,查看实际画面,交付可编辑场景、短视频和验证结果。 +> 运行 `first_delivery` 示例,让锁定的 GSO 扫描物体落到自建台面。检查接触与稳定结果, +> 导出原生短视频并审阅动作,交付可编辑场景、验证结果和视频来源映射。 ## 原有 NVIDIA USD 选材入口 diff --git a/plugins/build.py b/plugins/build.py index f0cd41b..52ab757 100644 --- a/plugins/build.py +++ b/plugins/build.py @@ -1,4 +1,4 @@ -"""Build separate portable and Claude plugin trees with isolated Python code.""" +"""Build portable, Claude and DeepSeek plugin trees with isolated Python code.""" import argparse import json import shutil @@ -7,7 +7,6 @@ import re import hashlib import tempfile -import importlib.util from pathlib import Path from importlib import metadata @@ -88,6 +87,11 @@ def verify_source_snapshot(root, snapshot, commit, paths=None): dependency completeness must be checked for each selected model. The optional layout, Sand3D and USDCraft SDK runtimes are configured separately; small pinned example recipes are included without model payloads. + +The DeepSeek layout includes `deepseek_patch.py`. From that package's final +directory, run `python3 deepseek_patch.py` and then +`dsh web --patch "$(pwd)/cordis.patch.yml"`. Use `--output` with an unused +path to regenerate the overlay after moving the package again. ''' EXAMPLE_DATA={ 'first_delivery':('README.md', 'assets.lock.json', 'case.json', 'recipe.json'), @@ -224,8 +228,8 @@ def build(destination, use_installed_deps=False): for name in names:shutil.copyfile(snapshot/'examples'/example/name,target/name) helper_root=portable/'experiments';helper_root.mkdir() for name in EXAMPLE_HELPERS:shutil.copyfile(snapshot/'experiments'/name,helper_root/name) - patch_spec=importlib.util.spec_from_file_location('simscene_snapshot_deepseek_patch',snapshot/'plugins'/'deepseek_patch.py') - patch_module=importlib.util.module_from_spec(patch_spec);patch_spec.loader.exec_module(patch_module) + deepseek.mkdir(parents=True) + shutil.copyfile(snapshot/'plugins'/'deepseek_patch.py',deepseek/'deepseek_patch.py') versions_lock={item.metadata['Name']:item.version for item in metadata.distributions(path=[str(vendor)])} write(portable/'server'/'dependency-lock.json',versions_lock) (portable/'server'/'launch.py').write_text(LAUNCHER) @@ -257,7 +261,6 @@ def build(destination, use_installed_deps=False): shutil.copyfile(portable/notice,claude/notice) write(claude/'.claude-plugin'/'plugin.json',{'name':'simscene','version':PACKAGE_VERSION,'description':'Discover assets, compose and run experimental simulation scenes.'}) write(claude/'.mcp.json',{'mcpServers':{'simscene':{'command':'python3','args':['${CLAUDE_PLUGIN_ROOT}/server/launch.py']}}}) - deepseek.mkdir(parents=True) shutil.copytree(portable/'server',deepseek/'server') shutil.copytree(portable/'skills',deepseek/'skills') shutil.copytree(portable/'examples',deepseek/'examples') @@ -265,7 +268,6 @@ def build(destination, use_installed_deps=False): shutil.copyfile(portable/'README.md',deepseek/'README.md') for notice in ('LICENSE','NOTICE','OPEN_SOURCE_NOTICES.md'): shutil.copyfile(portable/notice,deepseek/notice) - patch_module.write_patch(deepseek,deepseek/'cordis.patch.yml',sys.executable) return {'portable':str(portable),'claude':str(claude),'deepseek':str(deepseek),'python':sys.version.split()[0], 'python_version':PYTHON_VERSION,'plugin_version':PACKAGE_VERSION,'wheel_sha256':wheel_sha256, 'status':'packages_built_not_registered_or_installed', diff --git a/plugins/deepseek_patch.py b/plugins/deepseek_patch.py index a6e9a24..992814b 100644 --- a/plugins/deepseek_patch.py +++ b/plugins/deepseek_patch.py @@ -1,21 +1,54 @@ """Generate a local DeepSeek Harness Cordis MCP overlay without installing it.""" -import argparse,os,shutil,sys + +import argparse +import json +import os +import shutil +import sys from pathlib import Path -import yaml -def write_patch(plugin_root,output,python): - root=Path(plugin_root).expanduser().resolve();launcher=root/'server'/'launch.py' - if not launcher.is_file():raise FileNotFoundError(f'packaged server not found: {launcher}') - executable=shutil.which(str(python)) - if not executable:raise FileNotFoundError(f'Python executable not found: {python}') - executable=str(Path(executable).resolve());output=Path(output).expanduser().resolve() - patch=[{'insert':[{'id':'simscene-mcp','name':'@deepseek-ai/dsh-mcp-client','config':{ - 'serverName':'simscene','transport':'stdio','command':executable,'args':[str(launcher)],'env':{},'cwd':str(root)}}]}] - output.parent.mkdir(parents=True,exist_ok=True) - with output.open('x',encoding='utf8') as file:yaml.safe_dump(patch,file,allow_unicode=True,sort_keys=False) - return {'patch':str(output),'plugin_root':str(root),'status':'generated_not_installed'} -if __name__=='__main__': - import json - parser=argparse.ArgumentParser();parser.add_argument('--plugin-root',required=True);parser.add_argument('--output',required=True);parser.add_argument('--python',default=sys.executable) - args=parser.parse_args();print(json.dumps(write_patch(args.plugin_root,args.output,args.python),indent=2)) +def write_patch(plugin_root, output, python): + import yaml + + root = Path(plugin_root).expanduser().resolve() + launcher = root / 'server' / 'launch.py' + if not launcher.is_file(): + raise FileNotFoundError(f'packaged server not found: {launcher}') + executable = shutil.which(os.path.expanduser(python)) + if not executable: + raise FileNotFoundError(f'Python executable not found: {python}') + # Preserve virtual environment symlinks so Python uses the selected environment. + executable = str(Path(executable).absolute()) + output = Path(output).expanduser().resolve() + patch = [{'insert': [{ + 'id': 'simscene-mcp', + 'name': '@deepseek-ai/dsh-mcp-client', + 'config': { + 'serverName': 'simscene', + 'transport': 'stdio', + 'command': executable, + 'args': [str(launcher)], + 'env': {}, + 'cwd': str(root), + }, + }]}] + output.parent.mkdir(parents=True, exist_ok=True) + with output.open('x', encoding='utf8') as file: + yaml.safe_dump(patch, file, allow_unicode=True, sort_keys=False) + return {'patch': str(output), 'plugin_root': str(root), 'status': 'generated_not_installed'} + + +if __name__ == '__main__': + local_root = Path(__file__).resolve().parent + vendor = local_root / 'server' / 'vendor' + if vendor.is_dir(): + sys.path.insert(0, str(vendor)) + + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--plugin-root', type=Path, default=local_root) + parser.add_argument('--output', type=Path) + parser.add_argument('--python', default=sys.executable) + args = parser.parse_args() + output = args.output or args.plugin_root / 'cordis.patch.yml' + print(json.dumps(write_patch(args.plugin_root, output, args.python), indent=2)) diff --git a/src/simscene/catalog/audit.py b/src/simscene/catalog/audit.py index 8922559..bf362db 100644 --- a/src/simscene/catalog/audit.py +++ b/src/simscene/catalog/audit.py @@ -124,6 +124,33 @@ def _text(value): return str(value).replace('|', '\\|').replace('\n', ' ').replace('\r', ' ').replace('<', '<').replace('>', '>') +def _source_summary(source): + formats = { + 'nvidia': 'USD', 'abo': 'GLB', 'hf_manifest': 'GLB', 'usdcraft': 'USD', + 'artvip': 'USD', 'simready_package': 'USD', 'http_assets': 'HDRI / material maps (selected IDs)', + 'simready_central': 'USD locators (metadata only)', + }.get(source.adapter, 'unknown') + link = f'[{_text(source.source_id)}]({source.homepage})' + return (link, source.state, 'yes' if source.default_enabled else 'no', formats) + + +def _table_row(columns): + return '| ' + ' | '.join(_text(value) for value in columns) + ' |' + + +def update_readme_sources(readme, registry=None): + """Replace the single marked source table using the packaged registry.""" + start = '' + end = '' + if readme.count(start) != 1 or readme.count(end) != 1 or readme.index(start) > readme.index(end): + raise ValueError('README must contain one ordered pair of asset source markers') + if registry is None: + registry = load_registry() + lines = ['| Source ID | State | Default | Formats |', '| --- | --- | --- | --- |'] + lines.extend(_table_row(_source_summary(source)) for source in registry.sources) + return readme[:readme.index(start)] + '\n'.join([start, '', *lines, '', '']) + readme[readme.index(end):] + + def build_source_list(registry=None, audit_snapshot=None): """Render SOURCES.md solely from registry and an explicit optional audit view.""" registry = registry or load_registry() @@ -134,17 +161,12 @@ def build_source_list(registry=None, audit_snapshot=None): '|---|---|---|---|---|---|---|---|'] for source in registry.sources: examples = [item for item in source.evidence if isinstance(item, dict) and item.get('evidence_basis') == 'locally_executed' and item.get('runtime_validation') == 'pass'] - formats = {'nvidia': 'USD', 'abo': 'GLB', 'hf_manifest': 'GLB', 'usdcraft': 'USD', 'artvip': 'USD', - 'simready_package':'USD', 'http_assets':'HDRI / material maps (selected IDs)', - 'simready_central':'USD locators (metadata only)'}.get(source.adapter, 'unknown') license_info = source.license_policy license_label = license_info.get('license') or license_info.get('status', 'unknown') license_label += '; per-asset review required' if license_info.get('per_asset_required') else '' - columns = [f'[{_text(source.source_id)}]({source.homepage})', source.state, - 'yes' if source.default_enabled else 'no', formats, - source.acquisition_granularity or 'unknown', license_label, - source.checked_at or 'unknown', str(len(examples))] - lines.append('| ' + ' | '.join(_text(value) for value in columns) + ' |') + columns = (*_source_summary(source), source.acquisition_granularity or 'unknown', + license_label, source.checked_at or 'unknown', str(len(examples))) + lines.append(_table_row(columns)) lines += ['', '## Lifecycle inventory', ''] for state in ('enabled', 'audited', 'candidate', 'quarantined', 'reference_only'): identifiers = ', '.join(source.source_id for source in registry.sources if source.state == state) or '(none)' diff --git a/tests/agent/test_package.py b/tests/agent/test_package.py index e465e4a..2bdf137 100644 --- a/tests/agent/test_package.py +++ b/tests/agent/test_package.py @@ -16,6 +16,16 @@ async def check(root,plugin): result=await session.call_tool(name,args) self.assertFalse(result.isError,f'{name}: {result}') self.assertTrue((root/'scene.usda').is_file()) + async def check_overlay(config, env): + server = StdioServerParameters(command=config['command'], args=config['args'], + cwd=config['cwd'], env=env) + async with stdio_client(server) as (reader, writer): + async with ClientSession(reader, writer) as session: + await session.initialize() + names = {tool.name for tool in (await session.list_tools()).tools} + self.assertIn('catalog_search', names) + self.assertIn('video_export_start', names) + async def check_independent_metadata(root,plugin): # A new venv has neither checkout imports nor host site-packages. interpreter=root/'isolated-python' @@ -146,10 +156,42 @@ async def check_independent_metadata(root,plugin): config=json.loads((plugin/'mcp.json').read_text());self.assertEqual(config['mcpServers']['simscene']['type'],'stdio') elif kind=='claude':self.assertTrue((plugin/'.claude-plugin/plugin.json').is_file()) else: - patch=yaml.safe_load((plugin/'cordis.patch.yml').read_text());row=patch[0]['insert'][0] - self.assertEqual(row['name'],'@deepseek-ai/dsh-mcp-client') - self.assertEqual(row['config']['args'],[str(plugin/'server'/'launch.py')]) - self.assertEqual(row['config']['cwd'],str(plugin)) + self.assertFalse((plugin/'cordis.patch.yml').exists()) + moved = stage/'moved plugin' + if supplied: + shutil.copytree(plugin, moved) + else: + plugin.rename(moved) + plugin = moved + generator = plugin/'deepseek_patch.py' + self.assertEqual(generator.read_bytes(), (ROOT/'plugins/deepseek_patch.py').read_bytes()) + interpreter = stage/'local python' + subprocess.run([sys.executable, '-m', 'venv', '--without-pip', str(interpreter)], check=True) + python = interpreter/'bin/python' + env = dict(os.environ, PYTHONPATH='', PYTHONNOUSERSITE='1', SIMSCENE_HOME=str(stage/'state')) + command = [str(python), '-I', str(generator)] + completed = subprocess.run(command, cwd=stage, env=env, capture_output=True, text=True, check=True) + overlay = plugin/'cordis.patch.yml' + self.assertEqual(json.loads(completed.stdout)['status'], 'generated_not_installed') + row = yaml.safe_load(overlay.read_text())[0]['insert'][0] + self.assertEqual(row['name'], '@deepseek-ai/dsh-mcp-client') + config = row['config'] + self.assertEqual(config['transport'], 'stdio') + self.assertEqual(config['command'], str(python)) + self.assertEqual(config['args'], [str(plugin/'server/launch.py')]) + self.assertEqual(config['cwd'], str(plugin)) + asyncio.run(check_overlay(config, env)) + original = overlay.read_bytes() + duplicate = subprocess.run(command, cwd=stage, env=env, capture_output=True, text=True) + self.assertNotEqual(duplicate.returncode, 0) + self.assertEqual(overlay.read_bytes(), original) + + new_overlay = stage/'regenerated overlay.yml' + explicit = command + ['--plugin-root', str(plugin), '--output', str(new_overlay), + '--python', './python'] + subprocess.run(explicit, cwd=python.parent, env=env, capture_output=True, text=True, check=True) + regenerated = yaml.safe_load(new_overlay.read_text())[0]['insert'][0]['config'] + self.assertEqual(regenerated, config) asyncio.run(check(stage,plugin)) if kind=='portable':asyncio.run(check_independent_metadata(stage,plugin)) if shutil.which('codex'): diff --git a/tests/test_catalog_audit.py b/tests/test_catalog_audit.py index 5296c11..6b5d45b 100644 --- a/tests/test_catalog_audit.py +++ b/tests/test_catalog_audit.py @@ -119,6 +119,29 @@ def test_generated_sources_file_matches_registry_single_truth(self): self.assertIn('unknown; per-asset review required', text) self.assertIn('not registered sources or prepared assets', text) + def test_readme_source_table_matches_registry_without_changing_other_content(self): + from simscene.catalog.audit import update_readme_sources + + root = Path(__file__).resolve().parents[1] + readme = (root / 'README.md').read_text() + registry = load_registry() + self.assertEqual(update_readme_sources(readme, registry), readme) + + updated_registry = Registry(tuple( + replace(source, default_enabled=False) if source.source_id == 'abo-glb' else source + for source in registry.sources + )) + changed = update_readme_sources(readme, updated_registry) + before, right = readme.split('') + after = right.split('')[1] + self.assertTrue(changed.startswith(before)) + self.assertTrue(changed.endswith(after)) + self.assertIn('[abo-glb](https://huggingface.co/datasets/codepawl/abo-glb) | enabled | no |', changed) + self.assertIn('[artvip](https://huggingface.co/datasets/X-Humanoid/ArtVIP) | audited | no |', changed) + for invalid in ('', readme + readme, ''): + with self.subTest(invalid=invalid[:40]), self.assertRaises(ValueError): + update_readme_sources(invalid, registry) + def test_candidate_version_and_unknown_contract_values_fail_explicitly(self): for changes in ({'schema_version': True}, {'default_enabled': True}, {'state': 'enabled'}, {'formats': 'glb'}, {'license': {'status': 'runtime_verified', 'declarations': []}}):