SIM-R2: L2 可运行板 (ADR-019) #3

Open
jiaqi02.sun wants to merge 93 commits from codex/sim-r2 into main
Owner

基于 SIM-R1;独立测试全过(AT-038..041,836/836,覆盖96.35%;见 docs/testing/evidence/sim-r2/)。建议先合 SIM-R1 再合本分支。

基于 SIM-R1;独立测试全过(AT-038..041,836/836,覆盖96.35%;见 docs/testing/evidence/sim-r2/)。建议先合 SIM-R1 再合本分支。
jiaqi02.sun added 93 commits 2026-08-27 19:38:32 +08:00
- Close 2B-0 Webots preview gate: fix 3D black-screen (z-fighting), preview/
  batch lifecycle separation, explicit Python executable, reset recovery.
- Add rdk_agent_sim package: deterministic 2WD/arm/gripper world, run-bound
  capability endpoint, scenario schema, sim-stdio transport, preflight.
- Harden deterministic runtime: cancel/timeout/deadline/explicit-stop/disconnect
  safe-stop, fault schedule (drop_frames/wheel_slip), enforced ticket
  environment_kind, dual production/Oracle verifier channel.
- Fix two state-machine bugs exposed by branch coverage: cancel path now walks
  RUNNING→CANCELLING→CANCELLED, crash path RUNNING→TIMED_OUT→FAILED.
- Raise rdk_agent_sim branch coverage to 93% (>=90% gate).
- ADR-016 Accepted; Webots R2025a frozen (external dependency, SHA-256 pinned).
- Add public barrel entry (index.ts) for @rdk/rdk-agent-surface with explicit
  exports: DeviceService, TaskService, TaskServiceOptions, buildTaskService.
  Add main/types/exports to package.json. Add barrel contract test.
- Upgrade desktop Electron from 34 to 43.4.0 (Node 24.17.0, resolves undici
  crash on Electron 34's Node 20.18.1). Add version guard at startup.
- Fix __dirname ESM compatibility in main.ts.
- Add task.list RPC to host frames/server/stores + acceptance test fix.
- Surface: TaskService, TaskServiceFactory, OwnerLock, Workspace, TUI, CLI,
  MCP, healthCard, and integration tests.
- Desktop: Electron main/preload/renderer, security, IPC handlers, build
  (HTML copy to dist), test suite (5/5).
- Electron 34 → 43.4.0 (Node 24.18.1) resolves undici crash on Node 20;
  split bootstrap (main.ts version guard) from mainImpl.ts (dynamic import).
- workspace-root explicit: desktop uses userData/workspaces (never home);
  CLI/TUI reject a missing --workspace-root instead of falling back to cwd.
- Fix MCP runMcpServer: connect() is non-blocking (stdio start() only registers
  stdin listeners); block until stdin end/close or signal so the TaskService is
  not closed before any tool call.
- esbuild-bundle preload → preload.cjs (sandbox CJS) and the renderer tsx.
- Add RDK_DESKTOP_SMOKE=1 real-launch smoke (real Host + Fake Device + Pi
  ScriptedModel session → DESKTOP_SMOKE_OK).
- Add cross-surface e2e (real Host integration): CLI starts, MCP observes,
  owner conflict, cancel, take-over resume, shared device snapshot.
- Evidence: docs/testing/evidence/S1-B.md.

Gates: Python 619 passed; surface 62/3; pi 18/4; desktop 5; e2e 1 passed;
ruff/format/mypy clean.
- P1: restrict renderer navigation to the exact packaged index.html URL
  (isAllowedRendererNavigation) instead of a bare file: scheme, so an arbitrary
  local HTML page can no longer load into the window and receive the preload
  task/device bridge.
- P1: await window.loadFile() and assert the preload bridge (window.rdk) is
  exposed before the real-launch smoke fires, so DESKTOP_SMOKE_OK now proves the
  renderer/preload mounted.
- P2: add a spawned-stdio MCP lifecycle test (handshake → tool call reaches an
  open TaskService → stdin close → clean exit) regressing the runMcpServer bug;
  runMcpServer handles an already-ended stdin and drops unused signal listeners.
- P2: add tsconfig.typecheck.json (noEmit, covers preload.ts + renderer tsx that
  esbuild does not type-check) and wire it into .

Gates: desktop typecheck+build+test 7; surface build+test 62/3; real e2e +
mcpLifecycle 2 passed; Electron RDK_DESKTOP_SMOKE=1 → DESKTOP_SMOKE_OK, no
residual Host/Device.
- S1A-DEBT-001: SshDeviceConnector passes the registered device_id to the
  s100-readonly Helper as --device-id (remote_command); application.connector_for
  wires device_id=device_id. The Helper no longer exits RDK-INV-001 on a missing
  --device-id.
- S1A-DEBT-002: scripts/install-device-helper.sh (build|install|update) bundles
  rdk-agent-device + rdk-s100 + rdk-agent-core (pure-py py3-none-any wheels) into
  ~/.rdk/bin/rdk-agent-device. .gitignore dist-helper/.
- Tests: test_ssh_argv_passes_device_id_to_readonly_helper; full pytest green
  (620) + install smoke (wheel build -> install -> rdk_s100 import -> s100-readonly
  serve --device-id boots).
- Migrate smoke assets into packages/rdk_agent_sim/assets: self-made red_cube_
  grasp.wbt (2WD + USB camera + 3-DOF arm + two-finger gripper + static red cube)
  and two stdlib-only controllers.
- Separate the Robot data plane (rdk_robot_bridge: camera/base/arm/gripper/
  encoder over RDK_ROBOT_SOCKET) from the Oracle plane (rdk_oracle_supervisor:
  ground-truth truth/reset over RDK_SUPERVISOR_SOCKET) — different sockets,
  ground truth never reaches the Agent.
- WebotsWorld + WebotsSession: launch Webots.app --mode=fast --batch, connect
  both controllers, and expose the same SimWorld surface as DeterministicWorld
  so the capability endpoint / action script / recorder / oracle are unchanged.
- WebotsBackend (ExecutionBackend) reuses CapabilityEndpoint + action_script +
  recorder + oracle; profile=webots is now served (no longer blocked).
- Extract a SimWorld Protocol (robot/cube/inside_gripper + capability methods)
  so capability_endpoint / recorder / oracle are fidelity-neutral.
- Episode reset is a fresh Webots process per run (simpler and more isolated
  than worldReload + cross-reload markers).

Gates: Python 621 passed; ruff/mypy/format clean; headless batch end-to-end
(inside_gripper=true, gripper 0.97, arm joints set, target_visible=true).
Real-device validation (S100P) exposed two defects in the DEBT-002 install:
- --no-deps skipped pydantic (rdk-agent-core's dep); pydantic-core is a compiled
  extension and the board has no internet, so build now vendors the aarch64
  cp310 closure into dist-helper/deps via 'uv pip install --target --python-platform'.
- 'pip install --target' entry points run without the target dir on sys.path;
  install now writes a PYTHONPATH wrapper instead of a bare symlink.

syntax-checked and rebuild-verified (dist-helper = 3 wheels + deps/).
- collect_s100_inventory.py: SSH-backed CommandRunner driving the product S100
  Inventory Engine against the live board (read-only). Produced the real
  snapshot (docs/testing/evidence/s100p-snapshot.json): D-Robotics RDK S100P
  V1P0, RDK OS 4.0.5-Beta, aarch64, 21.3GB, Realtek USB camera present, TROS
  humble, 8/8 probes complete.
- Records S1C-FIND-001 (model NUL byte) and S1C-FIND-002 (bpu false-positive).
- Host fingerprint SHA256:IDmdMLvf3cET0+X+qbsJpAIxo4XtibiULpnohvFp7/I.
With user-authorized SSH key auth in place, drive_formal_chain.py runs the
production SshDeviceConnector (DEBT-001 --device-id, BatchMode key auth,
StrictHostKeyChecking, fixed helper path) -> on-board s100-readonly Helper ->
real inventory. Snapshot_id matches the direct-SSH engine path
(sha256:77f789f8...), confirming identical real facts across both transports.
- WebotsSession gains realtime=True: launches --mode=realtime (3D window at
  wall-clock speed) instead of --batch --no-rendering, and leaves the window
  open for the human after the run instead of terminating it.
- rdk-agent-sim serve --profile webots --mode realtime opens the GUI and runs
  the grasp; --mode batch (default) stays headless for CI.
- Close the accepted controller sockets on __exit__.

Gates: Python 621 passed; ruff/mypy/format clean; realtime run opens the window,
completes inside_gripper=true, and leaves the window open.
- FIND-001: FileProbe strips the device-tree NUL terminator from
  /proc/device-tree/model (was trailing \x00 in the model string).
- FIND-002: bpu.runtime probe no longer pipes ls through 'head -1' (which masked
  ls's non-zero rc behind head's 0), and bpu.inference.static is only advertised
  when a libdnn path is actually observed. Absent runtime -> unknown, not a
  false-positive available.

Tests: model with NUL -> 'RDK S100P'; bpu rc=2 -> None; bpu rc=0-empty -> None.
5 passed; ruff/mypy clean.
Re-ran the fixed S100 engine against the live board: model has no NUL, bpu
probe now fails honestly (completeness=partial), bpu.inference.static absent.
Replace the abstract blue-box robot with a DIY form factor: a green S100P PCB
(SoC + edge connectors + pin header), a 2WD differential base, a USB camera
mounted on the deck, and a 3-DOF servo arm with a two-finger gripper — all
self-made basic geometry, device names and the capability/controller/Oracle
chain unchanged.

Oracle cube pose updated to the new rest pose (0.42, 0.06).
- Set Viewpoint to follow red_cube_robot (Pan and Tilt Shot) so the GUI camera
  automatically aims at the robot (follow only updates under interactive GUI,
  which is why batch screenshots looked off-target).
- Add an oracle 'screenshot' command (exportImage) for visual verification.
- Keep REAL scale (S100P board 14cm, chassis 40cm) — refraining from the
  visual-favoring scale-up that would snowball every future peripheral.
- Light ground (0.88) vs dark chassis (0.12) so the low-profile robot no longer
  blends into gray; brighter green PCB and blue arm.
- Center the fixed top-down viewpoint between the robot and the cube (0.38m) so
  both are in frame and the scene is no longer a sky/ground blob.
Real ExecutionBackend (docs/02 §4.11, ADR-003/012): runs the manifest
entrypoint as the ordinary user from the product run root:
- fail-closed relpath containment before any state transition (no .. escape,
  no missing-source half-started run);
- fixed cwd = run root, minimal env + manifest env allowlist, umask 0o077;
- wall-time + output-bytes bounds (policy defaults);
- new process group (start_new_session); cancel/timeout SIGTERM group ->
  SIGKILL after grace, cleanup unconfirmed only if the group can't be reaped;
- stdout.log + result.json artifacts, state machine STAGING->RUNNING->…
  (COLLECTING/VERIFYING)->SUCCEEDED/FAILED/TIMED_OUT/CANCELLED.

7 unit tests (success / non-zero / timeout / cancel-with-grandchild-kill /
missing-source / path-escape / output-cap). 628 pytest total; ruff/mypy clean.
Protocol 1.1 adds run.stage (docs/03 §4.4): the Host ships the plan-bound
workspace source to the device between prepare and start; the device only
accepts bytes whose per-file digests and aggregate digest match the HMAC
ticket's source binding, refuses staging after start, and treats a
same-binding replay as an idempotent rewrite. Staged source lives in the
run's source/ subtree, never next to registry files.

- UserProcessBackend runs from source/, re-verifies every staged file
  against stage.json before spawn (tamper fail-closed), and collects
  manifest-declared file artifacts from the program cwd; a missing required
  artifact is an event, never a silent pass.
- New s100-exec Helper profile: real s100 inventory + UserProcessBackend;
  HMAC ticket key from an owner-only file (default ~/.rdk/ticket_key),
  never argv, never the fake key. SshDeviceConnector gains a host-side
  helper_profile selection (default stays s100-readonly).
- WorkspaceService.iter_source_files refuses secret-named files and
  enforces the staging bounds (256 files / 256 KiB file / 768 KiB total).

Gates: 652 pytest passed; ruff/mypy clean; core coverage 95.57%.
- tests/integration/test_exec_device_end_to_end.py: the full S2 slice over
  a real rdk-agent-device subprocess (s100-exec profile, provisioned key
  file): stage → UserProcessBackend run → declared artifact → verifier
  aggregation, plus idempotent replay, source-drift plan invalidation and
  cancel with confirmed process-group cleanup.
- scripts/drive_s2_health_card.py: production-path driver for the Starter 1
  real-device evidence (AgentApplicationService + SshDeviceConnector).
- scripts/install-device-helper.sh keygen: provision the owner-only ticket
  key file the s100-exec profile requires.

Gates: 656 pytest passed; ruff/mypy clean; core coverage 95.57%.
The device default runs root is RELATIVE (.rdk/runs under the Helper login
cwd). UserProcessBackend._verify_staged_source compares a resolved file path
against the unresolved source root, so every staged file 'escaped' and start
was denied on the real board (found by the first S2 health-card attempt).
Includes a relative-root roundtrip regression test.
- docs/testing/evidence/S2.md + s2-health-card/{drive-result,health}.json:
  the full chain on the real S100P (inspect → code → plan → stage → run →
  artifacts → verify) with idempotent replay, plan invalidation, timeout
  and cancel all cleanup-confirmed; includes both real-device failure
  rounds (ssh user, relative runs-root) and their fixes.
- scripts/drive_s2_health_card.py: default to sunrise@192.168.127.10.
- scripts/install-device-helper.sh: install wipes the managed lib dir
  (pip --target never replaced stale code).
- docs/09: current task is S2; slice 1 recorded, remaining slices listed.
The oracle previously passed whenever the cube sat near its spawn point
and the gripper was commanded closed — the robot could be flung 62 m away
and still "grasp". Rework the slice so every pass is earned:

- oracle supervisor: inside_gripper now requires the measured cube center
  inside a real capture region around the measured jaw (<=0.10 m
  horizontal/vertical) AND the jaw hinge actually closed; reports jaw and
  robot poses plus jaw-to-cube distances as ground truth
- world: explicit NUE coordinateSystem for the Y-up scene; HingeJoint
  endPoint Solids carry their own anchor translation; wheel cylinders
  wrapped in rotated Transforms so ODE collision geometry matches the
  visual wheels (R2025a lessons, recorded inline in the .wbt)
- robot bridge: firmware-side action envelopes (linear/angular/duration,
  arm joint limits, gripper range) rejected fail-closed; camera warm-up
  steps so the first snapshot is a real frame; clean exit on session EOF
- action script: fold the arm before driving (an extended arm bulldozes
  the cube), drive 0.3 m/s x 640 ms (~0.19 m), unfold onto the IK grasp
  pose, then close; timeouts track servo maxVelocity
- deterministic world: encoders report wheel radians like the real
  PositionSensor; cube spawn matched to the shared script's drive distance
- webots world: robot pose comes from Supervisor measurement, never from
  encoder odometry (odometry stays production evidence, not ground truth)

Gates: ruff/format clean; sim unit tests green; Webots physics evidence
lands with the regression suite in the follow-up commit.
- tests/integration/test_sim_webots_physics.py: real-Webots regression for
  the grasp slice — positive run asserts Supervisor-measured motion
  (~0.19 m), a real camera frame with red pixels, oracle pass on measured
  geometry, and the diagram artifact; negative control moves the cube out
  of reach and requires the oracle to fail. Skips with blocked semantics
  (TEST_STRATEGY: a skip is not a pass) when the frozen R2025a is absent.
- diagram.py: human-facing ASCII 2D view of the S100P + peripherals grasp
  task annotated with the episode's ACTUAL production state (oracle truth
  is never drawn); persisted as diagram.txt run artifact by WebotsBackend.
- run_tmp.py: hash run_id into the TemporaryDirectory prefix so the
  capability socket stays under macOS's 104-char AF_UNIX sun_path limit
  regardless of run_id length; both backends use it.

Gates: ruff/format clean; 60 sim unit tests pass; integration suite
2 passed in ~4.4 s against Webots R2025a (not skipped).
ADR-016 §2 mandates that a simulation/board_in_loop pass never counts as
hil acceptance and that the report layer forcibly separates (报告层强制分
列). report_task now also returns environment_outcomes: verification
results are aggregated per environment group, so a grasp that passed in
Webots reports {"simulation": "passed"} — never a "hil" key. Runs without
provenance group under "unknown" instead of defaulting to hardware. The
existing aggregate outcome semantics are unchanged, and the
budget-exhausted early return carries the field too.

Registers AT-028 in ACCEPTANCE_TESTS.md and maps ADR-016 §2 →
TestReportEnvironmentSeparation in TRACEABILITY.md. Student journey: a
boardless student's passing simulation run reads as "simulation: passed",
never as hardware validation (honest-result spirit of CFR-025).

Gates: ruff/format clean; 574 unit tests pass (5 new); integration +
acceptance 30 passed.
Closes the S2 'Agent development loop' milestone (docs/06 §6) on the
codex/s2-agent-loop branch:

- task lifecycle (slice 2): _advance_task anchors EXECUTING at task-bound
  run start and VERIFYING at terminal observation (run_status/reconcile/link);
  report_task no longer crashes on created->completed (the product path now
  drives the funnel). _adopt_terminal_device_record reconciles a terminal
  same-plan device run on host-state-loss replay instead of failing it.
- budgets (slice 3): start_run gates on task budget BEFORE device side
  effects (idempotent replay wins, AT-004); _account_terminal_run charges
  host-measured duration at terminal observation (immune to device clock
  skew); Budgets._consume clamps to limit so exhausted() reads true; report
  surfaces budget exhaustion over verifier aggregation.
- verify-on-status (slice 3): a run finishing after the start wait window
  is verified when run_status observes the SUCCEEDED transition (AT-010),
  not only in the start path.
- resume productization (slice 3): resumeTask reconciles device truth,
  freezes a recovery checkpoint, and injects recovery context (goal/state/
  runs/unsatisfied verifiers) into the session (docs/08 §6); CLI gains
  'task artifact' to read declared artifacts/success evidence.
- contract surface: task.reconcile / task_reconcile added to the AT-021
  method registry and TS allowlist.

Real device: sliceS2 scripted loop (19/0) and the disconnect-reconcile
drill (scripts/drive_s2_reconcile.py) both pass on the S100P; the drill
proves reconcile reads device truth without re-starting, orphaned runs
fail closed, and a fresh recovery run completes the task.

Gates: pytest 663 passed; pi 18/5skip · surface 65/4skip · desktop 7/0;
ruff + format + mypy clean.

Evidence: docs/testing/evidence/S2.md slices 2-3 + s2-agent-loop/ +
s2-reconcile/
The product surfaces defaulted to a deterministic ScriptedModel (no network,
no credentials). docs/08 §8 specifies two real-model paths: Pi provider
login or API key. This adds the API-key path.

New anthropicModel.ts resolves the key at runtime from (in order) the
RDK_ANTHROPIC_API_KEY env var, the macOS keychain item rdk-agent/
anthropic-api-key, or the 0600 keyfile ~/.rdk/anthropic-key. When a key is
present, the TaskService defaultModelFactory writes a real
anthropic-messages provider into the per-task agentDir's models.json
(0600, under the gitignored state dir) and returns no in-process handle —
createAgentSession then resolves the model from that config and the real
LLM drives the tool loop. With no key, the deterministic ScriptedModel
fallback is unchanged (all existing tests stay green).

Model id and base URL are configurable (RDK_ANTHROPIC_MODEL default
claude-sonnet-5, RDK_ANTHROPIC_BASE_URL default api.anthropic.com).

Tests: 4 new in anthropicModel.test.ts (env/keychain/keyfile precedence,
config content, 0600 mode, null fallback). Gates: pi 22/5skip, surface
65/4skip, desktop 7/0.
A single 0600 file ~/.rdk/anthropic-config.json ({baseUrl,apiKey,model})
covers the custom-gateway case where all three differ from the Anthropic
defaults. Env vars still override field-for-field. Keychain and the plain
keyfile remain as key-only fallbacks. Tests +2 (gateway config, env override).
The real-model factory's wire format is now configurable: anthropic-messages
(default) or openai-responses for an OpenAI-Responses-compatible gateway.
Renamed the neutral surface (createAnthropicModel -> createRealModel,
REAL_MODEL_PROVIDER, resolveRealModelConfig) since it is no longer
Anthropic-specific. Config file gains an 'api' field; RDK_MODEL_API env
overrides; unknown apis reject and fall back to scripted. Tests +2
(openai-responses gateway, unknown-api rejection); 8 total.
Replaces the keychain + keyfile + JSON-config-file machinery with one flat
0600 .env at ~/.rdk/.env (gitignored) holding four variables:
RDK_ANTHROPIC_BASE_URL / _API_KEY / _MODEL / RDK_MODEL_API. Real process.env
still overrides field-for-field. Simpler for users, fewer code paths; the
wire format stays configurable (anthropic-messages default, openai-responses
for gateways). Tests rewritten to the .env shape (6 cases).
The product agent loop now completes end-to-end with a real LLM on the real
S100P, not just the scripted model. Three root causes found and fixed by
driving Qwen then kimi-k3 against the board:

1. rdk-develop SKILL.md was never reaching the model (noSkills suppresses
   discovery; no skill-read tool is allowlisted). Inject the SKILL.md body
   into appendSystemPrompt alongside task-summary.md — the one channel the
   model always reads. Added a concrete Run manifest shape example
   (entrypoint/requirements/resources/artifacts/verifiers) so models stop
   inventing {steps,capabilities,intent,...} schemas.
2. device.inventory rejected free-text 'reason' (TS advertises Type.String,
   host enforced InventoryReason enum) — a contract mismatch that stalled
   every non-Claude model at inventory. Host now coerces unknown reason ->
   USER_REQUEST and drops unknown targets (DeviceInventoryParams validators).
3. task-summary.md said 'M0 only fake-001, S100P does not exist' — stale,
   biased models into refusing s100p-001. Updated: s100p-001 is a verified
   real-device target; rdk_device_list empty on a fresh state dir does not
   mean unavailable; inventory the user-named device directly.

Real-device result (kimi-k3, ai-api.d-robotics.cc/v1, openai-responses):
inventory -> write -> checkpoint -> plan (valid manifest) -> run_start ->
run succeeded / outcome=passed / exit=0 / cleanup=confirmed on the S100P.
Residual: the model did not task-bind the run (created the task after
run_start), so task_report couldn't aggregate — workflow-ordering gap, not
a run defect; the run itself passed verifiers on real hardware.

Gates: pytest 664, pi 24/5skip, surface 65/0/4, ruff/mypy clean.
Driving kimi-k3 on a coding task exposed three harness gaps, now fixed in the
skill (the one channel the model reads, via appendSystemPrompt):

- Iteration section: on a failed run, diagnose via artifact/stdout/events,
  workspace_patch, RE-PLAN (source digest change invalidates the old plan,
  AT-003), and re-run with a NEW requestId (reusing one is an idempotent
  replay that executes nothing). This was the core blocker: the model reused
  request_ids, so re-runs were no-ops and it never converged.
- Verifier-alignment section: json.assert path/equals must match the JSON the
  program ACTUALLY writes; a program that exits 0 but whose verifier path is
  absent is a failed run, not a pass.
- Manifest example abstracted to a skeleton (no complete health-card program
  to copy) so the model writes the user's task, not the example.

Result on real S100P with kimi-k3: the loop now converges — write -> plan ->
run -> verify -> report, task-linked, fresh request_ids, run
succeeded/passed, task completed. Residual: kimi-k3 still defaults to writing
a generic health card regardless of the requested task (CPU sampler) — a
model task-adherence limit, not a harness defect; a stronger model would
follow the specific task. Gates: pytest 664, ruff/mypy clean.
The agent kept writing a health card regardless of the requested task. Root
cause was a harness bug, not the model: TaskService.startTask hard-coded the
session prompt to '启动系统健康卡' (S1-B scripted-demo legacy), so the user's
goal was stored in the task record but NEVER sent to the model. Every real-
model run therefore received 'start a health card' and produced one.

Fixes (harness, model-agnostic):
- startTask now prompts the session with the user's actual goal + a
  workflow nudge, not a hard-coded health-card string.
- json.assert gained a key-existence mode: omit 'equals' to assert the path
  is present and non-null (for variable outputs like busiest_core that the
  model can't predict). 'equals: null' still means strict null. The skill
  was telling models to use equals:null for existence — wrong; corrected.
- skill diagnose guidance: exit=0 + json.assert fail => verifier config is
  wrong, not the program; fix the manifest verifier (re-plan), don't
  rewrite a program that already exits 0.
- skill manifest example abstracted (no complete health-card to copy);
  verifier-alignment guidance.

Real-device result (kimi-k3, openai-responses gateway, S100P): the agent
wrote cpu_sampler.py (read /proc/stat twice, compute per-core usage %),
ran it on the board, iterated with fresh request_ids, converged to
run succeeded / outcome=passed / task completed. Device artifact cpu.json
holds real per-core CPU usage (6 cores). The agent can now CODE a novel
embedded capability on the device, not just replay a health card.

Gates: pytest 666, pi 24/5skip, surface 65/0/4, ruff/mypy clean.
A Pack freezes a run's source + manifest into a named, reusable capability:
save_pack (freeze workspace source + plan manifest), list_packs, run_pack
(re-stage + re-plan + start_run with NO model in the loop — deterministic
replay of a saved capability). Pack + FilePackStore (state/packs/<name>/).
Host frames pack.save/list/run + server dispatch; TS tools rdk_pack_save/
list/run in the allowlist; CLI 'rdk-agent pack save/list/run'. Contract
tests (AT-021 + TS allowlist) updated for the 3 new methods.

Real-device evidence (scripts/drive_s3_pack.py, kimi not in the save/run
loop): agent's cpu_sampler run succeeded/passed -> pack.save 'cpu-sampler'
-> pack.list -> pack.run produced a different run_id, succeeded/passed,
no LLM. The capability is now retained and re-runnable.

Also: journey battery (4 varied capabilities on real S100P — USB enumerate,
thermal hottest-zone, network interfaces, top-mem — each a different
program, all succeeded/passed, no collapse) + the goal-driven-prompt and
json.assert key-existence harness fixes that made real-model coding work.

Gates: pytest 667, ruff/mypy clean (44 files).
S4 (设备中心补齐):
- capability_matrix.py: per-board capability support (supported/degraded/
  unavailable) with S100P + generic-SSH matrices; unknown boards fail closed;
  serial-only link is never Agent-runnable. Classify is the pure decision the
  device center and Agent both consult (docs/06 §8.1, docs/11).
- serial_console.py: discover /dev/cu.*/tty.* + a READ-ONLY log tail with
  high-confidence secret redaction. Policy: serial is never an Agent-run
  target and never Agent-writable; the Agent only reads redacted lines
  (§8.2 — don't mistake a serial link for an Agent-run target).

S5 (系统准备烧录):
- flashing.py: FlashState machine (idle->selected->confirmed->writing->
  verifying->done/failed/cancelled), FlashImage catalog, FlashManifest with
  recovery steps + a human-only confirm token.
- flashing_service.py: FlashingService — Agent-facing suggest_flash (builds
  the wizard plan, NEVER executes); human-only confirm_flash (rejects any
  non-USER actor — FLASH_AGENT_DENIED); pluggable write engine; fake engine
  covers the state machine. The real XBurn engine runs only under human-watch
  HIL (§9.1; CLAUDE.md: Agent never triggers the final flash).

S6 (替代发布门禁):
- docs/11 replacement matrix gains an 证据 column per row (automated/HIL/
  usability or honest pending-<phase>); scripts/check_replacement_matrix.py
  machine-checks every row has an evidence cell; S6 closure asserts pending==0.

Gates: pytest 681 (+14), ruff/mypy clean (48 files).
The Electron shell was a minimal S1-B health-card demo (only 工作台, fake
device, scripted model). Wire it to the real pipeline:

- 工作台: free-form goal + device id (default s100p-001), start/status/cancel.
  TaskService now sends the user's goal to the session (goal-driven prompt),
  and defaultModelFactory uses the real model from ~/.rdk/.env — so the GUI
  drives the real agent loop on the real board when launched with the device
  env (RDK_DEVICE_COMMAND / RDK_TICKET_KEY).
- 设备: inspect (quick refresh) shows the real DeviceSnapshot + capabilities.
- 作品: list saved Project Packs + re-run a pack with no LLM (pack.list/run IPC).
- 项目/设置 remain honest phase notes.

preload + security expose a new pack surface (list/run); mainImpl wires
pack:list/run IPC to TaskService.listPacks/runPack. typecheck+build+7 tests
pass.
The two remaining GUI pages were placeholders; wire them to the real flow:

- 设置: read/write ~/.rdk/.env from the GUI. config:get masks the key (last 4);
  config:set writes baseUrl/model/api + optional new key (empty keeps the old).
  pi package gains writeRealModelDotEnv + defaultRealModelDotEnvPath; surface
  re-exports them so the desktop (single dep on surface) can use them.
- 项目: workspace file tree + read/write editor. workspace:list/read/write IPC
  against the product workspace root, sandboxed (no .. / absolute / escape).
  Lets the user browse + edit the agent's workspace without a terminal.

Now all five GUI entries are wired (workbench/device/works/project/settings);
no more PhaseNote placeholders. typecheck+build+tests green
(pi 24/5skip, surface 65/0, desktop 7/0, pytest 681).
The last GUI gap: the device SSH connection (host/user/key/ticket) was only
settable via launch env. Now the GUI manages it:

- deviceConnections.ts: ConnectionStore (persists userData/connections/
  device-connections.json 0600). The ticket HMAC key is a SECRET — it goes to
  the macOS keychain (security CLI) or a 0600 keyfile off-macOS, never the
  JSON. Host key pinned by TOFU: keyscan on add -> append to the product
  known_hosts -> store the SHA256 fingerprint for StrictHostKeyChecking.
  buildSshDeviceCommand(conn) assembles the RDK_DEVICE_COMMAND ssh argv.
- mainImpl: on startup, applyActiveConnection() materializes
  RDK_DEVICE_COMMAND/TICKET_KEY/DEVICE_ID from the first saved connection
  (explicit env still wins for CLI users). connection:list/add/remove IPC.
- 设备 page: saved-connection list + add form (name/host/user/device_id/
  profile/ticket key) with a fingerprint readout + remove.

The GUI now launches with no device env: configure the connection in the
设备 page once, then npm start anywhere. typecheck+build+7 tests green;
pytest 681, ruff clean.
The agent loop's last closeout gap: the model often calls rdk_run_start
without task_id, so the run succeeded but wasn't linked to its task — the
task stayed 'created' even after a passed run, and report_task couldn't
complete it. Start_run now resolves a task binding when task_id is None: if
exactly one non-terminal task shares the plan's workspace, bind to it
(don't guess when multiple match). The run then links, the task advances to
verifying on the terminal observation, and report_task completes it.

resume context injection (reconcile + checkpoint + goal/state/runs/
unsatisfied-verifiers re-injected into the session) was already in place.

Tests: test_run_auto_binds_to_task_when_model_omits_task_id,
test_no_autobind_when_multiple_tasks_share_workspace. pytest 683, ruff/mypy
clean.
A smoke that launches the Electron window then drives the RENDERER's
window.rdk bridge via executeJavaScript — exercising preload -> IPC ->
TaskService -> real model -> real board, without a human clicking. Polls
task status to a terminal state (9m) and prints a DESKTOP_REAL_SMOKE_OK/
FAIL/TIMEOUT sentinel.

Validation: launched against the real S100P with kimi-k3; the renderer bridge
created a task and the real model ran inventory/write/checkpoint/plan/report
through the GUI path. The GUI wiring (renderer -> preload -> IPC -> real
model -> real device) is proven end-to-end. (Model non-convergence — kimi
skipping run_start on a given run — is the known non-deterministic gap, not
a GUI defect; the CLI path converges on the same TaskService.)
Human-only device authority (docs/05 §7, docs/12 §4) exposed on the stdio
protocol without touching the model-facing AGENT_METHODS (AT-021, CAT-006B):
serve --stdio --role human dispatches AGENT_METHODS ∪ HUMAN_METHODS; agent
role rejects human methods with RDK-PROTO-001.

- hostkey.show/confirm (TOFU, sanitized: public_key never crosses),
  device.register (system-generated dev- ids), device.unregister,
  device.discover (bounded read-only: RNDIS default first, RFC1918 /24
  scans with direct-link (no default route) subnets first, TCP 22 only)
- service wrappers off service._config; known_hosts.load_candidate;
  ed25519>ecdsa>rsa key preference; ssh_host_identity() strips login user
  for verification; remote helper gets --device-id (S1A-DEBT-001 port)
- rdkctl host-key segment now calls the same service methods
- regression tests incl. agent-role rejection and ifconfig parsing
- DeviceService second client spawns 'serve --stdio --role human':
  showHostKey/confirmHostKey/registerDevice/unregisterDevice/discoverDevices
- ProjectService: read-only workspace.list/read for the GUI project page
- barrel exports extended explicitly (package entry contract kept)
- rdkos_info: /etc/version + uname -sr parsed into rdk_os_version/os/kernel
- resources/thermal: actually parse MemTotal/df/nproc and thermal zones
- bpu.runtime: rdkos_info [CPU And BPU Status] section (libdnn is X-series;
  always rc=2 on S100P), first bpu telemetry line, empty section fails closed
- tros.distro lands in software.tros_distro
- rdk-develop skill: official doc-center references as coding hints
  (observed facts still only from inventory)
Google AI Studio-style redesign (tokens in renderer/styles.css) with every
page real except 作品 (S3-constrained placeholder):

- 设备: auto-discovery connect wizard (pick candidate + confirm fingerprint,
  manual entry folded), device card rendering real inventory snapshots,
  honest host_key_confirmed badges
- 工作台: device chips bind tasks to boards; task console = event timeline
  with steer/resume/cancel, required_action human-only notice, 2.5s poll,
  raw JSON folded under 进阶
- 项目: read-only workspace browser (ProjectService bridge)
- 设置: secret-free local facts; gateway presence only, values never cross
- preload whitelist extended to 5 namespaces; security tripwires updated
- force-renderer-accessibility; RDK_DESKTOP_REAL_SMOKE real-device chain
- evidence S1C-DEVICE-CONNECT §1-9 (real S100P acceptance incl.)
- keeps the human authority plane (--role human) for register/TOFU/discover;
  model-facing AGENT_METHODS untouched
- adopts main's S3-S6 services (packs/real-model config/connections) and
  surfaces them in the redesigned renderer: works = real Pack list/re-run,
  settings = local facts + model gateway editor (key masked, 0600 env),
  project = workspace browser + editor via the host service
- preload whitelist grows to 8 reviewed namespaces; tripwire tests updated
- task lifecycle tests adapted to main's _advance_task anchor
User product rule: project spaces must not be shared across devices.
- create_task routes '.' to the device's own space (space id = device id),
  rejects cross-device use of a bound space and multi-device tasks
  (RDK-INV-001, category WORKSPACE_DEVICE); bindings persisted atomically;
  run_pack ephemeral workspaces registered too; host is the source of truth
- surface startTask mirrors the routing; '.' + multi-device fails fast
- GUI project page: per-device chips, browse + edit pass workspaceId;
  device list refreshes on page return
- TestWorkspaceDeviceBinding 4 cases; gates green
- DeviceRegistration gains optional registered_at/last_seen_at (schema-major-1
  additive; schemas regenerated); device.list exposes ssh_host/fingerprint/
  record timestamps; quick/full inventory stamps last_seen_at
- GUI device rows show the saved record (host, fingerprint prefix, registered,
  last seen) and a two-click remove (device.unregister first surfaced)
- LAN SSH boards without pre-installed keys: docs/05 §5 controlled login —
  device.auth_check (BatchMode probe) + device.onboard_key (one-shot password
  via SSH_ASKPASS temp helper installing the product ed25519 key; password
  never in argv/config/logs; temp files unlinked); connector tries the product
  identity via IdentityFile with user ssh config/agent as fallback
- wizard: after fingerprint trust, key login probe → register, or the
  one-shot 'install key and connect' step
- 3 new host tests; gates green
A stopped board RTC left snapshot.captured_at permanently old, so policy
freshness.stale-denies looped forever on real hardware (agent re-inventoried
three times, still denied). Capture time is now host wall-clock at save
(_host_stamp); content addressing excludes captured_at so snapshot ids are
unaffected. Same rationale as S2's host-timed run budgets.

Validated end-to-end: kimi-k3 via the GUI-main-service chain completed the
full rdk-develop loop on the real S100P (run succeeded, verifier passed,
cpu.json artifact read back, task report completed/passed) — LEFT-006
service layer closed. Regression test for the stopped-clock loop.
- human plane: serial.ports/serial.tail (read-only, redacted, never an Agent
  run target) and flash.images/suggest/confirm/run/status/cancel (suggest
  yields plan + human-only confirm token; confirm requires USER actor)
- fake engine ships a clearly-labelled rehearsal catalog (local://rehearsal);
  real write engines arrive with XBurn integration (S6); flashing is never
  automated-tested
- preload whitelist grows to 10 reviewed namespaces (console, flash);
  security tripwires updated
- GUI: 7-entry nav; console page (port chips, 2s auto-refresh, redacted log,
  honest empty state); flash wizard (image+device pick, risk confirm with
  rehearsal banner + recovery steps + acknowledgement checkbox, progress bar
  with cancel)
A missing IdentityFile under a strict client ssh config (IdentitiesOnly)
suppressed the user's working keys and broke board auth (Permission denied).
connector_for now passes the product identity only if ~/.rdk/id_ed25519
exists; onboarding creates and installs it on first use.
- human plane approval.decide (agent role rejected RDK-PROTO-001; USER-only
  decision; already-decided fails closed) — the GUI was the last surface
  without a human approval entry (was rdkctl-only)
- TaskService gains a lazy human-role client (same pattern as DeviceService)
- workbench: pending-approval card (approve/reject, refreshes on decide) +
  recent-task chips (click loads the task into the console)
- gates green
- human plane template.list/template.run: reviewed fixed programs run through
  the normal plan->policy->run->verify pipeline without any model
- template.list hard-filters by observed snapshot capabilities and reports
  what is missing (CFR-014 'why runnable / what's missing')
- verifiers assert result.json exit_code==0 (produced by fake AND real
  backends); the visible deliverable (health.json/temps.json) is collected
- GUI workbench 'Quick' card: one-click run, non-runnable templates grayed
  with the missing capability named
- 4 host tests; gates green
- bare 'rdk-agent' (no subcommand) drops straight into the interactive TUI
- 'rdk-agent gui' launches the Electron desktop app
- auto-resolve repo-local venv host+device (walk up for .venv) so a
  npm-linked 'rdk-agent' works with no env; explicit env still wins
- TUI/MCP default to a product-owned workspace created on demand
  (CLI 'run' keeps explicit --workspace-root per docs/12 §6)
- 'rdk-agent' installed on PATH via npm link
- scripts/make-app.sh builds a thin 'RDK Agent.app' bundle whose launcher
  execs the repo-local Electron binary with the desktop package dir
- no electron-builder / no network; double-click or 'open' to enter the GUI
- dist-macos/ ignored (build artifact)
- mcpClient.ts connects ONLY to servers a human wrote into the allowlist
  (RDK_MCP_CONFIG / ~/.rdk/mcp.json); external results are untrusted text for
  the human plane, never device facts/capabilities/policy inputs
- NOT exposed to the Pi agent or external MCP callers (CSEC-011/012)
- CLI: rdk-agent mcp-client list|call --server <name>
- live-tested against our own rdk-agent mcp --stdio as the external server;
  unit test asserts non-allowlisted servers are rejected
ADR-016 §12 requires placeholder parameters to carry provenance, and §7
requires the deterministic state machine, the Webots controllers and the
.wbt world to share one set of physics facts. This slice delivers both:

- kinematics.py is now the canonical record: ROBOT_PARAMETERS (wheel
  radius, half-track, arm links, joint limits, motor envelopes, gripper
  closure, oracle capture, cube geometry), ACTION_ENVELOPES and
  HARDWARE_PROFILE (calibration_status=placeholder,
  parameter_source=engineering_placeholder,
  hardware_profile_version=0.1.0).
- Fixes a half-track drift defect: action_runtime.py had 0.05 inlined
  while the Webots controller and the .wbt world both used 0.14. Angular
  requests now turn identically in both fidelities. Existing golden
  traces are unaffected (all straight-line, angular=0).
- Controllers stay Python 3.9 compatible: Webots launches controllers
  with the PATH python3 (system 3.9 in a bare shell), where
  zip(..., strict=) is a call-time TypeError — invisible to import or
  py_compile, which crashed arm-fold on the real machine while uv-run
  integration tests (venv 3.12) stayed green. An AST-scan regression test
  guards against strict zip / match / TryStar creeping back in.
- red_cube_grasp.wbt viewpoint fixed (previous values rendered only sky);
  controller-connect timeout raised to 60 s for cold first launches.

Adds docs/sim-parameter-backfill-plan.md (plan, not calibration) and
registers AT-029. Student journey: a simulation run keeps behaving the
same across fidelities and never overclaims sim-to-real while the
parameters are placeholders (CFR-025 honest results).

Gates: full unit suite green (incl. 6 parity + py39-compat tests);
Webots physics integration green on R2025a.
Students plugging in a chassis driver board or serial adapter previously
had zero visibility: the snapshot only said "USB present". probe_set
1.2.0 adds accessory enumeration as strictly read-only facts (FR-003–009):

- linux.usb.enumerate@2 keeps the raw lsusb list in the snapshot
  (peripherals.usb_devices: VID:PID + description). No device-class
  inference: a VID:PID never becomes "a chassis is connected".
- linux.serial.nodes@1 (ttyACM/ttyUSB/ttyAMA) and
  linux.can.interfaces@1 enumerate nodes; empty means unavailable, not a
  probe failure.
- ecosystem.lerobot@1 observes the installed LeRobot version or null.
- InventoryTarget gains serial/can/software; DeviceSnapshot gains the
  additive peripherals block (pre-1.2.0 snapshots stay valid) and
  software.lerobot_version; schemas and examples regenerated.
- rdkctl device inspect learns --refresh cached|quick|full (docs/12
  §6.2): cached reads the store, quick/full run a live inventory.

There is intentionally NO motor/servo bus probing: actuators stay
unavailable until the safe hardware kit + acceptance suite exist, and
the probes keep zero interaction with motor buses (no PING, no writes).

Evidence: PROBE-SET-1.2.0-ACCESSORY.md + a real S100P snapshot
(serial_hash null, no secrets). AT-002 updated: accessory fields in
scope, raw-fact and zero-motor-interaction pass conditions added.
Student journey: connecting an accessory shows up as honest enumeration
facts in Device Center, never as guessed capabilities.

Gates: full unit suite green (plugin + cli inspect tests); no device
writes anywhere in the new probes.
- /skills lists trusted local skills; /skill <name> [request] injects the
  SKILL.md body into the current task as a steer so the model follows it
- skills remain read-only/trusted: human picks from the local set, model has
  no skill-write tool
- unit tests for parse routing + skill discovery/read; gates green
- workbench skill dropdown injects the chosen trusted skill body into the goal
  (GUI /skill, like '/' in other agents); preload 'skill' ns (list/read)
- sample skill rdk-temp-watch demonstrates install (drop into skills/) + invoke
- device card capabilities relabeled as capability matrix (CFR-058): unavailable
  shown up-front with probe_errors as the 'why', never guessed
- settings model center (CFR-056): edit baseUrl/model/api + save (0600 env) +
  connectivity test; secrets never enter project/conversation
- desktop 7 tests green
ADR-016 §2's composite environment lands as a first slice: the student
program runs on the REAL S100P (s100-exec helper, UserProcessBackend —
stage/digest/cancel/cleanup unchanged), while the robot body/world is
simulated on the Host. One run, one RunRecord, environment_kind=
board_in_loop end to end; never counted as hil (report separation reuses
AT-028's environment_outcomes).

Data plane (ADR-016 §4, §5):
- CapabilityEndpoint gains a TCP mode bound to 127.0.0.1 only, plus
  observed-traffic recording so the episode is built from what the
  board program actually called (it is arbitrary code, not a fixture).
- New `rdk-agent-sim world` subcommand hosts the world (deterministic or
  webots) per run, prints a JSON ready line (port + run-bound token),
  then finalizes on a single stdin command: episode + oracle are written
  host-side under the same run_id but OUTSIDE the board run's artifact
  namespace (ADR-016 §6). EOF without finalize = safe-stop abort.
- The board reaches the Host through an SSH remote forward
  (-R board_port:127.0.0.1:host_port + ExitOnForwardFailure=yes); neither
  end binds a non-loopback interface (docs/05). Disconnect ⇒ safe stop.
- Board student program: assets/board_programs/grasp_client.py,
  stdlib-only, hand-rolled capability.call frames over TCP, reads the
  host-injected RDK_SIM_ENDPOINT/RDK_SIM_TOKEN/RDK_RUN_ID env (board
  python 3.10 compatible; same grasp sequence across fidelities, §7).

Provenance (ADR-016 §2):
- rdk-agent-device serve gains --environment-kind; the exec helper now
  declares its launch mode so ticket/environment mismatches fail closed
  device-side (previously a no-op on the real board).
- Host: start_board_in_loop_run orchestrates preflight → world service →
  board exec connector (s100-exec + forward + declared kind) → plan/
  ticket/record all stamped board_in_loop → finalize → teardown. start_run
  and plan_run take connector/environment_kind overrides; the primary
  connector path is unchanged.

Tests: 7 new unit tests (TCP endpoint loopback/token/recording, world
service protocol finalize/abort, ssh argv, env injection) and 2
integration tests running the REAL board program in a separate process
against the deterministic world (pass + idle-run negative control). Full
suite (~795) green; ruff + mypy --strict clean. No sim-to-real or
calibration claims are made — this slice stays honest about placeholder
parameters (ADR-016 §12).

(Also: ruff --fix merged an import block in templates.py and the added
noqa there keeps RUF001 suppressed for Chinese full-width punctuation.)
probe_set 1.2.0 evidence changed the hardware picture since the plan was
written, so the plan and baseline now state it honestly:

- LeKiwi chassis driver board (1a86:55d3 USB-CDC → /dev/ttyACM0) and a USB
  camera (1e45:0209) are CONNECTED and enumerated as read-only facts;
  camera.snapshot.usb is available (AT-013 path), while servo/motor
  actuation stays unavailable (12V not powered, no safe fixture, probes
  keep zero motor-bus interaction).
- Backfill is split into geometry (caliper-measurable without power) vs
  electrical (vendor-datasheet first, measured once the safe kit exists).
- Records the open product decision: the sim world models a generic
  2WD+3DOF DIY build while the real accessory is a LeKiwi — the sim model
  reconstruction vs same-shape-parameter backfill must be decided before
  values are written.
- Adds an UNFILLED measurement template (docs/testing/evidence/
  calibration-measurements.yaml) so the backfill is mechanical once a
  human measures; it is no calibration claim (all values null, source
  restricted to measured/vendor_datasheet).

CURRENT_HARDWARE_BASELINE bumped to v0.6: board/OS/kernel/BPU/TROS rows
carry probe-verified values, board_in_loop joins the allowed HIL list,
and the blocked list keeps servo/PWM/motor/GPIO/MIPI/flash deny.
- rdk-knowledge skill grounded from the official doc center: board lineup +
  TOPS/cores/interfaces, OS/BPU/TROS facts, accessory compatibility + current
  availability rules (USB cam / MIPI / stereo / BMI088 / servo-PWM denied)
- appended to the system prompt so the model always has RDK cognition; also
  discoverable via listSkills; answers use facts + capability matrix, no guess
- pi 24 tests green
The cross-machine data plane now has real-hardware evidence: the stdlib
student program ran on the actual S100P (python3.10) and drove the full
grasp sequence through ssh -R into the Host-hosted world — 7/7 capability
calls ok, oracle pass, episode carries environment_kind=board_in_loop
without leaking ground truth, oracle stays in its own namespace. Artifact
SHA-256 digests recorded; the ephemeral run token is redacted (never
committed).

Also ships scripts/drive_board_in_loop_dataplane.sh so the check is
repeatable without product registration/ticket.

Explicitly NOT covered (human-authority steps, runbook in the doc):
device registration + TOFU host-key confirmation, RDK_TICKET_KEY
provisioning, and the full product orchestration path through
start_board_in_loop_run; plus a webots-fidelity board run. No
sim-to-real and no calibration claims: parameters remain
calibration_status=placeholder, and no actuator on the board was touched.
- X3/X3 Module 5 TOPS (CM4-compat), X5 10 TOPS 8-core A55 (2 MIPI+4 USB3)
- OS Ubuntu-based per line; BPU via PyPI hobot-dnn-rdkx5
- board model still resolved from live inventory, never guessed
Connected boards and accessories are not fixed, so the simulated robot can
no longer be hardcoded. The embodiment is now selected from OBSERVED device
facts via a curated, versioned registry (model SELECTION, never capability
inference — accessory product names stay out of device snapshots, AT-002).

Core (rdk_agent_core.simulation):
- EmbodimentProfile + EMBODIMENT_REGISTRY: default DIY virtual robot
  (the only one with a .wbt), lekiwi-v1 (matches the LeKiwi chassis board,
  USB 1a86:55d3 / ttyACM evidence), and rdk-camera-only-v1.
- select_embodiment(snapshot) -> (profile, reason); reason is structured
  provenance for events/reports. No board / no accessory -> default DIY
  virtual robot, honestly labeled (boardless-student path preserved).

Sim runtime:
- Capability surface narrows to declared ∩ implemented (ADR-016 §7); sim
  inventory (capabilities + identity.model) is generated per embodiment.
- Two fail-closed gates: scenario needs vs declared capabilities
  (embodiment_incompatible) and physics fidelity without a 3D asset
  (embodiment_not_modeled, ADR-016 §8 blocked semantics; deterministic
  fidelity unaffected).
- kinematics HARDWARE_PROFILE / LEKIWI_HARDWARE_PROFILE derive from the
  registry (single source); LeKiwi params remain §12 placeholders.
- scenario_for() picks the grasp task for full-motion forms and a new
  camera-only "look" task (oracle gains a geometric `visible` relation,
  truth from supervisor-measured poses) for camera-only forms.

Host:
- start_board_in_loop_run now inventories the board first, selects the
  embodiment on the trusted path, gates, and launches the world service
  with --hardware-profile; selection is recorded as a policy.enforced
  event and returned in the result. Registered SSH devices inventory via
  their per-device connector.

Tests: 11 new embodiment unit tests + 4 board_in_loop integration cases
(lekiwi runs the grasp across processes; un-modeled physics blocks).
Full suite green; ruff + mypy --strict clean.

Also folds in the interleaved same-tree work it depends on: the teleop
manual-driving tool (rdk-agent-sim teleop) and the per-device inventory
routing fix, both from the concurrent session. NOT included: unrelated
rdk-agent-surface/GUI WIP left for that session to commit.

No sim-to-real or calibration claims: LeKiwi stays placeholder until the
backfill plan's measurement steps run.
Completes the interrupted real-hardware check now that the board link is
back: lsusb confirms the LeKiwi chassis board (1a86:55d3) attached, and
the verified run shows
- lekiwi-v1 + webots -> blocked(embodiment_not_modeled) on the real host
  (honest, exit 4 — no DIY geometry substitution);
- lekiwi-v1 + deterministic: ready carries embodiment=lekiwi-v1, the real
  student program executes 7/7 capability calls over ssh -R from the S100P,
  and finalize reports environment_kind=board_in_loop, oracle pass;
- artifact SHA-256 digests recorded (token redacted, per hygiene).

Placeholder stance unchanged: no calibration / sim-to-real claims; LeKiwi
physics stays blocked until a 3D asset exists.
The full production chain now runs end-to-end on the real board — exactly
the path the four product surfaces share:

  TOFU host-key (fetch → verify vs recorded baseline → confirm, fail-closed
  on mismatch) → register_ssh_device → inventory via per-device connector →
  select_embodiment → world service → plan/ticket/record
  provenance=board_in_loop → run.stage → real non-root student run →
  SSH -R loopback data plane → world finalize (oracle) → report.

Real-run result: run succeeded, environment_kind=board_in_loop, embodiment
lekiwi-v1 (detected from the attached chassis board, USB 1a86:55d3), oracle
pass, 7/7 capability calls over the data plane. Evidence recorded in
docs/testing/evidence/board-in-loop-orchestration/ (ticket key redacted;
only public host-key fingerprints recorded).

Also fixes a latent finalize bug the real run exposed: _finalize_world_service
pre-closed the world's stdin before communicate(), whose flush of the closed
file raised ValueError; communicate() now closes stdin itself, with a salvage
path if the world already exited.

Security handling: the host key is never blindly trusted (baseline comparison
fails closed), and RDK_TICKET_KEY is read from the environment only — never
written to any file, log or evidence. scripts/drive_board_in_loop_real.py
makes the chain repeatable.
The lekiwi-v1 embodiment (selected from the attached chassis board) now has a
real Webots world, unlocking physics fidelity for the detected robot instead of
blocking it:

- assets/worlds/lekiwi_grasp.wbt: S100P + round deck + arm + gripper + front
  camera grasping the red cube. Placeholder geometry (ADR-016 §12). The drive
  is a DIFFERENTIAL two-wheel stand-in for the real LeKiwi 3-wheel Kiwi
  (holonomic) base — the omni-wheel contact variant lost traction in Webots
  (wheels spun, robot stayed put), so the proven differential drive is the
  honest placeholder; holonomic drive + SO-ARM101 6-DOF are documented
  calibration-stage refinements (backfill plan).
- Oracle supervisor now tracks the robot by name per embodiment world
  (red_cube_robot OR lekiwi_robot) — previously it only found the DIY robot,
  so LeKiwi ground truth read a stale [0,0,0].
- Registry: lekiwi-v1 physics_world = lekiwi_grasp.wbt; the not-modeled gate
  now uses camera-only (physics_world=None) as its fixture.

Verified: test_lekiwi_world_grasps_with_physics — Supervisor-measured ~0.19 m
roll, camera sees the cube, oracle inside_gripper pass; DIY physics + the
out-of-reach negative control still green. Full suite + ruff + mypy --strict
clean. Evidence: docs/testing/evidence/LEKIWI-PHYSICS.md. No sim-to-real or
calibration claims — geometry stays placeholder.
First legitimate calibration step for the lekiwi-v1 embodiment (backfill plan
sanctions vendor_datasheet for ELECTRICAL params; geometry still needs the
physical fixture):

- LeKiwi uses Feetech STS3215 bus servos (SO-ARM101 + base, 1:345 gear).
  Feetech/Seeed datasheets (consistent across sources): no-load 52 RPM @7.4V
  = 5.45 rad/s, stall 19.5 kg·cm @7.4V = 1.91 N·m.
- LEKIWI_ROBOT_PARAMETERS now carries those for arm/gripper max_velocity +
  max_torque (source=vendor_datasheet). GEOMETRY stays placeholder — wheel
  radius / half-track / arm links / joint limits / gripper closure still need
  real LeKiwi caliper measurement (gated on the calibration fixture).
- Provenance: calibration_status placeholder→partial, hardware_profile_version
  0.1.0→0.2.0, parameter_source=vendor_datasheet+placeholder.

The DIY record (ROBOT_PARAMETERS) and its three-source parity guard are
untouched. Electrical backfill updates the canonical provenance record, not
runtime behavior (the .wbt motor constants + action_runtime globals are the
later wiring step). Parity + embodiment tests, ruff, mypy --strict all green.
No sim-to-real claim — geometry remains placeholder.
The old simulation system (ADR-016: Webots physics + deterministic state
machine) moved wholesale to /Users/d-robotics/Documents/rdk-sim-webots-legacy
(standalone git repo, byte-verified copy). This commit excises every hook:

- packages/rdk_agent_sim deleted (assets/worlds/controllers/scenarios included)
- rdk_agent_core: simulation.py removed; environment_kind dropped from
  ExecutionPlan/RunTicket/RunRecord; TransportType.SIM_STDIO removed
- rdk_agent_device: --environment-kind flag, ticket environment check and the
  now-unused public run_dir accessor removed
- rdk_agent_host: board_in_loop orchestration (world spawn/finalize, sim env
  injection, remote-forward connector) removed; sim_command/environment_kind
  config removed; per-environment report grouping removed
- schemas: scenario/oracle/preflight/hardware-profile removed; plan/ticket/
  record/registration regenerated (SIM-R0, superseded by upcoming ADR-017)
- tests: 19 sim test files deleted, AT-028 report-separation class removed
- docs: AT-028..031 archived (pointer left; new acceptance resumes at AT-034),
  sim evidence + ADR-016 + backfill plan archived

Gates: ruff/mypy clean, 657 passed, core coverage 95.9%, no schema drift.
ADR-019 §11 open item 1 resolved: cadquery-ocp-novtk 7.9.3.1.1 wheels cover
macOS arm64/x86_64, manylinux x86_64/aarch64, win_amd64 for cp310-cp314;
build123d 0.11.1 py.typed + cadquery-ocp-stubs pass mypy --strict without
overrides; boolean/volume/STL-export smoke exact. Geometry kernel frozen.
- ADR-019 Proposed->Accepted; §11 open items closed (OCC wheel evidence,
  L1 interface scope, RunRecord.origin naming); license note frozen.
- docs/00 §4 decision line; docs/02 §4.16 sim component; docs/03 §2.10
  DeviceSpec aggregate; docs/06 §2 SIM track row.
- TEST_STRATEGY §2 sim layer + §12.2 determinism contract (digest-equality
  goldens, fixed dt, decimation, float-tolerance rule).
- TRACEABILITY dated SIM-R1 section; ADR-017 dangling refs repointed to
  ADR-019 (ACCEPTANCE_TESTS + TRACEABILITY).
- ACCEPTANCE_TESTS: AT-034 circuit verdicts, AT-035 kinematics determinism,
  AT-036 STL/printability, AT-037 virtual-board L1 fidelity + origin split.
- remove dead tests/unit/sim_controller_stub (legacy Webots leftover).
ADR-019 §4: versioned DeviceSpec (mechanical/electrical/control with
per-parameter provenance, content-addressed spec_id); RunOrigin enum +
RunRecord.origin additive within schema 1.0 (None=unknown, never real);
TransportType.SIM_STDIO; schemas + golden example regenerated in the same
commit (byte-stability gate).
Rewritten from zero per ADR-019 (name reused, nothing carried over):
- stdio DeviceServer reusing rdk_agent_device.DeviceServer with
  snapshot-driven L1 inventory (real S100P facts, NUL-stripped, provenance
  header; annotated-mock limitations on bpu/camera) and SimExecutionBackend
  (label-driven, staged-source re-verified, never executes staged code);
- circuit layer: netlist-driven MNA + explicit Euler, PWM H-bridge with
  freewheel path, stall/undervoltage/overcurrent verdicts, deterministic;
- kinematics/stability: diff-drive preview integration, CoM support-polygon
  and quasi-static margins (pure math, no physics engine);
- geometry: build123d==0.11.1 parametric solids from reviewed templates,
  binary STL + BOM + printability verifier, 900KiB per-part budget;
- RunRegistry origin stamping (simulation / real_device); numpy pinned
  2.2.6 (stub/py3.10-mypy compat); CI mypy covers the new package.
Typed bounded ops sim_evaluate/sim_export_stl over the existing
Plan/Run path (fixed-label manifest passes PolicyEngine unchanged at R0);
connector_for/_connector_for_inventory SIM_STDIO branches with host-built
fixed argv (RDK_SIM_COMMAND); origin cross-check demotes mismatched claims
to unknown with WARNING; report_task evidence_by_origin split; rdkctl sim
provision/evaluate/export + device register --transport sim-stdio.
D1: regenerate virtual-board facts with the trailing NUL actually removed
(provenance claim now true).
D2: assert_within_root resolves the combined path before the containment
check; PartInstance.id restricted to a path-safe charset at the schema
boundary (schemas regenerated).
D3: stall scenario split per clarified AT-034 — 'stall' (healthy battery:
per-channel avg >=1.5x nominal + overcurrent) and 'stall_weak' (worn
battery 8x r_int: undervoltage); the two criteria cannot coexist in one
scenario physically.
D4: backend transitions STAGING before label validation so an illegal
sim.kind reaches terminal FAILED (QUEUED only allows STAGING).
91+ tests authored and frozen by the independent test agent per
AGENTS.md dev/test separation: unit (DeviceSpec invariants, circuit/
kinematics/geometry/virtual-board/backend), contract (13-method protocol,
ticket fail-closed, stage tamper), integration (register->inventory->
evaluate/export, origin split), acceptance TestAT034..037, golden traces
(tests/golden/sim, zero-tolerance digests, STL byte digests pinned to
macOS arm64 with structural invariants elsewhere).
Final verdict: AT-034..037 all pass; 753 tests green; core branch
coverage 96.27% (>=90 gate).
evidence(sim): record independent test verdict (AT-034..037 all pass)
Some checks failed
ci / python (pull_request) Has been cancelled
ci / typescript (pull_request) Has been cancelled
fc5bb9b74a
Templates live in rdk_agent_core so the host (staging) and the sim device
(L2 reviewed-source digest gate, ADR-019 / CFR-027) share one source of
truth; host/templates.py becomes a compat shim. Adds
template_source_digest()/reviewed_template_digests(), per-template resources
and extra artifacts/verifiers, and the usb-camera-snapshot /
bpu-static-inference reviewed templates (virtual branches use the
rdk_virtual_board shim; real branches fail closed with exit 3 until the real
camera/BPU paths are evidenced). health-card/temp-watch gain virtual branches.
system.facts() (snapshot resources + frozen decimals), camera.frame()
(hand-rolled byte-stable PNG, dims bounded), bpu.infer() (sha256-derived
labels/scores, reviewed model digests only, fail-closed). Pure stdlib, no
clock/random; every result carries origin=simulation + provenance.
s100p.json regenerated from s100p-accessory-snapshot.json (peripherals,
software.tros_distro, 6 capabilities) with virtual_facts frozen decimals and
a provenance ground_truth_note documenting the bpu FIND-002 contradiction
(not silently resolved; real-device matrix untouched). interface_fidelity.json
becomes the full 12-row three-tier enumeration (ADR-019 §11 open item 2).
Pinned test expectations updated accordingly.
SimProgramBackend(UserProcessBackend) with two fail-closed boundaries:
staged source must exactly equal the reviewed template digest (CFR-027,
model-crafted programs never execute) and the environment is 100%
backend-controlled (manifest env ignored; rdk_virtual_board shim injected).
Headless rdk-agent-sim run + pipeline.run_template_on_virtual_board share the
same executor. Also fixes a latent SyntaxError in the health-card template
(brace-less dict comprehension is invalid Python).
L2 product path: sim_run stages the reviewed template, exercises policy
honestly (R2 bpu -> REQUIRE_APPROVAL, human approves, replay with
approval_id; agent plane can never self-approve), drives the sim device over
the shared stdio protocol and verifies with image.basic/json.assert/exit
verifiers. AGENT_METHODS gains sim.evaluate/sim.export_stl/sim.run (AT-021 pin
updated). image.basic parses PNG/JPEG headers, never fails open.
ADR-019 §11 open item 2 closed (12-row three-tier enumeration; bpu/camera
promoted real-sim with synthetic limitations; FIND-002 contradiction documented
not silently resolved). docs/02 §4.16 L2 paragraph; TEST_STRATEGY §12.2
synthetic-frame/BPU determinism; AT-038..041 reserved; traceability + 00/06
registration.
A crafted-source run_program raised before any transition, stranding the
device record in QUEUED (SIM-R1 D4 class). The dispatch now drives
QUEUED -> STAGING -> FAILED on refusal so the state machine always reaches
a terminal state; verified crafted-source ends FAILED.
PNG parsing now walks chunks with length guards: truncated payload,
missing IDAT, or absent/non-final IEND all return None -> FAIL instead of
PASS/ERROR. JPEG segment-length reads are bounds-guarded. AT-039
never-fail-open criterion restored; full suite green.
FF FF fill bytes no longer terminate the entropy scan early; complete
JPEGs with fill bytes before EOI verify, truncations still FAIL. Closes the
never-fail-open invariant for both formats.
test(sim): independent SIM-R2 suite (AT-038..041) + final verdict evidence
Some checks failed
ci / python (pull_request) Has been cancelled
ci / typescript (pull_request) Has been cancelled
806cc0b24a
Test-agent authored: unit (templates/virtual_api/program/verifier_image),
contract (host sim RPC frame round-trips), integration (sim_run incl. bpu
approval flow and crafted-manifest fail-closed), golden sim_r2 section
(SIM-R1 section byte-unchanged), acceptance AT-038..041. Final verdict:
SIM-R2 acceptance passed; D1/D-SIMR2-1/D-SIMR2-2 closed via 1132760/59130c7/
7b85af6. 836/836, core branch coverage 96.35%.
Some checks failed
ci / python (pull_request) Has been cancelled
ci / typescript (pull_request) Has been cancelled
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin codex/sim-r2:codex/sim-r2
git checkout codex/sim-r2
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jiaqi02.sun/rdkagentsun#3
No description provided.