From c7bc409d8d4fa0cc63fb94e9219f3dc854d13074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Wed, 16 Sep 2026 16:25:14 +0800 Subject: [PATCH 01/10] bump version --- src/leapflow/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/leapflow/version.py b/src/leapflow/version.py index 1a745016..441a47b0 100644 --- a/src/leapflow/version.py +++ b/src/leapflow/version.py @@ -1,4 +1,4 @@ # Copyright (c) Alibaba, Inc. and its affiliates. """Version information for leapflow.""" -__version__ = "0.2.0+main" +__version__ = "0.2.1+main" From 40ef78eef716d26a1139c8cc16b9b8089e3803ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Fri, 18 Sep 2026 10:54:43 +0800 Subject: [PATCH 02/10] feat(board,evolution): fix LeapBoard P0-P2 defects and add explicit evolution trigger LeapBoard / evolution observability - Markdown node now parses blockquote/strong/inline-code (escape-then-whitelist, no third-party parser) instead of printing raw markup - evolution_live metrics split into live vs snapshot provenance with a drift note, so figures that cannot refresh no longer freeze while looking current - co-evolution governance sweep runs on an empty trajectory too (moved out of the `if trajectory:` branch); effect-verification/quarantine/reclamation segments become observable - page-level provenance bar: observed_at vs checked_at, stale verdict at 2x cadence, and a Refresh now affordance that closes the prescribe->confirm loop - lifecycle segment judged by state transition, not row count (all-PENDING queue reads no_evidence); empty live lanes carry guidance and equal height; removed the duplicate evolution_live KPI grid - evolution axis (Pipeline evidence over time); sparkline draws a single sample Evolution trigger - run_learning_boundary() + evolution.run RPC + `leap evolve` CLI so the boundary is callable on demand, not only at process shutdown - bounded trajectory buffer; manual watch refresh records run bookkeeping; WatchView exposes interval_seconds for freshness judging Tests: +49 dashboard/provenance/trigger regressions; full i18n coverage in 6 locales Also folds in pending feat/demo_exp work (leapspace app_space refactor, AAAI-27 demo scaffolding, and related tests). --- .gitignore | 19 + src/leapflow/cli/cli.py | 19 +- src/leapflow/cli/commands/evolve.py | 95 +++ src/leapflow/cli/context.py | 181 +++++- src/leapflow/daemon/client.py | 4 + src/leapflow/daemon/monitor_coordinator.py | 23 +- src/leapflow/daemon/protocol.py | 10 + src/leapflow/daemon/service.py | 17 + src/leapflow/dashboard/hub.py | 18 + src/leapflow/dashboard/server.py | 12 +- src/leapflow/dashboard/service.py | 149 +++++ src/leapflow/dashboard/static/app.js | 542 +++++++++++++++++- src/leapflow/dashboard/static/index.html | 4 +- src/leapflow/dashboard/static/styles.css | 80 ++- .../dashboard/templates/causal_trace.yaml | 87 +++ .../dashboard/templates/evolution.yaml | 32 ++ .../dashboard/templates/evolution_live.yaml | 58 ++ src/leapflow/engine/engine.py | 7 +- src/leapflow/learning/degradation_sink.py | 38 +- src/leapflow/learning/world_model_driver.py | 223 ++++++- src/leapflow/llm/openai_provider.py | 13 +- src/leapflow/monitor/evolution_producer.py | 41 +- src/leapflow/monitor/manager.py | 27 +- src/leapflow/monitor/types.py | 7 + .../plugins/tool_plugins/self_management.py | 82 ++- .../storage/capability_proposal_queue.py | 40 +- .../telemetry/evolution_presentation.py | 91 +++ src/leapflow/version.py | 2 +- src/leapflow/world_model/prediction.py | 16 +- src/leapspace/app_space/actor.py | 2 +- src/leapspace/app_space/apps/_base.py | 45 +- src/leapspace/app_space/harness.py | 4 +- src/leapspace/app_space/host_rpc.py | 162 ++++++ src/leapspace/app_space/image.py | 78 +++ src/leapspace/app_space/signal.py | 2 +- .../app_space/{utils.py => state.py} | 77 +-- .../app_space/tasks/task-001/action.py | 2 +- temp/papers/aaai27_demo/aaai_demo/__init__.py | 17 + temp/papers/aaai27_demo/aaai_demo/cli.py | 107 ++++ temp/papers/aaai27_demo/aaai_demo/evidence.py | 528 +++++++++++++++++ .../aaai27_demo/aaai_demo/headless_seam.py | 220 +++++++ temp/papers/aaai27_demo/aaai_demo/poster.py | 113 ++++ temp/papers/aaai27_demo/aaai_demo/render.py | 169 ++++++ .../headless-chat-probe-drifts.json | 69 +++ .../task-001-structural-drifts.json | 124 ++++ ...31\344\275\234\350\256\241\345\210\222.md" | 280 +++++++++ temp/papers/aaai27_demo/reproduction.md | 118 ++++ .../aaai27_demo/tests/test_demo_artifacts.py | 210 +++++++ tests/leapspace/test_actor.py | 2 +- tests/leapspace/test_harness.py | 2 +- tests/leapspace/test_signal_bridge_live.py | 113 ++++ .../{test_utils.py => test_state.py} | 27 +- tests/test_adaptation_verdict.py | 28 +- tests/test_coevolution_sweep_wiring.py | 50 ++ tests/test_dashboard_frontend_static.py | 200 +++++++ tests/test_dashboard_launcher.py | 6 +- tests/test_dashboard_provenance.py | 170 ++++++ tests/test_dashboard_view.py | 54 +- tests/test_evolution_governance_reachable.py | 44 ++ tests/test_evolution_presentation.py | 45 ++ tests/test_evolution_producer.py | 6 + tests/test_evolution_tap.py | 40 ++ tests/test_evolution_trigger_boundary.py | 267 +++++++++ tests/test_llm_provider_retry_ownership.py | 51 ++ tests/test_world_model_driver.py | 67 +++ ...test_world_model_proposal_sink_contract.py | 133 +++++ 66 files changed, 5411 insertions(+), 158 deletions(-) create mode 100644 src/leapflow/cli/commands/evolve.py create mode 100644 src/leapflow/dashboard/templates/causal_trace.yaml create mode 100644 src/leapflow/dashboard/templates/evolution_live.yaml create mode 100644 src/leapflow/telemetry/evolution_presentation.py create mode 100644 src/leapspace/app_space/host_rpc.py create mode 100644 src/leapspace/app_space/image.py rename src/leapspace/app_space/{utils.py => state.py} (68%) create mode 100644 temp/papers/aaai27_demo/aaai_demo/__init__.py create mode 100644 temp/papers/aaai27_demo/aaai_demo/cli.py create mode 100644 temp/papers/aaai27_demo/aaai_demo/evidence.py create mode 100644 temp/papers/aaai27_demo/aaai_demo/headless_seam.py create mode 100644 temp/papers/aaai27_demo/aaai_demo/poster.py create mode 100644 temp/papers/aaai27_demo/aaai_demo/render.py create mode 100644 temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json create mode 100644 temp/papers/aaai27_demo/demo_fixtures/task-001-structural-drifts.json create mode 100644 "temp/papers/aaai27_demo/plan/AAAI-27_Demo_\350\256\272\346\226\207\345\206\231\344\275\234\350\256\241\345\210\222.md" create mode 100644 temp/papers/aaai27_demo/reproduction.md create mode 100644 temp/papers/aaai27_demo/tests/test_demo_artifacts.py create mode 100644 tests/leapspace/test_signal_bridge_live.py rename tests/leapspace/{test_utils.py => test_state.py} (66%) create mode 100644 tests/test_dashboard_frontend_static.py create mode 100644 tests/test_dashboard_provenance.py create mode 100644 tests/test_evolution_presentation.py create mode 100644 tests/test_evolution_trigger_boundary.py create mode 100644 tests/test_llm_provider_retry_ownership.py create mode 100644 tests/test_world_model_proposal_sink_contract.py diff --git a/.gitignore b/.gitignore index ccaffcb7..b762e5b9 100644 --- a/.gitignore +++ b/.gitignore @@ -235,5 +235,24 @@ Package.resolved leapflow.sock temp +# The AAAI demo tooling is a reproducible artifact, not disposable scratch data. +# Re-ignore every other temporary artifact after reopening each parent directory. +!temp/ +temp/* +!temp/papers/ +temp/papers/* +!temp/papers/aaai27_demo/ +temp/papers/aaai27_demo/* +!temp/papers/aaai27_demo/aaai_demo/ +!temp/papers/aaai27_demo/aaai_demo/*.py +!temp/papers/aaai27_demo/demo_fixtures/ +!temp/papers/aaai27_demo/demo_fixtures/task-001-structural-drifts.json +!temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json +!temp/papers/aaai27_demo/plan/ +temp/papers/aaai27_demo/plan/* +!temp/papers/aaai27_demo/plan/AAAI-27_Demo_论文写作计划.md +!temp/papers/aaai27_demo/reproduction.md +!temp/papers/aaai27_demo/tests/ +!temp/papers/aaai27_demo/tests/test_demo_artifacts.py .DS_Store AGENTS.md diff --git a/src/leapflow/cli/cli.py b/src/leapflow/cli/cli.py index 8054ef3e..e25e9e60 100644 --- a/src/leapflow/cli/cli.py +++ b/src/leapflow/cli/cli.py @@ -286,6 +286,16 @@ def main(argv: list[str] | None = None) -> int: dashboard_parser.add_argument("--bind", default="", help="Override the dashboard bind address") dashboard_parser.add_argument("--no-open", action="store_true", help="Print the URL instead of opening a browser") + # leap evolve (run the learning boundary now) + evolve_parser = subparsers.add_parser( + "evolve", help="Run the learning boundary now and report what it did" + ) + evolve_parser.add_argument( + "--reason", default="manual", + help="Label recorded with this run (default: manual)", + ) + evolve_parser.add_argument("--json", action="store_true", help="Emit machine-readable JSON") + # leap hw (hardware inspection and direct intervention) hw_parser = subparsers.add_parser("hw", help="Inspect hardware and intervene in it directly") hw_sub = hw_parser.add_subparsers(dest="hw_action") @@ -359,7 +369,7 @@ def main(argv: list[str] | None = None) -> int: # ── Pre-parse: detect if first non-flag arg is a known subcommand ── # If not, treat everything non-flag as a chat prompt. - known_commands = {"teach", "run", "skills", "relearn", "host", "daemon", "config", "board", "hw"} + known_commands = {"teach", "run", "skills", "relearn", "host", "daemon", "config", "board", "hw", "evolve"} effective_argv = list(argv) if argv is not None else sys.argv[1:] # Find first non-flag argument, skipping values owned by global options. @@ -459,6 +469,13 @@ def main(argv: list[str] | None = None) -> int: from leapflow.cli.commands.dashboard import cmd_dashboard return cmd_dashboard(args) + # Evolve routes to leapd, which owns the context holding the trajectory buffer. + # Running it in this process would build a second, empty context and grade + # nothing, so no Context is initialized here either. + if args.command == "evolve": + from leapflow.cli.commands.evolve import cmd_evolve + return cmd_evolve(args) + # Hardware inspection/intervention: reads run in-process, pause/resume route # to leapd over RPC. No engine Context is needed either way. if args.command == "hw": diff --git a/src/leapflow/cli/commands/evolve.py b/src/leapflow/cli/commands/evolve.py new file mode 100644 index 00000000..3700f946 --- /dev/null +++ b/src/leapflow/cli/commands/evolve.py @@ -0,0 +1,95 @@ +"""`leap evolve` — run the learning boundary now, and report what it did. + +Capability evolution is driven from exactly one place: the learning boundary, which +grades the recorded trajectory, lets the world model propose capabilities it found +missing, and runs the cold-path governance sweep. That boundary used to be reachable +only from context cleanup, which in daemon mode means *process shutdown* — so a +daemon that ran for a week never evolved, one killed with SIGKILL never evolved at +all, and there was no way to answer "did it evolve, and what happened" without +stopping the daemon and reading its log. + +This command makes the boundary an explicit, observable operation. It routes to the +daemon rather than doing the work locally, because the daemon owns the context that +holds the trajectory buffer and the proposal queue; a second context would grade an +empty buffer and truthfully report that nothing happened. + +It decides nothing on its own: whether a proposal is even *written* still depends on +``evolution.enabled``, and whether it is acted on still depends on generation, +review, approval and trust. Running this is asking the framework to look at what it +has already done, not granting it new permission. +""" + +from __future__ import annotations + +import argparse +import asyncio +import json + +from leapflow.config import load_config + + +def cmd_evolve(args: argparse.Namespace) -> int: + """Entry point for the ``leap evolve`` subcommand.""" + try: + return asyncio.run(_run(args)) + except KeyboardInterrupt: + return 130 + + +async def _run(args: argparse.Namespace) -> int: + from leapflow.daemon.client import ensure_daemon_client + + settings = load_config() + as_json = bool(getattr(args, "json", False)) + + try: + client = await ensure_daemon_client(settings) + except Exception as exc: # noqa: BLE001 - a missing daemon is a normal outcome here + _report_error(f"leapd unavailable: {exc}", as_json) + return 1 + + try: + result = await client.evolution_run(reason=str(getattr(args, "reason", "") or "manual")) + except Exception as exc: # noqa: BLE001 - surfaced, never a traceback + _report_error(str(exc), as_json) + return 1 + + if as_json: + print(json.dumps(result, ensure_ascii=False, indent=2)) + return 0 if result.get("ok") else 1 + + if not result.get("ok"): + print(f"Learning boundary failed: {result.get('error', 'unknown error')}") + return 1 + + steps = int(result.get("trajectory_steps") or 0) + print( + f"Learning boundary ran ({result.get('reason', 'manual')}) in " + f"{result.get('duration_s', 0)}s — {steps} trajectory step(s) graded." + ) + if not steps: + # Said plainly, because an empty trajectory is the common case and looks + # identical to a failure otherwise. The governance sweep still ran: that is + # the whole reason it sits outside the trajectory branch. + print( + " No turns were recorded since the last boundary, so the teacher had " + "nothing to grade. The governance sweep still ran." + ) + if not getattr(settings, "evolution_enabled", False): + print( + " Self-evolution is off, so no capability proposal was written. " + "The world model still graded and recorded what it learned. " + "Enable with: leap config set evolution.enabled true" + ) + print(" See the result on the board: leap board evolution") + return 0 + + +def _report_error(message: str, as_json: bool) -> None: + if as_json: + print(json.dumps({"ok": False, "error": message}, ensure_ascii=False)) + else: + print(f"evolve: {message}") + + +__all__ = ["cmd_evolve"] diff --git a/src/leapflow/cli/context.py b/src/leapflow/cli/context.py index 11a3e91c..288e80b2 100644 --- a/src/leapflow/cli/context.py +++ b/src/leapflow/cli/context.py @@ -3114,12 +3114,15 @@ def _capability_observation_service(self): ) return self._observation_service - def _current_environment_dict(self): - """The environment evidence is recorded against. - - Carried with each degradation so one application upgrade that breaks N - capabilities is recognisable as one transition rather than N coincidences -- the - teacher can then answer once, and usually with a rebind rather than N rebuilds. + def _current_environment_fingerprint(self): + """The environment a capability decision is made against, as a fingerprint. + + A single object so the world-model driver's distillation path and its + acquisition path agree on the environment: the distilled-knowledge store tags + each entry with the fingerprint id, and a queued proposal carries the same + fingerprint into the lifecycle queue so the causal ledger can place it. Returns + ``None`` when the platform layer is unavailable, which the callers degrade + around. """ try: from leapflow.domain.environment_fingerprint import EnvironmentFingerprint @@ -3128,10 +3131,20 @@ def _current_environment_dict(self): return EnvironmentFingerprint.from_platform_manifest( PlatformManifest.default_darwin(), workspace_root=str(getattr(self.settings, "workspace_root", "") or ""), - ).to_dict() + ) except (ImportError, AttributeError, TypeError, ValueError): logger.debug("environment fingerprint unavailable", exc_info=True) - return {} + return None + + def _current_environment_dict(self): + """The environment evidence is recorded against. + + Carried with each degradation so one application upgrade that breaks N + capabilities is recognisable as one transition rather than N coincidences -- the + teacher can then answer once, and usually with a rebind rather than N rebuilds. + """ + fingerprint = self._current_environment_fingerprint() + return fingerprint.to_dict() if fingerprint is not None else {} def _current_affordances(self): """App-level affordances the task environment currently offers. @@ -3198,6 +3211,14 @@ def _resolve_lifecycle_governor(self): profile_layout.capability_proposal_queue_path ), outcome_store=JsonPluginOutcomeStore(profile_layout.plugin_outcomes_path), + # The approval-gated actor that actually disables a plugin. Without it the + # governor decided "quarantine" and nothing happened: trust dropped but the + # plugin kept serving, and the queue never advanced past PROBATION. Built + # from the live registry's self_management plugin, and left ``None`` only + # when that plugin is absent (an in-process CLI that composed no lifecycle + # surface) -- in which case quarantine records intent without executing it, + # which is the honest degradation rather than a silent no-op. + lifecycle_actor=self._plugin_lifecycle_actor(), # The process ledger, hydrated from DuckDB -- not a fresh one. Letting # the governor default to its own would give one process two divergent # views of trust: the transitions it computed would land in a throwaway @@ -3233,6 +3254,69 @@ def _process_trust_ledger(self): return None return getattr(advisor, "_trust_ledger", None) if advisor is not None else None + def _plugin_lifecycle_actor(self): + """The approval-gated actor that executes governance decisions, or ``None``. + + ``LifecycleGovernor`` decides *quarantine*; something has to carry it out, and + that something is the ``self_management`` plugin's approval-gated disable/remove + path. Without an actor the governor's decision was inert -- trust fell but the + plugin kept serving and the queue never advanced -- which is a wiring gap a unit + test cannot see because every unit test injects its own actor. + + Returns ``None`` when the registry has no ``self_management`` plugin (an + in-process CLI that composed no lifecycle surface). That is honest degradation: + the governor still records the intended transition; it simply cannot execute it + until a runtime with the plugin is present. + """ + try: + from leapflow.plugins import get_registry + from leapflow.plugins.adaptive_loop import SelfManagementLifecycleActor + + return SelfManagementLifecycleActor.from_registry(get_registry()) + except (ImportError, RuntimeError, AttributeError): + logger.debug("plugin lifecycle actor unavailable", exc_info=True) + return None + + def _active_proposal_ids(self) -> dict: + """Map ``plugin_id -> proposal_id`` from the live lifecycle queue. + + The sweep verifies an acquired plugin's effect and feeds the verdict to + ``LifecycleGovernor.record_outcome``, which keys the lifecycle record by + proposal id. The plugin only knows its own id, so this bridges the two: the + proposal sink stamped ``metadata.plugin_id`` on each queued item, so the map is + a read of the queue rather than a second bookkeeping structure that could drift. + + Empty on any failure -- an unresolvable map degrades a governance outcome to an + untracked one, which is preferable to failing the cold-path sweep. + """ + settings = getattr(self, "settings", None) + profile_layout = getattr(settings, "profile_layout", None) + if profile_layout is None: + return {} + try: + from leapflow.storage.capability_proposal_queue import ( + JsonCapabilityProposalQueue, + ) + + queue = JsonCapabilityProposalQueue( + profile_layout.capability_proposal_queue_path + ) + mapping: dict = {} + # ``active()`` returns items newest-first (sorted by updated/created), so the + # first mapping seen for a plugin is its most recent lifecycle record. Keep + # that one: a plugin can hold several active records (different capability, + # environment, or source), and governing the *newest* is what the sweep + # means by "this plugin's outcome". Overwriting unconditionally would leave + # the map pointing at the oldest record and update the wrong one. + for item in queue.active(limit=0): + plugin_id = str(dict(item.metadata).get("plugin_id") or "") + if plugin_id and plugin_id not in mapping: + mapping[plugin_id] = item.proposal_id + return mapping + except (ImportError, AttributeError, OSError, RuntimeError, TypeError, ValueError): + logger.debug("active proposal id map unavailable", exc_info=True) + return {} + async def _run_coevolution_sweep(self): """Cold-path governance sweep: verify effects, drain quarantine, find residue. @@ -3260,6 +3344,11 @@ async def _run_coevolution_sweep(self): governor=self._resolve_lifecycle_governor(), tracker=getattr(self, "_quarantine_tracker", None) or current_quarantine_tracker(), + # plugin_id -> proposal_id, so a governance outcome updates the *right* + # lifecycle record rather than calling ``record_outcome`` with an empty + # proposal id (a silent no-op that left the queue frozen). Read from the + # queue's live items, whose ``metadata.plugin_id`` the proposal sink set. + proposal_ids=self._active_proposal_ids(), ) # Facts are collected where they are produced -- the engine's resolution # path, the install tools, and the tool-outcome sink -- so the sweep reads @@ -3350,16 +3439,52 @@ async def _drive_world_model_evolution(self, trajectory: list, goal: str): if getattr(settings, "evolution_enabled", False) else None ), + # P5 authority in the production path: only an authorised requirement + # origin may drive an acquisition. Rebind-vs-acquire (whether an + # installed provider already covers the capability) is decided upstream + # by the teacher from failed-outcome hindsight and the alternatives it + # was shown -- a declared-fitness re-check here would re-introduce the + # semantic-regression blind spot -- so the driver adds authority only. + authorising_origins=tuple( + getattr(settings, "evolution_authorising_origins", ()) or () + ), ) return await driver.drive( trajectory, goal, + environment=self._current_environment_fingerprint(), workspace_root=str(getattr(settings, "workspace_root", "") or ""), ) except (ImportError, AttributeError, OSError, RuntimeError, TypeError, ValueError): logger.debug("world-model evolution driver unavailable", exc_info=True) return None + async def run_learning_boundary(self, *, reason: str = "shutdown") -> dict[str, Any]: + """Run the learning boundary once and report what it did. + + This is the only place capability evolution is driven from, so *when* it is + called decides when the framework can evolve at all. It used to be reachable + only from :meth:`cleanup`, which in daemon mode means process shutdown: a + daemon that ran for a week never evolved, one killed with SIGKILL never + evolved at all, and the single flush at the end mixed every session and every + workspace of that lifetime into one episode carrying the last user's goal. + + Named and public so a semantic boundary can drive it -- a finished session, + or an explicit ``leap evolve`` -- instead of only the process dying. + ``reason`` is recorded rather than inspected: the pipeline does the same work + either way, and the label is what lets a reader tell a shutdown flush from a + session boundary from a hand-run one. + """ + started = time.perf_counter() + before = len(self.prediction_loop.trajectory_buffer) if self.prediction_loop else 0 + await self._on_session_end_learning() + return { + "ok": True, + "reason": reason, + "trajectory_steps": before, + "duration_s": round(time.perf_counter() - started, 3), + } + async def _on_session_end_learning(self) -> None: """End-of-session OPD learning pipeline (8 phases) with full observability. @@ -3390,6 +3515,7 @@ async def _on_session_end_learning(self) -> None: t0 = time.perf_counter() try: trajectory, goal = self.prediction_loop.flush_trajectory() + phase_detail: dict[str, Any] = {} if trajectory: # The world model is the first driver of capability evolution: # the same hindsight call that grades the episode also proposes @@ -3404,26 +3530,29 @@ async def _on_session_end_learning(self) -> None: ) if grades and self.replay_engine is not None: self.replay_engine.set_replay_priorities(grades) - phase_detail = {"actions_graded": len(grades) if grades else 0} + phase_detail["actions_graded"] = len(grades) if grades else 0 if drive is not None: phase_detail.update(drive.to_dict()) - # Cold-path governance sweep: effect verification, quarantine - # drain, reclamation. Runs whether or not the teacher proposed - # anything, so its no-op traces distinguish a quiet session from - # a sweep that never ran. - sweep = await self._run_coevolution_sweep() - if sweep is not None: - phase_detail.update(sweep.to_dict()) - observer.on_phase_success( - "trajectory_grading", time.perf_counter() - t0, phase_detail, - ) - phases_ok += 1 else: - observer.on_phase_success( - "trajectory_grading", time.perf_counter() - t0, - {"actions_graded": 0, "note": "empty_trajectory"}, - ) - phases_ok += 1 + phase_detail.update({"actions_graded": 0, "note": "empty_trajectory"}) + # Cold-path governance sweep: effect verification, quarantine drain, + # reclamation. Outside the trajectory branch, because its whole + # purpose is that its no-op traces distinguish a quiet session from a + # sweep that never ran -- and nested inside it, an empty trajectory + # skipped the sweep entirely and produced exactly the ambiguity it + # was written to remove. Three reachability segments read + # "no sweep trace observed" on a live board for that reason alone. + # + # Nothing here depends on the trajectory: the sweep reads the process + # observation buffer and the proposal queue, both of which carry work + # from turns that predate this boundary. + sweep = await self._run_coevolution_sweep() + if sweep is not None: + phase_detail.update(sweep.to_dict()) + observer.on_phase_success( + "trajectory_grading", time.perf_counter() - t0, phase_detail, + ) + phases_ok += 1 except Exception as exc: observer.on_phase_failure("trajectory_grading", exc, time.perf_counter() - t0) phases_failed += 1 @@ -3776,7 +3905,7 @@ async def cleanup(self) -> None: logger.debug("EventBus shutdown failed", exc_info=True) # OPD end-of-session learning pipeline if self.settings.replay_on_session_end: - await self._on_session_end_learning() + await self.run_learning_boundary(reason="shutdown") # Persist session summary before memory shutdown await self._persist_session_summary() # Shutdown all memory providers (stops GC, closes DB) diff --git a/src/leapflow/daemon/client.py b/src/leapflow/daemon/client.py index 93095770..bfebee0a 100644 --- a/src/leapflow/daemon/client.py +++ b/src/leapflow/daemon/client.py @@ -522,6 +522,10 @@ async def session_analyze(self) -> dict[str, Any]: """Ensure a session-analysis watch and run one analysis cycle now.""" return dict(await self.request("session.analyze") or {}) + async def evolution_run(self, reason: str = "manual") -> dict[str, Any]: + """Run the learning boundary in the daemon now.""" + return dict(await self.request("evolution.run", {"reason": reason}) or {}) + async def signal_record(self, event_type: str, payload: dict[str, Any]) -> dict[str, Any]: """Inject a signal event into the daemon's EventBus.""" return dict(await self.request( diff --git a/src/leapflow/daemon/monitor_coordinator.py b/src/leapflow/daemon/monitor_coordinator.py index 5945b5d2..c48b9c76 100644 --- a/src/leapflow/daemon/monitor_coordinator.py +++ b/src/leapflow/daemon/monitor_coordinator.py @@ -69,6 +69,9 @@ async def start(self, ctx: Any, notification_bus: Any, settings: Any) -> None: from leapflow.monitor.signal_producer import SignalObservationProducer bus = notification_bus + # The evolution publisher captures this before the trace sink is installed. + # It schedules display fan-out on the event loop, never on a probe site. + self._notification_bus = bus self._monitors = MonitorManager( holder=ctx._db_holder, emit=lambda event_type, payload: bus.emit_event(event_type, **payload), @@ -178,6 +181,8 @@ def _make_evolution_publisher(self, ctx: Any) -> Any: except RuntimeError: return None + notification_bus = self._notification_bus + def _publish(trace: Any) -> None: detail = dict(getattr(trace, "detail", None) or {}) if detail.get("phase") == "composition": @@ -189,10 +194,22 @@ def _publish(trace: Any) -> None: "correlation": dict(getattr(trace, "correlation", None) or {}), } event_type = f"evolution.{payload['kind'] or 'trace'}" + + def _dispatch() -> None: + asyncio.ensure_future(bus.handle_event(event_type, payload)) + if notification_bus is not None: + try: + from leapflow.telemetry.evolution_presentation import EvolutionPresentationEvent + + presentation = EvolutionPresentationEvent.from_trace(trace).to_dict() + notification_bus.emit(Notification( + event_type="evolution.presentation", payload=presentation, + )) + except Exception: # noqa: BLE001 - display fan-out must stay best-effort + logger.debug("daemon: evolution presentation not published", exc_info=True) + try: - loop.call_soon_threadsafe( - lambda: asyncio.ensure_future(bus.handle_event(event_type, payload)) - ) + loop.call_soon_threadsafe(_dispatch) except RuntimeError: # Loop already closed (shutdown). The trace is still buffered and # will be flushed by the atexit hook; only the live refresh is lost. diff --git a/src/leapflow/daemon/protocol.py b/src/leapflow/daemon/protocol.py index bd81e417..c2f0ea84 100644 --- a/src/leapflow/daemon/protocol.py +++ b/src/leapflow/daemon/protocol.py @@ -248,6 +248,15 @@ async def session_analyze(self) -> Dict[str, Any]: """Ensure a session-analysis watch and run one analysis cycle now.""" ... + async def evolution_run(self, reason: str = "manual") -> Dict[str, Any]: + """Run the learning boundary now, the one path that drives evolution. + + Exposed because the boundary was otherwise reachable only from context + cleanup -- process shutdown in daemon mode -- which made "when does the + framework evolve" unanswerable and untestable without killing the daemon. + """ + ... + async def status(self, session_id: str = "") -> Dict[str, Any]: """Return daemon status (uptime, connections, db path, etc.). @@ -480,6 +489,7 @@ async def gateway_send( "session.history": "session_history", "session.detail": "session_detail", "session.analyze": "session_analyze", + "evolution.run": "evolution_run", "daemon.status": "status", "daemon.shutdown": "shutdown", "host.status": "host_status", diff --git a/src/leapflow/daemon/service.py b/src/leapflow/daemon/service.py index 39727bc7..718e9371 100644 --- a/src/leapflow/daemon/service.py +++ b/src/leapflow/daemon/service.py @@ -936,6 +936,23 @@ async def session_detail( async def session_analyze(self) -> dict[str, Any]: return await self._session_coordinator.analyze(self._monitors, self._ctx, self._settings) + async def evolution_run(self, reason: str = "manual") -> dict[str, Any]: + """Drive the learning boundary in the daemon's context, now. + + The daemon owns the context that holds the trajectory buffer, the world-model + teacher and the proposal queue, so this has to run here rather than in the + calling CLI process -- a second context would grade an empty buffer and + report success having done nothing. + """ + ctx = self._ctx + if ctx is None: + return {"ok": False, "error": "daemon context unavailable"} + try: + return await ctx.run_learning_boundary(reason=str(reason or "manual")) + except Exception as exc: # noqa: BLE001 - reported to the caller, never fatal + logger.warning("daemon: learning boundary failed: %s", exc, exc_info=True) + return {"ok": False, "error": str(exc), "reason": str(reason or "manual")} + def _ensure_session_registry(self, base_engine: Any) -> Any: return self._session_coordinator.ensure_registry(base_engine, self._settings) diff --git a/src/leapflow/dashboard/hub.py b/src/leapflow/dashboard/hub.py index 1912e7ab..285f168d 100644 --- a/src/leapflow/dashboard/hub.py +++ b/src/leapflow/dashboard/hub.py @@ -21,6 +21,9 @@ class ViewHub: def __init__(self, maxsize: int = 128) -> None: self._subscribers: dict[str, asyncio.Queue[Optional[dict[str, Any]]]] = {} + # A dropped increment must not leave a live lens permanently stale. The next + # successful delivery asks that browser to fetch its authoritative snapshot. + self._resync_required: set[str] = set() self._maxsize = maxsize def subscribe(self, subscriber_id: str) -> asyncio.Queue[Optional[dict[str, Any]]]: @@ -32,6 +35,7 @@ def subscribe(self, subscriber_id: str) -> asyncio.Queue[Optional[dict[str, Any] def unsubscribe(self, subscriber_id: str) -> None: """Remove a browser subscriber.""" self._subscribers.pop(subscriber_id, None) + self._resync_required.discard(subscriber_id) def broadcast(self, message: dict[str, Any]) -> int: """Deliver a message to all subscribers (non-blocking); return count. @@ -41,10 +45,23 @@ def broadcast(self, message: dict[str, Any]) -> int: """ delivered = 0 for sid, queue in list(self._subscribers.items()): + resynced = False + if sid in self._resync_required: + try: + queue.put_nowait({"type": "view.resync", "payload": {"reason": "dropped_events"}}) + self._resync_required.discard(sid) + resynced = True + except asyncio.QueueFull: + continue try: queue.put_nowait(message) delivered += 1 except asyncio.QueueFull: + # A successful resync marker already occupies the one available + # slot. Do not re-arm it because the marker itself tells the client + # to fetch the snapshot and discard this increment. + if not resynced: + self._resync_required.add(sid) logger.debug("view_hub: dropped message for slow subscriber %s", sid) return delivered @@ -60,6 +77,7 @@ async def shutdown(self) -> None: except asyncio.QueueFull: pass self._subscribers.clear() + self._resync_required.clear() __all__ = ["ViewHub"] diff --git a/src/leapflow/dashboard/server.py b/src/leapflow/dashboard/server.py index 3aeb237f..b5d183f4 100644 --- a/src/leapflow/dashboard/server.py +++ b/src/leapflow/dashboard/server.py @@ -76,7 +76,17 @@ def _index_html(index: Path) -> str: return _ASSET_VERSION_RE.sub(rf"\1?v={_asset_version()}", index.read_text(encoding="utf-8")) -_MONITOR_EVENTS = frozenset({EVENT_FINDING, EVENT_WATCH_STATE, EVENT_ERROR, EVENT_HEARTBEAT, "signal.stream"}) +_MONITOR_EVENTS = frozenset({ + EVENT_FINDING, + EVENT_WATCH_STATE, + EVENT_ERROR, + EVENT_HEARTBEAT, + "signal.stream", + # Presentation-only increment for the hidden evolution_live lens. The daemon + # publishes it after buffering the trace and from the event loop, never inline + # with a registry/trust mutation. + "evolution.presentation", +}) # Only these RPCs may be triggered by browser actions (least privilege). # # The hardware entries are read-or-request only, and that boundary is the whole point. diff --git a/src/leapflow/dashboard/service.py b/src/leapflow/dashboard/service.py index 507e8620..c0e20000 100644 --- a/src/leapflow/dashboard/service.py +++ b/src/leapflow/dashboard/service.py @@ -11,6 +11,7 @@ from __future__ import annotations import logging +import time from typing import Any, Protocol, runtime_checkable from leapflow.dashboard.intent import DashboardIntent @@ -215,6 +216,130 @@ def _empty_state(domain: str, watch: dict[str, Any]) -> dict[str, Any]: } +def _provenance(payload: dict[str, Any], watch: dict[str, Any]) -> dict[str, Any]: + """State when the rendered data was observed, when it was last confirmed, and + whether the watch behind it is keeping its cadence. + + Two instants, deliberately not merged, because merging them is what made the + board unreadable: + + * ``observed_at`` -- when the content on screen was produced. Findings dedup on + a content fingerprint, so an unchanged subject keeps its previous finding and + this can legitimately be hours old. + * ``checked_at`` -- when a cycle last completed. It advances on every run, + including one that concluded nothing had changed and therefore wrote nothing. + + Reporting only the first made a correct system look broken: pressing refresh ran + a real cycle, the fingerprint matched, no finding was written, and every figure + on the page -- including its own age -- stayed frozen. Reporting only the second + would be worse: it would age a stale page from the clock and call it current. + + So ``stale`` is a verdict about the *watch*, not the content: a cycle has not + completed in two cadences, which means the page cannot be trusted to reflect + anything. Content that is old but freshly confirmed is not stale, it is stable, + and ``unchanged_for_seconds`` says how long it has been so. + + Two cadences rather than a fixed number of seconds: one missed cycle is + scheduling jitter, two is a cadence that is not being kept. With no declared + cadence (event, cron, condition) the verdict is withheld rather than guessed -- + judging an event-driven watch against an invented interval would be the same + class of error this block exists to remove. + """ + now = time.time() + observed_at = float(payload.get("observed_at") or 0.0) + checked_at = float(watch.get("last_run_at") or 0.0) + # A payload with no instant of its own is dated by the cycle that produced it. + if observed_at <= 0.0: + observed_at = checked_at + cadence = float(watch.get("interval_seconds") or 0.0) + next_due_at = float(watch.get("next_due_at") or 0.0) + return { + "observed_at": observed_at, + "age_seconds": max(0.0, now - observed_at) if observed_at > 0.0 else 0.0, + "checked_at": checked_at, + "checked_age_seconds": max(0.0, now - checked_at) if checked_at > 0.0 else 0.0, + # How long the subject has held still. Only meaningful once a check has + # happened after the observation; otherwise there is nothing to compare. + "unchanged_for_seconds": ( + max(0.0, checked_at - observed_at) + if checked_at > 0.0 and observed_at > 0.0 + else 0.0 + ), + "cadence_seconds": cadence, + "next_due_at": next_due_at, + "next_due_in_seconds": max(0.0, next_due_at - now) if next_due_at > 0.0 else 0.0, + "run_count": int(watch.get("run_count") or 0), + "watch_state": str(watch.get("state") or ""), + "muted": bool(watch.get("muted")), + # The identity of what produced the page, so the bar can offer a refresh + # rather than only report that the page is behind. Being able to re-run the + # cycle from here is what turns the freshness reading into a closed loop: + # the reader changes something the board told them to change, refreshes, and + # sees whether it landed. + "watch_id": str(watch.get("watch_id") or ""), + # Absent is not the same as fresh. A board whose watch never ran has no + # instant to age, and saying "0s ago" there would invent one. + "observed": observed_at > 0.0, + "checked": checked_at > 0.0, + "stale": bool( + cadence > 0.0 + and checked_at > 0.0 + and (now - checked_at) > cadence * 2 + ), + } + + +def _evidence_trend(findings: list[dict[str, Any]]) -> dict[str, Any]: + """Turn the retained framework_evolution findings into one evolution axis. + + The board could say what the framework *is* and never what direction it is + moving. Every panel was a cross-section of one instant; the only time-shaped + element was the episode timeline, which is gated on episodes and therefore hidden + in exactly the state where "has anything started yet" is the question being asked. + + So the axis is built from the findings already retained for the domain. They are + persisted newest-first and deduped on content, which makes them a record of + *changes* rather than of ticks -- one point per distinct state, which is the right + granularity for this question and cheaper than sampling every cycle. + + A single point is emitted and drawn. It reads "one observation, here it is", + which is a fact; suppressing it until a second arrives would hide the beginning + of every evolution the board exists to show. + """ + points: list[dict[str, Any]] = [] + for finding in reversed(findings or []): # oldest first, so the axis reads left to right + payload = finding.get("payload") + if not isinstance(payload, dict): + continue + summary = payload.get("summary") + if not isinstance(summary, dict): + continue + with_evidence = summary.get("segments_with_evidence") + if with_evidence is None: + continue + observed_at = float(payload.get("observed_at") or finding.get("ts") or 0.0) + points.append({ + "x": observed_at, + "y": int(with_evidence), + "at": observed_at, + }) + total = 0 + for finding in findings or []: + payload = finding.get("payload") + if isinstance(payload, dict) and isinstance(payload.get("summary"), dict): + total = int(payload["summary"].get("segments_total") or 0) + break + return { + "series": [{"label": "Segments with runtime evidence", "points": points}] if points else [], + "samples": len(points), + "segments_total": total, + "first_at": points[0]["at"] if points else 0.0, + "last_at": points[-1]["at"] if points else 0.0, + # Direction, stated rather than left to the reader's eye on a two-point line. + "delta": (points[-1]["y"] - points[0]["y"]) if len(points) > 1 else 0, + } + + def _hardware_notice( inventory: dict[str, Any], digest: dict[str, Any] ) -> dict[str, str] | None: @@ -332,6 +457,12 @@ def _short_id(value: Any) -> str: # template -> (finding domain, data key the template binds to) "capability": ("capability_adaptation", "capability_plan"), "evolution": ("framework_evolution", "evolution"), + # The hidden demo/audit lens reads the same immutable evolution snapshot. + # It adds no data source or mutation path. + "causal_trace": ("framework_evolution", "evolution"), + # The live lens consumes the same authoritative snapshot and only augments it + # with presentation events delivered through the browser WebSocket. + "evolution_live": ("framework_evolution", "evolution"), "hardware": ("hardware", "hardware"), } """Templates whose data is a producer's finding payload, not a session lens. @@ -524,6 +655,7 @@ async def _build_from_finding_payload( data_key: payload, "findings": domain_findings or None, "watch": watch, + "provenance": _provenance(payload, watch), "observation": { "watch_state": watch.get("state", ""), "watch_muted": watch.get("muted", False), @@ -539,6 +671,13 @@ async def _build_from_finding_payload( # idle with nothing to report, and no watch at all means the producer is # not being scheduled -- three different next steps. data["empty"] = _empty_state(finding_domain, watch) + if finding_domain == "framework_evolution": + # A sibling top-level key, not folded into the bound payload. The producer + # owns everything under ``evolution.*`` and a test asserts that contract; + # this series is derived here because only the retained finding list + # carries history, and hiding a service-derived figure inside the + # producer's namespace would make that ownership unreadable. + data["evidence_trend"] = _evidence_trend(domain_findings or []) if template == "hardware": # The fleet list comes from the live registry rather than the cycle payload. # The digest is capped at eight charted channels and is up to a monitor @@ -587,6 +726,7 @@ async def _build_session(self, template: str, provider: DashboardDataProvider) - "title": "Session Analysis", "analysis": analysis, "observation": observation, + "provenance": _provenance(analysis, session_watch), "artifact_context": analysis.get("artifact_context") or [], "findings": session_findings, "watch": session_watch, @@ -607,6 +747,15 @@ def _render(self, template: str, data: dict[str, Any]) -> dict[str, Any]: meta["templates"] = self._templates.visible_names() meta["hidden_templates"] = self._templates.hidden_names() meta["active_template"] = name + # Freshness rides in ``meta`` rather than the component tree so it is + # page chrome on every lens at once, and so a template author cannot + # forget to bind it. Lifted here for the same reason the lens list is: + # this is the one place every build path passes through. A build path + # that computes no provenance says nothing rather than claiming the + # page is current. + provenance = data.get("provenance") + if isinstance(provenance, dict): + meta["provenance"] = provenance return spec async def _build_signals(self, template: str, provider: DashboardDataProvider) -> dict[str, Any]: diff --git a/src/leapflow/dashboard/static/app.js b/src/leapflow/dashboard/static/app.js index 6992c1da..29473de5 100644 --- a/src/leapflow/dashboard/static/app.js +++ b/src/leapflow/dashboard/static/app.js @@ -18,6 +18,9 @@ const HIDDEN_NAV_TEMPLATES = new Set(["finance", "research", "sentiment"]); let figSeq = 0; // academic figure counter, reset each render() let tblSeq = 0; // academic table counter, reset each render() + // Custom live lenses are recreated from the authoritative snapshot after every + // fetch. WebSocket increments only update the currently rendered instances. + let _evolutionLiveControllers = []; // ── Signal auto-refresh state ── let _signalRefreshTimer = null; @@ -221,26 +224,172 @@ "near": "у границы", "outside": "вне допуска", "unknown": "неизвестно" } }; + const I18N_LIVE = { + en: { + "Evolution live": "Evolution live", "Read-only event lanes for environment, decision, and governance evidence.": "Read-only event lanes for environment, decision, and governance evidence.", + "Run posture": "Run posture", "Current snapshot and live increments stay distinct; missing evidence remains visible.": "Current snapshot and live increments stay distinct; missing evidence remains visible.", + "Episodes": "Episodes", "Pipeline evidence": "Pipeline evidence", "Unadmitted intents": "Unadmitted intents", "Regressions": "Regressions", + "Live event lanes": "Live event lanes", "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.": "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.", + "Counterfactual / mutation matrix": "Counterfactual / mutation matrix", "Latest durable episode projection; rows do not imply an unrecorded install or approval.": "Latest durable episode projection; rows do not imply an unrecorded install or approval.", + "Trigger": "Trigger", "Capability": "Capability", "Decision": "Decision", "Mutation": "Mutation", "Evidence tier": "Evidence tier", "Gap closure": "Gap closure", + "Environment lane": "Environment lane", "Decision lane": "Decision lane", "Governance lane": "Governance lane", "Live events": "Live events", "Event count": "Event count", "No live events": "No live events", "Event detail": "Event detail", "Select a live event to inspect its evidence references.": "Select a live event to inspect its evidence references.", + "Live since snapshot": "Live since snapshot", + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.": "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.", + "Environment events appear when a probe records a change in the surroundings.": "Environment events appear when a probe records a change in the surroundings.", + "Decision events appear when a recorded observation drives a capability choice.": "Decision events appear when a recorded observation drives a capability choice.", + "Governance events appear when trust, quarantine or reclamation moves.": "Governance events appear when trust, quarantine or reclamation moves." + }, + zh: { + "Evolution live": "演化实时视图", "Read-only event lanes for environment, decision, and governance evidence.": "面向环境、决策和治理证据的只读事件泳道。", + "Run posture": "运行态势", "Current snapshot and live increments stay distinct; missing evidence remains visible.": "当前快照与实时增量保持区分;缺失证据保持可见。", + "Episodes": "剧集", "Pipeline evidence": "管道证据", "Unadmitted intents": "未准入意图", "Regressions": "回归", + "Live event lanes": "实时事件泳道", "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.": "仅展示的追踪投影。重连时从当前演化快照重新同步。", + "Counterfactual / mutation matrix": "反事实 / 变更矩阵", "Latest durable episode projection; rows do not imply an unrecorded install or approval.": "最新持久剧集投影;行内容不代表未记录的安装或审批。", + "Trigger": "触发源", "Capability": "能力", "Decision": "决策", "Mutation": "变更", "Evidence tier": "证据层级", "Gap closure": "缺口闭合", + "Environment lane": "环境泳道", "Decision lane": "决策泳道", "Governance lane": "治理泳道", "Live events": "实时事件", "Event count": "事件数", "No live events": "暂无实时事件", "Event detail": "事件详情", "Select a live event to inspect its evidence references.": "选择实时事件以查看其证据引用。", + "Live since snapshot": "快照后新增", + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.": "{count} 条事件在此快照之后到达。快照类指标将在下一个监控周期刷新。", + "Environment events appear when a probe records a change in the surroundings.": "当探针记录到周边环境发生变化时,环境事件会出现在这里。", + "Decision events appear when a recorded observation drives a capability choice.": "当已记录的观测驱动一次能力选择时,决策事件会出现在这里。", + "Governance events appear when trust, quarantine or reclamation moves.": "当信任、隔离或回收发生变动时,治理事件会出现在这里。" + }, + fr: { + "Evolution live": "Évolution en direct", "Read-only event lanes for environment, decision, and governance evidence.": "Voies d’événements en lecture seule pour les preuves d’environnement, de décision et de gouvernance.", + "Run posture": "État d’exécution", "Current snapshot and live increments stay distinct; missing evidence remains visible.": "L’instantané et les incréments restent distincts ; les preuves manquantes restent visibles.", + "Episodes": "Épisodes", "Pipeline evidence": "Preuves du pipeline", "Unadmitted intents": "Intentions non admises", "Regressions": "Régressions", + "Live event lanes": "Voies d’événements live", "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.": "Projection de trace réservée à l’affichage. La reconnexion se resynchronise depuis l’instantané d’évolution actuel.", + "Counterfactual / mutation matrix": "Matrice contrefactuelle / mutations", "Latest durable episode projection; rows do not imply an unrecorded install or approval.": "Projection du dernier épisode durable ; les lignes n’impliquent ni installation ni approbation non enregistrée.", + "Trigger": "Déclencheur", "Capability": "Capacité", "Decision": "Décision", "Mutation": "Mutation", "Evidence tier": "Niveau de preuve", "Gap closure": "Clôture de l’écart", + "Environment lane": "Voie environnement", "Decision lane": "Voie décision", "Governance lane": "Voie gouvernance", "Live events": "Événements live", "Event count": "Nombre d’événements", "No live events": "Aucun événement live", "Event detail": "Détail de l’événement", "Select a live event to inspect its evidence references.": "Sélectionnez un événement live pour examiner ses références de preuve.", + "Live since snapshot": "En direct depuis l’instantané", + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.": "{count} événement(s) sont arrivés après cet instantané. Les métriques d’instantané seront actualisées au prochain cycle de surveillance.", + "Environment events appear when a probe records a change in the surroundings.": "Les événements d’environnement apparaissent lorsqu’une sonde enregistre un changement des alentours.", + "Decision events appear when a recorded observation drives a capability choice.": "Les événements de décision apparaissent lorsqu’une observation enregistrée motive un choix de capacité.", + "Governance events appear when trust, quarantine or reclamation moves.": "Les événements de gouvernance apparaissent lorsque la confiance, la quarantaine ou la récupération évolue." + }, + es: { + "Evolution live": "Evolución en vivo", "Read-only event lanes for environment, decision, and governance evidence.": "Carriles de eventos de solo lectura para evidencia de entorno, decisión y gobernanza.", + "Run posture": "Estado de ejecución", "Current snapshot and live increments stay distinct; missing evidence remains visible.": "La instantánea y los incrementos en vivo siguen siendo distintos; la evidencia faltante permanece visible.", + "Episodes": "Episodios", "Pipeline evidence": "Evidencia del pipeline", "Unadmitted intents": "Intenciones no admitidas", "Regressions": "Regresiones", + "Live event lanes": "Carriles de eventos en vivo", "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.": "Proyección de trazas solo para presentación. La reconexión resincroniza desde la instantánea de evolución actual.", + "Counterfactual / mutation matrix": "Matriz contrafactual / de mutaciones", "Latest durable episode projection; rows do not imply an unrecorded install or approval.": "Proyección del último episodio durable; las filas no implican instalación ni aprobación no registradas.", + "Trigger": "Desencadenante", "Capability": "Capacidad", "Decision": "Decisión", "Mutation": "Mutación", "Evidence tier": "Nivel de evidencia", "Gap closure": "Cierre de la brecha", + "Environment lane": "Carril de entorno", "Decision lane": "Carril de decisión", "Governance lane": "Carril de gobernanza", "Live events": "Eventos en vivo", "Event count": "Conteo de eventos", "No live events": "No hay eventos en vivo", "Event detail": "Detalle del evento", "Select a live event to inspect its evidence references.": "Seleccione un evento en vivo para inspeccionar sus referencias de evidencia.", + "Live since snapshot": "En vivo desde la instantánea", + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.": "{count} evento(s) llegaron después de esta instantánea. Las métricas de instantánea se actualizarán en el próximo ciclo de monitoreo.", + "Environment events appear when a probe records a change in the surroundings.": "Los eventos de entorno aparecen cuando una sonda registra un cambio en el entorno.", + "Decision events appear when a recorded observation drives a capability choice.": "Los eventos de decisión aparecen cuando una observación registrada impulsa una elección de capacidad.", + "Governance events appear when trust, quarantine or reclamation moves.": "Los eventos de gobernanza aparecen cuando cambian la confianza, la cuarentena o la recuperación." + }, + ar: { + "Evolution live": "التطور المباشر", "Read-only event lanes for environment, decision, and governance evidence.": "مسارات أحداث للقراءة فقط لأدلة البيئة والقرار والحوكمة.", + "Run posture": "حالة التشغيل", "Current snapshot and live increments stay distinct; missing evidence remains visible.": "تظل اللقطة والزيادات المباشرة منفصلة؛ وتبقى الأدلة المفقودة مرئية.", + "Episodes": "الحلقات", "Pipeline evidence": "أدلة المسار", "Unadmitted intents": "نيات غير مقبولة", "Regressions": "الانحدارات", + "Live event lanes": "مسارات الأحداث المباشرة", "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.": "إسقاط أثر للعرض فقط. تعيد إعادة الاتصال المزامنة من لقطة التطور الحالية.", + "Counterfactual / mutation matrix": "مصفوفة الافتراضات المضادة / التغييرات", "Latest durable episode projection; rows do not imply an unrecorded install or approval.": "إسقاط أحدث حلقة دائمة؛ لا تعني الصفوف تثبيتًا أو موافقة غير مسجلة.", + "Trigger": "المحفز", "Capability": "القدرة", "Decision": "القرار", "Mutation": "التغيير", "Evidence tier": "طبقة الدليل", "Gap closure": "إغلاق الفجوة", + "Environment lane": "مسار البيئة", "Decision lane": "مسار القرار", "Governance lane": "مسار الحوكمة", "Live events": "الأحداث المباشرة", "Event count": "عدد الأحداث", "No live events": "لا توجد أحداث مباشرة", "Event detail": "تفاصيل الحدث", "Select a live event to inspect its evidence references.": "اختر حدثًا مباشرًا لفحص مراجع أدلته.", + "Live since snapshot": "مباشر منذ اللقطة", + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.": "وصل {count} حدث بعد هذه اللقطة. تُحدَّث مقاييس اللقطة في دورة المراقبة التالية.", + "Environment events appear when a probe records a change in the surroundings.": "تظهر أحداث البيئة عندما يسجّل مِجَسّ تغيّرًا في المحيط.", + "Decision events appear when a recorded observation drives a capability choice.": "تظهر أحداث القرار عندما تدفع ملاحظة مسجّلة إلى اختيار قدرة.", + "Governance events appear when trust, quarantine or reclamation moves.": "تظهر أحداث الحوكمة عند تغيّر الثقة أو الحجر أو الاستعادة." + }, + ru: { + "Evolution live": "Эволюция в реальном времени", "Read-only event lanes for environment, decision, and governance evidence.": "Потоки событий только для чтения для доказательств окружения, решений и управления.", + "Run posture": "Состояние запуска", "Current snapshot and live increments stay distinct; missing evidence remains visible.": "Снимок и живые приращения остаются раздельными; отсутствующие доказательства остаются видимыми.", + "Episodes": "Эпизоды", "Pipeline evidence": "Свидетельства конвейера", "Unadmitted intents": "Непринятые намерения", "Regressions": "Регрессии", + "Live event lanes": "Потоки живых событий", "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot.": "Проекция трассы только для отображения. При переподключении выполняется синхронизация из текущего снимка эволюции.", + "Counterfactual / mutation matrix": "Контрфактическая матрица / мутации", "Latest durable episode projection; rows do not imply an unrecorded install or approval.": "Проекция последнего долговечного эпизода; строки не означают незафиксированную установку или согласование.", + "Trigger": "Триггер", "Capability": "Возможность", "Decision": "Решение", "Mutation": "Изменение", "Evidence tier": "Уровень доказательств", "Gap closure": "Закрытие пробела", + "Environment lane": "Поток окружения", "Decision lane": "Поток решений", "Governance lane": "Поток управления", "Live events": "Живые события", "Event count": "Число событий", "No live events": "Нет живых событий", "Event detail": "Детали события", "Select a live event to inspect its evidence references.": "Выберите живое событие, чтобы просмотреть ссылки на его доказательства.", + "Live since snapshot": "Живых с момента снимка", + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.": "{count} событий поступило после этого снимка. Метрики снимка обновятся в следующем цикле мониторинга.", + "Environment events appear when a probe records a change in the surroundings.": "События окружения появляются, когда зонд фиксирует изменение обстановки.", + "Decision events appear when a recorded observation drives a capability choice.": "События решений появляются, когда записанное наблюдение приводит к выбору возможности.", + "Governance events appear when trust, quarantine or reclamation moves.": "События управления появляются при изменении доверия, карантина или высвобождения." + } + }; const I18N_TEMPLATES = { // Every literal a board template renders, per locale. Held apart from I18N and // I18N_PATCH because those two grew with the first two lenses and were never // extended: five of seven templates shipped untranslated in every language, and // the i18n test only checked signal keys, so nothing failed. Keyed by the English // source string, so an untranslated key still renders readable English. - zh: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **尚未记录任何效果判定**,因此没有可度量的奖励信号。上面的比率有意留空而非显示 0%。只有当需求声明了预期效果才可能验证,而目前只有世界模型撰写的需求带有预期效果。", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **回归:已闭合的缺口再次复发。** 一次看起来成功的演进并未站住。这是本看板上唯一需要立即处理的发现。", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **仅快照。** 目前尚无可重建的因果历史,因此时间线是「缺席」而非「空白」。原因由管道贯通度中的 `策略决策` 一行说明;实时快照与贯通度表本身不受影响。", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **部分插件因内部缺陷被冻结。** 冻结的插件仍报告 `DRAFT`,而信任维度只做「打分」,因此若未同时注销,它仍可被选中——请查看 `可被选中` 列。", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **验证层级:L2(声明式适配)。** 观测被退役,只意味着某个候选**声明**自己提供该能力,并不意味着该能力被观测到确实生效。效果验证(L3)尚未接线,因此本看板上的任何闭合都不应被读作「已证实」。", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> 需要至少完成一个观测周期才会有内容。若持续为空,请检查调度器是否启用、`framework-evolution` watch 是否已 armed 且未静音。", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> 当一次环境观测导向一次能力决策时,才会写下一条剧集。目前尚无记录——这既可能是系统本就安静,也可能是管道更早就断了:**管道**页签会指出它断在哪一段,以及什么能解除阻塞。", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> 目前没有任何机制自动回收它们。每一个都占着一个工具名、出现在能力列表里,却不可被选中——注册表朝着没有任何需求能用的方向增长。", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> 这些提议未进入任何管道,因此不会出现在任何决策记录或观测中。是否准入是一项配置选择。", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "比值低于 1.0 表示采样循环未能维持其声明的节奏。", "Abstained": "弃权", "Acquisition authority": "获取授权", "Acquisition lifecycle": "获取生命周期", "Action": "动作", "After": "变更后", "An unverified declaration has its writable channels demoted to read-only.": "未核验的声明,其可写通道会被降级为只读。", "Approval": "审批", "Autonomous governance": "自主治理", "Autonomy": "自主级别", "Before": "变更前", "CANDIDATE": "候选级", "Calibrated at": "校准时间", "Calibration health": "校准健康度", "Calls": "调用次数", "Calls (decisions)": "观点(决策)", "Candlestick": "K 线", "Capability": "能力", "Capability adaptation": "能力适配", "Capability observations": "能力观测", "Capability ownership": "能力归属", "Capability topology": "能力拓扑", "Change": "变化", "Channel": "通道", "Channels": "通道数", "Channels that have never been calibrated or whose calibration has expired are shown first.": "从未校准或校准已过期的通道排在最前。", "Command": "命令", "Commanded versus observed, best tracking first": "命令值与实测值对比,跟随最好者在前", "Composition": "组成", "Concerns (open questions)": "关切(待答问题)", "Confidence": "置信度", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "统计所有绘制通道。“接近”指处于声明边界的 5% 以内。", "Cycles run": "已运行周期", "DRAFT": "草稿级", "Days since": "距今天数", "Decision": "决策", "Decisions read as calls; action items as the execution checklist.": "决策即观点,行动项即执行清单。", "Declared Hz": "声明频率 (Hz)", "Desk brief": "交易台简报", "Device": "设备", "Dropped samples": "丢弃的样本", "Each row names one blocked segment and the change that would unblock it.": "每一行指出一个受阻环节,以及能解除阻塞的那项变更。", "Effect verification (L3)": "效果验证(L3)", "Effects declared": "已声明效果", "Entities as references, and recommended next prompts to advance the work.": "实体作为参考,并给出推进工作的后续追问。", "Entities in play and the open risks still to resolve.": "涉及的实体,以及尚未解决的敞口风险。", "Envelope, rate, staleness and quality observations · newest first": "包络、速率、失联与质量观测 · 最新在前", "Environment": "环境", "Environment to framework": "环境 → 框架", "Environment, selected plugin tools, and orchestration order.": "环境、已选插件工具及编排顺序。", "Error rate": "错误率", "Events paced out": "被配速抑制的事件", "Ever used": "是否用过", "Evidence": "证据", "Evidence admission": "证据准入", "Evolution": "演进", "Evolution timeline": "演进时间线", "Executable": "可执行", "Execution checklist": "执行清单", "Extracted from this session's tool/file output (not model-generated).": "数据来自本次会话的工具/文件产物(非模型生成)。", "Failures": "失败次数", "Fiber": "Fiber 状态", "Fiber state changes since the previous cycle, including load retries.": "自上一周期以来的 Fiber 状态变化,含加载重试。", "Finance lens": "金融视图", "Follow-ups": "后续事项", "Framework change": "框架变更", "Framework changes as they happened, from runtime probes.": "来自运行时探针的框架变更实况。", "Framework evolution": "框架演进", "Framework size and how much of the evolution pipeline shows runtime evidence.": "框架规模,以及演进管道中有多少环节呈现运行时证据。", "From": "从", "Frozen plugins": "已冻结插件", "Gap closure": "缺口闭合", "Halt": "可急停", "How closures are verified": "闭合是如何验证的", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "效果信号中有多少可真正用作反馈。这决定了是否值得构建学习策略。", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "框架中有多少是它自己长出来的,以及演进管道中有多少环节呈现运行时证据。", "How often each window sat inside, near, or outside its declared limits": "各窗口处于声明限值内、接近边界或越界的频次", "Inquiry brief": "研究简报", "Insights carded as evidence, capped for fast review.": "洞察以证据卡呈现,数量受限以便快速浏览。", "Instruments & counterparties": "标的与交易对手", "Kept": "保留", "Latest capability decision": "最新能力决策", "Lifecycle records": "生命周期记录", "Lifecycle timeline": "生命周期时间线", "Lifecycle transitions": "生命周期迁移", "Line of inquiry": "研究主线", "Live activity": "实时动态", "Location": "位置", "Loop phase": "循环阶段", "Mean of each downsample window. Declared limits are listed per channel below.": "每个降采样窗口的均值。各通道的声明限值见下方。", "Model's reasoning": "模型的推理", "Mutation": "变更", "Narrative": "叙事", "Narrative pulse": "叙事脉搏", "Needs attention": "需要关注", "Next recal due": "下次校准期限", "Next step": "下一步", "No causal history yet": "尚无因果历史", "Normalized error": "归一化误差", "Normalized error is the residual as a share of the channel's declared span.": "归一化误差是残差占该通道声明量程的比例。", "Not yet observed": "尚未观测", "Nothing has driven a framework change, so there is no episode to narrate.": "尚无任何事驱动过框架变更,因此没有可讲述的剧集。", "OHLC extracted from captured session market data.": "OHLC 提取自本次会话捕获的行情数据。", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "观测待办、提案状态、策略决策与生命周期结果。", "Observations": "观测数", "Observed Hz": "实测频率 (Hz)", "Observed rate against declared rate": "实测速率与声明速率对比", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "单一全局命名空间,先注册者胜。挑战者会被记录,绝不静默丢弃。", "Open": "已连接", "Open risks": "敞口风险", "Open/high/low/close from captured tool output.": "开/高/低/收,来自捕获的工具输出。", "Origin": "来源", "Outcome": "结果", "PRODUCTION": "生产级", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "逐条剧集:触发源、决策、变更,以及缺口是否闭合。", "Per-channel calibration state, freshness, and residual correction": "各通道的校准状态、时效性与残差校正", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "逐段运行时证据。模块存在并不等于有任何代码调用它。", "Pipeline": "管道", "Pipeline evidence": "管道证据", "Pipeline reachability": "管道贯通度", "Plan": "计划", "Plan steps": "计划步骤", "Plugin": "插件", "Plugin roster and trust": "插件名册与信任", "Plugins": "插件数", "Plugins by origin": "按来源分布的插件", "Plugins by trust class": "按信任等级分布的插件", "Policy": "策略", "Policy decisions": "策略决策", "Positions & actions": "持仓与操作", "Posture": "态势", "Price action": "价格行为", "Proposal": "提案", "Proposal status": "提案状态", "Proposed, not admitted": "已提议,未准入", "Pulse": "脉搏", "Quarantine feed": "隔离进料", "Ratio": "比值", "Read live from the registry and trust ledger every cycle.": "每个周期从注册表与信任账本实时读取。", "Recent episodes": "近期剧集", "Reclaim candidates": "可回收候选", "Reclaimable": "可回收", "References & follow-ups": "参考与后续", "References (entities)": "参考(实体)", "Registry": "注册表", "Registry delta": "注册表变化", "Registry version": "注册表版本", "Regressions": "回归", "Rejected": "被拒", "Representative observations, capped for quick scanning.": "代表性观察,数量受限以便快速浏览。", "Requirements": "能力需求", "Research lens": "研究视图", "Residual": "残差", "Reward signal bandwidth": "奖励信号带宽", "Runtime evidence": "运行时证据", "Sampled history per channel, newest on the right": "按通道的采样历史,最新在右侧", "Segment": "管道段", "Segments by status": "按状态分布的管道段", "Selectable": "可被选中", "Selection delta": "选择变化", "Self-acquired": "自获取", "Self-acquired plugins that are registered but unselectable or never once used.": "已注册但不可被选中、或从未被使用过的自获取插件。", "Sentiment lens": "情绪视图", "Series": "序列", "Session analysis": "会话分析", "Signal strength": "信号强度", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "表明某处长错了、或被扣下未放行的信号。无论打开哪个页签都会显示。", "Skipped slots": "跳过的采样点", "State": "状态", "Storyline and signal strength before drilling into positions and actions.": "先看叙事与信号强度,再深入持仓与操作。", "Streaming": "采样中", "Suggested next steps": "建议的下一步", "The line of investigation and where the open questions concentrate.": "研究主线,以及待答问题的集中之处。", "The narrative arc and how strongly themes are trending.": "叙事走向,以及主题的趋势强度。", "The world model asked for these capabilities and nothing took them up.": "世界模型请求了这些能力,但无人受理。", "Theme intensity": "主题强度", "Themes": "主题", "This board reports how the framework changes itself. Nothing has been recorded yet.": "本看板报告框架如何改变自身。目前尚无任何记录。", "To": "到", "Tool": "工具", "Tool-name conflicts": "工具名冲突", "Tools": "工具数", "Transport": "传输方式", "Transport, provenance and channel counts": "传输方式、来源与通道数量", "Trust": "信任级别", "Trust accrual": "信任累积", "Trust class": "信任语义", "Unselectable reclamation": "不可选回收", "Usable": "可用", "VERIFIED": "已验证级", "Verdicts": "判定数", "Verdicts by reason": "按原因分布的判定", "Verified": "已核验", "Verified by": "验证依据", "Voices & concerns": "声音与关切", "Watchlist": "关注列表", "What changed in the environment, and what the framework did about it.": "环境发生了什么变化,框架又为此做了什么。", "Which plugin owns which tool, and which capability that tool provides.": "哪个插件拥有哪个工具,以及该工具提供什么能力。", "Who/what is in the conversation, and the concerns still open.": "谁/什么在被讨论,以及尚未解决的关切。", "Why": "原因", "Why not admitted": "未准入原因", "Why this page is empty": "这个页面为何是空的", "World-model driver": "世界模型驱动器", "Writable": "可写", "aborted": "已中断", "accruing": "正在累积", "active": "运行中", "appeared": "新出现", "armed": "已就绪", "assess_compatibility": "评估兼容性", "built_in": "内置", "capability_expand": "扩展能力", "committed": "已定论", "conformance": "合规", "declared_fitness": "声明式适配", "disable": "停用", "disposed": "已释放", "effect_observed": "效果已观测", "environment_probe": "环境探测", "execution_failed": "执行失败", "expected_effect_absent": "预期效果未出现", "failed": "已失败", "frozen": "已冻结", "gone": "已消失", "idle": "空闲无变化", "install": "安装", "loading": "加载中", "manual": "人工", "moved": "已迁移", "new_unproven": "新,未验证", "no": "否", "no_evidence": "无证据", "no_expected_effect_declared": "未声明预期效果", "no_outcome_observed": "未观测到结果", "none": "无", "not_admitted": "未准入", "not_applicable": "不适用", "observe_only": "仅观察", "observed_effect": "观测效果", "open": "进行中", "pending": "待启", "reload": "重载", "remove": "移除", "reopened": "已复发", "resolved": "已闭合", "rollback": "回滚", "runtime": "运行时", "self_acquired": "自获取", "still_open": "仍未闭合", "tool_reported_no_effect": "工具未报告效果", "trusted": "已信任", "unknown": "未知", "unknown_tool": "未知工具", "unloading": "卸载中", "unscheduled": "未调度", "unverifiable": "无法核实", "unverified": "未验证", "waiting": "等待首个周期", "watching": "监视中", "wired": "已贯通", "world_model": "世界模型", "yes": "是"}, - fr: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aucun verdict d'effet n'a encore été enregistré**, il n'y a donc aucun signal de récompense à mesurer. Les taux ci-dessus sont volontairement vides plutôt que nuls. Un effet ne peut être vérifié que si l'exigence en a déclaré un, et seules les exigences rédigées par le modèle du monde en portent aujourd'hui.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Régression : un écart comblé s'est reproduit.** Une évolution qui semblait réussie n'a pas tenu. C'est le seul constat de ce tableau qui exige une attention immédiate.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Instantané seulement.** Aucun historique causal à reconstruire pour l'instant : la chronologie est absente, non vide. La raison est indiquée par la ligne `Décisions de politique` sous la couverture du pipeline ; l'instantané et le tableau de couverture ne sont pas affectés.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Certains plugins sont gelés par un défaut interne.** Un plugin gelé signale toujours `DRAFT`, et la dimension de confiance ne fait que *noter*, donc il reste sélectionnable tant qu'il n'est pas également désenregistré — voir la colonne `Sélectionnable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Niveau de vérification : L2 (aptitude déclarée).** Une observation retirée signifie qu'un candidat a *déclaré* fournir la capacité, non que la capacité a été observée en fonctionnement. La vérification d'effet (L3) n'est pas câblée, donc aucune clôture de ce tableau ne doit être lue comme prouvée.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Un cycle d'observation doit s'achever avant qu'il y ait quoi que ce soit à montrer. Si cela persiste, vérifiez que le planificateur est actif et que la surveillance `framework-evolution` est armée et non silencée.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un épisode est écrit lorsqu'une observation de l'environnement conduit à une décision de capacité. Aucun n'a été enregistré : soit le système est calme, soit le pipeline s'arrête plus tôt — l'onglet **Pipeline** nomme le segment où il s'arrête et ce qui le débloquerait.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Rien ne les récupère automatiquement. Chacun occupe un nom d'outil et figure dans la liste des capacités sans être sélectionnable : le registre grandit dans une direction qu'aucune exigence ne peut utiliser.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Ces propositions n'ont intégré aucun pipeline : elles n'apparaissent donc dans aucun enregistrement de décision ni observation. Les admettre est un choix de configuration.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Un ratio inférieur à 1,0 signifie que la boucle d’échantillonnage ne tient pas sa cadence déclarée.", "Abstained": "Abstention", "Acquisition authority": "Autorité d'acquisition", "Acquisition lifecycle": "Cycle de vie d'acquisition", "Action": "Action", "After": "Après", "An unverified declaration has its writable channels demoted to read-only.": "Une déclaration non vérifiée voit ses canaux inscriptibles rétrogradés en lecture seule.", "Approval": "Approbation", "Autonomous governance": "Gouvernance autonome", "Autonomy": "Autonomie", "Before": "Avant", "CANDIDATE": "Candidat", "Calibrated at": "Calibré le", "Calibration health": "État de calibration", "Calls": "Appels", "Calls (decisions)": "Recommandations (décisions)", "Candlestick": "Chandeliers", "Capability": "Capacité", "Capability adaptation": "Adaptation des capacités", "Capability observations": "Observations de capacités", "Capability ownership": "Propriété des capacités", "Capability topology": "Topologie des capacités", "Change": "Changement", "Channel": "Canal", "Channels": "Canaux", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Les canaux jamais calibrés ou dont la calibration a expiré apparaissent en premier.", "Command": "Commande", "Commanded versus observed, best tracking first": "Commandé contre observé, meilleur suivi d’abord", "Composition": "Composition", "Concerns (open questions)": "Préoccupations (questions ouvertes)", "Confidence": "Confiance", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Compté sur tous les canaux tracés. « près » signifie à moins de 5 % d’une borne déclarée.", "Cycles run": "Cycles exécutés", "DRAFT": "Brouillon", "Days since": "Jours écoulés", "Decision": "Décision", "Decisions read as calls; action items as the execution checklist.": "Les décisions se lisent comme des recommandations ; les actions comme la liste d’exécution.", "Declared Hz": "Hz déclarés", "Desk brief": "Note de desk", "Device": "Appareil", "Dropped samples": "Échantillons perdus", "Each row names one blocked segment and the change that would unblock it.": "Chaque ligne nomme un segment bloqué et le changement qui le débloquerait.", "Effect verification (L3)": "Vérification d'effet (L3)", "Effects declared": "Effets déclarés", "Entities as references, and recommended next prompts to advance the work.": "Entités comme références, et invites suivantes recommandées pour avancer.", "Entities in play and the open risks still to resolve.": "Entités concernées et risques ouverts à résoudre.", "Envelope, rate, staleness and quality observations · newest first": "Observations d’enveloppe, de débit, d’obsolescence et de qualité · les plus récentes d’abord", "Environment": "Environnement", "Environment to framework": "De l'environnement au framework", "Environment, selected plugin tools, and orchestration order.": "Environnement, outils de plugin sélectionnés et ordre d’orchestration.", "Error rate": "Taux d'erreur", "Events paced out": "Événements limités", "Ever used": "Déjà utilisé", "Evidence": "Preuve", "Evidence admission": "Admission des preuves", "Evolution": "Évolution", "Evolution timeline": "Chronologie de l'évolution", "Executable": "Exécutable", "Execution checklist": "Liste d’exécution", "Extracted from this session's tool/file output (not model-generated).": "Extrait des sorties d’outils/fichiers de cette session (non généré par le modèle).", "Failures": "Échecs", "Fiber": "Fibre", "Fiber state changes since the previous cycle, including load retries.": "Changements d'état de fiber depuis le cycle précédent, y compris les tentatives de chargement.", "Finance lens": "Vue finance", "Follow-ups": "Suivis", "Framework change": "Changement du framework", "Framework changes as they happened, from runtime probes.": "Changements du framework en temps réel, via les sondes d'exécution.", "Framework evolution": "Évolution du framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Taille du framework et part du pipeline d'évolution qui présente des preuves d'exécution.", "From": "De", "Frozen plugins": "Plugins gelés", "Gap closure": "Clôture de l'écart", "Halt": "Arrêt", "How closures are verified": "Comment les clôtures sont vérifiées", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Quelle part du signal d'effet est exploitable comme rétroaction. C'est ce qui détermine s'il vaut la peine de construire une politique d'apprentissage.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Quelle part du framework il a fait croître lui-même, et quelle part du pipeline présente des preuves d'exécution.", "How often each window sat inside, near, or outside its declared limits": "Fréquence à laquelle chaque fenêtre était dans, près de, ou hors de ses limites déclarées", "Inquiry brief": "Note d’enquête", "Insights carded as evidence, capped for fast review.": "Analyses présentées comme preuves, limitées pour une revue rapide.", "Instruments & counterparties": "Instruments et contreparties", "Kept": "Conservé", "Latest capability decision": "Dernière décision de capacité", "Lifecycle records": "Enregistrements de cycle de vie", "Lifecycle timeline": "Chronologie du cycle de vie", "Lifecycle transitions": "Transitions de cycle de vie", "Line of inquiry": "Ligne d’enquête", "Live activity": "Activité en direct", "Location": "Emplacement", "Loop phase": "Phase de boucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Moyenne de chaque fenêtre de sous-échantillonnage. Les limites déclarées figurent par canal ci-dessous.", "Model's reasoning": "Raisonnement du modèle", "Mutation": "Mutation", "Narrative": "Récit", "Narrative pulse": "Pouls narratif", "Needs attention": "Requiert attention", "Next recal due": "Prochaine recalibration", "Next step": "Étape suivante", "No causal history yet": "Pas encore d'historique causal", "Normalized error": "Erreur normalisée", "Normalized error is the residual as a share of the channel's declared span.": "L’erreur normalisée est le résidu en proportion de l’étendue déclarée du canal.", "Not yet observed": "Pas encore observé", "Nothing has driven a framework change, so there is no episode to narrate.": "Rien n'a encore déclenché de changement du framework : il n'y a donc aucun épisode à raconter.", "OHLC extracted from captured session market data.": "OHLC extrait des données de marché capturées durant la session.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "File d’observations, état des propositions, décisions de politique et résultats du cycle de vie.", "Observations": "Observations", "Observed Hz": "Hz observés", "Observed rate against declared rate": "Débit observé par rapport au débit déclaré", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un espace de noms global unique, arbitré au premier arrivé. Le concurrent est enregistré, jamais supprimé en silence.", "Open": "Ouvert", "Open risks": "Risques ouverts", "Open/high/low/close from captured tool output.": "Ouverture/haut/bas/clôture issus des sorties d’outils capturées.", "Origin": "Origine", "Outcome": "Résultat", "PRODUCTION": "Production", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Par épisode : le déclencheur, la décision, le changement, et si l'écart a été comblé.", "Per-channel calibration state, freshness, and residual correction": "État de calibration, fraîcheur et correction résiduelle par canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Preuves d'exécution par segment. L'existence d'un module ne prouve pas qu'il soit appelé.", "Pipeline": "Pipeline", "Pipeline evidence": "Preuves du pipeline", "Pipeline reachability": "Accessibilité du pipeline", "Plan": "Plan", "Plan steps": "Étapes du plan", "Plugin": "Plugin", "Plugin roster and trust": "Registre des plugins et confiance", "Plugins": "Plugins", "Plugins by origin": "Plugins par origine", "Plugins by trust class": "Plugins par classe de confiance", "Policy": "Politique", "Policy decisions": "Décisions de politique", "Positions & actions": "Positions et actions", "Posture": "Posture", "Price action": "Action des prix", "Proposal": "Proposition", "Proposal status": "Statut de la proposition", "Proposed, not admitted": "Proposé, non admis", "Pulse": "Pouls", "Quarantine feed": "Flux de quarantaine", "Ratio": "Ratio", "Read live from the registry and trust ledger every cycle.": "Lu en direct depuis le registre et le registre de confiance à chaque cycle.", "Recent episodes": "Épisodes récents", "Reclaim candidates": "Candidats à la récupération", "Reclaimable": "Récupérable", "References & follow-ups": "Références et suivis", "References (entities)": "Références (entités)", "Registry": "Registre", "Registry delta": "Delta du registre", "Registry version": "Version du registre", "Regressions": "Régressions", "Rejected": "Rejeté", "Representative observations, capped for quick scanning.": "Observations représentatives, limitées pour une lecture rapide.", "Requirements": "Exigences", "Research lens": "Vue recherche", "Residual": "Résidu", "Reward signal bandwidth": "Bande passante du signal de récompense", "Runtime evidence": "Preuve d'exécution", "Sampled history per channel, newest on the right": "Historique échantillonné par canal, le plus récent à droite", "Segment": "Segment", "Segments by status": "Segments par statut", "Selectable": "Sélectionnable", "Selection delta": "Delta de sélection", "Self-acquired": "Auto-acquis", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins auto-acquis qui sont enregistrés mais non sélectionnables, ou jamais utilisés une seule fois.", "Sentiment lens": "Vue sentiment", "Series": "Série", "Session analysis": "Analyse de session", "Signal strength": "Force du signal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Signaux indiquant qu'une évolution a mal tourné ou a été retenue. Affichés quel que soit l'onglet ouvert.", "Skipped slots": "Créneaux manqués", "State": "État", "Storyline and signal strength before drilling into positions and actions.": "Récit et force du signal avant d’examiner positions et actions.", "Streaming": "Diffusion", "Suggested next steps": "Prochaines étapes suggérées", "The line of investigation and where the open questions concentrate.": "La ligne d’investigation et où se concentrent les questions ouvertes.", "The narrative arc and how strongly themes are trending.": "L’arc narratif et l’intensité des tendances thématiques.", "The world model asked for these capabilities and nothing took them up.": "Le modèle du monde a demandé ces capacités et personne ne les a prises en charge.", "Theme intensity": "Intensité des thèmes", "Themes": "Thèmes", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Ce tableau rend compte de la façon dont le framework se modifie lui-même. Rien n'a encore été enregistré.", "To": "Vers", "Tool": "Outil", "Tool-name conflicts": "Conflits de noms d'outils", "Tools": "Outils", "Transport": "Transport", "Transport, provenance and channel counts": "Transport, provenance et nombre de canaux", "Trust": "Confiance", "Trust accrual": "Accumulation de confiance", "Trust class": "Classe de confiance", "Unselectable reclamation": "Récupération non sélectionnable", "Usable": "Exploitable", "VERIFIED": "Vérifié", "Verdicts": "Verdicts", "Verdicts by reason": "Verdicts par motif", "Verified": "Vérifié", "Verified by": "Vérifié par", "Voices & concerns": "Voix et préoccupations", "Watchlist": "Liste de suivi", "What changed in the environment, and what the framework did about it.": "Ce qui a changé dans l'environnement, et ce que le framework a fait en réponse.", "Which plugin owns which tool, and which capability that tool provides.": "Quel plugin possède quel outil, et quelle capacité cet outil fournit.", "Who/what is in the conversation, and the concerns still open.": "Qui/quoi est dans la conversation, et les préoccupations encore ouvertes.", "Why": "Pourquoi", "Why not admitted": "Motif de non-admission", "Why this page is empty": "Pourquoi cette page est vide", "World-model driver": "Pilote du modèle du monde", "Writable": "Inscriptible", "aborted": "Abandonné", "accruing": "En accumulation", "active": "Actif", "appeared": "Apparu", "armed": "Armé", "assess_compatibility": "Évaluer la compatibilité", "built_in": "Intégré", "capability_expand": "Étendre les capacités", "committed": "Conclu", "conformance": "Conformité", "declared_fitness": "Aptitude déclarée", "disable": "Désactiver", "disposed": "Libéré", "effect_observed": "Effet observé", "environment_probe": "Sonde d'environnement", "execution_failed": "Échec d'exécution", "expected_effect_absent": "Effet attendu absent", "failed": "Échoué", "frozen": "Gelé", "gone": "Disparu", "idle": "Au repos", "install": "Installer", "loading": "Chargement", "manual": "Manuel", "moved": "Déplacé", "new_unproven": "Nouveau, non éprouvé", "no": "Non", "no_evidence": "Aucune preuve", "no_expected_effect_declared": "Aucun effet attendu déclaré", "no_outcome_observed": "Aucun résultat observé", "none": "Aucun", "not_admitted": "Non admis", "not_applicable": "Sans objet", "observe_only": "Observer seulement", "observed_effect": "Effet observé", "open": "Ouvert", "pending": "En attente", "reload": "Recharger", "remove": "Supprimer", "reopened": "Réouvert", "resolved": "Résolu", "rollback": "Annuler", "runtime": "Exécution", "self_acquired": "Auto-acquis", "still_open": "Toujours ouvert", "tool_reported_no_effect": "L'outil n'a signalé aucun effet", "trusted": "De confiance", "unknown": "Inconnu", "unknown_tool": "Outil inconnu", "unloading": "Déchargement", "unscheduled": "Non planifié", "unverifiable": "Invérifiable", "unverified": "Non vérifié", "waiting": "En attente", "watching": "En surveillance", "wired": "Câblé", "world_model": "Modèle du monde", "yes": "Oui"}, - es: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aún no se ha registrado ningún veredicto de efecto**, por lo que no hay señal de recompensa que medir. Las tasas anteriores están en blanco a propósito, no en cero. Un efecto solo puede verificarse si el requisito declaró uno, y hoy solo los requisitos redactados por el modelo del mundo lo llevan.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Regresión: una brecha cerrada ha vuelto a aparecer.** Una evolución que parecía exitosa no se sostuvo. Es el único hallazgo de este panel que exige atención inmediata.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Solo instantánea.** Todavía no hay historia causal que reconstruir, por lo que la cronología está ausente, no vacía. El motivo lo indica la fila `Decisiones de política` bajo la cobertura del pipeline; la instantánea y la tabla de cobertura no se ven afectadas.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Algunos plugins están congelados por un defecto interno.** Un plugin congelado sigue informando `DRAFT`, y la dimensión de confianza solo *puntúa*, por lo que permanece seleccionable a menos que también se desregistre — consulte la columna `Seleccionable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Nivel de verificación: L2 (aptitud declarada).** Una observación retirada significa que un candidato *declaró* que proporciona la capacidad, no que se observara funcionando. La verificación de efecto (L3) no está conectada, así que ningún cierre de este panel debe leerse como probado.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Debe completarse un ciclo de observación antes de que haya algo que mostrar. Si persiste, compruebe que el planificador está activo y que la vigilancia `framework-evolution` está armada y no silenciada.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un episodio se escribe cuando una observación del entorno conduce a una decisión de capacidad. No se ha registrado ninguno: o el sistema está tranquilo o el pipeline se detiene antes — la pestaña **Pipeline** nombra el segmento donde se detiene y qué lo desbloquearía.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Nada los recupera automáticamente. Cada uno ocupa un nombre de herramienta y aparece en la lista de capacidades sin ser seleccionable: el registro crece en una dirección que ningún requisito puede usar.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Estas propuestas no entraron en ningún pipeline, por lo que no aparecen en ningún registro de decisión ni observación. Admitirlas es una elección de configuración.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Una relación inferior a 1,0 significa que el bucle de muestreo no mantiene su cadencia declarada.", "Abstained": "Abstenido", "Acquisition authority": "Autoridad de adquisición", "Acquisition lifecycle": "Ciclo de vida de adquisición", "Action": "Acción", "After": "Después", "An unverified declaration has its writable channels demoted to read-only.": "Una declaración no verificada degrada sus canales escribibles a solo lectura.", "Approval": "Aprobación", "Autonomous governance": "Gobernanza autónoma", "Autonomy": "Autonomía", "Before": "Antes", "CANDIDATE": "Candidato", "Calibrated at": "Calibrado el", "Calibration health": "Estado de calibración", "Calls": "Llamadas", "Calls (decisions)": "Recomendaciones (decisiones)", "Candlestick": "Velas", "Capability": "Capacidad", "Capability adaptation": "Adaptación de capacidades", "Capability observations": "Observaciones de capacidad", "Capability ownership": "Propiedad de capacidades", "Capability topology": "Topología de capacidades", "Change": "Cambio", "Channel": "Canal", "Channels": "Canales", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Los canales nunca calibrados o con calibración vencida se muestran primero.", "Command": "Comando", "Commanded versus observed, best tracking first": "Comandado frente a observado, mejor seguimiento primero", "Composition": "Composición", "Concerns (open questions)": "Inquietudes (preguntas abiertas)", "Confidence": "Confianza", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Contado en todos los canales graficados. «cerca» significa dentro del 5 % de un límite declarado.", "Cycles run": "Ciclos ejecutados", "DRAFT": "Borrador", "Days since": "Días desde", "Decision": "Decisión", "Decisions read as calls; action items as the execution checklist.": "Las decisiones se leen como recomendaciones; las acciones como la lista de ejecución.", "Declared Hz": "Hz declarados", "Desk brief": "Informe de mesa", "Device": "Dispositivo", "Dropped samples": "Muestras descartadas", "Each row names one blocked segment and the change that would unblock it.": "Cada fila nombra un segmento bloqueado y el cambio que lo desbloquearía.", "Effect verification (L3)": "Verificación de efecto (L3)", "Effects declared": "Efectos declarados", "Entities as references, and recommended next prompts to advance the work.": "Entidades como referencias y siguientes preguntas recomendadas para avanzar.", "Entities in play and the open risks still to resolve.": "Entidades implicadas y riesgos abiertos por resolver.", "Envelope, rate, staleness and quality observations · newest first": "Observaciones de envolvente, tasa, obsolescencia y calidad · las más recientes primero", "Environment": "Entorno", "Environment to framework": "Del entorno al framework", "Environment, selected plugin tools, and orchestration order.": "Entorno, herramientas de plugin seleccionadas y orden de orquestación.", "Error rate": "Tasa de error", "Events paced out": "Eventos limitados", "Ever used": "Alguna vez usado", "Evidence": "Evidencia", "Evidence admission": "Admisión de evidencia", "Evolution": "Evolución", "Evolution timeline": "Cronología de la evolución", "Executable": "Ejecutable", "Execution checklist": "Lista de ejecución", "Extracted from this session's tool/file output (not model-generated).": "Extraído de la salida de herramientas/archivos de esta sesión (no generado por el modelo).", "Failures": "Fallos", "Fiber": "Fibra", "Fiber state changes since the previous cycle, including load retries.": "Cambios de estado de fiber desde el ciclo anterior, incluidos los reintentos de carga.", "Finance lens": "Vista financiera", "Follow-ups": "Seguimientos", "Framework change": "Cambio del framework", "Framework changes as they happened, from runtime probes.": "Cambios del framework en tiempo real, desde sondas de ejecución.", "Framework evolution": "Evolución del framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Tamaño del framework y qué parte del pipeline de evolución muestra evidencia en ejecución.", "From": "Desde", "Frozen plugins": "Plugins congelados", "Gap closure": "Cierre de la brecha", "Halt": "Parada", "How closures are verified": "Cómo se verifican los cierres", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Cuánto de la señal de efecto es utilizable como retroalimentación. Esto decide si vale la pena construir una política de aprendizaje.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Cuánto del framework hizo crecer por sí mismo y cuánto del pipeline muestra evidencia de ejecución.", "How often each window sat inside, near, or outside its declared limits": "Con qué frecuencia cada ventana estuvo dentro, cerca o fuera de sus límites declarados", "Inquiry brief": "Informe de indagación", "Insights carded as evidence, capped for fast review.": "Hallazgos presentados como evidencia, limitados para revisión rápida.", "Instruments & counterparties": "Instrumentos y contrapartes", "Kept": "Conservado", "Latest capability decision": "Última decisión de capacidad", "Lifecycle records": "Registros de ciclo de vida", "Lifecycle timeline": "Cronología del ciclo de vida", "Lifecycle transitions": "Transiciones de ciclo de vida", "Line of inquiry": "Línea de indagación", "Live activity": "Actividad en vivo", "Location": "Ubicación", "Loop phase": "Fase del bucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Media de cada ventana de submuestreo. Los límites declarados se listan por canal abajo.", "Model's reasoning": "Razonamiento del modelo", "Mutation": "Mutación", "Narrative": "Narrativa", "Narrative pulse": "Pulso narrativo", "Needs attention": "Requiere atención", "Next recal due": "Próxima recalibración", "Next step": "Siguiente paso", "No causal history yet": "Aún no hay historia causal", "Normalized error": "Error normalizado", "Normalized error is the residual as a share of the channel's declared span.": "El error normalizado es el residuo como fracción del rango declarado del canal.", "Not yet observed": "Aún no observado", "Nothing has driven a framework change, so there is no episode to narrate.": "Nada ha impulsado todavía un cambio del framework, por lo que no hay ningún episodio que narrar.", "OHLC extracted from captured session market data.": "OHLC extraído de los datos de mercado capturados en la sesión.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Cola de observaciones, estado de propuestas, decisiones de política y resultados del ciclo de vida.", "Observations": "Observaciones", "Observed Hz": "Hz observados", "Observed rate against declared rate": "Tasa observada frente a la tasa declarada", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un único espacio de nombres global, arbitrado por orden de llegada. El aspirante queda registrado, nunca se descarta en silencio.", "Open": "Abierto", "Open risks": "Riesgos abiertos", "Open/high/low/close from captured tool output.": "Apertura/máximo/mínimo/cierre desde la salida de herramientas capturada.", "Origin": "Origen", "Outcome": "Resultado", "PRODUCTION": "Producción", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Por episodio: el desencadenante, la decisión, el cambio y si la brecha se cerró.", "Per-channel calibration state, freshness, and residual correction": "Estado de calibración, vigencia y corrección residual por canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Evidencia en ejecución por segmento. Que un módulo exista no prueba que algo lo invoque.", "Pipeline": "Pipeline", "Pipeline evidence": "Evidencia del pipeline", "Pipeline reachability": "Alcanzabilidad del pipeline", "Plan": "Plan", "Plan steps": "Pasos del plan", "Plugin": "Plugin", "Plugin roster and trust": "Registro de plugins y confianza", "Plugins": "Plugins", "Plugins by origin": "Plugins por origen", "Plugins by trust class": "Plugins por clase de confianza", "Policy": "Política", "Policy decisions": "Decisiones de política", "Positions & actions": "Posiciones y acciones", "Posture": "Postura", "Price action": "Acción del precio", "Proposal": "Propuesta", "Proposal status": "Estado de la propuesta", "Proposed, not admitted": "Propuesto, no admitido", "Pulse": "Pulso", "Quarantine feed": "Entrada de cuarentena", "Ratio": "Relación", "Read live from the registry and trust ledger every cycle.": "Leído en vivo del registro y del libro de confianza en cada ciclo.", "Recent episodes": "Episodios recientes", "Reclaim candidates": "Candidatos a recuperación", "Reclaimable": "Recuperable", "References & follow-ups": "Referencias y seguimientos", "References (entities)": "Referencias (entidades)", "Registry": "Registro", "Registry delta": "Delta del registro", "Registry version": "Versión del registro", "Regressions": "Regresiones", "Rejected": "Rechazado", "Representative observations, capped for quick scanning.": "Observaciones representativas, limitadas para lectura rápida.", "Requirements": "Requisitos", "Research lens": "Vista de investigación", "Residual": "Residuo", "Reward signal bandwidth": "Ancho de banda de la señal de recompensa", "Runtime evidence": "Evidencia en ejecución", "Sampled history per channel, newest on the right": "Historial muestreado por canal, el más reciente a la derecha", "Segment": "Segmento", "Segments by status": "Segmentos por estado", "Selectable": "Seleccionable", "Selection delta": "Delta de selección", "Self-acquired": "Autoadquirido", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins autoadquiridos que están registrados pero no son seleccionables, o nunca se han usado.", "Sentiment lens": "Vista de sentimiento", "Series": "Serie", "Session analysis": "Análisis de sesión", "Signal strength": "Fuerza de la señal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Señales de que algo creció mal o fue retenido. Se muestran independientemente de la pestaña abierta.", "Skipped slots": "Ranuras omitidas", "State": "Estado", "Storyline and signal strength before drilling into positions and actions.": "Narrativa y fuerza de la señal antes de entrar en posiciones y acciones.", "Streaming": "Transmisión", "Suggested next steps": "Próximos pasos sugeridos", "The line of investigation and where the open questions concentrate.": "La línea de investigación y dónde se concentran las preguntas abiertas.", "The narrative arc and how strongly themes are trending.": "El arco narrativo y con qué fuerza se mueven los temas.", "The world model asked for these capabilities and nothing took them up.": "El modelo del mundo pidió estas capacidades y nada las asumió.", "Theme intensity": "Intensidad temática", "Themes": "Temas", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Este panel informa de cómo el framework se modifica a sí mismo. Todavía no se ha registrado nada.", "To": "Hasta", "Tool": "Herramienta", "Tool-name conflicts": "Conflictos de nombres de herramientas", "Tools": "Herramientas", "Transport": "Transporte", "Transport, provenance and channel counts": "Transporte, procedencia y número de canales", "Trust": "Confianza", "Trust accrual": "Acumulación de confianza", "Trust class": "Clase de confianza", "Unselectable reclamation": "Recuperación no seleccionable", "Usable": "Utilizable", "VERIFIED": "Verificado", "Verdicts": "Veredictos", "Verdicts by reason": "Veredictos por motivo", "Verified": "Verificado", "Verified by": "Verificado por", "Voices & concerns": "Voces e inquietudes", "Watchlist": "Lista de seguimiento", "What changed in the environment, and what the framework did about it.": "Qué cambió en el entorno y qué hizo el framework al respecto.", "Which plugin owns which tool, and which capability that tool provides.": "Qué plugin posee qué herramienta y qué capacidad proporciona esa herramienta.", "Who/what is in the conversation, and the concerns still open.": "Quién/qué está en la conversación y las inquietudes aún abiertas.", "Why": "Por qué", "Why not admitted": "Motivo de no admisión", "Why this page is empty": "Por qué esta página está vacía", "World-model driver": "Controlador del modelo del mundo", "Writable": "Escribible", "aborted": "Abortado", "accruing": "Acumulando", "active": "Activo", "appeared": "Apareció", "armed": "Armado", "assess_compatibility": "Evaluar compatibilidad", "built_in": "Integrado", "capability_expand": "Ampliar capacidad", "committed": "Concluido", "conformance": "Conformidad", "declared_fitness": "Aptitud declarada", "disable": "Desactivar", "disposed": "Liberado", "effect_observed": "Efecto observado", "environment_probe": "Sonda de entorno", "execution_failed": "Ejecución fallida", "expected_effect_absent": "Efecto esperado ausente", "failed": "Fallido", "frozen": "Congelado", "gone": "Desapareció", "idle": "Inactivo", "install": "Instalar", "loading": "Cargando", "manual": "Manual", "moved": "Se movió", "new_unproven": "Nuevo, no probado", "no": "No", "no_evidence": "Sin evidencia", "no_expected_effect_declared": "Sin efecto esperado declarado", "no_outcome_observed": "Sin resultado observado", "none": "Ninguno", "not_admitted": "No admitido", "not_applicable": "No aplicable", "observe_only": "Solo observar", "observed_effect": "Efecto observado", "open": "Abierto", "pending": "Pendiente", "reload": "Recargar", "remove": "Eliminar", "reopened": "Reabierto", "resolved": "Resuelto", "rollback": "Revertir", "runtime": "Tiempo de ejecución", "self_acquired": "Autoadquirido", "still_open": "Aún abierto", "tool_reported_no_effect": "La herramienta no informó efecto", "trusted": "De confianza", "unknown": "Desconocido", "unknown_tool": "Herramienta desconocida", "unloading": "Descargando", "unscheduled": "No planificado", "unverifiable": "No verificable", "unverified": "No verificado", "waiting": "En espera", "watching": "Vigilando", "wired": "Conectado", "world_model": "Modelo del mundo", "yes": "Sí"}, - ar: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **لم يُسجَّل أي حكم على الأثر بعد**، لذا لا توجد إشارة مكافأة لقياسها. النسب أعلاه فارغة عن قصد وليست صفرًا. لا يمكن التحقق من الأثر إلا إذا أعلنه المطلب، واليوم لا تحمل الأثر المتوقع سوى المطالب التي كتبها نموذج العالم.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **انحدار: فجوة أُغلقت عادت للظهور.** تطوّر بدا ناجحًا لم يصمد. هذا هو الاكتشاف الوحيد في هذه اللوحة الذي يستدعي انتباهًا فوريًا.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **لقطة فقط.** لا يوجد بعد تاريخ سببي لإعادة بنائه، لذا فالخط الزمني غائب وليس فارغًا. السبب مبيَّن في صف `قرارات السياسة` تحت تغطية المسار؛ اللقطة الحيّة وجدول التغطية غير متأثرين.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **بعض الإضافات مُجمَّدة بسبب خلل داخلي.** الإضافة المُجمَّدة لا تزال تُبلِّغ `DRAFT`، وبُعد الثقة يقوم بالتقييم فقط، لذا تبقى قابلة للاختيار إلا إذا أُلغي تسجيلها أيضًا — راجع عمود `قابل للاختيار`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **مستوى التحقق: L2 (الملاءمة المُعلنة).** سحب الرصد يعني أن مرشّحًا *أعلن* أنه يوفّر القدرة، لا أن القدرة رُصدت وهي تعمل. التحقق من الأثر (L3) غير موصول، لذا لا ينبغي قراءة أي إغلاق في هذه اللوحة كأمر مُثبَت.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> يجب أن تكتمل دورة مراقبة واحدة قبل ظهور أي محتوى. إذا استمر ذلك، تحقّق من تمكين المُجدول وأن مراقبة `framework-evolution` مُسلّحة وغير مكتومة.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> تُكتب الحلقة عندما يؤدي رصد للبيئة إلى قرار بشأن قدرة. لم يُسجَّل أي منها، وهذا يعني إمّا نظامًا هادئًا أو مسارًا يتوقف قبل ذلك — تبويب **المسار** يحدّد الجزء الذي يتوقف عنده وما الذي يزيل التعطيل.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> لا شيء يستعيدها تلقائيًا. كل واحدة تحتجز اسم أداة وتظهر في قائمة القدرات دون أن تكون قابلة للاختيار، فينمو السجل في اتجاه لا يمكن لأي مطلب استخدامه.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> لم تدخل هذه المقترحات أي مسار، لذا لا تظهر في أي سجل قرار أو رصد. قبولها خيار في الإعدادات.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "نسبة أقل من 1.0 تعني أن حلقة أخذ العينات لا تحافظ على وتيرتها المعلنة.", "Abstained": "امتناع", "Acquisition authority": "سلطة الاكتساب", "Acquisition lifecycle": "دورة حياة الاكتساب", "Action": "الإجراء", "After": "بعد", "An unverified declaration has its writable channels demoted to read-only.": "الإعلان غير المُتحقَّق منه تُخفَّض قنواته القابلة للكتابة إلى القراءة فقط.", "Approval": "الموافقة", "Autonomous governance": "الحكم الذاتي", "Autonomy": "الاستقلالية", "Before": "قبل", "CANDIDATE": "مرشّح", "Calibrated at": "تاريخ المعايرة", "Calibration health": "سلامة المعايرة", "Calls": "الاستدعاءات", "Calls (decisions)": "التوصيات (القرارات)", "Candlestick": "الشموع", "Capability": "القدرة", "Capability adaptation": "تكييف القدرات", "Capability observations": "رصد القدرات", "Capability ownership": "ملكية القدرات", "Capability topology": "طوبولوجيا القدرات", "Change": "التغيير", "Channel": "القناة", "Channels": "القنوات", "Channels that have never been calibrated or whose calibration has expired are shown first.": "تظهر أولاً القنوات التي لم تُعاير قط أو التي انتهت صلاحية معايرتها.", "Command": "الأمر", "Commanded versus observed, best tracking first": "المأمور مقابل المرصود، الأفضل تتبعاً أولاً", "Composition": "التركيب", "Concerns (open questions)": "المخاوف (أسئلة مفتوحة)", "Confidence": "الثقة", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "محسوب على كل قناة مرسومة. \"قريب\" تعني داخل 5% من حد معلن.", "Cycles run": "الدورات المنفَّذة", "DRAFT": "مسوّدة", "Days since": "الأيام المنقضية", "Decision": "القرار", "Decisions read as calls; action items as the execution checklist.": "القرارات تُقرأ كتوصيات؛ والإجراءات كقائمة تنفيذ.", "Declared Hz": "الهرتز المعلن", "Desk brief": "موجز المكتب", "Device": "الجهاز", "Dropped samples": "العينات المفقودة", "Each row names one blocked segment and the change that would unblock it.": "كل صف يحدّد جزءًا معطَّلًا والتغيير الذي يزيل التعطيل.", "Effect verification (L3)": "التحقق من الأثر (L3)", "Effects declared": "الآثار المُعلنة", "Entities as references, and recommended next prompts to advance the work.": "الكيانات كمراجع، والمطالبات التالية الموصى بها لدفع العمل.", "Entities in play and the open risks still to resolve.": "الكيانات المعنية والمخاطر المفتوحة التي لم تُحل.", "Envelope, rate, staleness and quality observations · newest first": "رصدات المغلف والمعدل والتقادم والجودة · الأحدث أولاً", "Environment": "البيئة", "Environment to framework": "من البيئة إلى الإطار", "Environment, selected plugin tools, and orchestration order.": "البيئة والأدوات المختارة وترتيب التنسيق.", "Error rate": "معدل الأخطاء", "Events paced out": "الأحداث المُقيَّدة", "Ever used": "استُخدم سابقًا", "Evidence": "الدليل", "Evidence admission": "قبول الأدلة", "Evolution": "التطور", "Evolution timeline": "الخط الزمني للتطور", "Executable": "قابل للتنفيذ", "Execution checklist": "قائمة التنفيذ", "Extracted from this session's tool/file output (not model-generated).": "مستخرج من مخرجات الأدوات/الملفات في هذه الجلسة (ليس من إنشاء النموذج).", "Failures": "الأعطال", "Fiber": "الخيط", "Fiber state changes since the previous cycle, including load retries.": "تغييرات حالة الـ fiber منذ الدورة السابقة، بما في ذلك محاولات التحميل.", "Finance lens": "منظور مالي", "Follow-ups": "المتابعات", "Framework change": "تغيير الإطار", "Framework changes as they happened, from runtime probes.": "تغييرات الإطار لحظة حدوثها، من مجسّات وقت التشغيل.", "Framework evolution": "تطور الإطار", "Framework size and how much of the evolution pipeline shows runtime evidence.": "حجم الإطار ومقدار ما يُظهره مسار التطور من أدلة وقت التشغيل.", "From": "من", "Frozen plugins": "الإضافات المُجمَّدة", "Gap closure": "إغلاق الفجوة", "Halt": "إيقاف", "How closures are verified": "كيف يُتحقَّق من الإغلاقات", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "ما مقدار إشارة الأثر القابل للاستخدام كتغذية راجعة. هذا يحدّد ما إذا كان بناء سياسة تعلّم يستحق العناء.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "ما مقدار ما نمّاه الإطار بنفسه، وما مقدار المسار الذي يُظهر أدلة وقت التشغيل.", "How often each window sat inside, near, or outside its declared limits": "عدد المرات التي كانت فيها كل نافذة داخل حدودها المعلنة أو قريبة منها أو خارجها", "Inquiry brief": "موجز الاستقصاء", "Insights carded as evidence, capped for fast review.": "الرؤى معروضة كأدلة، ومحدودة العدد للمراجعة السريعة.", "Instruments & counterparties": "الأدوات والأطراف المقابلة", "Kept": "المحتفظ به", "Latest capability decision": "أحدث قرار للقدرات", "Lifecycle records": "سجلات دورة الحياة", "Lifecycle timeline": "الخط الزمني لدورة الحياة", "Lifecycle transitions": "انتقالات دورة الحياة", "Line of inquiry": "خط الاستقصاء", "Live activity": "النشاط المباشر", "Location": "الموقع", "Loop phase": "مرحلة الحلقة", "Mean of each downsample window. Declared limits are listed per channel below.": "متوسط كل نافذة تخفيض للعينات. الحدود المعلنة مدرجة لكل قناة أدناه.", "Model's reasoning": "استدلال النموذج", "Mutation": "التغيير", "Narrative": "السرد", "Narrative pulse": "نبض السرد", "Needs attention": "يستدعي الانتباه", "Next recal due": "موعد إعادة المعايرة", "Next step": "الخطوة التالية", "No causal history yet": "لا يوجد تاريخ سببي بعد", "Normalized error": "الخطأ المعياري", "Normalized error is the residual as a share of the channel's declared span.": "الخطأ المعياري هو المتبقي كنسبة من المدى المعلن للقناة.", "Not yet observed": "لم يُرصد بعد", "Nothing has driven a framework change, so there is no episode to narrate.": "لم يدفع أي شيء بعد إلى تغيير في الإطار، لذا لا توجد حلقة لسردها.", "OHLC extracted from captured session market data.": "OHLC مستخرج من بيانات السوق المسجلة في الجلسة.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "قائمة الرصد وحالة المقترحات وقرارات السياسة ونتائج دورة الحياة.", "Observations": "الرصدات", "Observed Hz": "الهرتز المرصود", "Observed rate against declared rate": "المعدل المرصود مقابل المعدل المعلن", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "مساحة أسماء عالمية واحدة، تُحكَّم بأسبقية التسجيل. يُسجَّل المتنافس ولا يُهمَل بصمت.", "Open": "مفتوح", "Open risks": "المخاطر المفتوحة", "Open/high/low/close from captured tool output.": "الافتتاح/الأعلى/الأدنى/الإغلاق من مخرجات الأدوات المسجلة.", "Origin": "المصدر", "Outcome": "النتيجة", "PRODUCTION": "إنتاج", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "لكل حلقة: المُحفِّز والقرار والتغيير وما إذا أُغلقت الفجوة.", "Per-channel calibration state, freshness, and residual correction": "حالة المعايرة وحداثتها وتصحيح المتبقي لكل قناة", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "أدلة وقت التشغيل لكل مقطع. وجود وحدة لا يعني أن شيئًا يستدعيها.", "Pipeline": "المسار", "Pipeline evidence": "أدلة المسار", "Pipeline reachability": "إمكانية الوصول إلى المسار", "Plan": "الخطة", "Plan steps": "خطوات الخطة", "Plugin": "الملحق", "Plugin roster and trust": "قائمة الملحقات والثقة", "Plugins": "الملحقات", "Plugins by origin": "الإضافات حسب المصدر", "Plugins by trust class": "الإضافات حسب فئة الثقة", "Policy": "السياسة", "Policy decisions": "قرارات السياسة", "Positions & actions": "المراكز والإجراءات", "Posture": "الوضع", "Price action": "حركة السعر", "Proposal": "المقترح", "Proposal status": "حالة المقترح", "Proposed, not admitted": "مُقترح وغير مقبول", "Pulse": "النبض", "Quarantine feed": "تغذية الحجر", "Ratio": "النسبة", "Read live from the registry and trust ledger every cycle.": "يُقرأ مباشرة من السجل ودفتر الثقة في كل دورة.", "Recent episodes": "الحلقات الأخيرة", "Reclaim candidates": "مرشّحو الاسترجاع", "Reclaimable": "قابل للاسترجاع", "References & follow-ups": "المراجع والمتابعات", "References (entities)": "المراجع (الكيانات)", "Registry": "السجل", "Registry delta": "فرق السجل", "Registry version": "إصدار السجل", "Regressions": "الانحدارات", "Rejected": "المرفوض", "Representative observations, capped for quick scanning.": "رصدات تمثيلية، محدودة العدد للقراءة السريعة.", "Requirements": "المتطلبات", "Research lens": "منظور بحثي", "Residual": "المتبقي", "Reward signal bandwidth": "نطاق إشارة المكافأة", "Runtime evidence": "دليل وقت التشغيل", "Sampled history per channel, newest on the right": "سجل العينات لكل قناة، الأحدث على اليمين", "Segment": "المقطع", "Segments by status": "الأجزاء حسب الحالة", "Selectable": "قابل للاختيار", "Selection delta": "فرق الاختيار", "Self-acquired": "مُكتسَب ذاتيًا", "Self-acquired plugins that are registered but unselectable or never once used.": "إضافات مُكتسَبة ذاتيًا مُسجَّلة لكنها غير قابلة للاختيار أو لم تُستخدم قطّ.", "Sentiment lens": "منظور المشاعر", "Series": "السلسلة", "Session analysis": "تحليل الجلسة", "Signal strength": "قوة الإشارة", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "إشارات على أن شيئًا نما بشكل خاطئ أو تم حجبه. تظهر أيًا كان التبويب المفتوح.", "Skipped slots": "الفتحات المتخطاة", "State": "الحالة", "Storyline and signal strength before drilling into positions and actions.": "السرد وقوة الإشارة قبل التوسع في المراكز والإجراءات.", "Streaming": "بث", "Suggested next steps": "الخطوات التالية المقترحة", "The line of investigation and where the open questions concentrate.": "خط البحث وأين تتركز الأسئلة المفتوحة.", "The narrative arc and how strongly themes are trending.": "قوس السرد ومدى قوة اتجاه الموضوعات.", "The world model asked for these capabilities and nothing took them up.": "طلب نموذج العالم هذه القدرات ولم يتبنّها شيء.", "Theme intensity": "شدة الموضوعات", "Themes": "الموضوعات", "This board reports how the framework changes itself. Nothing has been recorded yet.": "تُبلِّغ هذه اللوحة عن كيفية تغيير الإطار لنفسه. لم يُسجَّل أي شيء بعد.", "To": "إلى", "Tool": "الأداة", "Tool-name conflicts": "تعارضات أسماء الأدوات", "Tools": "الأدوات", "Transport": "النقل", "Transport, provenance and channel counts": "النقل والمنشأ وعدد القنوات", "Trust": "الثقة", "Trust accrual": "تراكم الثقة", "Trust class": "فئة الثقة", "Unselectable reclamation": "استرجاع غير القابل للاختيار", "Usable": "قابل للاستخدام", "VERIFIED": "مُتحقَّق", "Verdicts": "الأحكام", "Verdicts by reason": "الأحكام حسب السبب", "Verified": "مُتحقَّق", "Verified by": "تم التحقق بواسطة", "Voices & concerns": "الأصوات والمخاوف", "Watchlist": "قائمة المتابعة", "What changed in the environment, and what the framework did about it.": "ما تغيّر في البيئة، وما فعله الإطار حيال ذلك.", "Which plugin owns which tool, and which capability that tool provides.": "أي ملحق يملك أي أداة، وأي قدرة توفرها تلك الأداة.", "Who/what is in the conversation, and the concerns still open.": "من/ما هو في المحادثة، والمخاوف التي لا تزال مفتوحة.", "Why": "السبب", "Why not admitted": "سبب عدم القبول", "Why this page is empty": "لماذا هذه الصفحة فارغة", "World-model driver": "مُشغِّل نموذج العالم", "Writable": "قابل للكتابة", "aborted": "مُلغى", "accruing": "قيد التراكم", "active": "نشط", "appeared": "ظهر", "armed": "مُسلّح", "assess_compatibility": "تقييم التوافق", "built_in": "مدمج", "capability_expand": "توسيع القدرة", "committed": "مُنجَز", "conformance": "المطابقة", "declared_fitness": "الملاءمة المُعلنة", "disable": "تعطيل", "disposed": "تم التخلص منه", "effect_observed": "تم رصد الأثر", "environment_probe": "مِجَس البيئة", "execution_failed": "فشل التنفيذ", "expected_effect_absent": "الأثر المتوقع غائب", "failed": "فشل", "frozen": "مُجمَّد", "gone": "اختفى", "idle": "خامل", "install": "تثبيت", "loading": "قيد التحميل", "manual": "يدوي", "moved": "انتقل", "new_unproven": "جديد وغير مُثبَت", "no": "لا", "no_evidence": "لا يوجد دليل", "no_expected_effect_declared": "لم يُعلَن أثر متوقع", "no_outcome_observed": "لم يُرصد أي ناتج", "none": "لا شيء", "not_admitted": "غير مقبول", "not_applicable": "غير منطبق", "observe_only": "المراقبة فقط", "observed_effect": "الأثر المرصود", "open": "مفتوح", "pending": "معلّق", "reload": "إعادة تحميل", "remove": "إزالة", "reopened": "أُعيد فتحه", "resolved": "تم الحل", "rollback": "تراجع", "runtime": "وقت التشغيل", "self_acquired": "مُكتسَب ذاتيًا", "still_open": "لا يزال مفتوحًا", "tool_reported_no_effect": "الأداة لم تُبلِّغ عن أثر", "trusted": "موثوق", "unknown": "غير معروف", "unknown_tool": "أداة غير معروفة", "unloading": "قيد الإلغاء", "unscheduled": "غير مُجدول", "unverifiable": "غير قابل للتحقق", "unverified": "غير مُتحقَّق", "waiting": "في الانتظار", "watching": "يراقب", "wired": "موصول", "world_model": "نموذج العالم", "yes": "نعم"}, - ru: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Ни одного заключения об эффекте пока не записано**, поэтому измерять нечего. Показатели выше намеренно пусты, а не равны нулю. Эффект можно проверить только если требование его заявило, а сегодня заявленный эффект несут лишь требования, составленные моделью мира.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Регрессия: закрытый пробел возобновился.** Эволюция, казавшаяся успешной, не удержалась. Это единственный вывод на этой панели, требующий немедленного внимания.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Только снимок.** Причинной истории для восстановления пока нет, поэтому хронология отсутствует, а не пуста. Причина указана в строке `Решения политики` под покрытием конвейера; снимок и таблица покрытия не затронуты.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Некоторые плагины заморожены из-за внутреннего дефекта.** Замороженный плагин по-прежнему сообщает `DRAFT`, а измерение доверия только *оценивает*, поэтому он остаётся выбираемым, пока не будет также снят с регистрации — см. столбец `Выбираемо`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Уровень проверки: L2 (заявленная пригодность).** Снятое наблюдение означает, что кандидат *заявил* о предоставлении возможности, а не что возможность наблюдалась в работе. Проверка эффекта (L3) не подключена, поэтому ни одно закрытие на этой панели не следует считать доказанным.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Прежде чем появятся данные, должен завершиться хотя бы один цикл наблюдения. Если это сохраняется, проверьте, включён ли планировщик и что наблюдение `framework-evolution` активно и не отключено.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Эпизод записывается, когда наблюдение окружения приводит к решению о возможности. Ни одного не зафиксировано: либо система спокойна, либо конвейер останавливается раньше — вкладка **Конвейер** называет сегмент остановки и то, что его разблокирует.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Ничто не утилизирует их автоматически. Каждый занимает имя инструмента и присутствует в списке возможностей, не будучи выбираемым: реестр растёт в направлении, непригодном ни для одного требования.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Эти предложения не вошли ни в один конвейер, поэтому не отражены ни в одной записи решения или наблюдения. Их приём — вопрос конфигурации.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Отношение ниже 1,0 означает, что цикл выборки не выдерживает объявленный ритм.", "Abstained": "Воздержалось", "Acquisition authority": "Право на получение", "Acquisition lifecycle": "Жизненный цикл получения", "Action": "Действие", "After": "После", "An unverified declaration has its writable channels demoted to read-only.": "У непроверенного объявления записываемые каналы понижаются до только чтения.", "Approval": "Согласование", "Autonomous governance": "Автономное управление", "Autonomy": "Автономность", "Before": "До", "CANDIDATE": "Кандидат", "Calibrated at": "Калиброван", "Calibration health": "Состояние калибровки", "Calls": "Вызовы", "Calls (decisions)": "Рекомендации (решения)", "Candlestick": "Свечи", "Capability": "Возможность", "Capability adaptation": "Адаптация возможностей", "Capability observations": "Наблюдения возможностей", "Capability ownership": "Владение возможностями", "Capability topology": "Топология возможностей", "Change": "Изменение", "Channel": "Канал", "Channels": "Каналы", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Каналы, которые никогда не калибровались или чья калибровка истекла, показаны первыми.", "Command": "Команда", "Commanded versus observed, best tracking first": "Заданное против наблюдаемого, лучшее отслеживание первым", "Composition": "Состав", "Concerns (open questions)": "Опасения (открытые вопросы)", "Confidence": "Уверенность", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Подсчитано по всем отображаемым каналам. «У границы» — в пределах 5% от объявленного предела.", "Cycles run": "Выполнено циклов", "DRAFT": "Черновик", "Days since": "Дней с тех пор", "Decision": "Решение", "Decisions read as calls; action items as the execution checklist.": "Решения читаются как рекомендации; действия — как чек-лист исполнения.", "Declared Hz": "Объявл. Гц", "Desk brief": "Сводка деска", "Device": "Устройство", "Dropped samples": "Отброшенные образцы", "Each row names one blocked segment and the change that would unblock it.": "Каждая строка называет заблокированный сегмент и изменение, которое его разблокирует.", "Effect verification (L3)": "Проверка эффекта (L3)", "Effects declared": "Заявлено эффектов", "Entities as references, and recommended next prompts to advance the work.": "Сущности как ссылки и рекомендуемые следующие запросы.", "Entities in play and the open risks still to resolve.": "Задействованные сущности и нерешённые риски.", "Envelope, rate, staleness and quality observations · newest first": "Наблюдения по огибающей, частоте, устареванию и качеству · сначала новые", "Environment": "Окружение", "Environment to framework": "От окружения к фреймворку", "Environment, selected plugin tools, and orchestration order.": "Окружение, выбранные инструменты плагинов и порядок оркестрации.", "Error rate": "Частота ошибок", "Events paced out": "Событий подавлено", "Ever used": "Использовался", "Evidence": "Обоснование", "Evidence admission": "Приём данных", "Evolution": "Эволюция", "Evolution timeline": "Хронология эволюции", "Executable": "Исполнимо", "Execution checklist": "Чек-лист исполнения", "Extracted from this session's tool/file output (not model-generated).": "Извлечено из вывода инструментов/файлов этой сессии (не сгенерировано моделью).", "Failures": "Сбои", "Fiber": "Файбер", "Fiber state changes since the previous cycle, including load retries.": "Изменения состояния fiber с предыдущего цикла, включая повторные загрузки.", "Finance lens": "Финансовый ракурс", "Follow-ups": "Продолжения", "Framework change": "Изменение фреймворка", "Framework changes as they happened, from runtime probes.": "Изменения фреймворка в момент их появления, от рантайм-зондов.", "Framework evolution": "Эволюция фреймворка", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Размер фреймворка и какая часть конвейера эволюции показывает свидетельства времени выполнения.", "From": "Из", "Frozen plugins": "Замороженные плагины", "Gap closure": "Закрытие пробела", "Halt": "Останов", "How closures are verified": "Как проверяются закрытия", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Какая часть сигнала об эффекте пригодна как обратная связь. Это определяет, стоит ли строить обучающую политику.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Какую часть фреймворка он вырастил сам и какая часть конвейера показывает данные времени выполнения.", "How often each window sat inside, near, or outside its declared limits": "Как часто каждое окно было внутри, у границы или вне объявленных пределов", "Inquiry brief": "Сводка исследования", "Insights carded as evidence, capped for fast review.": "Инсайты как карточки-обоснования, ограничены для быстрого просмотра.", "Instruments & counterparties": "Инструменты и контрагенты", "Kept": "Оставлен", "Latest capability decision": "Последнее решение о возможностях", "Lifecycle records": "Записи жизненного цикла", "Lifecycle timeline": "Хронология жизненного цикла", "Lifecycle transitions": "Переходы жизненного цикла", "Line of inquiry": "Линия исследования", "Live activity": "Текущая активность", "Location": "Расположение", "Loop phase": "Фаза цикла", "Mean of each downsample window. Declared limits are listed per channel below.": "Среднее по каждому окну прореживания. Объявленные пределы указаны по каналам ниже.", "Model's reasoning": "Обоснование модели", "Mutation": "Изменение", "Narrative": "Сюжет", "Narrative pulse": "Нарративный пульс", "Needs attention": "Требует внимания", "Next recal due": "Следующая рекалибровка", "Next step": "Следующий шаг", "No causal history yet": "Причинной истории пока нет", "Normalized error": "Нормированная ошибка", "Normalized error is the residual as a share of the channel's declared span.": "Нормированная ошибка — остаток как доля объявленного диапазона канала.", "Not yet observed": "Ещё не наблюдалось", "Nothing has driven a framework change, so there is no episode to narrate.": "Ничто пока не вызвало изменения фреймворка, поэтому рассказывать не о чем.", "OHLC extracted from captured session market data.": "OHLC извлечён из рыночных данных, записанных в сессии.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Очередь наблюдений, состояние предложений, решения политики и итоги жизненного цикла.", "Observations": "Наблюдения", "Observed Hz": "Наблюд. Гц", "Observed rate against declared rate": "Наблюдаемая частота против объявленной", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Единое глобальное пространство имён, арбитраж по первому пришедшему. Претендент записывается, а не отбрасывается молча.", "Open": "Открыт", "Open risks": "Открытые риски", "Open/high/low/close from captured tool output.": "Открытие/максимум/минимум/закрытие из записанного вывода инструментов.", "Origin": "Источник", "Outcome": "Результат", "PRODUCTION": "Продакшн", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "По эпизодам: триггер, решение, изменение и закрылся ли пробел.", "Per-channel calibration state, freshness, and residual correction": "Состояние калибровки, актуальность и остаточная поправка по каналам", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Свидетельства времени выполнения по сегментам. Наличие модуля не доказывает, что его кто-то вызывает.", "Pipeline": "Конвейер", "Pipeline evidence": "Свидетельства конвейера", "Pipeline reachability": "Достижимость конвейера", "Plan": "План", "Plan steps": "Шаги плана", "Plugin": "Плагин", "Plugin roster and trust": "Реестр плагинов и доверие", "Plugins": "Плагины", "Plugins by origin": "Плагины по происхождению", "Plugins by trust class": "Плагины по классу доверия", "Policy": "Политика", "Policy decisions": "Решения политики", "Positions & actions": "Позиции и действия", "Posture": "Состояние", "Price action": "Ценовое движение", "Proposal": "Предложение", "Proposal status": "Статус предложения", "Proposed, not admitted": "Предложено, не принято", "Pulse": "Пульс", "Quarantine feed": "Поток карантина", "Ratio": "Отношение", "Read live from the registry and trust ledger every cycle.": "Читается напрямую из реестра и журнала доверия каждый цикл.", "Recent episodes": "Недавние эпизоды", "Reclaim candidates": "Кандидаты на утилизацию", "Reclaimable": "Утилизируемо", "References & follow-ups": "Ссылки и продолжения", "References (entities)": "Ссылки (сущности)", "Registry": "Реестр", "Registry delta": "Изменение реестра", "Registry version": "Версия реестра", "Regressions": "Регрессии", "Rejected": "Отклонён", "Representative observations, capped for quick scanning.": "Показательные наблюдения, ограничены для быстрого просмотра.", "Requirements": "Требования", "Research lens": "Исследовательский ракурс", "Residual": "Остаток", "Reward signal bandwidth": "Пропускная способность сигнала вознаграждения", "Runtime evidence": "Свидетельство времени выполнения", "Sampled history per channel, newest on the right": "История выборок по каналам, самое новое справа", "Segment": "Сегмент", "Segments by status": "Сегменты по статусу", "Selectable": "Выбираемый", "Selection delta": "Изменение выбора", "Self-acquired": "Самостоятельно получено", "Self-acquired plugins that are registered but unselectable or never once used.": "Самостоятельно полученные плагины, которые зарегистрированы, но невыбираемы или ни разу не использовались.", "Sentiment lens": "Ракурс тональности", "Series": "Серия", "Session analysis": "Анализ сессии", "Signal strength": "Сила сигнала", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Признаки того, что что-то выросло неверно или было задержано. Показываются независимо от открытой вкладки.", "Skipped slots": "Пропущенные слоты", "State": "Состояние", "Storyline and signal strength before drilling into positions and actions.": "Сюжет и сила сигнала до перехода к позициям и действиям.", "Streaming": "Потоковая передача", "Suggested next steps": "Рекомендуемые следующие шаги", "The line of investigation and where the open questions concentrate.": "Линия исследования и где сосредоточены открытые вопросы.", "The narrative arc and how strongly themes are trending.": "Нарративная дуга и насколько сильно растут темы.", "The world model asked for these capabilities and nothing took them up.": "Модель мира запросила эти возможности, и никто их не принял.", "Theme intensity": "Интенсивность тем", "Themes": "Темы", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Эта панель сообщает, как фреймворк изменяет сам себя. Пока ничего не записано.", "To": "В", "Tool": "Инструмент", "Tool-name conflicts": "Конфликты имён инструментов", "Tools": "Инструменты", "Transport": "Транспорт", "Transport, provenance and channel counts": "Транспорт, происхождение и число каналов", "Trust": "Доверие", "Trust accrual": "Накопление доверия", "Trust class": "Класс доверия", "Unselectable reclamation": "Утилизация невыбираемого", "Usable": "Пригодно", "VERIFIED": "Проверено", "Verdicts": "Заключений", "Verdicts by reason": "Заключения по причине", "Verified": "Проверено", "Verified by": "Подтверждено", "Voices & concerns": "Голоса и опасения", "Watchlist": "Список наблюдения", "What changed in the environment, and what the framework did about it.": "Что изменилось в окружении и что фреймворк с этим сделал.", "Which plugin owns which tool, and which capability that tool provides.": "Какой плагин владеет каким инструментом и какую возможность этот инструмент предоставляет.", "Who/what is in the conversation, and the concerns still open.": "Кто/что в разговоре и какие опасения остаются.", "Why": "Почему", "Why not admitted": "Причина отклонения", "Why this page is empty": "Почему эта страница пуста", "World-model driver": "Драйвер модели мира", "Writable": "Записываемый", "aborted": "Прервано", "accruing": "Накапливается", "active": "Активно", "appeared": "Появился", "armed": "Активно", "assess_compatibility": "Оценка совместимости", "built_in": "Встроенный", "capability_expand": "Расширение возможностей", "committed": "Завершено", "conformance": "Соответствие", "declared_fitness": "Заявленная пригодность", "disable": "Отключение", "disposed": "Освобождено", "effect_observed": "Эффект наблюдался", "environment_probe": "Зонд окружения", "execution_failed": "Сбой выполнения", "expected_effect_absent": "Ожидаемый эффект отсутствует", "failed": "Сбой", "frozen": "Заморожено", "gone": "Исчез", "idle": "Простой", "install": "Установка", "loading": "Загрузка", "manual": "Вручную", "moved": "Перешёл", "new_unproven": "Новое, непроверенное", "no": "Нет", "no_evidence": "Нет данных", "no_expected_effect_declared": "Ожидаемый эффект не заявлен", "no_outcome_observed": "Результат не наблюдался", "none": "Нет", "not_admitted": "Не принято", "not_applicable": "Неприменимо", "observe_only": "Только наблюдение", "observed_effect": "Наблюдаемый эффект", "open": "Открыто", "pending": "Ожидает", "reload": "Перезагрузка", "remove": "Удаление", "reopened": "Возобновлено", "resolved": "Закрыто", "rollback": "Откат", "runtime": "Среда выполнения", "self_acquired": "Самостоятельно получено", "still_open": "Всё ещё открыто", "tool_reported_no_effect": "Инструмент не сообщил об эффекте", "trusted": "Доверенное", "unknown": "Неизвестно", "unknown_tool": "Неизвестный инструмент", "unloading": "Выгрузка", "unscheduled": "Не запланировано", "unverifiable": "Не проверяемо", "unverified": "Непроверенное", "waiting": "Ожидание", "watching": "Наблюдает", "wired": "Подключено", "world_model": "Модель мира", "yes": "Да"} + zh: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **尚未记录任何效果判定**,因此没有可度量的奖励信号。上面的比率有意留空而非显示 0%。只有当需求声明了预期效果才可能验证,而目前只有世界模型撰写的需求带有预期效果。", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **回归:已闭合的缺口再次复发。** 一次看起来成功的演进并未站住。这是本看板上唯一需要立即处理的发现。", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **仅快照。** 目前尚无可重建的因果历史,因此时间线是「缺席」而非「空白」。原因由管道贯通度中的 `策略决策` 一行说明;实时快照与贯通度表本身不受影响。", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **部分插件因内部缺陷被冻结。** 冻结的插件仍报告 `DRAFT`,而信任维度只做「打分」,因此若未同时注销,它仍可被选中——请查看 `可被选中` 列。", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **验证层级:L2(声明式适配)。** 观测被退役,只意味着某个候选**声明**自己提供该能力,并不意味着该能力被观测到确实生效。效果验证(L3)尚未接线,因此本看板上的任何闭合都不应被读作「已证实」。", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> 需要至少完成一个观测周期才会有内容。若持续为空,请检查调度器是否启用、`framework-evolution` watch 是否已 armed 且未静音。", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> 当一次环境观测导向一次能力决策时,才会写下一条剧集。目前尚无记录——这既可能是系统本就安静,也可能是管道更早就断了:**管道**页签会指出它断在哪一段,以及什么能解除阻塞。", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> 目前没有任何机制自动回收它们。每一个都占着一个工具名、出现在能力列表里,却不可被选中——注册表朝着没有任何需求能用的方向增长。", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> 这些提议未进入任何管道,因此不会出现在任何决策记录或观测中。是否准入是一项配置选择。", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "比值低于 1.0 表示采样循环未能维持其声明的节奏。", "Abstained": "弃权", "Acquisition authority": "获取授权", "Acquisition lifecycle": "获取生命周期", "Action": "动作", "After": "变更后", "An unverified declaration has its writable channels demoted to read-only.": "未核验的声明,其可写通道会被降级为只读。", "Approval": "审批", "Autonomous governance": "自主治理", "Autonomy": "自主级别", "Before": "变更前", "CANDIDATE": "候选级", "Calibrated at": "校准时间", "Calibration health": "校准健康度", "Calls": "调用次数", "Calls (decisions)": "观点(决策)", "Candlestick": "K 线", "Capability": "能力", "Capability adaptation": "能力适配", "Capability observations": "能力观测", "Capability ownership": "能力归属", "Capability topology": "能力拓扑", "Change": "变化", "Channel": "通道", "Channels": "通道数", "Channels that have never been calibrated or whose calibration has expired are shown first.": "从未校准或校准已过期的通道排在最前。", "Command": "命令", "Commanded versus observed, best tracking first": "命令值与实测值对比,跟随最好者在前", "Composition": "组成", "Concerns (open questions)": "关切(待答问题)", "Confidence": "置信度", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "统计所有绘制通道。“接近”指处于声明边界的 5% 以内。", "Cycles run": "已运行周期", "DRAFT": "草稿级", "Days since": "距今天数", "Decision": "决策", "Decisions read as calls; action items as the execution checklist.": "决策即观点,行动项即执行清单。", "Declared Hz": "声明频率 (Hz)", "Desk brief": "交易台简报", "Device": "设备", "Dropped samples": "丢弃的样本", "Each row names one blocked segment and the change that would unblock it.": "每一行指出一个受阻环节,以及能解除阻塞的那项变更。", "Effect verification (L3)": "效果验证(L3)", "Effects declared": "已声明效果", "Entities as references, and recommended next prompts to advance the work.": "实体作为参考,并给出推进工作的后续追问。", "Entities in play and the open risks still to resolve.": "涉及的实体,以及尚未解决的敞口风险。", "Envelope, rate, staleness and quality observations · newest first": "包络、速率、失联与质量观测 · 最新在前", "Environment": "环境", "Environment to framework": "环境 → 框架", "Environment, selected plugin tools, and orchestration order.": "环境、已选插件工具及编排顺序。", "Error rate": "错误率", "Events paced out": "被配速抑制的事件", "Ever used": "是否用过", "Evidence": "证据", "Evidence admission": "证据准入", "Evolution": "演进", "Evolution timeline": "演进时间线", "Executable": "可执行", "Execution checklist": "执行清单", "Extracted from this session's tool/file output (not model-generated).": "数据来自本次会话的工具/文件产物(非模型生成)。", "Failures": "失败次数", "Fiber": "Fiber 状态", "Fiber state changes since the previous cycle, including load retries.": "自上一周期以来的 Fiber 状态变化,含加载重试。", "Finance lens": "金融视图", "Follow-ups": "后续事项", "Framework change": "框架变更", "Framework changes as they happened, from runtime probes.": "来自运行时探针的框架变更实况。", "Framework evolution": "框架演进", "Framework size and how much of the evolution pipeline shows runtime evidence.": "框架规模,以及演进管道中有多少环节呈现运行时证据。", "From": "从", "Frozen plugins": "已冻结插件", "Gap closure": "缺口闭合", "Halt": "可急停", "How closures are verified": "闭合是如何验证的", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "效果信号中有多少可真正用作反馈。这决定了是否值得构建学习策略。", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "框架中有多少是它自己长出来的,以及演进管道中有多少环节呈现运行时证据。", "How often each window sat inside, near, or outside its declared limits": "各窗口处于声明限值内、接近边界或越界的频次", "Inquiry brief": "研究简报", "Insights carded as evidence, capped for fast review.": "洞察以证据卡呈现,数量受限以便快速浏览。", "Instruments & counterparties": "标的与交易对手", "Kept": "保留", "Latest capability decision": "最新能力决策", "Lifecycle records": "生命周期记录", "Lifecycle timeline": "生命周期时间线", "Lifecycle transitions": "生命周期迁移", "Line of inquiry": "研究主线", "Live activity": "实时动态", "Location": "位置", "Loop phase": "循环阶段", "Mean of each downsample window. Declared limits are listed per channel below.": "每个降采样窗口的均值。各通道的声明限值见下方。", "Model's reasoning": "模型的推理", "Mutation": "变更", "Narrative": "叙事", "Narrative pulse": "叙事脉搏", "Needs attention": "需要关注", "Next recal due": "下次校准期限", "Next step": "下一步", "No causal history yet": "尚无因果历史", "Normalized error": "归一化误差", "Normalized error is the residual as a share of the channel's declared span.": "归一化误差是残差占该通道声明量程的比例。", "Not yet observed": "尚未观测", "Nothing has driven a framework change, so there is no episode to narrate.": "尚无任何事驱动过框架变更,因此没有可讲述的剧集。", "OHLC extracted from captured session market data.": "OHLC 提取自本次会话捕获的行情数据。", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "观测待办、提案状态、策略决策与生命周期结果。", "Observations": "观测数", "Observed Hz": "实测频率 (Hz)", "Observed rate against declared rate": "实测速率与声明速率对比", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "单一全局命名空间,先注册者胜。挑战者会被记录,绝不静默丢弃。", "Open": "已连接", "Open risks": "敞口风险", "Open/high/low/close from captured tool output.": "开/高/低/收,来自捕获的工具输出。", "Origin": "来源", "Outcome": "结果", "PRODUCTION": "生产级", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "逐条剧集:触发源、决策、变更,以及缺口是否闭合。", "Per-channel calibration state, freshness, and residual correction": "各通道的校准状态、时效性与残差校正", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "逐段运行时证据。模块存在并不等于有任何代码调用它。", "Pipeline": "管道", "Pipeline evidence": "管道证据", "Pipeline reachability": "管道贯通度", "Plan": "计划", "Plan steps": "计划步骤", "Plugin": "插件", "Plugin roster and trust": "插件名册与信任", "Plugins": "插件数", "Plugins by origin": "按来源分布的插件", "Plugins by trust class": "按信任等级分布的插件", "Policy": "策略", "Policy decisions": "策略决策", "Positions & actions": "持仓与操作", "Posture": "态势", "Price action": "价格行为", "Proposal": "提案", "Proposal status": "提案状态", "Proposed, not admitted": "已提议,未准入", "Pulse": "脉搏", "Quarantine feed": "隔离进料", "Ratio": "比值", "Read live from the registry and trust ledger every cycle.": "每个周期从注册表与信任账本实时读取。", "Recent episodes": "近期剧集", "Reclaim candidates": "可回收候选", "Reclaimable": "可回收", "References & follow-ups": "参考与后续", "References (entities)": "参考(实体)", "Registry": "注册表", "Registry delta": "注册表变化", "Registry version": "注册表版本", "Regressions": "回归", "Rejected": "被拒", "Representative observations, capped for quick scanning.": "代表性观察,数量受限以便快速浏览。", "Requirements": "能力需求", "Research lens": "研究视图", "Residual": "残差", "Reward signal bandwidth": "奖励信号带宽", "Runtime evidence": "运行时证据", "Sampled history per channel, newest on the right": "按通道的采样历史,最新在右侧", "Segment": "管道段", "Segments by status": "按状态分布的管道段", "Selectable": "可被选中", "Selection delta": "选择变化", "Self-acquired": "自获取", "Self-acquired plugins that are registered but unselectable or never once used.": "已注册但不可被选中、或从未被使用过的自获取插件。", "Sentiment lens": "情绪视图", "Series": "序列", "Session analysis": "会话分析", "Signal strength": "信号强度", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "表明某处长错了、或被扣下未放行的信号。无论打开哪个页签都会显示。", "Skipped slots": "跳过的采样点", "State": "状态", "Storyline and signal strength before drilling into positions and actions.": "先看叙事与信号强度,再深入持仓与操作。", "Streaming": "采样中", "Suggested next steps": "建议的下一步", "The line of investigation and where the open questions concentrate.": "研究主线,以及待答问题的集中之处。", "The narrative arc and how strongly themes are trending.": "叙事走向,以及主题的趋势强度。", "The world model asked for these capabilities and nothing took them up.": "世界模型请求了这些能力,但无人受理。", "Theme intensity": "主题强度", "Themes": "主题", "This board reports how the framework changes itself. Nothing has been recorded yet.": "本看板报告框架如何改变自身。目前尚无任何记录。", "To": "到", "Tool": "工具", "Tool-name conflicts": "工具名冲突", "Tools": "工具数", "Transport": "传输方式", "Transport, provenance and channel counts": "传输方式、来源与通道数量", "Trust": "信任级别", "Trust accrual": "信任累积", "Trust class": "信任语义", "Unselectable reclamation": "不可选回收", "Usable": "可用", "VERIFIED": "已验证级", "Verdicts": "判定数", "Verdicts by reason": "按原因分布的判定", "Verified": "已核验", "Verified by": "验证依据", "Voices & concerns": "声音与关切", "Watchlist": "关注列表", "What changed in the environment, and what the framework did about it.": "环境发生了什么变化,框架又为此做了什么。", "Which plugin owns which tool, and which capability that tool provides.": "哪个插件拥有哪个工具,以及该工具提供什么能力。", "Who/what is in the conversation, and the concerns still open.": "谁/什么在被讨论,以及尚未解决的关切。", "Why": "原因", "Why not admitted": "未准入原因", "Why this page is empty": "这个页面为何是空的", "World-model driver": "世界模型驱动器", "Writable": "可写", "aborted": "已中断", "accruing": "正在累积", "active": "运行中", "appeared": "新出现", "armed": "已就绪", "assess_compatibility": "评估兼容性", "built_in": "内置", "capability_expand": "扩展能力", "committed": "已定论", "conformance": "合规", "declared_fitness": "声明式适配", "disable": "停用", "disposed": "已释放", "effect_observed": "效果已观测", "environment_probe": "环境探测", "execution_failed": "执行失败", "expected_effect_absent": "预期效果未出现", "failed": "已失败", "frozen": "已冻结", "gone": "已消失", "idle": "空闲无变化", "install": "安装", "loading": "加载中", "manual": "人工", "moved": "已迁移", "new_unproven": "新,未验证", "no": "否", "no_evidence": "无证据", "no_expected_effect_declared": "未声明预期效果", "no_outcome_observed": "未观测到结果", "none": "无", "not_admitted": "未准入", "not_applicable": "不适用", "observe_only": "仅观察", "observed_effect": "观测效果", "open": "进行中", "pending": "待启", "reload": "重载", "remove": "移除", "reopened": "已复发", "resolved": "已闭合", "rollback": "回滚", "runtime": "运行时", "self_acquired": "自获取", "still_open": "仍未闭合", "tool_reported_no_effect": "工具未报告效果", "trusted": "已信任", "unknown": "未知", "unknown_tool": "未知工具", "unloading": "卸载中", "unscheduled": "未调度", "unverifiable": "无法核实", "unverified": "未验证", "waiting": "等待首个周期", "watching": "监视中", "wired": "已贯通", "world_model": "世界模型", "yes": "是", "Causal trace": "因果追踪", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "单个框架演进快照的只读环境到治理证据。", "Evidence boundary": "证据边界", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "因果追踪展示已记录的事实;不推断缺失的审批或已观测效果。", "Episodes": "剧集", "Declared-fitness closures": "声明式适配闭合", "Counterfactual / mutation matrix": "反事实 / 变更矩阵", "Each row preserves the driver, decision, registry delta, and verification tier.": "每一行保留驱动因素、决策、注册表变化和验证层级。", "Trigger": "触发源", "Evidence tier": "证据层级", "Episode timeline": "剧集时间线", "Rebuilt from existing decision and observation records.": "从现有决策和观测记录重建。", "Durable trace feed": "持久追踪流", "Rejected and no-op decisions remain visible when their trace sink is installed.": "安装追踪接收器后,被拒绝和无操作决策仍保持可见。", "Lifecycle": "生命周期", "Pipeline evidence over time": "管道证据随时间变化", "One point per recorded change in framework state, oldest first.": "每一个点对应一次已记录的框架状态变化,最旧在左。", "Samples": "样本数", "Net change": "净变化"}, + fr: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aucun verdict d'effet n'a encore été enregistré**, il n'y a donc aucun signal de récompense à mesurer. Les taux ci-dessus sont volontairement vides plutôt que nuls. Un effet ne peut être vérifié que si l'exigence en a déclaré un, et seules les exigences rédigées par le modèle du monde en portent aujourd'hui.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Régression : un écart comblé s'est reproduit.** Une évolution qui semblait réussie n'a pas tenu. C'est le seul constat de ce tableau qui exige une attention immédiate.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Instantané seulement.** Aucun historique causal à reconstruire pour l'instant : la chronologie est absente, non vide. La raison est indiquée par la ligne `Décisions de politique` sous la couverture du pipeline ; l'instantané et le tableau de couverture ne sont pas affectés.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Certains plugins sont gelés par un défaut interne.** Un plugin gelé signale toujours `DRAFT`, et la dimension de confiance ne fait que *noter*, donc il reste sélectionnable tant qu'il n'est pas également désenregistré — voir la colonne `Sélectionnable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Niveau de vérification : L2 (aptitude déclarée).** Une observation retirée signifie qu'un candidat a *déclaré* fournir la capacité, non que la capacité a été observée en fonctionnement. La vérification d'effet (L3) n'est pas câblée, donc aucune clôture de ce tableau ne doit être lue comme prouvée.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Un cycle d'observation doit s'achever avant qu'il y ait quoi que ce soit à montrer. Si cela persiste, vérifiez que le planificateur est actif et que la surveillance `framework-evolution` est armée et non silencée.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un épisode est écrit lorsqu'une observation de l'environnement conduit à une décision de capacité. Aucun n'a été enregistré : soit le système est calme, soit le pipeline s'arrête plus tôt — l'onglet **Pipeline** nomme le segment où il s'arrête et ce qui le débloquerait.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Rien ne les récupère automatiquement. Chacun occupe un nom d'outil et figure dans la liste des capacités sans être sélectionnable : le registre grandit dans une direction qu'aucune exigence ne peut utiliser.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Ces propositions n'ont intégré aucun pipeline : elles n'apparaissent donc dans aucun enregistrement de décision ni observation. Les admettre est un choix de configuration.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Un ratio inférieur à 1,0 signifie que la boucle d’échantillonnage ne tient pas sa cadence déclarée.", "Abstained": "Abstention", "Acquisition authority": "Autorité d'acquisition", "Acquisition lifecycle": "Cycle de vie d'acquisition", "Action": "Action", "After": "Après", "An unverified declaration has its writable channels demoted to read-only.": "Une déclaration non vérifiée voit ses canaux inscriptibles rétrogradés en lecture seule.", "Approval": "Approbation", "Autonomous governance": "Gouvernance autonome", "Autonomy": "Autonomie", "Before": "Avant", "CANDIDATE": "Candidat", "Calibrated at": "Calibré le", "Calibration health": "État de calibration", "Calls": "Appels", "Calls (decisions)": "Recommandations (décisions)", "Candlestick": "Chandeliers", "Capability": "Capacité", "Capability adaptation": "Adaptation des capacités", "Capability observations": "Observations de capacités", "Capability ownership": "Propriété des capacités", "Capability topology": "Topologie des capacités", "Change": "Changement", "Channel": "Canal", "Channels": "Canaux", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Les canaux jamais calibrés ou dont la calibration a expiré apparaissent en premier.", "Command": "Commande", "Commanded versus observed, best tracking first": "Commandé contre observé, meilleur suivi d’abord", "Composition": "Composition", "Concerns (open questions)": "Préoccupations (questions ouvertes)", "Confidence": "Confiance", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Compté sur tous les canaux tracés. « près » signifie à moins de 5 % d’une borne déclarée.", "Cycles run": "Cycles exécutés", "DRAFT": "Brouillon", "Days since": "Jours écoulés", "Decision": "Décision", "Decisions read as calls; action items as the execution checklist.": "Les décisions se lisent comme des recommandations ; les actions comme la liste d’exécution.", "Declared Hz": "Hz déclarés", "Desk brief": "Note de desk", "Device": "Appareil", "Dropped samples": "Échantillons perdus", "Each row names one blocked segment and the change that would unblock it.": "Chaque ligne nomme un segment bloqué et le changement qui le débloquerait.", "Effect verification (L3)": "Vérification d'effet (L3)", "Effects declared": "Effets déclarés", "Entities as references, and recommended next prompts to advance the work.": "Entités comme références, et invites suivantes recommandées pour avancer.", "Entities in play and the open risks still to resolve.": "Entités concernées et risques ouverts à résoudre.", "Envelope, rate, staleness and quality observations · newest first": "Observations d’enveloppe, de débit, d’obsolescence et de qualité · les plus récentes d’abord", "Environment": "Environnement", "Environment to framework": "De l'environnement au framework", "Environment, selected plugin tools, and orchestration order.": "Environnement, outils de plugin sélectionnés et ordre d’orchestration.", "Error rate": "Taux d'erreur", "Events paced out": "Événements limités", "Ever used": "Déjà utilisé", "Evidence": "Preuve", "Evidence admission": "Admission des preuves", "Evolution": "Évolution", "Evolution timeline": "Chronologie de l'évolution", "Executable": "Exécutable", "Execution checklist": "Liste d’exécution", "Extracted from this session's tool/file output (not model-generated).": "Extrait des sorties d’outils/fichiers de cette session (non généré par le modèle).", "Failures": "Échecs", "Fiber": "Fibre", "Fiber state changes since the previous cycle, including load retries.": "Changements d'état de fiber depuis le cycle précédent, y compris les tentatives de chargement.", "Finance lens": "Vue finance", "Follow-ups": "Suivis", "Framework change": "Changement du framework", "Framework changes as they happened, from runtime probes.": "Changements du framework en temps réel, via les sondes d'exécution.", "Framework evolution": "Évolution du framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Taille du framework et part du pipeline d'évolution qui présente des preuves d'exécution.", "From": "De", "Frozen plugins": "Plugins gelés", "Gap closure": "Clôture de l'écart", "Halt": "Arrêt", "How closures are verified": "Comment les clôtures sont vérifiées", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Quelle part du signal d'effet est exploitable comme rétroaction. C'est ce qui détermine s'il vaut la peine de construire une politique d'apprentissage.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Quelle part du framework il a fait croître lui-même, et quelle part du pipeline présente des preuves d'exécution.", "How often each window sat inside, near, or outside its declared limits": "Fréquence à laquelle chaque fenêtre était dans, près de, ou hors de ses limites déclarées", "Inquiry brief": "Note d’enquête", "Insights carded as evidence, capped for fast review.": "Analyses présentées comme preuves, limitées pour une revue rapide.", "Instruments & counterparties": "Instruments et contreparties", "Kept": "Conservé", "Latest capability decision": "Dernière décision de capacité", "Lifecycle records": "Enregistrements de cycle de vie", "Lifecycle timeline": "Chronologie du cycle de vie", "Lifecycle transitions": "Transitions de cycle de vie", "Line of inquiry": "Ligne d’enquête", "Live activity": "Activité en direct", "Location": "Emplacement", "Loop phase": "Phase de boucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Moyenne de chaque fenêtre de sous-échantillonnage. Les limites déclarées figurent par canal ci-dessous.", "Model's reasoning": "Raisonnement du modèle", "Mutation": "Mutation", "Narrative": "Récit", "Narrative pulse": "Pouls narratif", "Needs attention": "Requiert attention", "Next recal due": "Prochaine recalibration", "Next step": "Étape suivante", "No causal history yet": "Pas encore d'historique causal", "Normalized error": "Erreur normalisée", "Normalized error is the residual as a share of the channel's declared span.": "L’erreur normalisée est le résidu en proportion de l’étendue déclarée du canal.", "Not yet observed": "Pas encore observé", "Nothing has driven a framework change, so there is no episode to narrate.": "Rien n'a encore déclenché de changement du framework : il n'y a donc aucun épisode à raconter.", "OHLC extracted from captured session market data.": "OHLC extrait des données de marché capturées durant la session.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "File d’observations, état des propositions, décisions de politique et résultats du cycle de vie.", "Observations": "Observations", "Observed Hz": "Hz observés", "Observed rate against declared rate": "Débit observé par rapport au débit déclaré", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un espace de noms global unique, arbitré au premier arrivé. Le concurrent est enregistré, jamais supprimé en silence.", "Open": "Ouvert", "Open risks": "Risques ouverts", "Open/high/low/close from captured tool output.": "Ouverture/haut/bas/clôture issus des sorties d’outils capturées.", "Origin": "Origine", "Outcome": "Résultat", "PRODUCTION": "Production", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Par épisode : le déclencheur, la décision, le changement, et si l'écart a été comblé.", "Per-channel calibration state, freshness, and residual correction": "État de calibration, fraîcheur et correction résiduelle par canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Preuves d'exécution par segment. L'existence d'un module ne prouve pas qu'il soit appelé.", "Pipeline": "Pipeline", "Pipeline evidence": "Preuves du pipeline", "Pipeline reachability": "Accessibilité du pipeline", "Plan": "Plan", "Plan steps": "Étapes du plan", "Plugin": "Plugin", "Plugin roster and trust": "Registre des plugins et confiance", "Plugins": "Plugins", "Plugins by origin": "Plugins par origine", "Plugins by trust class": "Plugins par classe de confiance", "Policy": "Politique", "Policy decisions": "Décisions de politique", "Positions & actions": "Positions et actions", "Posture": "Posture", "Price action": "Action des prix", "Proposal": "Proposition", "Proposal status": "Statut de la proposition", "Proposed, not admitted": "Proposé, non admis", "Pulse": "Pouls", "Quarantine feed": "Flux de quarantaine", "Ratio": "Ratio", "Read live from the registry and trust ledger every cycle.": "Lu en direct depuis le registre et le registre de confiance à chaque cycle.", "Recent episodes": "Épisodes récents", "Reclaim candidates": "Candidats à la récupération", "Reclaimable": "Récupérable", "References & follow-ups": "Références et suivis", "References (entities)": "Références (entités)", "Registry": "Registre", "Registry delta": "Delta du registre", "Registry version": "Version du registre", "Regressions": "Régressions", "Rejected": "Rejeté", "Representative observations, capped for quick scanning.": "Observations représentatives, limitées pour une lecture rapide.", "Requirements": "Exigences", "Research lens": "Vue recherche", "Residual": "Résidu", "Reward signal bandwidth": "Bande passante du signal de récompense", "Runtime evidence": "Preuve d'exécution", "Sampled history per channel, newest on the right": "Historique échantillonné par canal, le plus récent à droite", "Segment": "Segment", "Segments by status": "Segments par statut", "Selectable": "Sélectionnable", "Selection delta": "Delta de sélection", "Self-acquired": "Auto-acquis", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins auto-acquis qui sont enregistrés mais non sélectionnables, ou jamais utilisés une seule fois.", "Sentiment lens": "Vue sentiment", "Series": "Série", "Session analysis": "Analyse de session", "Signal strength": "Force du signal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Signaux indiquant qu'une évolution a mal tourné ou a été retenue. Affichés quel que soit l'onglet ouvert.", "Skipped slots": "Créneaux manqués", "State": "État", "Storyline and signal strength before drilling into positions and actions.": "Récit et force du signal avant d’examiner positions et actions.", "Streaming": "Diffusion", "Suggested next steps": "Prochaines étapes suggérées", "The line of investigation and where the open questions concentrate.": "La ligne d’investigation et où se concentrent les questions ouvertes.", "The narrative arc and how strongly themes are trending.": "L’arc narratif et l’intensité des tendances thématiques.", "The world model asked for these capabilities and nothing took them up.": "Le modèle du monde a demandé ces capacités et personne ne les a prises en charge.", "Theme intensity": "Intensité des thèmes", "Themes": "Thèmes", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Ce tableau rend compte de la façon dont le framework se modifie lui-même. Rien n'a encore été enregistré.", "To": "Vers", "Tool": "Outil", "Tool-name conflicts": "Conflits de noms d'outils", "Tools": "Outils", "Transport": "Transport", "Transport, provenance and channel counts": "Transport, provenance et nombre de canaux", "Trust": "Confiance", "Trust accrual": "Accumulation de confiance", "Trust class": "Classe de confiance", "Unselectable reclamation": "Récupération non sélectionnable", "Usable": "Exploitable", "VERIFIED": "Vérifié", "Verdicts": "Verdicts", "Verdicts by reason": "Verdicts par motif", "Verified": "Vérifié", "Verified by": "Vérifié par", "Voices & concerns": "Voix et préoccupations", "Watchlist": "Liste de suivi", "What changed in the environment, and what the framework did about it.": "Ce qui a changé dans l'environnement, et ce que le framework a fait en réponse.", "Which plugin owns which tool, and which capability that tool provides.": "Quel plugin possède quel outil, et quelle capacité cet outil fournit.", "Who/what is in the conversation, and the concerns still open.": "Qui/quoi est dans la conversation, et les préoccupations encore ouvertes.", "Why": "Pourquoi", "Why not admitted": "Motif de non-admission", "Why this page is empty": "Pourquoi cette page est vide", "World-model driver": "Pilote du modèle du monde", "Writable": "Inscriptible", "aborted": "Abandonné", "accruing": "En accumulation", "active": "Actif", "appeared": "Apparu", "armed": "Armé", "assess_compatibility": "Évaluer la compatibilité", "built_in": "Intégré", "capability_expand": "Étendre les capacités", "committed": "Conclu", "conformance": "Conformité", "declared_fitness": "Aptitude déclarée", "disable": "Désactiver", "disposed": "Libéré", "effect_observed": "Effet observé", "environment_probe": "Sonde d'environnement", "execution_failed": "Échec d'exécution", "expected_effect_absent": "Effet attendu absent", "failed": "Échoué", "frozen": "Gelé", "gone": "Disparu", "idle": "Au repos", "install": "Installer", "loading": "Chargement", "manual": "Manuel", "moved": "Déplacé", "new_unproven": "Nouveau, non éprouvé", "no": "Non", "no_evidence": "Aucune preuve", "no_expected_effect_declared": "Aucun effet attendu déclaré", "no_outcome_observed": "Aucun résultat observé", "none": "Aucun", "not_admitted": "Non admis", "not_applicable": "Sans objet", "observe_only": "Observer seulement", "observed_effect": "Effet observé", "open": "Ouvert", "pending": "En attente", "reload": "Recharger", "remove": "Supprimer", "reopened": "Réouvert", "resolved": "Résolu", "rollback": "Annuler", "runtime": "Exécution", "self_acquired": "Auto-acquis", "still_open": "Toujours ouvert", "tool_reported_no_effect": "L'outil n'a signalé aucun effet", "trusted": "De confiance", "unknown": "Inconnu", "unknown_tool": "Outil inconnu", "unloading": "Déchargement", "unscheduled": "Non planifié", "unverifiable": "Invérifiable", "unverified": "Non vérifié", "waiting": "En attente", "watching": "En surveillance", "wired": "Câblé", "world_model": "Modèle du monde", "yes": "Oui", "Causal trace": "Trace causale", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Preuves en lecture seule reliant l’environnement à la gouvernance pour un instantané d’évolution du framework.", "Evidence boundary": "Limite des preuves", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Une trace causale montre les faits enregistrés ; elle n’infère ni approbation manquante ni effet observé.", "Episodes": "Épisodes", "Declared-fitness closures": "Clôtures par aptitude déclarée", "Counterfactual / mutation matrix": "Matrice contrefactuelle / mutations", "Each row preserves the driver, decision, registry delta, and verification tier.": "Chaque ligne conserve le déclencheur, la décision, le delta du registre et le niveau de vérification.", "Trigger": "Déclencheur", "Evidence tier": "Niveau de preuve", "Episode timeline": "Chronologie des épisodes", "Rebuilt from existing decision and observation records.": "Reconstruite à partir des enregistrements existants de décision et d’observation.", "Durable trace feed": "Flux de traces durables", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Les décisions rejetées et sans action restent visibles lorsque leur récepteur de traces est installé.", "Lifecycle": "Cycle de vie", "Pipeline evidence over time": "Évolution des preuves du convéoyeur", "One point per recorded change in framework state, oldest first.": "Un point par changement enregistré de l’état du framework, du plus ancien au plus récent.", "Samples": "Échantillons", "Net change": "Variation nette"}, + es: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aún no se ha registrado ningún veredicto de efecto**, por lo que no hay señal de recompensa que medir. Las tasas anteriores están en blanco a propósito, no en cero. Un efecto solo puede verificarse si el requisito declaró uno, y hoy solo los requisitos redactados por el modelo del mundo lo llevan.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Regresión: una brecha cerrada ha vuelto a aparecer.** Una evolución que parecía exitosa no se sostuvo. Es el único hallazgo de este panel que exige atención inmediata.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Solo instantánea.** Todavía no hay historia causal que reconstruir, por lo que la cronología está ausente, no vacía. El motivo lo indica la fila `Decisiones de política` bajo la cobertura del pipeline; la instantánea y la tabla de cobertura no se ven afectadas.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Algunos plugins están congelados por un defecto interno.** Un plugin congelado sigue informando `DRAFT`, y la dimensión de confianza solo *puntúa*, por lo que permanece seleccionable a menos que también se desregistre — consulte la columna `Seleccionable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Nivel de verificación: L2 (aptitud declarada).** Una observación retirada significa que un candidato *declaró* que proporciona la capacidad, no que se observara funcionando. La verificación de efecto (L3) no está conectada, así que ningún cierre de este panel debe leerse como probado.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Debe completarse un ciclo de observación antes de que haya algo que mostrar. Si persiste, compruebe que el planificador está activo y que la vigilancia `framework-evolution` está armada y no silenciada.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un episodio se escribe cuando una observación del entorno conduce a una decisión de capacidad. No se ha registrado ninguno: o el sistema está tranquilo o el pipeline se detiene antes — la pestaña **Pipeline** nombra el segmento donde se detiene y qué lo desbloquearía.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Nada los recupera automáticamente. Cada uno ocupa un nombre de herramienta y aparece en la lista de capacidades sin ser seleccionable: el registro crece en una dirección que ningún requisito puede usar.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Estas propuestas no entraron en ningún pipeline, por lo que no aparecen en ningún registro de decisión ni observación. Admitirlas es una elección de configuración.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Una relación inferior a 1,0 significa que el bucle de muestreo no mantiene su cadencia declarada.", "Abstained": "Abstenido", "Acquisition authority": "Autoridad de adquisición", "Acquisition lifecycle": "Ciclo de vida de adquisición", "Action": "Acción", "After": "Después", "An unverified declaration has its writable channels demoted to read-only.": "Una declaración no verificada degrada sus canales escribibles a solo lectura.", "Approval": "Aprobación", "Autonomous governance": "Gobernanza autónoma", "Autonomy": "Autonomía", "Before": "Antes", "CANDIDATE": "Candidato", "Calibrated at": "Calibrado el", "Calibration health": "Estado de calibración", "Calls": "Llamadas", "Calls (decisions)": "Recomendaciones (decisiones)", "Candlestick": "Velas", "Capability": "Capacidad", "Capability adaptation": "Adaptación de capacidades", "Capability observations": "Observaciones de capacidad", "Capability ownership": "Propiedad de capacidades", "Capability topology": "Topología de capacidades", "Change": "Cambio", "Channel": "Canal", "Channels": "Canales", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Los canales nunca calibrados o con calibración vencida se muestran primero.", "Command": "Comando", "Commanded versus observed, best tracking first": "Comandado frente a observado, mejor seguimiento primero", "Composition": "Composición", "Concerns (open questions)": "Inquietudes (preguntas abiertas)", "Confidence": "Confianza", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Contado en todos los canales graficados. «cerca» significa dentro del 5 % de un límite declarado.", "Cycles run": "Ciclos ejecutados", "DRAFT": "Borrador", "Days since": "Días desde", "Decision": "Decisión", "Decisions read as calls; action items as the execution checklist.": "Las decisiones se leen como recomendaciones; las acciones como la lista de ejecución.", "Declared Hz": "Hz declarados", "Desk brief": "Informe de mesa", "Device": "Dispositivo", "Dropped samples": "Muestras descartadas", "Each row names one blocked segment and the change that would unblock it.": "Cada fila nombra un segmento bloqueado y el cambio que lo desbloquearía.", "Effect verification (L3)": "Verificación de efecto (L3)", "Effects declared": "Efectos declarados", "Entities as references, and recommended next prompts to advance the work.": "Entidades como referencias y siguientes preguntas recomendadas para avanzar.", "Entities in play and the open risks still to resolve.": "Entidades implicadas y riesgos abiertos por resolver.", "Envelope, rate, staleness and quality observations · newest first": "Observaciones de envolvente, tasa, obsolescencia y calidad · las más recientes primero", "Environment": "Entorno", "Environment to framework": "Del entorno al framework", "Environment, selected plugin tools, and orchestration order.": "Entorno, herramientas de plugin seleccionadas y orden de orquestación.", "Error rate": "Tasa de error", "Events paced out": "Eventos limitados", "Ever used": "Alguna vez usado", "Evidence": "Evidencia", "Evidence admission": "Admisión de evidencia", "Evolution": "Evolución", "Evolution timeline": "Cronología de la evolución", "Executable": "Ejecutable", "Execution checklist": "Lista de ejecución", "Extracted from this session's tool/file output (not model-generated).": "Extraído de la salida de herramientas/archivos de esta sesión (no generado por el modelo).", "Failures": "Fallos", "Fiber": "Fibra", "Fiber state changes since the previous cycle, including load retries.": "Cambios de estado de fiber desde el ciclo anterior, incluidos los reintentos de carga.", "Finance lens": "Vista financiera", "Follow-ups": "Seguimientos", "Framework change": "Cambio del framework", "Framework changes as they happened, from runtime probes.": "Cambios del framework en tiempo real, desde sondas de ejecución.", "Framework evolution": "Evolución del framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Tamaño del framework y qué parte del pipeline de evolución muestra evidencia en ejecución.", "From": "Desde", "Frozen plugins": "Plugins congelados", "Gap closure": "Cierre de la brecha", "Halt": "Parada", "How closures are verified": "Cómo se verifican los cierres", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Cuánto de la señal de efecto es utilizable como retroalimentación. Esto decide si vale la pena construir una política de aprendizaje.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Cuánto del framework hizo crecer por sí mismo y cuánto del pipeline muestra evidencia de ejecución.", "How often each window sat inside, near, or outside its declared limits": "Con qué frecuencia cada ventana estuvo dentro, cerca o fuera de sus límites declarados", "Inquiry brief": "Informe de indagación", "Insights carded as evidence, capped for fast review.": "Hallazgos presentados como evidencia, limitados para revisión rápida.", "Instruments & counterparties": "Instrumentos y contrapartes", "Kept": "Conservado", "Latest capability decision": "Última decisión de capacidad", "Lifecycle records": "Registros de ciclo de vida", "Lifecycle timeline": "Cronología del ciclo de vida", "Lifecycle transitions": "Transiciones de ciclo de vida", "Line of inquiry": "Línea de indagación", "Live activity": "Actividad en vivo", "Location": "Ubicación", "Loop phase": "Fase del bucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Media de cada ventana de submuestreo. Los límites declarados se listan por canal abajo.", "Model's reasoning": "Razonamiento del modelo", "Mutation": "Mutación", "Narrative": "Narrativa", "Narrative pulse": "Pulso narrativo", "Needs attention": "Requiere atención", "Next recal due": "Próxima recalibración", "Next step": "Siguiente paso", "No causal history yet": "Aún no hay historia causal", "Normalized error": "Error normalizado", "Normalized error is the residual as a share of the channel's declared span.": "El error normalizado es el residuo como fracción del rango declarado del canal.", "Not yet observed": "Aún no observado", "Nothing has driven a framework change, so there is no episode to narrate.": "Nada ha impulsado todavía un cambio del framework, por lo que no hay ningún episodio que narrar.", "OHLC extracted from captured session market data.": "OHLC extraído de los datos de mercado capturados en la sesión.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Cola de observaciones, estado de propuestas, decisiones de política y resultados del ciclo de vida.", "Observations": "Observaciones", "Observed Hz": "Hz observados", "Observed rate against declared rate": "Tasa observada frente a la tasa declarada", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un único espacio de nombres global, arbitrado por orden de llegada. El aspirante queda registrado, nunca se descarta en silencio.", "Open": "Abierto", "Open risks": "Riesgos abiertos", "Open/high/low/close from captured tool output.": "Apertura/máximo/mínimo/cierre desde la salida de herramientas capturada.", "Origin": "Origen", "Outcome": "Resultado", "PRODUCTION": "Producción", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Por episodio: el desencadenante, la decisión, el cambio y si la brecha se cerró.", "Per-channel calibration state, freshness, and residual correction": "Estado de calibración, vigencia y corrección residual por canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Evidencia en ejecución por segmento. Que un módulo exista no prueba que algo lo invoque.", "Pipeline": "Pipeline", "Pipeline evidence": "Evidencia del pipeline", "Pipeline reachability": "Alcanzabilidad del pipeline", "Plan": "Plan", "Plan steps": "Pasos del plan", "Plugin": "Plugin", "Plugin roster and trust": "Registro de plugins y confianza", "Plugins": "Plugins", "Plugins by origin": "Plugins por origen", "Plugins by trust class": "Plugins por clase de confianza", "Policy": "Política", "Policy decisions": "Decisiones de política", "Positions & actions": "Posiciones y acciones", "Posture": "Postura", "Price action": "Acción del precio", "Proposal": "Propuesta", "Proposal status": "Estado de la propuesta", "Proposed, not admitted": "Propuesto, no admitido", "Pulse": "Pulso", "Quarantine feed": "Entrada de cuarentena", "Ratio": "Relación", "Read live from the registry and trust ledger every cycle.": "Leído en vivo del registro y del libro de confianza en cada ciclo.", "Recent episodes": "Episodios recientes", "Reclaim candidates": "Candidatos a recuperación", "Reclaimable": "Recuperable", "References & follow-ups": "Referencias y seguimientos", "References (entities)": "Referencias (entidades)", "Registry": "Registro", "Registry delta": "Delta del registro", "Registry version": "Versión del registro", "Regressions": "Regresiones", "Rejected": "Rechazado", "Representative observations, capped for quick scanning.": "Observaciones representativas, limitadas para lectura rápida.", "Requirements": "Requisitos", "Research lens": "Vista de investigación", "Residual": "Residuo", "Reward signal bandwidth": "Ancho de banda de la señal de recompensa", "Runtime evidence": "Evidencia en ejecución", "Sampled history per channel, newest on the right": "Historial muestreado por canal, el más reciente a la derecha", "Segment": "Segmento", "Segments by status": "Segmentos por estado", "Selectable": "Seleccionable", "Selection delta": "Delta de selección", "Self-acquired": "Autoadquirido", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins autoadquiridos que están registrados pero no son seleccionables, o nunca se han usado.", "Sentiment lens": "Vista de sentimiento", "Series": "Serie", "Session analysis": "Análisis de sesión", "Signal strength": "Fuerza de la señal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Señales de que algo creció mal o fue retenido. Se muestran independientemente de la pestaña abierta.", "Skipped slots": "Ranuras omitidas", "State": "Estado", "Storyline and signal strength before drilling into positions and actions.": "Narrativa y fuerza de la señal antes de entrar en posiciones y acciones.", "Streaming": "Transmisión", "Suggested next steps": "Próximos pasos sugeridos", "The line of investigation and where the open questions concentrate.": "La línea de investigación y dónde se concentran las preguntas abiertas.", "The narrative arc and how strongly themes are trending.": "El arco narrativo y con qué fuerza se mueven los temas.", "The world model asked for these capabilities and nothing took them up.": "El modelo del mundo pidió estas capacidades y nada las asumió.", "Theme intensity": "Intensidad temática", "Themes": "Temas", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Este panel informa de cómo el framework se modifica a sí mismo. Todavía no se ha registrado nada.", "To": "Hasta", "Tool": "Herramienta", "Tool-name conflicts": "Conflictos de nombres de herramientas", "Tools": "Herramientas", "Transport": "Transporte", "Transport, provenance and channel counts": "Transporte, procedencia y número de canales", "Trust": "Confianza", "Trust accrual": "Acumulación de confianza", "Trust class": "Clase de confianza", "Unselectable reclamation": "Recuperación no seleccionable", "Usable": "Utilizable", "VERIFIED": "Verificado", "Verdicts": "Veredictos", "Verdicts by reason": "Veredictos por motivo", "Verified": "Verificado", "Verified by": "Verificado por", "Voices & concerns": "Voces e inquietudes", "Watchlist": "Lista de seguimiento", "What changed in the environment, and what the framework did about it.": "Qué cambió en el entorno y qué hizo el framework al respecto.", "Which plugin owns which tool, and which capability that tool provides.": "Qué plugin posee qué herramienta y qué capacidad proporciona esa herramienta.", "Who/what is in the conversation, and the concerns still open.": "Quién/qué está en la conversación y las inquietudes aún abiertas.", "Why": "Por qué", "Why not admitted": "Motivo de no admisión", "Why this page is empty": "Por qué esta página está vacía", "World-model driver": "Controlador del modelo del mundo", "Writable": "Escribible", "aborted": "Abortado", "accruing": "Acumulando", "active": "Activo", "appeared": "Apareció", "armed": "Armado", "assess_compatibility": "Evaluar compatibilidad", "built_in": "Integrado", "capability_expand": "Ampliar capacidad", "committed": "Concluido", "conformance": "Conformidad", "declared_fitness": "Aptitud declarada", "disable": "Desactivar", "disposed": "Liberado", "effect_observed": "Efecto observado", "environment_probe": "Sonda de entorno", "execution_failed": "Ejecución fallida", "expected_effect_absent": "Efecto esperado ausente", "failed": "Fallido", "frozen": "Congelado", "gone": "Desapareció", "idle": "Inactivo", "install": "Instalar", "loading": "Cargando", "manual": "Manual", "moved": "Se movió", "new_unproven": "Nuevo, no probado", "no": "No", "no_evidence": "Sin evidencia", "no_expected_effect_declared": "Sin efecto esperado declarado", "no_outcome_observed": "Sin resultado observado", "none": "Ninguno", "not_admitted": "No admitido", "not_applicable": "No aplicable", "observe_only": "Solo observar", "observed_effect": "Efecto observado", "open": "Abierto", "pending": "Pendiente", "reload": "Recargar", "remove": "Eliminar", "reopened": "Reabierto", "resolved": "Resuelto", "rollback": "Revertir", "runtime": "Tiempo de ejecución", "self_acquired": "Autoadquirido", "still_open": "Aún abierto", "tool_reported_no_effect": "La herramienta no informó efecto", "trusted": "De confianza", "unknown": "Desconocido", "unknown_tool": "Herramienta desconocida", "unloading": "Descargando", "unscheduled": "No planificado", "unverifiable": "No verificable", "unverified": "No verificado", "waiting": "En espera", "watching": "Vigilando", "wired": "Conectado", "world_model": "Modelo del mundo", "yes": "Sí", "Causal trace": "Traza causal", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Evidencia de solo lectura del entorno a la gobernanza para una instantánea de evolución del framework.", "Evidence boundary": "Límite de evidencia", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Una traza causal muestra hechos registrados; no infiere aprobación ausente ni efecto observado.", "Episodes": "Episodios", "Declared-fitness closures": "Cierres por aptitud declarada", "Counterfactual / mutation matrix": "Matriz contrafactual / de mutaciones", "Each row preserves the driver, decision, registry delta, and verification tier.": "Cada fila conserva el desencadenante, la decisión, el delta del registro y el nivel de verificación.", "Trigger": "Desencadenante", "Evidence tier": "Nivel de evidencia", "Episode timeline": "Cronología de episodios", "Rebuilt from existing decision and observation records.": "Reconstruida a partir de registros existentes de decisión y observación.", "Durable trace feed": "Flujo de trazas durables", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Las decisiones rechazadas y sin acción permanecen visibles cuando se instala su receptor de trazas.", "Lifecycle": "Ciclo de vida", "Pipeline evidence over time": "Evidencia del canal a lo largo del tiempo", "One point per recorded change in framework state, oldest first.": "Un punto por cada cambio registrado del estado del framework, del más antiguo al más reciente.", "Samples": "Muestras", "Net change": "Cambio neto"}, + ar: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **لم يُسجَّل أي حكم على الأثر بعد**، لذا لا توجد إشارة مكافأة لقياسها. النسب أعلاه فارغة عن قصد وليست صفرًا. لا يمكن التحقق من الأثر إلا إذا أعلنه المطلب، واليوم لا تحمل الأثر المتوقع سوى المطالب التي كتبها نموذج العالم.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **انحدار: فجوة أُغلقت عادت للظهور.** تطوّر بدا ناجحًا لم يصمد. هذا هو الاكتشاف الوحيد في هذه اللوحة الذي يستدعي انتباهًا فوريًا.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **لقطة فقط.** لا يوجد بعد تاريخ سببي لإعادة بنائه، لذا فالخط الزمني غائب وليس فارغًا. السبب مبيَّن في صف `قرارات السياسة` تحت تغطية المسار؛ اللقطة الحيّة وجدول التغطية غير متأثرين.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **بعض الإضافات مُجمَّدة بسبب خلل داخلي.** الإضافة المُجمَّدة لا تزال تُبلِّغ `DRAFT`، وبُعد الثقة يقوم بالتقييم فقط، لذا تبقى قابلة للاختيار إلا إذا أُلغي تسجيلها أيضًا — راجع عمود `قابل للاختيار`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **مستوى التحقق: L2 (الملاءمة المُعلنة).** سحب الرصد يعني أن مرشّحًا *أعلن* أنه يوفّر القدرة، لا أن القدرة رُصدت وهي تعمل. التحقق من الأثر (L3) غير موصول، لذا لا ينبغي قراءة أي إغلاق في هذه اللوحة كأمر مُثبَت.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> يجب أن تكتمل دورة مراقبة واحدة قبل ظهور أي محتوى. إذا استمر ذلك، تحقّق من تمكين المُجدول وأن مراقبة `framework-evolution` مُسلّحة وغير مكتومة.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> تُكتب الحلقة عندما يؤدي رصد للبيئة إلى قرار بشأن قدرة. لم يُسجَّل أي منها، وهذا يعني إمّا نظامًا هادئًا أو مسارًا يتوقف قبل ذلك — تبويب **المسار** يحدّد الجزء الذي يتوقف عنده وما الذي يزيل التعطيل.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> لا شيء يستعيدها تلقائيًا. كل واحدة تحتجز اسم أداة وتظهر في قائمة القدرات دون أن تكون قابلة للاختيار، فينمو السجل في اتجاه لا يمكن لأي مطلب استخدامه.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> لم تدخل هذه المقترحات أي مسار، لذا لا تظهر في أي سجل قرار أو رصد. قبولها خيار في الإعدادات.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "نسبة أقل من 1.0 تعني أن حلقة أخذ العينات لا تحافظ على وتيرتها المعلنة.", "Abstained": "امتناع", "Acquisition authority": "سلطة الاكتساب", "Acquisition lifecycle": "دورة حياة الاكتساب", "Action": "الإجراء", "After": "بعد", "An unverified declaration has its writable channels demoted to read-only.": "الإعلان غير المُتحقَّق منه تُخفَّض قنواته القابلة للكتابة إلى القراءة فقط.", "Approval": "الموافقة", "Autonomous governance": "الحكم الذاتي", "Autonomy": "الاستقلالية", "Before": "قبل", "CANDIDATE": "مرشّح", "Calibrated at": "تاريخ المعايرة", "Calibration health": "سلامة المعايرة", "Calls": "الاستدعاءات", "Calls (decisions)": "التوصيات (القرارات)", "Candlestick": "الشموع", "Capability": "القدرة", "Capability adaptation": "تكييف القدرات", "Capability observations": "رصد القدرات", "Capability ownership": "ملكية القدرات", "Capability topology": "طوبولوجيا القدرات", "Change": "التغيير", "Channel": "القناة", "Channels": "القنوات", "Channels that have never been calibrated or whose calibration has expired are shown first.": "تظهر أولاً القنوات التي لم تُعاير قط أو التي انتهت صلاحية معايرتها.", "Command": "الأمر", "Commanded versus observed, best tracking first": "المأمور مقابل المرصود، الأفضل تتبعاً أولاً", "Composition": "التركيب", "Concerns (open questions)": "المخاوف (أسئلة مفتوحة)", "Confidence": "الثقة", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "محسوب على كل قناة مرسومة. \"قريب\" تعني داخل 5% من حد معلن.", "Cycles run": "الدورات المنفَّذة", "DRAFT": "مسوّدة", "Days since": "الأيام المنقضية", "Decision": "القرار", "Decisions read as calls; action items as the execution checklist.": "القرارات تُقرأ كتوصيات؛ والإجراءات كقائمة تنفيذ.", "Declared Hz": "الهرتز المعلن", "Desk brief": "موجز المكتب", "Device": "الجهاز", "Dropped samples": "العينات المفقودة", "Each row names one blocked segment and the change that would unblock it.": "كل صف يحدّد جزءًا معطَّلًا والتغيير الذي يزيل التعطيل.", "Effect verification (L3)": "التحقق من الأثر (L3)", "Effects declared": "الآثار المُعلنة", "Entities as references, and recommended next prompts to advance the work.": "الكيانات كمراجع، والمطالبات التالية الموصى بها لدفع العمل.", "Entities in play and the open risks still to resolve.": "الكيانات المعنية والمخاطر المفتوحة التي لم تُحل.", "Envelope, rate, staleness and quality observations · newest first": "رصدات المغلف والمعدل والتقادم والجودة · الأحدث أولاً", "Environment": "البيئة", "Environment to framework": "من البيئة إلى الإطار", "Environment, selected plugin tools, and orchestration order.": "البيئة والأدوات المختارة وترتيب التنسيق.", "Error rate": "معدل الأخطاء", "Events paced out": "الأحداث المُقيَّدة", "Ever used": "استُخدم سابقًا", "Evidence": "الدليل", "Evidence admission": "قبول الأدلة", "Evolution": "التطور", "Evolution timeline": "الخط الزمني للتطور", "Executable": "قابل للتنفيذ", "Execution checklist": "قائمة التنفيذ", "Extracted from this session's tool/file output (not model-generated).": "مستخرج من مخرجات الأدوات/الملفات في هذه الجلسة (ليس من إنشاء النموذج).", "Failures": "الأعطال", "Fiber": "الخيط", "Fiber state changes since the previous cycle, including load retries.": "تغييرات حالة الـ fiber منذ الدورة السابقة، بما في ذلك محاولات التحميل.", "Finance lens": "منظور مالي", "Follow-ups": "المتابعات", "Framework change": "تغيير الإطار", "Framework changes as they happened, from runtime probes.": "تغييرات الإطار لحظة حدوثها، من مجسّات وقت التشغيل.", "Framework evolution": "تطور الإطار", "Framework size and how much of the evolution pipeline shows runtime evidence.": "حجم الإطار ومقدار ما يُظهره مسار التطور من أدلة وقت التشغيل.", "From": "من", "Frozen plugins": "الإضافات المُجمَّدة", "Gap closure": "إغلاق الفجوة", "Halt": "إيقاف", "How closures are verified": "كيف يُتحقَّق من الإغلاقات", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "ما مقدار إشارة الأثر القابل للاستخدام كتغذية راجعة. هذا يحدّد ما إذا كان بناء سياسة تعلّم يستحق العناء.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "ما مقدار ما نمّاه الإطار بنفسه، وما مقدار المسار الذي يُظهر أدلة وقت التشغيل.", "How often each window sat inside, near, or outside its declared limits": "عدد المرات التي كانت فيها كل نافذة داخل حدودها المعلنة أو قريبة منها أو خارجها", "Inquiry brief": "موجز الاستقصاء", "Insights carded as evidence, capped for fast review.": "الرؤى معروضة كأدلة، ومحدودة العدد للمراجعة السريعة.", "Instruments & counterparties": "الأدوات والأطراف المقابلة", "Kept": "المحتفظ به", "Latest capability decision": "أحدث قرار للقدرات", "Lifecycle records": "سجلات دورة الحياة", "Lifecycle timeline": "الخط الزمني لدورة الحياة", "Lifecycle transitions": "انتقالات دورة الحياة", "Line of inquiry": "خط الاستقصاء", "Live activity": "النشاط المباشر", "Location": "الموقع", "Loop phase": "مرحلة الحلقة", "Mean of each downsample window. Declared limits are listed per channel below.": "متوسط كل نافذة تخفيض للعينات. الحدود المعلنة مدرجة لكل قناة أدناه.", "Model's reasoning": "استدلال النموذج", "Mutation": "التغيير", "Narrative": "السرد", "Narrative pulse": "نبض السرد", "Needs attention": "يستدعي الانتباه", "Next recal due": "موعد إعادة المعايرة", "Next step": "الخطوة التالية", "No causal history yet": "لا يوجد تاريخ سببي بعد", "Normalized error": "الخطأ المعياري", "Normalized error is the residual as a share of the channel's declared span.": "الخطأ المعياري هو المتبقي كنسبة من المدى المعلن للقناة.", "Not yet observed": "لم يُرصد بعد", "Nothing has driven a framework change, so there is no episode to narrate.": "لم يدفع أي شيء بعد إلى تغيير في الإطار، لذا لا توجد حلقة لسردها.", "OHLC extracted from captured session market data.": "OHLC مستخرج من بيانات السوق المسجلة في الجلسة.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "قائمة الرصد وحالة المقترحات وقرارات السياسة ونتائج دورة الحياة.", "Observations": "الرصدات", "Observed Hz": "الهرتز المرصود", "Observed rate against declared rate": "المعدل المرصود مقابل المعدل المعلن", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "مساحة أسماء عالمية واحدة، تُحكَّم بأسبقية التسجيل. يُسجَّل المتنافس ولا يُهمَل بصمت.", "Open": "مفتوح", "Open risks": "المخاطر المفتوحة", "Open/high/low/close from captured tool output.": "الافتتاح/الأعلى/الأدنى/الإغلاق من مخرجات الأدوات المسجلة.", "Origin": "المصدر", "Outcome": "النتيجة", "PRODUCTION": "إنتاج", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "لكل حلقة: المُحفِّز والقرار والتغيير وما إذا أُغلقت الفجوة.", "Per-channel calibration state, freshness, and residual correction": "حالة المعايرة وحداثتها وتصحيح المتبقي لكل قناة", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "أدلة وقت التشغيل لكل مقطع. وجود وحدة لا يعني أن شيئًا يستدعيها.", "Pipeline": "المسار", "Pipeline evidence": "أدلة المسار", "Pipeline reachability": "إمكانية الوصول إلى المسار", "Plan": "الخطة", "Plan steps": "خطوات الخطة", "Plugin": "الملحق", "Plugin roster and trust": "قائمة الملحقات والثقة", "Plugins": "الملحقات", "Plugins by origin": "الإضافات حسب المصدر", "Plugins by trust class": "الإضافات حسب فئة الثقة", "Policy": "السياسة", "Policy decisions": "قرارات السياسة", "Positions & actions": "المراكز والإجراءات", "Posture": "الوضع", "Price action": "حركة السعر", "Proposal": "المقترح", "Proposal status": "حالة المقترح", "Proposed, not admitted": "مُقترح وغير مقبول", "Pulse": "النبض", "Quarantine feed": "تغذية الحجر", "Ratio": "النسبة", "Read live from the registry and trust ledger every cycle.": "يُقرأ مباشرة من السجل ودفتر الثقة في كل دورة.", "Recent episodes": "الحلقات الأخيرة", "Reclaim candidates": "مرشّحو الاسترجاع", "Reclaimable": "قابل للاسترجاع", "References & follow-ups": "المراجع والمتابعات", "References (entities)": "المراجع (الكيانات)", "Registry": "السجل", "Registry delta": "فرق السجل", "Registry version": "إصدار السجل", "Regressions": "الانحدارات", "Rejected": "المرفوض", "Representative observations, capped for quick scanning.": "رصدات تمثيلية، محدودة العدد للقراءة السريعة.", "Requirements": "المتطلبات", "Research lens": "منظور بحثي", "Residual": "المتبقي", "Reward signal bandwidth": "نطاق إشارة المكافأة", "Runtime evidence": "دليل وقت التشغيل", "Sampled history per channel, newest on the right": "سجل العينات لكل قناة، الأحدث على اليمين", "Segment": "المقطع", "Segments by status": "الأجزاء حسب الحالة", "Selectable": "قابل للاختيار", "Selection delta": "فرق الاختيار", "Self-acquired": "مُكتسَب ذاتيًا", "Self-acquired plugins that are registered but unselectable or never once used.": "إضافات مُكتسَبة ذاتيًا مُسجَّلة لكنها غير قابلة للاختيار أو لم تُستخدم قطّ.", "Sentiment lens": "منظور المشاعر", "Series": "السلسلة", "Session analysis": "تحليل الجلسة", "Signal strength": "قوة الإشارة", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "إشارات على أن شيئًا نما بشكل خاطئ أو تم حجبه. تظهر أيًا كان التبويب المفتوح.", "Skipped slots": "الفتحات المتخطاة", "State": "الحالة", "Storyline and signal strength before drilling into positions and actions.": "السرد وقوة الإشارة قبل التوسع في المراكز والإجراءات.", "Streaming": "بث", "Suggested next steps": "الخطوات التالية المقترحة", "The line of investigation and where the open questions concentrate.": "خط البحث وأين تتركز الأسئلة المفتوحة.", "The narrative arc and how strongly themes are trending.": "قوس السرد ومدى قوة اتجاه الموضوعات.", "The world model asked for these capabilities and nothing took them up.": "طلب نموذج العالم هذه القدرات ولم يتبنّها شيء.", "Theme intensity": "شدة الموضوعات", "Themes": "الموضوعات", "This board reports how the framework changes itself. Nothing has been recorded yet.": "تُبلِّغ هذه اللوحة عن كيفية تغيير الإطار لنفسه. لم يُسجَّل أي شيء بعد.", "To": "إلى", "Tool": "الأداة", "Tool-name conflicts": "تعارضات أسماء الأدوات", "Tools": "الأدوات", "Transport": "النقل", "Transport, provenance and channel counts": "النقل والمنشأ وعدد القنوات", "Trust": "الثقة", "Trust accrual": "تراكم الثقة", "Trust class": "فئة الثقة", "Unselectable reclamation": "استرجاع غير القابل للاختيار", "Usable": "قابل للاستخدام", "VERIFIED": "مُتحقَّق", "Verdicts": "الأحكام", "Verdicts by reason": "الأحكام حسب السبب", "Verified": "مُتحقَّق", "Verified by": "تم التحقق بواسطة", "Voices & concerns": "الأصوات والمخاوف", "Watchlist": "قائمة المتابعة", "What changed in the environment, and what the framework did about it.": "ما تغيّر في البيئة، وما فعله الإطار حيال ذلك.", "Which plugin owns which tool, and which capability that tool provides.": "أي ملحق يملك أي أداة، وأي قدرة توفرها تلك الأداة.", "Who/what is in the conversation, and the concerns still open.": "من/ما هو في المحادثة، والمخاوف التي لا تزال مفتوحة.", "Why": "السبب", "Why not admitted": "سبب عدم القبول", "Why this page is empty": "لماذا هذه الصفحة فارغة", "World-model driver": "مُشغِّل نموذج العالم", "Writable": "قابل للكتابة", "aborted": "مُلغى", "accruing": "قيد التراكم", "active": "نشط", "appeared": "ظهر", "armed": "مُسلّح", "assess_compatibility": "تقييم التوافق", "built_in": "مدمج", "capability_expand": "توسيع القدرة", "committed": "مُنجَز", "conformance": "المطابقة", "declared_fitness": "الملاءمة المُعلنة", "disable": "تعطيل", "disposed": "تم التخلص منه", "effect_observed": "تم رصد الأثر", "environment_probe": "مِجَس البيئة", "execution_failed": "فشل التنفيذ", "expected_effect_absent": "الأثر المتوقع غائب", "failed": "فشل", "frozen": "مُجمَّد", "gone": "اختفى", "idle": "خامل", "install": "تثبيت", "loading": "قيد التحميل", "manual": "يدوي", "moved": "انتقل", "new_unproven": "جديد وغير مُثبَت", "no": "لا", "no_evidence": "لا يوجد دليل", "no_expected_effect_declared": "لم يُعلَن أثر متوقع", "no_outcome_observed": "لم يُرصد أي ناتج", "none": "لا شيء", "not_admitted": "غير مقبول", "not_applicable": "غير منطبق", "observe_only": "المراقبة فقط", "observed_effect": "الأثر المرصود", "open": "مفتوح", "pending": "معلّق", "reload": "إعادة تحميل", "remove": "إزالة", "reopened": "أُعيد فتحه", "resolved": "تم الحل", "rollback": "تراجع", "runtime": "وقت التشغيل", "self_acquired": "مُكتسَب ذاتيًا", "still_open": "لا يزال مفتوحًا", "tool_reported_no_effect": "الأداة لم تُبلِّغ عن أثر", "trusted": "موثوق", "unknown": "غير معروف", "unknown_tool": "أداة غير معروفة", "unloading": "قيد الإلغاء", "unscheduled": "غير مُجدول", "unverifiable": "غير قابل للتحقق", "unverified": "غير مُتحقَّق", "waiting": "في الانتظار", "watching": "يراقب", "wired": "موصول", "world_model": "نموذج العالم", "yes": "نعم", "Causal trace": "الأثر السببي", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "دليل للقراءة فقط يربط البيئة بالحوكمة للّقطة واحدة من تطور الإطار.", "Evidence boundary": "حدود الدليل", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "يعرض الأثر السببي الحقائق المسجلة ولا يستنتج موافقة مفقودة أو أثرًا مرصودًا.", "Episodes": "الحلقات", "Declared-fitness closures": "إغلاقات الملاءمة المعلنة", "Counterfactual / mutation matrix": "مصفوفة الافتراضات المضادة / التغييرات", "Each row preserves the driver, decision, registry delta, and verification tier.": "يحفظ كل صف المحفز والقرار وفرق السجل ومستوى التحقق.", "Trigger": "المحفز", "Evidence tier": "طبقة الدليل", "Episode timeline": "الخط الزمني للحلقات", "Rebuilt from existing decision and observation records.": "أُعيد بناؤه من سجلات القرار والرصد الموجودة.", "Durable trace feed": "تدفق آثار دائم", "Rejected and no-op decisions remain visible when their trace sink is installed.": "تبقى القرارات المرفوضة والتي بلا إجراء مرئية عند تثبيت مستقبل آثارها.", "Lifecycle": "دورة الحياة", "Pipeline evidence over time": "أدلة المسار عبر الزمن", "One point per recorded change in framework state, oldest first.": "نقطة واحدة لكل تغيير مسجّل في حالة الإطار، الأقدم أولًا.", "Samples": "العينات", "Net change": "التغير الصافي"}, + ru: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Ни одного заключения об эффекте пока не записано**, поэтому измерять нечего. Показатели выше намеренно пусты, а не равны нулю. Эффект можно проверить только если требование его заявило, а сегодня заявленный эффект несут лишь требования, составленные моделью мира.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Регрессия: закрытый пробел возобновился.** Эволюция, казавшаяся успешной, не удержалась. Это единственный вывод на этой панели, требующий немедленного внимания.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Только снимок.** Причинной истории для восстановления пока нет, поэтому хронология отсутствует, а не пуста. Причина указана в строке `Решения политики` под покрытием конвейера; снимок и таблица покрытия не затронуты.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Некоторые плагины заморожены из-за внутреннего дефекта.** Замороженный плагин по-прежнему сообщает `DRAFT`, а измерение доверия только *оценивает*, поэтому он остаётся выбираемым, пока не будет также снят с регистрации — см. столбец `Выбираемо`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Уровень проверки: L2 (заявленная пригодность).** Снятое наблюдение означает, что кандидат *заявил* о предоставлении возможности, а не что возможность наблюдалась в работе. Проверка эффекта (L3) не подключена, поэтому ни одно закрытие на этой панели не следует считать доказанным.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Прежде чем появятся данные, должен завершиться хотя бы один цикл наблюдения. Если это сохраняется, проверьте, включён ли планировщик и что наблюдение `framework-evolution` активно и не отключено.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Эпизод записывается, когда наблюдение окружения приводит к решению о возможности. Ни одного не зафиксировано: либо система спокойна, либо конвейер останавливается раньше — вкладка **Конвейер** называет сегмент остановки и то, что его разблокирует.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Ничто не утилизирует их автоматически. Каждый занимает имя инструмента и присутствует в списке возможностей, не будучи выбираемым: реестр растёт в направлении, непригодном ни для одного требования.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Эти предложения не вошли ни в один конвейер, поэтому не отражены ни в одной записи решения или наблюдения. Их приём — вопрос конфигурации.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Отношение ниже 1,0 означает, что цикл выборки не выдерживает объявленный ритм.", "Abstained": "Воздержалось", "Acquisition authority": "Право на получение", "Acquisition lifecycle": "Жизненный цикл получения", "Action": "Действие", "After": "После", "An unverified declaration has its writable channels demoted to read-only.": "У непроверенного объявления записываемые каналы понижаются до только чтения.", "Approval": "Согласование", "Autonomous governance": "Автономное управление", "Autonomy": "Автономность", "Before": "До", "CANDIDATE": "Кандидат", "Calibrated at": "Калиброван", "Calibration health": "Состояние калибровки", "Calls": "Вызовы", "Calls (decisions)": "Рекомендации (решения)", "Candlestick": "Свечи", "Capability": "Возможность", "Capability adaptation": "Адаптация возможностей", "Capability observations": "Наблюдения возможностей", "Capability ownership": "Владение возможностями", "Capability topology": "Топология возможностей", "Change": "Изменение", "Channel": "Канал", "Channels": "Каналы", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Каналы, которые никогда не калибровались или чья калибровка истекла, показаны первыми.", "Command": "Команда", "Commanded versus observed, best tracking first": "Заданное против наблюдаемого, лучшее отслеживание первым", "Composition": "Состав", "Concerns (open questions)": "Опасения (открытые вопросы)", "Confidence": "Уверенность", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Подсчитано по всем отображаемым каналам. «У границы» — в пределах 5% от объявленного предела.", "Cycles run": "Выполнено циклов", "DRAFT": "Черновик", "Days since": "Дней с тех пор", "Decision": "Решение", "Decisions read as calls; action items as the execution checklist.": "Решения читаются как рекомендации; действия — как чек-лист исполнения.", "Declared Hz": "Объявл. Гц", "Desk brief": "Сводка деска", "Device": "Устройство", "Dropped samples": "Отброшенные образцы", "Each row names one blocked segment and the change that would unblock it.": "Каждая строка называет заблокированный сегмент и изменение, которое его разблокирует.", "Effect verification (L3)": "Проверка эффекта (L3)", "Effects declared": "Заявлено эффектов", "Entities as references, and recommended next prompts to advance the work.": "Сущности как ссылки и рекомендуемые следующие запросы.", "Entities in play and the open risks still to resolve.": "Задействованные сущности и нерешённые риски.", "Envelope, rate, staleness and quality observations · newest first": "Наблюдения по огибающей, частоте, устареванию и качеству · сначала новые", "Environment": "Окружение", "Environment to framework": "От окружения к фреймворку", "Environment, selected plugin tools, and orchestration order.": "Окружение, выбранные инструменты плагинов и порядок оркестрации.", "Error rate": "Частота ошибок", "Events paced out": "Событий подавлено", "Ever used": "Использовался", "Evidence": "Обоснование", "Evidence admission": "Приём данных", "Evolution": "Эволюция", "Evolution timeline": "Хронология эволюции", "Executable": "Исполнимо", "Execution checklist": "Чек-лист исполнения", "Extracted from this session's tool/file output (not model-generated).": "Извлечено из вывода инструментов/файлов этой сессии (не сгенерировано моделью).", "Failures": "Сбои", "Fiber": "Файбер", "Fiber state changes since the previous cycle, including load retries.": "Изменения состояния fiber с предыдущего цикла, включая повторные загрузки.", "Finance lens": "Финансовый ракурс", "Follow-ups": "Продолжения", "Framework change": "Изменение фреймворка", "Framework changes as they happened, from runtime probes.": "Изменения фреймворка в момент их появления, от рантайм-зондов.", "Framework evolution": "Эволюция фреймворка", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Размер фреймворка и какая часть конвейера эволюции показывает свидетельства времени выполнения.", "From": "Из", "Frozen plugins": "Замороженные плагины", "Gap closure": "Закрытие пробела", "Halt": "Останов", "How closures are verified": "Как проверяются закрытия", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Какая часть сигнала об эффекте пригодна как обратная связь. Это определяет, стоит ли строить обучающую политику.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Какую часть фреймворка он вырастил сам и какая часть конвейера показывает данные времени выполнения.", "How often each window sat inside, near, or outside its declared limits": "Как часто каждое окно было внутри, у границы или вне объявленных пределов", "Inquiry brief": "Сводка исследования", "Insights carded as evidence, capped for fast review.": "Инсайты как карточки-обоснования, ограничены для быстрого просмотра.", "Instruments & counterparties": "Инструменты и контрагенты", "Kept": "Оставлен", "Latest capability decision": "Последнее решение о возможностях", "Lifecycle records": "Записи жизненного цикла", "Lifecycle timeline": "Хронология жизненного цикла", "Lifecycle transitions": "Переходы жизненного цикла", "Line of inquiry": "Линия исследования", "Live activity": "Текущая активность", "Location": "Расположение", "Loop phase": "Фаза цикла", "Mean of each downsample window. Declared limits are listed per channel below.": "Среднее по каждому окну прореживания. Объявленные пределы указаны по каналам ниже.", "Model's reasoning": "Обоснование модели", "Mutation": "Изменение", "Narrative": "Сюжет", "Narrative pulse": "Нарративный пульс", "Needs attention": "Требует внимания", "Next recal due": "Следующая рекалибровка", "Next step": "Следующий шаг", "No causal history yet": "Причинной истории пока нет", "Normalized error": "Нормированная ошибка", "Normalized error is the residual as a share of the channel's declared span.": "Нормированная ошибка — остаток как доля объявленного диапазона канала.", "Not yet observed": "Ещё не наблюдалось", "Nothing has driven a framework change, so there is no episode to narrate.": "Ничто пока не вызвало изменения фреймворка, поэтому рассказывать не о чем.", "OHLC extracted from captured session market data.": "OHLC извлечён из рыночных данных, записанных в сессии.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Очередь наблюдений, состояние предложений, решения политики и итоги жизненного цикла.", "Observations": "Наблюдения", "Observed Hz": "Наблюд. Гц", "Observed rate against declared rate": "Наблюдаемая частота против объявленной", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Единое глобальное пространство имён, арбитраж по первому пришедшему. Претендент записывается, а не отбрасывается молча.", "Open": "Открыт", "Open risks": "Открытые риски", "Open/high/low/close from captured tool output.": "Открытие/максимум/минимум/закрытие из записанного вывода инструментов.", "Origin": "Источник", "Outcome": "Результат", "PRODUCTION": "Продакшн", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "По эпизодам: триггер, решение, изменение и закрылся ли пробел.", "Per-channel calibration state, freshness, and residual correction": "Состояние калибровки, актуальность и остаточная поправка по каналам", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Свидетельства времени выполнения по сегментам. Наличие модуля не доказывает, что его кто-то вызывает.", "Pipeline": "Конвейер", "Pipeline evidence": "Свидетельства конвейера", "Pipeline reachability": "Достижимость конвейера", "Plan": "План", "Plan steps": "Шаги плана", "Plugin": "Плагин", "Plugin roster and trust": "Реестр плагинов и доверие", "Plugins": "Плагины", "Plugins by origin": "Плагины по происхождению", "Plugins by trust class": "Плагины по классу доверия", "Policy": "Политика", "Policy decisions": "Решения политики", "Positions & actions": "Позиции и действия", "Posture": "Состояние", "Price action": "Ценовое движение", "Proposal": "Предложение", "Proposal status": "Статус предложения", "Proposed, not admitted": "Предложено, не принято", "Pulse": "Пульс", "Quarantine feed": "Поток карантина", "Ratio": "Отношение", "Read live from the registry and trust ledger every cycle.": "Читается напрямую из реестра и журнала доверия каждый цикл.", "Recent episodes": "Недавние эпизоды", "Reclaim candidates": "Кандидаты на утилизацию", "Reclaimable": "Утилизируемо", "References & follow-ups": "Ссылки и продолжения", "References (entities)": "Ссылки (сущности)", "Registry": "Реестр", "Registry delta": "Изменение реестра", "Registry version": "Версия реестра", "Regressions": "Регрессии", "Rejected": "Отклонён", "Representative observations, capped for quick scanning.": "Показательные наблюдения, ограничены для быстрого просмотра.", "Requirements": "Требования", "Research lens": "Исследовательский ракурс", "Residual": "Остаток", "Reward signal bandwidth": "Пропускная способность сигнала вознаграждения", "Runtime evidence": "Свидетельство времени выполнения", "Sampled history per channel, newest on the right": "История выборок по каналам, самое новое справа", "Segment": "Сегмент", "Segments by status": "Сегменты по статусу", "Selectable": "Выбираемый", "Selection delta": "Изменение выбора", "Self-acquired": "Самостоятельно получено", "Self-acquired plugins that are registered but unselectable or never once used.": "Самостоятельно полученные плагины, которые зарегистрированы, но невыбираемы или ни разу не использовались.", "Sentiment lens": "Ракурс тональности", "Series": "Серия", "Session analysis": "Анализ сессии", "Signal strength": "Сила сигнала", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Признаки того, что что-то выросло неверно или было задержано. Показываются независимо от открытой вкладки.", "Skipped slots": "Пропущенные слоты", "State": "Состояние", "Storyline and signal strength before drilling into positions and actions.": "Сюжет и сила сигнала до перехода к позициям и действиям.", "Streaming": "Потоковая передача", "Suggested next steps": "Рекомендуемые следующие шаги", "The line of investigation and where the open questions concentrate.": "Линия исследования и где сосредоточены открытые вопросы.", "The narrative arc and how strongly themes are trending.": "Нарративная дуга и насколько сильно растут темы.", "The world model asked for these capabilities and nothing took them up.": "Модель мира запросила эти возможности, и никто их не принял.", "Theme intensity": "Интенсивность тем", "Themes": "Темы", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Эта панель сообщает, как фреймворк изменяет сам себя. Пока ничего не записано.", "To": "В", "Tool": "Инструмент", "Tool-name conflicts": "Конфликты имён инструментов", "Tools": "Инструменты", "Transport": "Транспорт", "Transport, provenance and channel counts": "Транспорт, происхождение и число каналов", "Trust": "Доверие", "Trust accrual": "Накопление доверия", "Trust class": "Класс доверия", "Unselectable reclamation": "Утилизация невыбираемого", "Usable": "Пригодно", "VERIFIED": "Проверено", "Verdicts": "Заключений", "Verdicts by reason": "Заключения по причине", "Verified": "Проверено", "Verified by": "Подтверждено", "Voices & concerns": "Голоса и опасения", "Watchlist": "Список наблюдения", "What changed in the environment, and what the framework did about it.": "Что изменилось в окружении и что фреймворк с этим сделал.", "Which plugin owns which tool, and which capability that tool provides.": "Какой плагин владеет каким инструментом и какую возможность этот инструмент предоставляет.", "Who/what is in the conversation, and the concerns still open.": "Кто/что в разговоре и какие опасения остаются.", "Why": "Почему", "Why not admitted": "Причина отклонения", "Why this page is empty": "Почему эта страница пуста", "World-model driver": "Драйвер модели мира", "Writable": "Записываемый", "aborted": "Прервано", "accruing": "Накапливается", "active": "Активно", "appeared": "Появился", "armed": "Активно", "assess_compatibility": "Оценка совместимости", "built_in": "Встроенный", "capability_expand": "Расширение возможностей", "committed": "Завершено", "conformance": "Соответствие", "declared_fitness": "Заявленная пригодность", "disable": "Отключение", "disposed": "Освобождено", "effect_observed": "Эффект наблюдался", "environment_probe": "Зонд окружения", "execution_failed": "Сбой выполнения", "expected_effect_absent": "Ожидаемый эффект отсутствует", "failed": "Сбой", "frozen": "Заморожено", "gone": "Исчез", "idle": "Простой", "install": "Установка", "loading": "Загрузка", "manual": "Вручную", "moved": "Перешёл", "new_unproven": "Новое, непроверенное", "no": "Нет", "no_evidence": "Нет данных", "no_expected_effect_declared": "Ожидаемый эффект не заявлен", "no_outcome_observed": "Результат не наблюдался", "none": "Нет", "not_admitted": "Не принято", "not_applicable": "Неприменимо", "observe_only": "Только наблюдение", "observed_effect": "Наблюдаемый эффект", "open": "Открыто", "pending": "Ожидает", "reload": "Перезагрузка", "remove": "Удаление", "reopened": "Возобновлено", "resolved": "Закрыто", "rollback": "Откат", "runtime": "Среда выполнения", "self_acquired": "Самостоятельно получено", "still_open": "Всё ещё открыто", "tool_reported_no_effect": "Инструмент не сообщил об эффекте", "trusted": "Доверенное", "unknown": "Неизвестно", "unknown_tool": "Неизвестный инструмент", "unloading": "Выгрузка", "unscheduled": "Не запланировано", "unverifiable": "Не проверяемо", "unverified": "Непроверенное", "waiting": "Ожидание", "watching": "Наблюдает", "wired": "Подключено", "world_model": "Модель мира", "yes": "Да", "Causal trace": "Причинная трасса", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Доказательства только для чтения от окружения к управлению для одного снимка эволюции фреймворка.", "Evidence boundary": "Граница доказательств", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Причинная трасса показывает записанные факты и не выводит отсутствующее согласование или наблюдаемый эффект.", "Episodes": "Эпизоды", "Declared-fitness closures": "Закрытия по заявленной пригодности", "Counterfactual / mutation matrix": "Контрфактическая матрица / мутации", "Each row preserves the driver, decision, registry delta, and verification tier.": "Каждая строка сохраняет триггер, решение, изменение реестра и уровень проверки.", "Trigger": "Триггер", "Evidence tier": "Уровень доказательств", "Episode timeline": "Хронология эпизодов", "Rebuilt from existing decision and observation records.": "Восстановлена из существующих записей решений и наблюдений.", "Durable trace feed": "Поток долговечных трасс", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Отклонённые решения и решения без действия остаются видимыми, когда установлен их приёмник трасс.", "Lifecycle": "Жизненный цикл", "Pipeline evidence over time": "Свидетельства конвейера во времени", "One point per recorded change in framework state, oldest first.": "Одна точка на каждое зафиксированное изменение состояния фреймворка, старшие слева.", "Samples": "Выборки", "Net change": "Итоговое изменение"} }; - Object.keys(I18N).concat(Object.keys(I18N_PATCH), Object.keys(I18N_TEMPLATES)) + // Page-chrome freshness strings. A table of their own because the provenance bar + // is not a lens: it renders above every board, so keying it off any one lens's + // table would tie a page-wide fact to an unrelated view. + const I18N_PROVENANCE = { + en: { + "Observed": "Observed", "Not yet observed": "Not yet observed", + "every {interval}": "every {interval}", "next in {interval}": "next in {interval}", + "event-driven": "event-driven", "muted": "muted", + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.": "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.", + "confirmed unchanged {interval} later": "confirmed unchanged {interval} later", + "{count} sec": "{count}s", "{count} min": "{count}m", "{count} hr": "{count}h", "{count} days": "{count}d", + "Refresh now": "Refresh now", "Refreshing\u2026": "Refreshing\u2026" + }, + zh: { + "Observed": "观测于", "Not yet observed": "尚未观测", + "every {interval}": "每 {interval}", "next in {interval}": "{interval} 后下一次", + "event-driven": "事件驱动", "muted": "已静音", + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.": "已过期:超过 {interval} 无任何周期完成。下方内容不可被当作当前状态。", + "confirmed unchanged {interval} later": "{interval} 后确认未变", + "{count} sec": "{count} 秒", "{count} min": "{count} 分钟", "{count} hr": "{count} 小时", "{count} days": "{count} 天", + "Refresh now": "立即刷新", "Refreshing\u2026": "刷新中…" + }, + fr: { + "Observed": "Observé à", "Not yet observed": "Pas encore observé", + "every {interval}": "toutes les {interval}", "next in {interval}": "prochain dans {interval}", + "event-driven": "piloté par événements", "muted": "en sourdine", + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.": "Périmé : aucun cycle achevé depuis plus de {interval}. Rien ci-dessous ne peut être considéré comme à jour.", + "confirmed unchanged {interval} later": "confirmé inchangé {interval} plus tard", + "{count} sec": "{count} s", "{count} min": "{count} min", "{count} hr": "{count} h", "{count} days": "{count} j", + "Refresh now": "Actualiser", "Refreshing\u2026": "Actualisation…" + }, + es: { + "Observed": "Observado a las", "Not yet observed": "Aún no observado", + "every {interval}": "cada {interval}", "next in {interval}": "siguiente en {interval}", + "event-driven": "impulsado por eventos", "muted": "silenciado", + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.": "Obsoleto: ningún ciclo completado en más de {interval}. Nada de lo siguiente puede considerarse actual.", + "confirmed unchanged {interval} later": "confirmado sin cambios {interval} después", + "{count} sec": "{count} s", "{count} min": "{count} min", "{count} hr": "{count} h", "{count} days": "{count} d", + "Refresh now": "Actualizar ahora", "Refreshing\u2026": "Actualizando…" + }, + ar: { + "Observed": "رُصِد عند", "Not yet observed": "لم يُرصَد بعد", + "every {interval}": "كل {interval}", "next in {interval}": "التالي بعد {interval}", + "event-driven": "مدفوع بالأحداث", "muted": "مكتوم", + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.": "قديم: لم تكتمل أي دورة لأكثر من {interval}. لا يمكن اعتبار أي مما أدناه حاليًا.", + "confirmed unchanged {interval} later": "تأكّد عدم تغيَّره بعد {interval}", + "{count} sec": "{count} ث", "{count} min": "{count} د", "{count} hr": "{count} س", "{count} days": "{count} ي", + "Refresh now": "تحديث الآن", "Refreshing\u2026": "جارٍ التحديث…" + }, + ru: { + "Observed": "Наблюдено в", "Not yet observed": "Ещё не наблюдалось", + "every {interval}": "каждые {interval}", "next in {interval}": "следующее через {interval}", + "event-driven": "по событиям", "muted": "без уведомлений", + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.": "Устарело: ни один цикл не завершён более {interval}. Ничто ниже нельзя считать актуальным.", + "confirmed unchanged {interval} later": "подтверждено без изменений через {interval}", + "{count} sec": "{count} с", "{count} min": "{count} мин", "{count} hr": "{count} ч", "{count} days": "{count} д", + "Refresh now": "Обновить", "Refreshing\u2026": "Обновление…" + } + }; + Object.keys(I18N).concat(Object.keys(I18N_PATCH), Object.keys(I18N_LIVE), Object.keys(I18N_TEMPLATES), Object.keys(I18N_PROVENANCE)) .filter((lang, at, all) => all.indexOf(lang) === at) .forEach((lang) => { // Later sources win, so a locale-specific template string overrides the English // fallback while an absent one still resolves to readable English. I18N[lang] = Object.assign( {}, I18N.en || {}, I18N[lang] || {}, - I18N_PATCH[lang] || {}, I18N_TEMPLATES[lang] || {}, + I18N_PATCH[lang] || {}, I18N_LIVE[lang] || {}, I18N_TEMPLATES[lang] || {}, + I18N_PROVENANCE[lang] || {}, ); }); @@ -308,6 +457,7 @@ render(payload); renderNav(payload.meta || {}); renderServerHealth(payload.meta || {}); + renderProvenance(payload.meta || {}); // Manage signal auto-refresh lifecycle on template switch var newTemplate = (payload.meta && payload.meta.active_template) || current.template || ""; if (newTemplate === "signals") { @@ -324,6 +474,106 @@ } } + // Freshness, stated on every lens. A finding-backed board renders the newest + // *persisted* finding, and findings dedup on a content fingerprint, so an + // unchanged subject keeps its previous finding and the page can be minutes old + // while looking current. ``observed_at`` was already in the payload and rendered + // nowhere, so a reader had no way to tell -- and a board that prescribes a fix it + // cannot confirm landed is a broken loop, not a slow one. + // + // Placed above the rendered tree rather than inside it: it describes the whole + // page, and putting it in the component tree would make it a template author's + // job to remember on each of ten lenses. + function renderProvenance(meta) { + const root = document.getElementById("root"); + const old = document.getElementById("provenance-bar"); + if (old) old.remove(); + const p = meta.provenance; + if (!root || !p || typeof p !== "object") return; + const bar = el("div", "provenance" + (p.stale ? " is-stale" : "")); + bar.id = "provenance-bar"; + + const facts = []; + if (p.observed) { + facts.push(t("Observed") + " " + clockLabel(p.observed_at) + + " \u00b7 " + relativeLabel(p.age_seconds)); + } else { + // No instant to age. Saying "0s ago" here would invent one, which is the + // failure this bar exists to prevent rather than commit. + facts.push(t("Not yet observed")); + } + // The second instant, and the reason the bar is trustworthy. A cycle that found + // nothing changed writes no finding, so without this the page looked frozen + // whenever it was in fact being confirmed correct on every tick. + if (p.checked && p.unchanged_for_seconds > 1) { + facts.push(fmt("confirmed unchanged {interval} later", + { interval: durationLabel(p.unchanged_for_seconds) })); + } + if (p.cadence_seconds > 0) { + facts.push(fmt("every {interval}", { interval: durationLabel(p.cadence_seconds) })); + if (p.next_due_in_seconds > 0) { + facts.push(fmt("next in {interval}", { interval: durationLabel(p.next_due_in_seconds) })); + } + } else { + facts.push(t("event-driven")); + } + if (p.muted) facts.push(t("muted")); + bar.appendChild(el("span", "provenance-facts", esc(facts.join(" \u00b7 ")))); + + if (p.stale) { + // The verdict is about the watch, not the content: no cycle has completed in + // two cadences, so nothing on the page can be trusted to reflect the present. + // Old-but-confirmed content is stable, not stale, and is not flagged here. + bar.appendChild(el("span", "provenance-stale", esc("\u26a0 " + fmt( + "Stale: no cycle completed in over {interval}. Nothing below can be trusted as current.", + { interval: durationLabel(p.cadence_seconds * 2) }, + )))); + } + // The affordance that closes the loop. Several boards prescribe a fix ("Next + // step: run this command"); without a way to re-run the cycle the reader had to + // wait out a whole cadence to learn whether it landed, and had no way to tell a + // failed change from a page that had not caught up. ``watch.refresh`` is already + // on the server's allow-list and re-runs one producer -- it decides nothing. + if (p.watch_id) { + const button = el("button", "provenance-refresh", esc(t("Refresh now"))); + button.type = "button"; + button.addEventListener("click", async () => { + button.disabled = true; + button.textContent = t("Refreshing\u2026"); + // postAction already refetches the view for an rpc, so the bar it rebuilds + // carries the new observed_at without a second request. + await postAction({ kind: "rpc", name: "watch.refresh", params: { watch_id: p.watch_id } }); + }); + bar.appendChild(button); + } + root.insertAdjacentElement("beforebegin", bar); + } + + // Wall-clock, for "which cycle am I looking at". Locale-independent digits on + // purpose: this is matched against log lines, not read as prose. + function clockLabel(epochSeconds) { + const at = new Date(Number(epochSeconds || 0) * 1000); + if (!isFinite(at.getTime())) return ""; + const pad = (n) => String(n).padStart(2, "0"); + return pad(at.getHours()) + ":" + pad(at.getMinutes()) + ":" + pad(at.getSeconds()); + } + + function durationLabel(seconds) { + const s = Math.max(0, Math.round(Number(seconds || 0))); + if (s < 60) return fmt("{count} sec", { count: s }); + if (s < 3600) return fmt("{count} min", { count: Math.round(s / 60) }); + if (s < 86400) return fmt("{count} hr", { count: Math.round(s / 3600) }); + return fmt("{count} days", { count: Math.round(s / 86400) }); + } + + // Reuses the signal timeline's relative keys, which are interpolated on {count}. + function relativeLabel(seconds) { + const s = Math.max(0, Math.round(Number(seconds || 0))); + if (s < 60) return fmt("seconds ago", { count: s }); + if (s < 3600) return fmt("minutes ago", { count: Math.round(s / 60) }); + return fmt("hours ago", { count: Math.round(s / 3600) }); + } + // Long-lived-process staleness: warns when this dashboard server process // predates the current source tree (see leapflow.utils.build_info). Purely // informational — the page still renders whatever data the stale process @@ -410,6 +660,80 @@ return e; } + // ── Markdown: the three constructs the templates actually author ───────── + // + // The ``Markdown`` node used to escape its text and print it verbatim, so every + // aside on the evolution board read as raw markup -- a leading ``>`` and literal + // ``**`` in front of the very sentence meant to carry the most weight. + // + // Escaping runs first and every transform below operates on the *escaped* text, + // so prose can never introduce an element: the only tags in the result are the + // ones added here. A general Markdown library is deliberately not pulled in -- + // the SDUI contract is a closed component catalog whose whole security argument + // is that no untrusted string reaches innerHTML unescaped, and widening that + // surface to gain three constructs is a bad trade. + // + // Recognised: ``> `` aside (consecutive lines fold into one blockquote), + // ``**bold**``, and ``` `code` ```. Anything else stays literal, which is the + // honest outcome for a construct the renderer does not claim to support. + function mdInline(escaped) { + const parts = String(escaped).split("`"); + // An unmatched trailing backtick is literal text, not an unterminated code + // span: an odd count re-joins the tail so a stray backtick cannot swallow the + // rest of the sentence into . + if (parts.length % 2 === 0) { + const tail = parts.pop(); + parts[parts.length - 1] += "`" + tail; + } + return parts + .map((part, at) => (at % 2 + // Odd segments sit between a backtick pair. Bold is not applied inside + // them, because a config key containing ``**`` is a key, not emphasis. + ? "" + part + "" + : part.replace(/\*\*([^*]+)\*\*/g, "$1"))) + .join(""); + } + + function renderMarkdown(raw) { + const host = el("div", "md prose"); + let quote = []; + let para = []; + // Both flushes join with a space rather than preserving the newline: the + // templates author these as YAML folded scalars, so a line break in the source + // is a wrapping artifact of the file and never an intended hard break. + const flushQuote = () => { + if (!quote.length) return; + host.appendChild(el("blockquote", "quote", mdInline(esc(quote.join(" "))))); + quote = []; + }; + const flushPara = () => { + if (!para.length) return; + host.appendChild(el("p", null, mdInline(esc(para.join(" "))))); + para = []; + }; + String(raw == null ? "" : raw).split(/\r?\n/).forEach((line) => { + const text = line.trim(); + if (!text) { flushQuote(); flushPara(); return; } + // Tested on the raw line, before escaping turns ``>`` into ``>``. + if (text.charAt(0) === ">") { + flushPara(); + quote.push(text.slice(1).trim()); + } else if (quote.length) { + // Lazy continuation: an unprefixed line directly under an aside belongs to + // it. The templates author these as YAML folded scalars, which arrive + // pre-joined, so this path exists for text that reaches the renderer any + // other way -- a literal scalar, or a bound payload string. Without it such + // a notice splits into a one-line quote plus an orphan paragraph. + quote.push(text); + } else { + para.push(text); + } + }); + flushQuote(); + flushPara(); + return host; + } + function renderChildren(node, parent) { (node.children || []).forEach((c) => parent.appendChild(renderNode(c))); return parent; @@ -430,6 +754,7 @@ d.appendChild(el("div", "chart-placeholder", esc(data.length + " " + t("Series")))); return d; }, gauge: (p) => renderGaugeValue(p.label || "Gauge", p.data), signalTimeline: renderSignalTimeline, + evolutionLive: renderEvolutionLive, }; function asArray(value) { return Array.isArray(value) ? value : []; } @@ -496,6 +821,175 @@ .concat(Object.keys(counts).sort().map((key) => ({ key, label: signalFamilyLabel(key), count: counts[key] }))); } + function normalizeEvolutionEvent(value) { + if (!value || typeof value !== "object") return null; + const stage = String(value.stage || ""); + const kind = String(value.kind || ""); + if (!stage || !kind) return null; + const correlation = value.correlation && typeof value.correlation === "object" ? value.correlation : {}; + return { + event_id: String(value.event_id || value.trace_id || (stage + ":" + kind + ":" + String(value.ts || ""))), + episode_id: String(value.episode_id || correlation.record_id || correlation.intent_id || correlation.requirement_id || value.trace_id || ""), + stage: stage, + kind: kind, + ts: Number(value.ts || 0), + summary: String(value.summary || ""), + evidence_level: String(value.evidence_level || "runtime_trace"), + verification_tier: String(value.verification_tier || "not_recorded"), + side_effect_state: String(value.side_effect_state || "not_recorded"), + payload_ref: value.payload_ref && typeof value.payload_ref === "object" ? value.payload_ref : correlation, + }; + } + + function evolutionLaneFor(stage) { + if (stage === "observe") return "environment"; + if (stage === "orient" || stage === "decide") return "decision"; + return "governance"; + } + + function evolutionSeverity(event) { + if (event.kind === "trust_frozen" || event.side_effect_state === "unknown") return "alert"; + if (event.kind.indexOf("unregistered") >= 0 || event.verification_tier === "not_recorded") return "notable"; + return "info"; + } + + function evolutionTimeLabel(event) { + const ms = Number(event.ts || 0) * 1000; + if (!Number.isFinite(ms) || ms <= 0) return "--:--:--"; + return new Date(ms).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" }); + } + + function showEvolutionDrawer(drawer, event) { + drawer.innerHTML = ""; + if (!event) { + drawer.appendChild(el("div", "card-title", esc(t("Event detail")))); + drawer.appendChild(el("div", "summary", esc(t("Select a live event to inspect its evidence references.")))); + return; + } + drawer.appendChild(el("div", "card-title", esc(event.stage + " · " + event.kind))); + drawer.appendChild(el("div", "summary", esc(event.summary || t("No entries.")))); + drawer.appendChild(el("pre", "evolution-live-json", esc(JSON.stringify({ + episode_id: event.episode_id, + evidence_level: event.evidence_level, + verification_tier: event.verification_tier, + side_effect_state: event.side_effect_state, + payload_ref: event.payload_ref, + }, null, 2)))); + } + + // Two provenances meet in this lens and must not be blended. ``Event count`` and + // ``Live since snapshot`` are recomputed from the event list on every append, so + // they are genuinely live. Everything else needs a full producer cycle -- a + // presentation event carries one fact, never a recount -- so those are labelled + // as of the snapshot instead of being redrawn as though the increment had moved + // them. The producer's own fingerprint docstring names this failure: a rendered + // value that cannot be refreshed "freezes on the page while still looking + // current, which is worse than not showing it". It held on the server and was + // then committed here, where five of six metrics sat on load-time values while + // the lanes advanced beside them. + function evolutionLiveStat(label, value, provenance) { + const stat = el("div", "stat prov-" + provenance); + stat.appendChild(el("div", "label", esc(t(label)))); + stat.appendChild(el("div", "value", esc(value))); + return stat; + } + + function renderEvolutionLive(props) { + const snapshot = props.data && typeof props.data === "object" ? props.data : {}; + const maxEvents = _clampInt(props.max_events || 60, 8, 120) || 60; + // The instant the snapshot metrics describe. Events at or before it are already + // counted in them; only strictly newer ones are uncounted increments. + const baselineAt = Number(snapshot.observed_at || 0); + const host = el("div", "evolution-live"); + const metrics = el("div", "evolution-live-metrics metric-strip"); + const drift = el("div", "evolution-live-drift"); + const lanes = el("div", "evolution-live-lanes"); + const drawer = el("div", "evolution-live-drawer card"); + const controller = { + events: asArray(snapshot.traces).map(normalizeEvolutionEvent).filter(Boolean), + maxEvents: maxEvents, + render: function () { + this.events.sort((left, right) => Number(right.ts || 0) - Number(left.ts || 0)); + this.events = this.events.slice(0, this.maxEvents); + const since = baselineAt + ? this.events.filter((event) => Number(event.ts || 0) > baselineAt).length + : 0; + metrics.innerHTML = ""; + const summary = snapshot.summary && typeof snapshot.summary === "object" ? snapshot.summary : {}; + [ + ["Event count", this.events.length, "live"], + ["Live since snapshot", since, "live"], + ["Episodes", summary.episode_count || 0, "snapshot"], + ["Mutation", summary.mutation_count || 0, "snapshot"], + ["Regressions", summary.regression_count || 0, "snapshot"], + ["Unadmitted intents", summary.unadmitted_intent_count || 0, "snapshot"], + ["Pipeline evidence", String(summary.segments_with_evidence || 0) + "/" + String(summary.segments_total || 0), "snapshot"], + ].forEach((triple) => { + metrics.appendChild(evolutionLiveStat(triple[0], triple[1], triple[2])); + }); + // Stated only when it is true. A permanent "these may be stale" caption is + // noise a reader learns to skip; a count that appears exactly when the two + // provenances have diverged is a fact, and it names what closes the gap. + drift.innerHTML = ""; + if (since > 0) { + drift.appendChild(el("div", "drift-note", esc(fmt( + "{count} event(s) arrived after this snapshot. Snapshot metrics refresh on the next monitor cycle.", + { count: since }, + )))); + } + lanes.innerHTML = ""; + const definitions = [ + ["environment", "Environment lane", "Environment events appear when a probe records a change in the surroundings."], + ["decision", "Decision lane", "Decision events appear when a recorded observation drives a capability choice."], + ["governance", "Governance lane", "Governance events appear when trust, quarantine or reclamation moves."], + ]; + definitions.forEach((definition) => { + const lane = el("section", "evolution-live-lane " + definition[0]); + lane.appendChild(el("div", "card-title", esc(t(definition[1])))); + const items = this.events.filter((event) => evolutionLaneFor(event.stage) === definition[0]); + if (!items.length) { + // An empty lane answers what would appear here and why nothing has, so + // "quiet" is distinguishable from "broken" without leaving the page. + // Reporting only "No live events" left the reader unable to tell which. + lane.appendChild(el("div", "empty-inline", esc(t("No live events")))); + lane.appendChild(el("div", "lane-hint", esc(t(definition[2])))); + } else { + items.forEach((event) => { + const row = el("button", "evolution-live-event sev-" + evolutionSeverity(event)); + row.type = "button"; + row.appendChild(el("span", "evolution-live-time", esc(evolutionTimeLabel(event)))); + row.appendChild(el("span", "evolution-live-kind", esc(event.stage + " \u00b7 " + event.kind))); + if (event.summary) row.appendChild(el("span", "evolution-live-summary", esc(event.summary))); + row.addEventListener("click", () => { showEvolutionDrawer(drawer, event); }); + lane.appendChild(row); + }); + } + lanes.appendChild(lane); + }); + }, + append: function (event) { + if (this.events.some((item) => item.event_id === event.event_id)) return; + this.events.unshift(event); + this.render(); + }, + }; + showEvolutionDrawer(drawer, null); + controller.render(); + _evolutionLiveControllers.push(controller); + host.appendChild(metrics); + host.appendChild(drift); + host.appendChild(lanes); + host.appendChild(drawer); + return host; + } + + function updateEvolutionLive(payload) { + if (getCurrentTemplate() !== "evolution_live") return; + const event = normalizeEvolutionEvent(payload); + if (!event) return; + _evolutionLiveControllers.forEach((controller) => controller.append(event)); + } + function renderSignalTimeline(props) { const box = el("div", "signal-timeline"); box._signalTimelineOptions = { maxItems: _clampInt(props.max_items || props.maxItems || 12, 1, 24) || 12 }; @@ -630,9 +1124,14 @@ function renderSparkline(data, title, opts) { const d = el("div", "chart card"); if (title) d.appendChild(el("div", "card-title", esc(tx(title)))); + // One point is kept, not discarded. A series with a single sample used to be + // filtered out and the chart reported "No entries." -- the reader was told there + // was no data when in fact there was exactly one observation, which for a board + // whose subject has just started evolving is the most important reading it has. + // A lone sample is drawn as a marker rather than an invented line. const groups = seriesGroups(data).slice(0, 4) .map((g) => ({ label: String(g.label || ""), points: asArray(g.points).map((p, i) => ({ x: p.x != null ? p.x : i, y: Number(p.y) })).filter((p) => Number.isFinite(p.y)) })) - .filter((g) => g.points.length >= 2); + .filter((g) => g.points.length >= 1); if (!groups.length) { d.appendChild(el("div", "chart-placeholder", esc(t("No entries.")))); return d; } const ys = []; groups.forEach((g) => g.points.forEach((p) => ys.push(p.y))); const min = Math.min.apply(null, ys), max = Math.max.apply(null, ys), span = (max - min) || 1; @@ -640,14 +1139,27 @@ const svg = svgEl("svg"); svg.setAttribute("viewBox", "0 0 " + W + " " + H); svg.setAttribute("preserveAspectRatio", "none"); svg.setAttribute("class", "sparkline"); const strokes = ["var(--accent)", "var(--info)", "var(--notable)", "var(--faint)"]; groups.forEach((g, gi) => { + const stroke = strokes[gi % strokes.length]; + const yAt = (p) => H - pad - ((p.y - min) / span) * (H - pad * 2); + if (g.points.length === 1) { + // Centred, because a single sample has no span to lay out along and pinning + // it to the left edge would read as the start of a trend that does not exist. + const dot = svgEl("circle"); + dot.setAttribute("cx", String(W / 2)); + dot.setAttribute("cy", yAt(g.points[0]).toFixed(1)); + dot.setAttribute("r", "3.5"); + dot.setAttribute("style", "fill:" + stroke + ";stroke:none"); + svg.appendChild(dot); + return; + } const n = Math.max(1, g.points.length - 1); - const coords = g.points.map((p, i) => (i * (W / n)).toFixed(1) + "," + (H - pad - ((p.y - min) / span) * (H - pad * 2)).toFixed(1)).join(" "); + const coords = g.points.map((p, i) => (i * (W / n)).toFixed(1) + "," + yAt(p).toFixed(1)).join(" "); if (opts && opts.area) { const poly = svgEl("polygon"); poly.setAttribute("points", "0," + (H - pad) + " " + coords + " " + W + "," + (H - pad)); - poly.setAttribute("style", "fill:" + strokes[gi % strokes.length] + ";opacity:.12;stroke:none"); svg.appendChild(poly); + poly.setAttribute("style", "fill:" + stroke + ";opacity:.12;stroke:none"); svg.appendChild(poly); } const line = svgEl("polyline"); line.setAttribute("points", coords); - line.setAttribute("style", "stroke:" + strokes[gi % strokes.length]); svg.appendChild(line); + line.setAttribute("style", "stroke:" + stroke); svg.appendChild(line); }); d.appendChild(svg); // Always name the line(s) so the chart is self-describing, even for a single @@ -1330,7 +1842,7 @@ // stayed English in all six locales; interpolated text still cannot match a // dictionary key, which is why templates keep counts in Stat and the prose // here literal. - Markdown: (n) => el("div", "md prose", esc(tx((n.props || {}).text))), + Markdown: (n) => renderMarkdown(tx((n.props || {}).text)), StoryPanel: (n) => { const p = n.props || {}; const d = el("div", "card story-panel"); d.appendChild(el("div", "card-title", esc(tx(p.title || "Storyline")))); d.appendChild(renderAbstract(p.text)); return d; }, @@ -1410,6 +1922,7 @@ function render(spec) { disposePreviews(); + _evolutionLiveControllers = []; rootEl.innerHTML = ""; figSeq = 0; tblSeq = 0; (spec.root || []).forEach((n) => rootEl.appendChild(renderNode(n))); @@ -1431,12 +1944,17 @@ const proto = location.protocol === "https:" ? "wss" : "ws"; const ws = new WebSocket(proto + "://" + location.host + "/ws?token=" + encodeURIComponent(TOKEN)); ws.onopen = () => { setConnectionStatus("live"); }; + // A reconnect may have missed bounded live events; the authoritative snapshot + // restores the live lens without asking the daemon to replay a mutation. + ws.addEventListener("open", () => { fetchView(); }); ws.onclose = () => { setConnectionStatus("reconnecting…"); setTimeout(connectWS, 3000); }; ws.onmessage = (ev) => { let msg; try { msg = JSON.parse(ev.data); } catch (_) { return; } if (msg.type === "monitor.finding") { toast(msg.payload || {}); fetchView(); } else if (msg.type === "approval_request") { showApproval(msg.payload || {}); } else if (msg.type === "watch.state") { fetchView(); } + else if (msg.type === "evolution.presentation") { updateEvolutionLive(msg.payload || {}); } + else if (msg.type === "view.resync") { fetchView(); } else if (msg.type === "signal.stream") { // Append to local signal stream buffer (max 50) if (!window._signalStream) window._signalStream = []; diff --git a/src/leapflow/dashboard/static/index.html b/src/leapflow/dashboard/static/index.html index c86b2145..de06d2a7 100644 --- a/src/leapflow/dashboard/static/index.html +++ b/src/leapflow/dashboard/static/index.html @@ -7,7 +7,7 @@ - +
@@ -30,6 +30,6 @@
Loading…
- + diff --git a/src/leapflow/dashboard/static/styles.css b/src/leapflow/dashboard/static/styles.css index 33fd6940..9d4869b4 100644 --- a/src/leapflow/dashboard/static/styles.css +++ b/src/leapflow/dashboard/static/styles.css @@ -233,9 +233,40 @@ button, .btn { } button:hover { border-color: var(--accent); color: var(--accent); } -/* ── Prose fallback ──────────────────────────────────────────────────────── */ +/* ── Prose ───────────────────────────────────────────────────────────────── */ .md { white-space: pre-wrap; } .prose { line-height: 1.55; color: var(--ink); } +/* The Markdown renderer emits blocks, so pre-wrap has to be released here or the + folded-scalar indentation the YAML carried would reappear as leading gaps. */ +.md.prose { white-space: normal; } +.md.prose > p { margin: 0 0 7px; } +.md.prose > p:last-child, .md.prose > blockquote:last-child { margin-bottom: 0; } +.md.prose > blockquote + p { margin-top: 7px; } +.md.prose > .quote { margin: 0 0 7px; } +.md.prose code, .evolution-live-lane code, .data-table code { + padding: 0 3px; background: var(--panel-2); font: 0.92em/1.4 var(--mono); + overflow-wrap: anywhere; +} + +/* ── Provenance bar (page-level freshness) ───────────────────────────────── */ +/* Above the rendered tree and on every lens: it describes the whole page, so it + must not compete with a section heading or be mistaken for one. Muted and thin + while the page is current; only the stale verdict earns colour. */ +.provenance { + display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; + margin: 0 0 12px; padding: 5px 0 6px; + border-bottom: 1px solid var(--line); + color: var(--muted); font-size: 0.79rem; letter-spacing: .02em; + font-variant-numeric: tabular-nums; +} +.provenance.is-stale { border-bottom-color: var(--alert); } +.provenance-stale { color: var(--alert); font-weight: 650; } +/* Sized down to the bar it lives in: this is a utility, not the page's action. */ +.provenance-refresh { + margin-inline-start: auto; padding: 2px 9px; + font-size: 0.76rem; color: var(--muted); +} +.provenance-refresh:disabled { color: var(--line); cursor: default; border-color: var(--line); } /* ── Toasts ──────────────────────────────────────────────────────────────── */ .toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; } @@ -370,3 +401,50 @@ button:hover { border-color: var(--accent); color: var(--accent); } border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: rgba(23, 24, 28, .015); } + +/* ── Evolution live (presentation-only event lanes) ──────────────────────── */ +.evolution-live { display: flex; flex-direction: column; gap: 10px; } +/* metric-strip supplies borders only; the custom live renderer owns its layout. */ +.evolution-live-metrics { display: flex; flex-wrap: wrap; margin-bottom: 0; } +/* Provenance is carried in the label, not the number: a snapshot-derived metric + gets a dotted underline so a reader can see at a glance which figures a live + event can move and which wait for the next producer cycle. */ +.evolution-live-metrics .prov-snapshot .label { + text-decoration: underline dotted var(--line); text-underline-offset: 3px; +} +.evolution-live-metrics .prov-live .label { color: var(--accent); } +.drift-note { + padding: 5px 9px; border-inline-start: 2px solid var(--notable); + background: var(--panel-2); color: var(--muted); font-size: .82rem; +} +/* Equal-height lanes: stretch is the grid default, but the fixed min-height meant + an empty lane stayed short and the row read as ragged. align-items keeps the + three columns level while the content decides how tall the row is. */ +.evolution-live-lanes { + display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); + align-items: stretch; gap: 9px; +} +.evolution-live-lane { + display: flex; flex-direction: column; min-width: 0; min-height: 132px; + padding: 9px; border: 1px solid var(--line); background: var(--panel); +} +/* The hint sits at the bottom of an otherwise empty lane, so the three lanes read + as one row of equal cards rather than three differently-filled boxes. */ +.evolution-live-lane .lane-hint { + margin-top: auto; padding-top: 7px; color: var(--muted); font-size: .78rem; + line-height: 1.4; border-top: 1px dashed var(--line); +} +.evolution-live-lane.environment { border-top: 3px solid var(--info); } +.evolution-live-lane.decision { border-top: 3px solid var(--notable); } +.evolution-live-lane.governance { border-top: 3px solid var(--accent); } +.evolution-live-event { display: grid; grid-template-columns: max-content 1fr; gap: 2px 7px; width: 100%; margin-top: 6px; padding: 5px 0 5px 8px; border: 0; border-left: 2px solid var(--line); text-align: left; background: transparent; } +.evolution-live-event:hover { border-left-color: var(--accent); color: inherit; } +.evolution-live-event.sev-alert { border-left-color: var(--alert); } +.evolution-live-event.sev-notable { border-left-color: var(--notable); } +.evolution-live-event.sev-info { border-left-color: var(--info); } +.evolution-live-time { grid-row: span 2; color: var(--muted); font-size: .76rem; font-variant-numeric: tabular-nums; } +.evolution-live-kind { font-weight: 650; font-size: .84rem; overflow-wrap: anywhere; } +.evolution-live-summary { grid-column: 2; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; } +.evolution-live-drawer { min-height: 76px; } +.evolution-live-json { margin: 7px 0 0; padding: 7px; overflow: auto; border-top: 1px solid var(--line); background: var(--panel-2); color: var(--muted); font: .76rem/1.45 var(--mono); } +@media (max-width: 900px) { .evolution-live-lanes { grid-template-columns: 1fr; } } diff --git a/src/leapflow/dashboard/templates/causal_trace.yaml b/src/leapflow/dashboard/templates/causal_trace.yaml new file mode 100644 index 00000000..a4033389 --- /dev/null +++ b/src/leapflow/dashboard/templates/causal_trace.yaml @@ -0,0 +1,87 @@ +# Read-only causal trace lens for the AAAI demonstration and audit sessions. +# +# It consumes the existing framework_evolution payload. The template introduces no +# actions and therefore cannot approve, install, reload, or otherwise mutate a plugin. +template: causal_trace +version: 1 +hidden: true +title: "Causal trace" +domain: framework_evolution +meta: + title: "Causal trace" + description: "Read-only environment-to-governance evidence for one framework-evolution snapshot." +layout: + - type: Page + props: + title: "Causal trace" + children: + - type: Section + when: evolution.summary + props: + title: "Evidence boundary" + subtitle: "A causal trace shows recorded facts; it does not infer missing approval or observed effect." + children: + - type: Grid + props: + cols: 4 + children: + - type: Stat + props: + label: "Episodes" + value: "{{ evolution.summary.episode_count }}" + - type: Stat + props: + label: "Self-acquired" + value: "{{ evolution.summary.self_acquired_count }}" + - type: Stat + props: + label: "Pipeline evidence" + value: "{{ evolution.summary.segments_with_evidence }}/{{ evolution.summary.segments_total }}" + - type: Stat + props: + label: "Declared-fitness closures" + value: "{{ evolution.summary.resolved_count }}" + - type: Section + when: evolution.mutation_matrix + props: + title: "Counterfactual / mutation matrix" + subtitle: "Each row preserves the driver, decision, registry delta, and verification tier." + children: + - type: Table + props: + bind: evolution.mutation_matrix + columns: + - key: driver + label: "Trigger" + - key: capability + label: "Capability" + - key: policy_action + label: "Decision" + - key: mutation_action + label: "Mutation" + - key: registry_delta + label: "Registry" + - key: lifecycle_status + label: "Lifecycle" + - key: verification_tier + label: "Evidence tier" + - key: gap_closure + label: "Gap closure" + - type: Section + when: evolution.timeline + props: + title: "Episode timeline" + subtitle: "Rebuilt from existing decision and observation records." + children: + - type: Timeline + props: + bind: evolution.timeline + - type: Section + when: evolution.trace_feed + props: + title: "Durable trace feed" + subtitle: "Rejected and no-op decisions remain visible when their trace sink is installed." + children: + - type: Timeline + props: + bind: evolution.trace_feed diff --git a/src/leapflow/dashboard/templates/evolution.yaml b/src/leapflow/dashboard/templates/evolution.yaml index d78fb74d..43ee3a92 100644 --- a/src/leapflow/dashboard/templates/evolution.yaml +++ b/src/leapflow/dashboard/templates/evolution.yaml @@ -166,6 +166,38 @@ layout: props: label: "Pipeline evidence" value: "{{ evolution.summary.segments_with_evidence }}/{{ evolution.summary.segments_total }}" + # ── The evolution axis ────────────────────────────────────────── + # Gated on the *series*, not on having two of them: the renderer draws a + # lone sample as a marker, and "one observation, here it is" is the most + # important reading a board has on the day its subject starts evolving. + # Every other panel on this page is a cross-section of one instant; this + # is the only one that answers which way the framework is moving. It sits + # outside the tabs with the posture strip because that question is not a + # detail of any one tab. + # + # Bound at ``evidence_trend`` rather than ``evolution.evidence_trend``: + # the producer owns the ``evolution.*`` namespace, and this series is + # derived by the view service from retained findings, which are the only + # thing that carries history across daemon restarts. + - type: AreaChart + when: evidence_trend.series + props: + title: "Pipeline evidence over time" + bind: evidence_trend.series + caption: "One point per recorded change in framework state, oldest first." + - type: Row + when: evidence_trend.series + props: + variant: meta + children: + - type: Stat + props: + label: "Samples" + value: "{{ evidence_trend.samples }}" + - type: Stat + props: + label: "Net change" + value: "{{ evidence_trend.delta }}" - type: Markdown when: evolution.degraded_reason props: diff --git a/src/leapflow/dashboard/templates/evolution_live.yaml b/src/leapflow/dashboard/templates/evolution_live.yaml new file mode 100644 index 00000000..c2b461bb --- /dev/null +++ b/src/leapflow/dashboard/templates/evolution_live.yaml @@ -0,0 +1,58 @@ +# Presentation-only live evolution lens for demonstrations and audits. +# +# The initial view binds the existing framework_evolution snapshot. Browser-side +# increments may append display events, but every reconnect resynchronizes from this +# immutable producer payload. No node declares an action. +# +# There is deliberately no metric row here. One used to sit above the lanes +# repeating Episodes, Pipeline evidence, Unadmitted intents and Regressions -- +# four of the six figures the live renderer already draws, forty pixels below and +# with no way to tell which of the two could move. The renderer owns the strip +# because only it knows which figures a live event can advance and which wait for +# the next producer cycle, and it labels them accordingly. Page-level freshness is +# carried by the provenance bar, above every lens. +template: evolution_live +version: 1 +hidden: true +title: "Evolution live" +domain: framework_evolution +meta: + title: "Evolution live" + description: "Read-only event lanes for environment, decision, and governance evidence." +layout: + - type: Page + props: + title: "Evolution live" + children: + - type: Section + props: + title: "Live event lanes" + subtitle: "Presentation-only trace projection. Reconnect resynchronizes from the current evolution snapshot." + children: + - type: Custom + props: + render: evolutionLive + bind: evolution + max_events: 60 + - type: Section + when: evolution.mutation_matrix + props: + title: "Counterfactual / mutation matrix" + subtitle: "Latest durable episode projection; rows do not imply an unrecorded install or approval." + children: + - type: Table + props: + bind: evolution.mutation_matrix + columns: + - key: driver + label: "Trigger" + - key: capability + label: "Capability" + - key: policy_action + label: "Decision" + - key: mutation_action + label: "Mutation" + - key: verification_tier + label: "Evidence tier" + - key: gap_closure + label: "Gap closure" diff --git a/src/leapflow/engine/engine.py b/src/leapflow/engine/engine.py index 6dc9420d..7cdf2d04 100644 --- a/src/leapflow/engine/engine.py +++ b/src/leapflow/engine/engine.py @@ -5703,7 +5703,12 @@ def _observe_capability_result(self, result: Any) -> None: registry_version_after=registry.version, mutation={ "action": "observe", - "error_type": "unknown_tool", + # The real evidence kind, not a hardcoded literal. Stamping every + # observation as "unknown_tool" made the causal ledger classify a + # world-model or environment-driven episode as an unknown-tool one, + # so the driver attribution on the board was wrong for exactly the + # episodes self-evolution cares about. + "error_type": str(result.get("error_type") or "unknown_tool"), "observation_id": (observation_record or {}).get("observation_id", ""), }, ) diff --git a/src/leapflow/learning/degradation_sink.py b/src/leapflow/learning/degradation_sink.py index a5da6b61..df609e2c 100644 --- a/src/leapflow/learning/degradation_sink.py +++ b/src/leapflow/learning/degradation_sink.py @@ -17,7 +17,7 @@ from __future__ import annotations import logging -from typing import Any, Callable, Mapping +from typing import Any, Callable, Mapping, Sequence logger = logging.getLogger(__name__) @@ -120,7 +120,7 @@ def sink( return sink -def build_proposal_sink(*, queue: Any) -> Callable[[Any], str]: +def build_proposal_sink(*, queue: Any) -> Callable[..., str]: """Return the sink that turns an accepted acquisition into a queued proposal. The last hop of the acquisition chain, and it was missing: the driver derived an @@ -134,9 +134,19 @@ def build_proposal_sink(*, queue: Any) -> Callable[[Any], str]: generated, so this hop makes the proposal *visible and actionable* rather than executed. That separation is why the sink can be wired by default while generation stays governed. + + ``observation_ids`` and ``environment`` are threaded from the driver so the queue + item carries the evidence and the task environment it was born from. The causal + ledger joins a proposal back to its motivating observations by exactly these ids; + without them a queued acquisition is an orphan the ledger cannot reconstruct. """ - def sink(proposal: Any) -> str: + def sink( + proposal: Any, + *, + observation_ids: Sequence[str] = (), + environment: Any = None, + ) -> str: requirement = _requirement_from(proposal) if requirement is None: # Without a capability the queue has nothing to deduplicate on and resolution @@ -148,14 +158,21 @@ def sink(proposal: Any) -> str: return "" evidence = tuple(getattr(proposal, "evidence", ()) or ()) metadata = dict(getattr(evidence[0], "metadata", {})) if evidence else {} + env_payload = _environment_dict(environment) try: item = queue.enqueue( requirements=(requirement,), + environment=env_payload, source="world_model", + observation_ids=tuple(str(o) for o in observation_ids if str(o)), risk={"max_risk_level": requirement.max_risk_level}, metadata={ "plugin_id": str(getattr(proposal, "plugin_id", "")), "capability_summary": str(getattr(proposal, "capability_summary", "")), + # The world model's own words and identity, carried so the ledger can + # render "why this evolved" and so a reviewer sees the hypothesis. + "intent_id": str(metadata.get("intent_id", "")), + "confidence": str(metadata.get("confidence", "")), # Carried so a reviewer can see what a challenger is challenging, and # so a rival stays distinguishable from a gap fill for the same # capability. @@ -170,6 +187,21 @@ def sink(proposal: Any) -> str: return sink +def _environment_dict(environment: Any) -> dict[str, Any]: + """Coerce a fingerprint or mapping into the queue's plain-dict environment.""" + if environment is None: + return {} + to_dict = getattr(environment, "to_dict", None) + if callable(to_dict): + try: + return dict(to_dict()) + except Exception: # noqa: BLE001 - a fingerprint is context, not a gate + return {} + if isinstance(environment, Mapping): + return dict(environment) + return {} + + def _requirement_from(proposal: Any) -> Any: """Rebuild the requirement the queue keys on, from the proposal's own evidence. diff --git a/src/leapflow/learning/world_model_driver.py b/src/leapflow/learning/world_model_driver.py index 7e3002d4..d771a409 100644 --- a/src/leapflow/learning/world_model_driver.py +++ b/src/leapflow/learning/world_model_driver.py @@ -29,6 +29,7 @@ from __future__ import annotations +import inspect import logging from dataclasses import dataclass, field from typing import Any, Mapping, Protocol, Sequence, runtime_checkable @@ -36,12 +37,38 @@ from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.domain.evolution_intent import ( MODEL_AUTHORED_RISK_CEILING, + WORLD_MODEL_ORIGIN, EvolutionIntent, ) from leapflow.domain.plugin_proposal import RiskLevel logger = logging.getLogger(__name__) +#: Exception types that mean "this call was wired wrongly", not "this datum was bad". +#: They are separated from the resilient catch-all so a contract break is reported +#: instead of being absorbed as one more skipped intent. +_INTERNAL_DEFECTS = (TypeError, AttributeError, NameError) + + +def _accepted_kwargs(target: Any, candidates: Sequence[str]) -> frozenset[str]: + """Which of ``candidates`` this callable can actually receive by keyword. + + Optional context must stay optional. A collaborator supplied by a caller keeps + whatever signature it was written against, so newer keywords are offered only to + the ones that declare them (or accept ``**kwargs``). When the signature cannot be + read -- a builtin, a C callable -- nothing extra is passed, which is the safe + direction: the original positional contract always works. + """ + if target is None: + return frozenset() + try: + parameters = inspect.signature(target).parameters + except (TypeError, ValueError): + return frozenset() + if any(p.kind is inspect.Parameter.VAR_KEYWORD for p in parameters.values()): + return frozenset(candidates) + return frozenset(name for name in candidates if name in parameters) + @runtime_checkable class CapabilityGapTeacher(Protocol): @@ -89,6 +116,15 @@ class WorldModelDriveResult: the evidence gate accepted. The two differ whenever the operator has not opted in, which is the normal default -- so a non-zero ``proposed`` with an empty ``admitted`` is a correct, quiet outcome, not a failure. + + Admission is only the first gate. An admitted requirement then passes the + authority filter: a hypothesis whose requirement origin the operator has not + authorised to drive acquisition is recorded in ``unauthorised`` -- a durable no-op, + the record of *why the framework did not change*, not dropped telemetry. Whether an + installed provider already covers the capability (rebind vs acquire) is decided + upstream by the teacher, which sees the failed-outcome hindsight the resolver never + does; re-checking it here by declared fitness would re-introduce the blind spot the + world model exists to bypass, so the driver does not. """ grades: tuple[Any, ...] = () @@ -107,6 +143,10 @@ class WorldModelDriveResult: #: Proposals queued for governed acquisition. Empty when no sink is installed, #: which is the default: an intent then reaches a requirement and stops there. queued_proposal_ids: tuple[str, ...] = () + #: Capabilities whose requirement origin may not authorise an acquisition. A + #: durable no-op, retired with its reason, so a rejected authority branch is + #: reconstructable rather than invisible. + unauthorised: tuple[str, ...] = () @property def proposed(self) -> int: @@ -122,6 +162,7 @@ def to_dict(self) -> dict[str, Any]: "proposed": self.proposed, "admitted": self.admitted, "queued": len(self.queued_proposal_ids), + "unauthorised": list(self.unauthorised), "capabilities": sorted({r.capability for r in self.requirements}), # Counted per action so a session that adapted purely by distilling # knowledge is distinguishable from one that did nothing. @@ -146,6 +187,7 @@ def __init__( proposal_sink: Any = None, knowledge_store: Any = None, alternatives_for: Any = None, + authorising_origins: Sequence[str] = (), ) -> None: self._teacher = teacher self._intake = intake @@ -162,6 +204,15 @@ def __init__( # and it stays optional because queueing proposals is a governed, opt-in # capability rather than something grading should do by default. self._proposal_sink = proposal_sink + # Which optional context this particular sink accepts. The sink is caller-supplied + # and its original contract was ``sink(proposal)``; passing newer keywords + # unconditionally raised ``TypeError`` inside the per-intent guard below, which + # swallowed it at debug level and silently stopped queueing *every* acquisition + # for any sink that had not adopted them. Resolving the signature once keeps the + # extra causal context additive instead of breaking the contract. + self._sink_kwargs = _accepted_kwargs( + proposal_sink, ("observation_ids", "environment") + ) # Where the cheap verdicts land. Three of the four actions change nothing except # what the acting agent knows, so without this they would be graded, traced, and # then thrown away -- the teacher would have judged correctly and the next @@ -173,6 +224,13 @@ def __init__( # capability covers this") and ``acquire`` ("nothing does") without being told # which is true -- the deciding fact for both. self._alternatives_for = alternatives_for + # Requirement origins permitted to drive an acquisition. Empty means + # unrestricted (shipped default). Setting it to ``("world_model",)`` is the + # executable form of "self-evolution's first driver is the world model": a + # requirement of any other origin is retired as a no-op rather than queued. + self._authorising_origins = tuple( + str(origin) for origin in (authorising_origins or ()) if str(origin) + ) async def drive( self, @@ -232,6 +290,10 @@ async def drive( # admitted, so a rejected hypothesis reached the proposal queue through a side # door -- the exact bypass the opt-in gate exists to prevent. admitted_intents: list[EvolutionIntent] = [] + # capability -> the observation ids that motivated it, so a queued proposal can + # carry the evidence back to the causal ledger instead of minting a fresh id + # the ledger cannot join. + obs_by_capability: dict[str, list[str]] = {} for intent in intents: try: record = self._intake.observe_result( @@ -250,6 +312,9 @@ async def drive( if observation_id: admitted.append(observation_id) admitted_intents.append(intent) + obs_by_capability.setdefault(intent.capability, []).append( + observation_id + ) requirements: tuple[CapabilityRequirement, ...] = () if admitted: @@ -263,6 +328,9 @@ async def drive( "'world_model_intent' to accepted_evidence_kinds to enable", len(intents), ) + queued, unauthorised = self._govern( + admitted_intents, requirements, environment, obs_by_capability, degraded + ) result = WorldModelDriveResult( grades=grades, verdicts=verdicts, @@ -270,15 +338,96 @@ async def drive( intents=intents, admitted_observation_ids=tuple(admitted), requirements=requirements, - queued_proposal_ids=( - self._queue_proposals(admitted_intents, degraded) - if admitted_intents - else () - ), + queued_proposal_ids=queued, + unauthorised=unauthorised, ) self._trace_drive(result) return result + def _govern( + self, + admitted_intents: Sequence[EvolutionIntent], + requirements: Sequence[CapabilityRequirement], + environment: Any, + obs_by_capability: Mapping[str, Sequence[str]], + degraded: Sequence[Mapping[str, Any]], + ) -> tuple[tuple[str, ...], tuple[str, ...]]: + """Turn admitted hypotheses into queued proposals, gated by authority. + + One gate stands between an admitted hypothesis and a queued proposal, and it + records its rejections rather than dropping them: a requirement whose origin + ``authorising_origins`` does not permit is retired with ``origin_not_authorised`` + -- the executable form of "only the world model may drive acquisition". + + There is deliberately no second, declared-fitness resolution-first gate here. + Rebind-vs-acquire -- whether an installed provider already covers the capability + in this environment -- is decided upstream by the teacher, which reasons from + failed-outcome hindsight and the alternatives it was shown. A declared-fitness + re-check would count a behaviourally broken but structurally present incumbent as + "satisfied" and suppress exactly the semantic-regression acquire the world model + exists to catch, so the acquire verdict is trusted as the resolution result. + + Only what survives authority is queued, and the scope is this session's admitted + intents -- they are by construction what this episode produced, so a stale + requirement from an earlier episode cannot be re-queued here. The proposal is + built from the intent itself (``proposal_from_evolution_intent``), so queueing + deliberately does not wait on the store having derived a requirement row: an + intersection with the requirement backlog silently made acquisition depend on + store thresholds and dropped every proposal when the backlog was empty. + """ + if not admitted_intents: + return (), () + capabilities = tuple( + sorted({str(getattr(i, "capability", "")) for i in admitted_intents} - {""}) + ) + # Everything this driver admits is world-model-authored, so authority is a + # single question about that origin rather than a per-requirement lookup. + if not self._origin_authorised(WORLD_MODEL_ORIGIN): + for capability in capabilities: + self._record_no_op(capability, "origin_not_authorised") + return (), capabilities + + queued = self._queue_proposals( + list(admitted_intents), + degraded, + obs_by_capability, + environment, + ) + return queued, () + + def _origin_authorised(self, origin: str) -> bool: + """Whether ``authorising_origins`` permits this origin to drive acquisition. + + Empty ``authorising_origins`` is unrestricted, so everything is authorised -- + the shipped default. The check is the same ``origin_may_authorise`` the + resolution-first gap gate uses on the observation path, so the driver and the + loop cannot disagree about who may authorise an acquisition. + """ + if not self._authorising_origins: + return True + from leapflow.learning.outcome_governance_feed import origin_may_authorise + + return bool(origin_may_authorise(origin, self._authorising_origins)) + + def _record_no_op(self, capability: str, reason: str) -> None: + """Retire a capability's evidence as a durable no-op, and trace why. + + A no-op branch is a first-class result: it is *why the framework did not + change*. Retiring the observation with a reason makes it reconstructable from + the store (the ledger reads observation status), and the trace makes it visible + on the board. Contained: bookkeeping a no-op must never fail the session. + """ + resolver = getattr(self._intake, "resolve_capability", None) + if callable(resolver): + try: + resolver(capability, reason=reason) + except Exception: # noqa: BLE001 - retirement is advisory + logger.debug( + "world_model_driver: could not retire %s (%s)", + capability, reason, exc_info=True, + ) + self._trace_no_op(capability, reason) + def _distil(self, verdicts: Any, environment: Any) -> tuple[str, ...]: """Persist what each verdict concluded, returning the capabilities recorded. @@ -387,14 +536,20 @@ def _queue_proposals( self, admitted_intents: Sequence[EvolutionIntent], degraded: Sequence[Mapping[str, Any]] = (), + obs_by_capability: Mapping[str, Sequence[str]] | None = None, + environment: Any = None, ) -> tuple[str, ...]: - """Turn *admitted* intents into queued proposals, if a sink is installed. + """Turn *unmet* intents into queued proposals, if a sink is installed. + + Takes only the intents that survived the authority and resolution-first gates, + never the full admitted set: an intent the operator has not opted into, or one + the catalog already satisfies, must not become a queued acquisition by a side + door. The proposal itself mutates nothing -- generation and installation remain + separately approval-gated -- so queueing is the last *observation-only* step. - Takes only the intents the evidence gate accepted, never the full set: an - intent the operator has not opted into must not become a queued acquisition by - a side door. The proposal itself mutates nothing -- generation and installation - remain separately approval-gated -- so queueing is the last *observation-only* - step. + The motivating ``observation_ids`` and the task ``environment`` travel with the + proposal so the causal ledger can join a queued acquisition back to the evidence + that produced it, rather than facing a proposal minted from nowhere. An intent whose capability appears in ``degraded`` is queued as a *rival* to the named incumbent rather than as a gap fill. That is a factual lookup against the @@ -408,6 +563,7 @@ def _queue_proposals( """ if self._proposal_sink is None or not admitted_intents: return () + obs_map = {k: tuple(v) for k, v in dict(obs_by_capability or {}).items()} incumbents = { str(item.get("capability") or ""): str(item.get("plugin_id") or "") for item in degraded or () @@ -428,13 +584,55 @@ def _queue_proposals( risk_ceiling=self._risk_ceiling, incumbent=incumbents.get(str(getattr(intent, "capability", "")), ""), ) - identifier = self._proposal_sink(proposal) + extra: dict[str, Any] = {} + if "observation_ids" in self._sink_kwargs: + extra["observation_ids"] = obs_map.get( + str(getattr(intent, "capability", "")), () + ) + if "environment" in self._sink_kwargs: + extra["environment"] = environment + identifier = self._proposal_sink(proposal, **extra) + except _INTERNAL_DEFECTS: + # A wiring fault, not a bad intent: the sink or the detector was called + # wrongly. Logged loudly because the loop continues -- at debug level + # this exact case hid a regression that silently disabled queueing. + logger.warning( + "world_model_driver: proposal sink rejected the call for %r; " + "acquisition not queued", + getattr(intent, "capability", ""), + exc_info=True, + ) + continue except Exception: # noqa: BLE001 - one bad intent must not stop the rest logger.debug("world_model_driver: proposal not queued", exc_info=True) continue queued.append(str(identifier or getattr(proposal, "proposal_id", ""))) return tuple(q for q in queued if q) + def _trace_no_op(self, capability: str, reason: str) -> None: + """Emit the no-op branch as a first-class evolution fact. + + An unauthorised requirement is *why the framework did not change*, which the + co-evolution contract requires to be as visible as why it did. Emitting it here + means the board can distinguish "the world model saw a gap it was not permitted + to act on" from "the world model saw nothing". + """ + try: + from leapflow.domain.evolution_trace import EvolutionStage + from leapflow.telemetry.evolution_tap import emit_trace, is_enabled + + if not is_enabled(): + return + emit_trace( + EvolutionStage.DECIDE, + "world_model_no_op", + correlation={"capability": str(capability)}, + summary=f"{capability}: {reason}", + detail={"capability": str(capability), "reason": str(reason)}, + ) + except Exception: # noqa: BLE001 - the teacher is advisory; telemetry more so + logger.debug("world_model_driver: no-op trace failed", exc_info=True) + def _trace_drive(self, result: WorldModelDriveResult) -> None: """Emit what the teacher concluded, admitted or not. @@ -482,6 +680,7 @@ def _trace_drive(self, result: WorldModelDriveResult) -> None: "intents": [self._intent_detail(i) for i in intents], "admitted_observation_ids": list(admitted), "queued_proposal_ids": list(result.queued_proposal_ids), + "unauthorised": list(result.unauthorised), "graded": len(result.grades), "requirements": len(result.requirements), "not_admitted_reason": ( diff --git a/src/leapflow/llm/openai_provider.py b/src/leapflow/llm/openai_provider.py index 0392789b..4edf53a1 100644 --- a/src/leapflow/llm/openai_provider.py +++ b/src/leapflow/llm/openai_provider.py @@ -138,8 +138,17 @@ def __init__( write=30.0, pool=30.0, ) - self._sync = OpenAI(api_key=api_key, base_url=base_url, timeout=timeout) - self._async = AsyncOpenAI(api_key=api_key, base_url=base_url, timeout=timeout) + # ``max_retries=0`` is load-bearing: the SDK retries twice by default, and this + # class already owns a retry policy with backoff. Leaving the SDK's default in + # place multiplies them -- effective attempts become ``max_retries * 3`` and a + # hard timeout blocks for three times the configured budget before surfacing, + # which breaks the turn-level deadline and recovery-budget accounting that + # assume ``timeout_s`` bounds one attempt. Measured: a 45s timeout failed after + # 137s. One retry owner, and it is this class. + self._sync = OpenAI(api_key=api_key, base_url=base_url, timeout=timeout, max_retries=0) + self._async = AsyncOpenAI( + api_key=api_key, base_url=base_url, timeout=timeout, max_retries=0 + ) self._model = model self._max_retries = max(1, int(max_retries)) self._base_url = base_url diff --git a/src/leapflow/monitor/evolution_producer.py b/src/leapflow/monitor/evolution_producer.py index b90b4d9c..541bfaad 100644 --- a/src/leapflow/monitor/evolution_producer.py +++ b/src/leapflow/monitor/evolution_producer.py @@ -121,6 +121,13 @@ def _percent(value: Any) -> str: UNVERIFIABLE = "unverifiable" NOT_ADMITTED = "not_admitted" +# Acquisition-lifecycle states a record is *created* in. Anything else is proof +# that something read the queue back and advanced it, which is what distinguishes a +# governed queue from a write-only one. Kept as a set of entry states rather than a +# list of advanced ones so a new terminal state cannot silently read as "not yet +# governed" (see storage.capability_proposal_queue.ProposalStatus). +_LIFECYCLE_ENTRY_STATES = frozenset({"PENDING", "UNKNOWN", ""}) + class EvolutionProducer: """Emit one framework-evolution snapshot per cycle.""" @@ -993,7 +1000,19 @@ def _segment_observations(self, store: Any) -> dict[str, Any]: ) def _segment_lifecycle(self) -> dict[str, Any]: - """Whether the trust/probation/quarantine tier has anything to govern.""" + """Whether the trust/probation/quarantine tier is actually governing. + + A non-empty queue used to be reported ``wired``, which read as the healthy + class beside a genuinely healthy ``Trust accrual``. On a real profile that + was 212 records, every one of them ``PENDING``, none carrying a policy + decision or install result, all of them written by ``plugin_propose`` and + nothing draining them: a monotonically growing dead end presented as a + working segment. + + So the evidence is a *transition*, not a row count. Records existing prove + the queue is writable; a record past ``PENDING`` proves something reads it + back and advances it, which is the only thing this segment claims to check. + """ store = self._json_store("capability_proposal_queue_path", "capability_proposal_queue", "JsonCapabilityProposalQueue") if store is None: return self._row("lifecycle", "Lifecycle records", UNVERIFIABLE, "queue unreadable") @@ -1008,7 +1027,25 @@ def _segment_lifecycle(self) -> dict[str, Any]: status = str(getattr(item, "status", "") or "unknown") counts[status] = counts.get(status, 0) + 1 spread = ", ".join(f"{k}={v}" for k, v in sorted(counts.items())) - return self._row("lifecycle", "Lifecycle records", WIRED, spread) + advanced = sum( + count for status, count in counts.items() + if status.upper() not in _LIFECYCLE_ENTRY_STATES + ) + if advanced: + return self._row("lifecycle", "Lifecycle records", WIRED, spread) + # Entry state only. The queue is written but never read back, so the + # governor is not running -- and the row says which way the count grows. + return self._row( + "lifecycle", + "Lifecycle records", + NO_EVIDENCE, + spread, + next_step=( + f"{len(items)} record(s) have never left their entry state, so nothing " + "reads the queue back. The governor advances a record only when the " + "co-evolution sweep runs; until then the queue only grows." + ), + ) return self._row( "lifecycle", "Lifecycle records", diff --git a/src/leapflow/monitor/manager.py b/src/leapflow/monitor/manager.py index 1c8227de..38355ab1 100644 --- a/src/leapflow/monitor/manager.py +++ b/src/leapflow/monitor/manager.py @@ -356,6 +356,13 @@ async def run_watch_once(self, watch_id: str, *, force: bool = False) -> dict: Bypasses the tick timer while reusing the same producer -> persist -> push path, so a user-triggered refresh is identical to a scheduled one. ``force=True`` signals producers to re-analyze even without new input. + + Run bookkeeping is applied here because it is the scheduler that normally + does it, and this path deliberately skips the scheduler. Without it a manual + refresh left no trace at all: findings dedup on content, so a cycle that + confirmed "nothing changed" wrote nothing and advanced nothing, and the board + could not tell a refresh that ran from one that never happened -- which is + precisely what a reader presses refresh to find out. """ task = self._task_store.load(watch_id) if task is None or not _is_watch(task): @@ -364,7 +371,15 @@ async def run_watch_once(self, watch_id: str, *, force: bool = False) -> dict: params.setdefault("watch_id", task.task_id) if force: params["_force"] = True - return await self._executor.execute(task.skill_name, params) + result = await self._executor.execute(task.skill_name, params) + # After the cycle, not before: ``last_run_at`` means "a cycle completed", + # and a producer that raised did not complete one. + if isinstance(result, dict) and result.get("ok"): + try: + self._task_store.increment_run_count(task.task_id) + except Exception: # noqa: BLE001 - bookkeeping must not fail the refresh + logger.debug("monitor: run bookkeeping failed for %s", watch_id, exc_info=True) + return result def schedule_watch_once(self, watch_id: str, *, force: bool = False) -> None: """Fire one observation cycle in the background (non-blocking). @@ -398,6 +413,7 @@ def _transition(self, watch_id: str, state: str) -> Optional[WatchView]: def _to_view(self, task: ArmedTask) -> WatchView: meta = task.metadata if isinstance(task.metadata, dict) else {} params = task.parameters if isinstance(task.parameters, dict) else {} + cfg = task.trigger_config if isinstance(task.trigger_config, dict) else {} return WatchView( watch_id=task.task_id, name=str(params.get("name") or task.task_id[:8]), @@ -410,6 +426,15 @@ def _to_view(self, task: ArmedTask) -> WatchView: last_run_at=task.last_run_at, finding_count=self._finding_store.count(watch_id=task.task_id), client_coupled=bool(meta.get(METADATA_CLIENT_COUPLED_KEY, False)), + # Only an interval trigger has one. Left at 0.0 for event, cron and + # condition watches, which the board reads as "no cadence to judge + # against" and so withholds a staleness verdict rather than inventing + # an interval for a watch that does not have one. + interval_seconds=( + float(cfg.get("interval_seconds", 0) or 0) + if task.trigger_type == "interval" + else 0.0 + ), ) def _emit_state(self, task: ArmedTask) -> None: diff --git a/src/leapflow/monitor/types.py b/src/leapflow/monitor/types.py index 1618c92a..3dcc5467 100644 --- a/src/leapflow/monitor/types.py +++ b/src/leapflow/monitor/types.py @@ -266,6 +266,12 @@ class WatchView: last_run_at: float finding_count: int = 0 client_coupled: bool = False + # Declared cadence in seconds, 0.0 for a watch with no fixed one (event, cron, + # condition). Exposed because the board judges its own freshness against it: a + # page two cadences past its last observation is stale, and only the watch knows + # what one cadence is. Deriving it from ``next_due_at - last_run_at`` was the + # alternative and is wrong after a skipped or forced run. + interval_seconds: float = 0.0 def to_dict(self) -> dict[str, Any]: return { @@ -280,6 +286,7 @@ def to_dict(self) -> dict[str, Any]: "last_run_at": self.last_run_at, "finding_count": self.finding_count, "client_coupled": self.client_coupled, + "interval_seconds": self.interval_seconds, } diff --git a/src/leapflow/plugins/tool_plugins/self_management.py b/src/leapflow/plugins/tool_plugins/self_management.py index 826e4971..2a519ce8 100644 --- a/src/leapflow/plugins/tool_plugins/self_management.py +++ b/src/leapflow/plugins/tool_plugins/self_management.py @@ -590,12 +590,16 @@ async def _plugin_generate_handler( the LLM generates conformant plugin code, and it's rigorously validated. Installation is a SEPARATE approval-gated step (plugin_install). """ + provides_capabilities: tuple[str, ...] = () + source = "" if proposal_id: - proposal = self._proposal_store().get(proposal_id) - if proposal is None: + source, resolved_plugin_id, resolved_description, provides_capabilities = ( + self._resolve_generation_source(proposal_id) + ) + if not source: return {"ok": False, "error": f"Plugin proposal '{proposal_id}' not found"} - plugin_id = plugin_id or proposal.plugin_id - description = description or proposal.capability_summary + plugin_id = plugin_id or resolved_plugin_id + description = description or resolved_description if not plugin_id or not description: return { "ok": False, @@ -631,17 +635,83 @@ async def _plugin_generate_handler( request = PluginGenerationRequest( plugin_id=plugin_id, description=description, - provides_capabilities=_declared_capabilities(proposal if proposal_id else None), + provides_capabilities=provides_capabilities, ) result = await generator.generate_and_validate(request) if proposal_id: result["proposal_id"] = proposal_id if result.get("ok"): - self._proposal_store().update_status(proposal_id, "review") + self._mark_generation_started(source, proposal_id) return result except (AttributeError, RuntimeError) as exc: return {"ok": False, "error": f"Generation failed: {exc}"} + def _resolve_generation_source( + self, proposal_id: str + ) -> tuple[str, str, str, tuple[str, ...]]: + """Resolve a generation request from *either* proposal store. + + Two stores can name a proposal, and both must reach generation: + + * the **review store** (``JsonPluginProposalStore``) holds a rich + ``PluginProposal`` created by the manual ``plugin_propose`` UX flow; + * the **lifecycle queue** (``JsonCapabilityProposalQueue``) holds the + acquisition record the world-model driver enqueues -- a + ``prop-`` id keyed on the requirement, carrying the capability, + the ``plugin_id`` the sink stamped, and the hypothesis as its summary. + + Before this, ``plugin_generate`` looked only in the review store, so a + world-model proposal could never be generated from its own id: Scene C could + not proceed from a real teacher verdict to a validated artifact. Returning a + normalised ``(source, plugin_id, description, provides_capabilities)`` unifies + the two consumption points without collapsing their distinct lifecycle + vocabularies. ``source`` is ``""`` when neither store knows the id. + """ + review = self._proposal_store().get(proposal_id) + if review is not None: + return ( + "review", + str(review.plugin_id), + str(review.capability_summary), + _declared_capabilities(review), + ) + try: + item = self._lifecycle_store().get(proposal_id) + except (RuntimeError, OSError, ValueError, AttributeError): + item = None + if item is not None: + requirements = [dict(r) for r in (item.requirements or ())] + capability = str((requirements[0].get("capability") if requirements else "") or "") + metadata = dict(item.metadata or {}) + plugin_id = str(metadata.get("plugin_id") or "") + description = str( + metadata.get("capability_summary") + or (requirements[0].get("evidence") if requirements else "") + or capability + ) + provides = (capability,) if capability else () + return ("lifecycle", plugin_id, description, provides) + return ("", "", "", ()) + + def _mark_generation_started(self, source: str, proposal_id: str) -> None: + """Advance the proposal's status in whichever store owns it. + + The two stores speak different vocabularies on purpose (see + ``evolution_contracts``): the review store moves to ``review`` (a human-accept + state), the lifecycle queue to ``GENERATED`` (an acquisition-lifecycle state + ``AdaptiveEvolutionPolicy`` reads next). Contained: a status write must not fail + a generation that already succeeded. + """ + try: + if source == "review": + self._proposal_store().update_status(proposal_id, "review") + elif source == "lifecycle": + self._lifecycle_store().update(proposal_id, status="GENERATED") + except (RuntimeError, OSError, ValueError, AttributeError): + logger.debug( + "plugin_generate: could not advance %s status", proposal_id, exc_info=True + ) + # ── Compatibility assessment (read-only) ───────────────── async def _assess_compatibility_handler( diff --git a/src/leapflow/storage/capability_proposal_queue.py b/src/leapflow/storage/capability_proposal_queue.py index d8f3d28f..84648857 100644 --- a/src/leapflow/storage/capability_proposal_queue.py +++ b/src/leapflow/storage/capability_proposal_queue.py @@ -115,7 +115,7 @@ def enqueue( ) -> CapabilityProposalItem: """Create or return an active proposal for the requirement/environment pair.""" req_payload = tuple(_requirement_dict(item) for item in requirements) - proposal_id = self._proposal_id(req_payload, environment or {}, observation_ids) + proposal_id = self._proposal_id(req_payload, environment or {}) existing = self.get(proposal_id) if existing is not None and existing.status in _ACTIVE_STATUSES: return existing @@ -203,9 +203,11 @@ def list_items( return items if limit <= 0 else items[:limit] def active(self, *, limit: int = 50) -> list[CapabilityProposalItem]: - return [item for item in self.list_items(limit=0) if item.status in _ACTIVE_STATUSES][ - :limit - ] + # ``limit <= 0`` means "all", matching ``list_items``. Slicing ``[:limit]`` + # unconditionally made ``active(limit=0)`` return an empty list -- the opposite + # of "no cap" -- which silently emptied any caller that asked for the full set. + items = [item for item in self.list_items(limit=0) if item.status in _ACTIVE_STATUSES] + return items if limit <= 0 else items[:limit] def _upsert(self, item: CapabilityProposalItem) -> None: payload = self._load_payload() @@ -219,16 +221,40 @@ def _proposal_id( self, requirements: Sequence[Mapping[str, Any]], environment: Mapping[str, Any], - observation_ids: Sequence[str], ) -> str: + """A content id over *stable identity only*, so dedup survives rewording. + + Hashing the whole requirement payload made the id a function of the free-text + ``evidence`` (the world model's hypothesis) and its metadata, so the same + capability re-proposed with different wording every session minted a fresh id + and the queue filled with duplicates -- the health of the queue then measured + how long the process had run rather than how many real gaps existed. Identity is + what a requirement *is* (its id, capability, origin, risk ceiling and platform + needs) plus the environment fingerprint it was raised in; the prose that + justifies it is not identity. ``observation_ids`` are carried on the item for + the causal ledger but deliberately excluded here: two profiles observing the + same gap mint different observation ids, and folding those into identity would + defeat dedup for the very case it exists to collapse. + """ + identity = [ + { + "requirement_id": str(item.get("requirement_id") or ""), + "capability": str(item.get("capability") or ""), + "origin": str(item.get("origin") or ""), + "max_risk_level": str(item.get("max_risk_level") or ""), + "required_platform_capabilities": sorted( + str(cap) for cap in (item.get("required_platform_capabilities") or []) + ), + } + for item in requirements + ] material = { - "requirements": [dict(item) for item in requirements], + "identity": identity, "environment": { "fingerprint_id": environment.get("fingerprint_id", ""), "platform_capabilities": environment.get("platform_capabilities", []), "workspace_markers": environment.get("workspace_markers", []), }, - "observation_ids": sorted(str(item) for item in observation_ids), } text = json.dumps(material, sort_keys=True, ensure_ascii=False, default=str) import hashlib diff --git a/src/leapflow/telemetry/evolution_presentation.py b/src/leapflow/telemetry/evolution_presentation.py new file mode 100644 index 00000000..60a11901 --- /dev/null +++ b/src/leapflow/telemetry/evolution_presentation.py @@ -0,0 +1,91 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Read-only presentation projection for one runtime evolution trace. + +The projection is intentionally smaller than :class:`EvolutionTrace`: it carries +only the stable identifiers and labels a live display needs. It is created after a +trace has been buffered, then published from the daemon event loop. It never +persists, approves, selects, or mutates anything. +""" + +from __future__ import annotations + +from dataclasses import dataclass +from typing import Any, Mapping + +from leapflow.domain.evolution_trace import EvolutionTrace + + +@dataclass(frozen=True) +class EvolutionPresentationEvent: + """One safe, display-oriented view of a runtime evolution fact.""" + + event_id: str + episode_id: str + stage: str + kind: str + ts: float + correlation: Mapping[str, str] + payload_ref: Mapping[str, str] + summary: str + evidence_level: str + verification_tier: str + side_effect_state: str + + @classmethod + def from_trace(cls, trace: EvolutionTrace) -> "EvolutionPresentationEvent": + """Project a trace without exposing its unbounded domain-private detail.""" + correlation = {str(key): str(value) for key, value in trace.correlation.items() if str(value)} + detail = dict(trace.detail) + episode_id = ( + correlation.get("record_id") + or correlation.get("intent_id") + or correlation.get("requirement_id") + or correlation.get("observation_id") + or correlation.get("lifecycle_proposal_id") + or trace.trace_id + ) + payload_ref = { + key: value + for key, value in correlation.items() + if key in { + "record_id", + "intent_id", + "requirement_id", + "observation_id", + "lifecycle_proposal_id", + "plugin_id", + "registry_version", + } + } + return cls( + event_id=trace.trace_id, + episode_id=episode_id, + stage=trace.stage.value, + kind=trace.kind, + ts=trace.ts, + correlation=correlation, + payload_ref=payload_ref, + summary=trace.summary, + evidence_level=str(detail.get("evidence_level") or "runtime_trace"), + verification_tier=str(detail.get("verification_tier") or "not_recorded"), + side_effect_state=str(detail.get("side_effect_state") or "not_recorded"), + ) + + def to_dict(self) -> dict[str, Any]: + """Return the JSON-safe event shape delivered to display clients.""" + return { + "event_id": self.event_id, + "episode_id": self.episode_id, + "stage": self.stage, + "kind": self.kind, + "ts": self.ts, + "correlation": dict(self.correlation), + "payload_ref": dict(self.payload_ref), + "summary": self.summary, + "evidence_level": self.evidence_level, + "verification_tier": self.verification_tier, + "side_effect_state": self.side_effect_state, + } + + +__all__ = ["EvolutionPresentationEvent"] diff --git a/src/leapflow/version.py b/src/leapflow/version.py index 441a47b0..bf3c1dd4 100644 --- a/src/leapflow/version.py +++ b/src/leapflow/version.py @@ -1,4 +1,4 @@ # Copyright (c) Alibaba, Inc. and its affiliates. """Version information for leapflow.""" -__version__ = "0.2.1+main" +__version__ = "0.3.0+main" diff --git a/src/leapflow/world_model/prediction.py b/src/leapflow/world_model/prediction.py index 6378fa58..3a83805c 100644 --- a/src/leapflow/world_model/prediction.py +++ b/src/leapflow/world_model/prediction.py @@ -16,6 +16,7 @@ import logging import time +from collections import deque from dataclasses import dataclass, replace from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, Tuple @@ -30,6 +31,12 @@ logger = logging.getLogger(__name__) +# Trajectory buffer ceiling. Sized for a long working session rather than a single +# task: the teacher grades the whole arc, so cutting it too fine would hide the +# early steps that explain a late failure. It exists to stop a long-lived daemon +# growing without bound, not to scope one episode -- the learning boundary does that. +_MAX_TRAJECTORY_STEPS = 2000 + _PREDICT_PROMPT = """\ Given the current state: - App: {app_bundle_id} | Window: {window_title} @@ -130,7 +137,14 @@ def __init__( self._failure_advantage = failure_advantage self._on_outcome = on_prediction_outcome self._hardware_learning_enabled = hardware_learning_enabled - self._trajectory_buffer: list[dict] = [] + # Bounded, because the only thing that drains it is the learning boundary and + # in daemon mode that used to be process shutdown: an unbounded list then + # accumulated every turn of every session for the daemon's whole lifetime. + # A deque discards oldest-first, which is the right end to lose -- the + # teacher grades with hindsight, so the most recent steps carry the most + # signal, and a truncated tail is far better than unbounded growth in a + # long-lived process. + self._trajectory_buffer: deque[dict] = deque(maxlen=_MAX_TRAJECTORY_STEPS) self._last_goal: str = "" self._pending_pre_snapshot: Any = None diff --git a/src/leapspace/app_space/actor.py b/src/leapspace/app_space/actor.py index 53e75fd8..1e7df6d7 100644 --- a/src/leapspace/app_space/actor.py +++ b/src/leapspace/app_space/actor.py @@ -49,7 +49,7 @@ from mcp.client.session import ClientSession from mcp.client.streamable_http import streamable_http_client -from leapspace.app_space.utils import ( +from leapspace.app_space.state import ( CUA_MCP_PORT, LINUX_LEAPFLOW_SRC, get_actor_stage_dir, diff --git a/src/leapspace/app_space/apps/_base.py b/src/leapspace/app_space/apps/_base.py index 9c6f9b31..156fceb5 100644 --- a/src/leapspace/app_space/apps/_base.py +++ b/src/leapspace/app_space/apps/_base.py @@ -64,7 +64,7 @@ QWidget, ) -from leapspace.app_space.utils import get_sandbox_state_dir, write_atomic +from leapspace.app_space.state import get_sandbox_state_dir, write_atomic # Widget types an agent may act on; self-check requires each to be named. INTERACTIVE_TYPES: tuple[type[QWidget], ...] = ( @@ -94,6 +94,16 @@ class BaseLeapApp(QMainWindow, ABC, metaclass=_LeapAppMeta): app_title: ClassVar[str] version: ClassVar[str] + # App-level affordances this version of the surface offers, e.g. + # ``("app.chat.v2",)``. Declared, never inferred: a capability provider states + # which affordances it needs (``requires_environment_affordances``) and the + # resolver excludes one the environment does not offer, so this is the channel + # that lets an app version express "the way to do this changed". Deliberately + # separate from *host* platform capabilities -- an app affordance is a property + # of the surface, not of the machine. Empty by default: an app that models no + # affordance simply says nothing. + affordances: ClassVar[tuple[str, ...]] = () + # Hook points this app opens to task hooks; apps extend with their own # before_xxx/after_xxx points (a superset tuple, always keeping # "before_launch" — the base fires it in the template below). @@ -367,6 +377,18 @@ def _persist(self) -> None: "app_title": self.app_title, "version": self.version, "interface": sorted(self._interface), + # App-level affordances this version declares (see the ClassVar). Part of + # the ground truth because an environment probe compares them across + # versions to tell an affordance migration from a pure rename. + "affordances": list(type(self).affordances), + # Role-aware structural view of the bound interface, derived from the + # live widget tree (not the declared name list). This is the AX-like + # signal LeapFlow's perception reads to tell one control from another + # and to name *which* element changed -- a renamed or removed control + # shows up here as a changed role/name set, which a bare name list can + # show only as "the set changed". Additive: consumers that read only + # ``interface`` are unaffected. + "elements": self._structure(), "a11y_violations": list(self._violations), "data": self._snapshot_data(), } @@ -379,3 +401,24 @@ def _persist(self) -> None: self._state_dir / "events.jsonl", "".join(json.dumps(event) + "\n" for event in self._events), ) + + def _structure(self) -> list[dict[str, Any]]: + """Role-aware view of the bound interface: ``[{name, role, enabled}]``. + + ``role`` is the Qt widget class (``QPushButton``, ``QLineEdit``, ...), the + closest headless analogue of an accessibility role. Derived from the live + widget objects ``bind`` recorded, so it tracks the real UI rather than a + declaration. Each widget read is guarded: a persist during teardown (the + C++ object already gone) must degrade to a stable placeholder, never crash + the ground-truth write. + """ + structure: list[dict[str, Any]] = [] + for name in sorted(self._interface): + widget = self._interface[name] + try: + role = type(widget).__name__ + enabled = bool(widget.isEnabled()) + except RuntimeError: + role, enabled = "QWidget", True + structure.append({"name": name, "role": role, "enabled": enabled}) + return structure diff --git a/src/leapspace/app_space/harness.py b/src/leapspace/app_space/harness.py index 152844c4..8824eb1f 100644 --- a/src/leapspace/app_space/harness.py +++ b/src/leapspace/app_space/harness.py @@ -29,9 +29,9 @@ RECORD_START_FILE, RECORD_STOP_FILE, ) -from leapspace.app_space.utils import ( +from leapspace.app_space.image import get_image +from leapspace.app_space.state import ( LeapAppImage, - get_image, get_image_venv_python, get_sandbox_state_dir, load_action, diff --git a/src/leapspace/app_space/host_rpc.py b/src/leapspace/app_space/host_rpc.py new file mode 100644 index 00000000..40010614 --- /dev/null +++ b/src/leapspace/app_space/host_rpc.py @@ -0,0 +1,162 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""LeapSpaceHostRpc — serve LeapFlow's HostRpc from leapspace ground truth. + +EVO-02 LS-3. The missing adapter that lets the *shipped* LeapFlow perception +(``StateSnapshotService``) observe a leapspace environment directly, instead of +LeapFlow's snapshots being disconnected from the environment the apps actually +render. It reads the ground truth ``BaseLeapApp`` already writes -- ``state.json`` +per app under the shared state root -- and answers the ``HostRpc`` method set +LeapFlow calls (``ax.tree``, ``window.active``, ``clipboard.get``, ``app.list``). + +Design constraints (executable, not aspirational): + +* **Stdlib only, no host SDK.** It reads JSON files; it never imports + ``cua_sandbox``. So it runs headless -- an offscreen Qt app (or any producer of + the real envelope) writes ``state.json`` and LeapFlow observes it, on any host, + with no hypervisor. +* **No LeapFlow import.** It satisfies the ``HostRpc`` Protocol structurally + (one ``async call`` method), keeping the dependency direction one-way: leapspace + never imports engine/registry/perception. The connection is a discoverable + adapter, which is what "Everything Is a Plugin" requires here. +* **Never raises.** An unknown method or a missing/corrupt ``state.json`` returns + a structured empty result, matching how ``StateSnapshotService`` already treats + RPC facets that degrade -- an absent environment lowers fidelity, it does not + fail a turn. + +Pixels are deliberately absent (``screen.capture_frame`` returns ``{}``): a +headless run has no framebuffer. The real-AX/pixel tier belongs to the VM lane +where the CUA driver is present; this adapter delivers the structural + event +signal that lane and this one share. +""" + +from __future__ import annotations + +import json +import logging +from pathlib import Path +from typing import Any, Dict, Optional + +logger = logging.getLogger(__name__) + + +class LeapSpaceHostRpc: + """A ``HostRpc`` backed by the app state root a leapspace run writes to. + + ``state_root`` is the directory holding one ``/`` subdir per running + app (the ``get_sandbox_state_dir`` convention); each subdir carries the app's + atomically written ``state.json`` and ``events.jsonl``. + """ + + def __init__(self, state_root: Path | str) -> None: + self._root = Path(state_root) + + async def call(self, method: str, params: Optional[Dict[str, Any]] = None) -> Any: + """Answer one HostRpc method from the on-disk ground truth.""" + params = dict(params or {}) + if method == "ax.tree": + return self._ax_tree(str(params.get("app_id") or "")) + if method == "window.active": + return self._window_active() + if method == "clipboard.get": + # A leapspace app models no system clipboard; report empty rather + # than fabricate, so the snapshot's clipboard facet is honestly blank. + return {"text": ""} + if method == "app.list": + return {"apps": self._app_ids()} + if method == "screen.capture_frame": + # No framebuffer headless; the phash facet degrades to empty. + return {} + # Unknown method: structured, non-raising, matching the graceful-degrade + # contract every HostRpc caller in LeapFlow already assumes. + return {"error": "unsupported_method", "method": str(method)} + + # ── ground-truth reads ──────────────────────────────────────────────── + + def _ax_tree(self, app_id: str) -> Dict[str, Any]: + """Structural element list for one app, in the shape ax.tree consumers read. + + Prefers an enriched ``elements`` channel (role + name), which a + role-aware ``BaseLeapApp`` can emit; falls back to the always-present + ``interface`` names so the digest is meaningful even before that + enrichment lands. Either way a rename/removal changes the element set, + which is exactly the structural signal a hash-only ``ax_digest`` needs. + """ + envelope = self._read_state(app_id) if app_id else self._read_active_state() + if not envelope: + return {"elements": []} + elements = _elements_from_envelope(envelope) + return { + "app_id": str(envelope.get("app_id") or ""), + "app_title": str(envelope.get("app_title") or ""), + "version": str(envelope.get("version") or ""), + "elements": elements, + } + + def _window_active(self) -> Dict[str, Any]: + envelope = self._read_active_state() + if not envelope: + return {"app_id": "", "title": ""} + return { + "app_id": str(envelope.get("app_id") or ""), + "title": str(envelope.get("app_title") or ""), + } + + def _app_ids(self) -> list[str]: + if not self._root.exists(): + return [] + return sorted( + child.name + for child in self._root.iterdir() + if child.is_dir() + and not child.name.startswith(".") + and (child / "state.json").exists() + ) + + def _read_state(self, app_id: str) -> Dict[str, Any]: + path = self._root / app_id / "state.json" + try: + data = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError, TypeError, ValueError): + return {} + return data if isinstance(data, dict) else {} + + def _read_active_state(self) -> Dict[str, Any]: + """The most recently modified app state -- the closest thing to focus. + + A single-app run has exactly one; a multi-app run reports the one whose + ground truth changed last, which is the app the last action touched. + """ + latest: tuple[float, Dict[str, Any]] | None = None + for app_id in self._app_ids(): + path = self._root / app_id / "state.json" + try: + mtime = path.stat().st_mtime + except OSError: + continue + envelope = self._read_state(app_id) + if envelope and (latest is None or mtime > latest[0]): + latest = (mtime, envelope) + return latest[1] if latest is not None else {} + + +def _elements_from_envelope(envelope: Dict[str, Any]) -> list[Dict[str, str]]: + """Project a state envelope into ``[{role, label}]`` for ax.tree consumers.""" + raw = envelope.get("elements") + if isinstance(raw, list) and raw: + rendered: list[Dict[str, str]] = [] + for item in raw: + if isinstance(item, dict): + label = str(item.get("name") or item.get("label") or "") + if label: + rendered.append({"role": str(item.get("role") or "widget"), "label": label}) + if rendered: + return rendered + # Fallback: the always-present interface names. Role is unknown headless, so + # it is reported uniformly; the label carries the identity a delta keys on. + interface = envelope.get("interface") + if isinstance(interface, list): + return [{"role": "widget", "label": str(name)} for name in interface if str(name)] + return [] + + +__all__ = ["LeapSpaceHostRpc"] diff --git a/src/leapspace/app_space/image.py b/src/leapspace/app_space/image.py new file mode 100644 index 00000000..521606d4 --- /dev/null +++ b/src/leapspace/app_space/image.py @@ -0,0 +1,78 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Host-only leapspace image construction. + +This is the half of the former ``utils.py`` that must import the host SDK +(``cua_sandbox``). It is kept strictly separate from ``state.py`` (EVO-02 LS-1) +so that importing the in-box verdict, the pure state helpers, or the PyQt6 apps +never drags in ``cua_sandbox`` -- the coupling that made a headless/off-sandbox +run impossible. Only the harness (which already needs the sandbox to boot a VM) +imports this module. +""" + +from __future__ import annotations + +import os +import subprocess +import tempfile +from pathlib import Path + +from cua_sandbox import Image + +from leapspace.app_space.state import ( + CUA_MCP_PORT, + LEAPFLOW_ARCHIVE_DST, + LINUX_LEAPFLOW_PATH, + PYQT_SYSTEM_LIBS, + LeapAppImage, +) + + +def _archive_checkout() -> Path: + """Pack this checkout's committed state for the image to copy in. + + The build VM reaches GitHub only through the host's flaky link, so the + repo travels as a host-built archive: no in-box clone, and the box runs + exactly the code under test (HEAD, not some remote ref). + """ + repo_root = Path(__file__).resolve().parents[3] + fd, name = tempfile.mkstemp(suffix=".tar.gz") + os.close(fd) + result = subprocess.run( + ["git", "archive", "--format=tar.gz", "-o", name, "HEAD"], + cwd=repo_root, + capture_output=True, + text=True, + ) + if result.returncode != 0: + raise RuntimeError(f"git archive failed: {result.stderr.strip()}") + return Path(name) + + +def get_image(image: LeapAppImage) -> Image: + """Return the preset image spec, rooted in an archive of this checkout. + + Image is frozen and chainable -- every mutation returns a new instance -- + so callers get a fresh spec (and a fresh archive) per run. needrestart + is removed before apt: installing python3-dev upgrades service + libraries, and needrestart's service restarts SIGTERM the layer's own + command transport. Host feasibility: LINUX runs under local QEMU+KVM; + WINDOWS is untested; MACOS requires an Apple Silicon host (Lume). + """ + archive = _archive_checkout() + if image == LeapAppImage.LINUX: + return ( + Image.linux(distro="ubuntu", version="24.04", kind="vm") + .expose(CUA_MCP_PORT) + .run("sudo apt-get remove -y needrestart") + .apt_install("python3-pyatspi", "python3-dev", *PYQT_SYSTEM_LIBS, "git", "make") + .pip_install("PyQt6", "uv") + .copy(str(archive), LEAPFLOW_ARCHIVE_DST) + .run( + f"mkdir -p {LINUX_LEAPFLOW_PATH} && " + f"tar xzf {LEAPFLOW_ARCHIVE_DST} -C {LINUX_LEAPFLOW_PATH} && " + f"rm {LEAPFLOW_ARCHIVE_DST}" + ) + .run(f"cd {LINUX_LEAPFLOW_PATH} && make space-sync") + ) + else: + raise NotImplementedError(f"image preset not defined for {image}") diff --git a/src/leapspace/app_space/signal.py b/src/leapspace/app_space/signal.py index c12198d0..0f103eba 100644 --- a/src/leapspace/app_space/signal.py +++ b/src/leapspace/app_space/signal.py @@ -17,7 +17,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Any -from leapspace.app_space.utils import write_atomic +from leapspace.app_space.state import write_atomic if TYPE_CHECKING: from leapflow.analysis.intent_inferrer import InferenceResult diff --git a/src/leapspace/app_space/utils.py b/src/leapspace/app_space/state.py similarity index 68% rename from src/leapspace/app_space/utils.py rename to src/leapspace/app_space/state.py index 3e87dc91..7531e2c2 100644 --- a/src/leapspace/app_space/utils.py +++ b/src/leapspace/app_space/state.py @@ -1,18 +1,24 @@ # Copyright (c) Alibaba, Inc. and its affiliates. -"""Shared leapspace helpers: image presets, the state-dir convention, and -task action loading.""" +"""In-box-safe leapspace helpers: the state-dir convention, atomic writes, +the verdict ``check`` line, and task action loading. + +Split out from the former ``utils.py`` (EVO-02 LS-1). Everything here is +stdlib-only and imports no host SDK, so the in-box verdict program +(``action.py``'s ``expect()``), the pure state helpers, and the PyQt6 apps +(``apps/_base``) are importable with ``cua_sandbox`` absent -- which is what +lets a real app run headless (offscreen Qt) or a verdict run on any host. +Host-only image construction lives in the sibling ``image.py``. +""" + +from __future__ import annotations import importlib.util import os import platform -import subprocess -import tempfile from enum import Enum from pathlib import Path, PurePath, PurePosixPath, PureWindowsPath from typing import TYPE_CHECKING, Awaitable, Callable, Literal -from cua_sandbox import Image - if TYPE_CHECKING: from leapspace.app_space.actor import LeapAppActor @@ -41,7 +47,7 @@ def load_action( """Import a task's action.py once; return its (reference, expect) pair. Module-level imports are lint-guaranteed in-sandbox-safe (stdlib / - PyQt6 / leapspace) — a set the host import satisfies as well — and + PyQt6 / leapspace) -- a set the host import satisfies as well -- and exec_module honors the __main__ guard, so loading never triggers the verdict. """ @@ -81,13 +87,13 @@ def get_sandbox_state_dir( in_sandbox: bool, system: Literal["linux", "macos", "windows"] | None = None, ) -> PurePath: - """The apps' state root — the one path harness and apps must agree on. + """The apps' state root -- the one path harness and apps must agree on. Two consumers, two ways to know the sandbox OS: apps run inside and detect it with platform.system(); the harness runs on the host, where detection would answer the host's OS, so it names the sandbox's OS (an image preset's value) instead. Callers append the app_id. No env - override — hermetic tests monkeypatch this function. + override -- hermetic tests monkeypatch this function. """ if in_sandbox: system = platform.system().lower() @@ -124,7 +130,7 @@ def get_sandbox_state_dir( # Repo checkout path inside the sandbox image. LINUX_LEAPFLOW_PATH = "/opt/leapflow" -# Source tree inside the checkout — PYTHONPATH for interpreters outside the +# Source tree inside the checkout -- PYTHONPATH for interpreters outside the # repo venv (the OS python's apt stack: pyatspi). LINUX_LEAPFLOW_SRC = f"{LINUX_LEAPFLOW_PATH}/src" @@ -132,57 +138,6 @@ def get_sandbox_state_dir( LEAPFLOW_ARCHIVE_DST = "/tmp/leapflow-checkout.tar.gz" -def _archive_checkout() -> Path: - """Pack this checkout's committed state for the image to copy in. - - The build VM reaches GitHub only through the host's flaky link, so the - repo travels as a host-built archive: no in-box clone, and the box runs - exactly the code under test (HEAD, not some remote ref). - """ - repo_root = Path(__file__).resolve().parents[3] - fd, name = tempfile.mkstemp(suffix=".tar.gz") - os.close(fd) - result = subprocess.run( - ["git", "archive", "--format=tar.gz", "-o", name, "HEAD"], - cwd=repo_root, - capture_output=True, - text=True, - ) - if result.returncode != 0: - raise RuntimeError(f"git archive failed: {result.stderr.strip()}") - return Path(name) - - -def get_image(image: LeapAppImage) -> Image: - """Return the preset image spec, rooted in an archive of this checkout. - - Image is frozen and chainable — every mutation returns a new instance — - so callers get a fresh spec (and a fresh archive) per run. needrestart - is removed before apt: installing python3-dev upgrades service - libraries, and needrestart's service restarts SIGTERM the layer's own - command transport. Host feasibility: LINUX runs under local QEMU+KVM; - WINDOWS is untested; MACOS requires an Apple Silicon host (Lume). - """ - archive = _archive_checkout() - if image == LeapAppImage.LINUX: - return ( - Image.linux(distro="ubuntu", version="24.04", kind="vm") - .expose(CUA_MCP_PORT) - .run("sudo apt-get remove -y needrestart") - .apt_install("python3-pyatspi", "python3-dev", *PYQT_SYSTEM_LIBS, "git", "make") - .pip_install("PyQt6", "uv") - .copy(str(archive), LEAPFLOW_ARCHIVE_DST) - .run( - f"mkdir -p {LINUX_LEAPFLOW_PATH} && " - f"tar xzf {LEAPFLOW_ARCHIVE_DST} -C {LINUX_LEAPFLOW_PATH} && " - f"rm {LEAPFLOW_ARCHIVE_DST}" - ) - .run(f"cd {LINUX_LEAPFLOW_PATH} && make space-sync") - ) - else: - raise NotImplementedError(f"image preset not defined for {image}") - - def get_image_venv_python(system: Literal["linux", "macos", "windows"]) -> str: """Interpreter inside the image's repo venv, keyed by sandbox OS. diff --git a/src/leapspace/app_space/tasks/task-001/action.py b/src/leapspace/app_space/tasks/task-001/action.py index e5f34270..748193a2 100644 --- a/src/leapspace/app_space/tasks/task-001/action.py +++ b/src/leapspace/app_space/tasks/task-001/action.py @@ -34,7 +34,7 @@ from pathlib import Path from typing import TYPE_CHECKING -from leapspace.app_space.utils import check +from leapspace.app_space.state import check if TYPE_CHECKING: from leapspace.app_space.actor import LeapAppActor diff --git a/temp/papers/aaai27_demo/aaai_demo/__init__.py b/temp/papers/aaai27_demo/aaai_demo/__init__.py new file mode 100644 index 00000000..333f92f8 --- /dev/null +++ b/temp/papers/aaai27_demo/aaai_demo/__init__.py @@ -0,0 +1,17 @@ +"""Publication-local tooling for the AAAI-27 LeapFlow demonstration.""" + +from aaai_demo.evidence import ( + EvidenceBundleError, + build_evidence_bundle, + export_evidence_bundle, +) +from aaai_demo.poster import render_poster_source +from aaai_demo.render import render_demo_package + +__all__ = [ + "EvidenceBundleError", + "build_evidence_bundle", + "export_evidence_bundle", + "render_poster_source", + "render_demo_package", +] diff --git a/temp/papers/aaai27_demo/aaai_demo/cli.py b/temp/papers/aaai27_demo/aaai_demo/cli.py new file mode 100644 index 00000000..36fdebb7 --- /dev/null +++ b/temp/papers/aaai27_demo/aaai_demo/cli.py @@ -0,0 +1,107 @@ +"""Command-line entry points for AAAI demo evidence packaging.""" + +from __future__ import annotations + +import argparse +import json +from pathlib import Path +from typing import Sequence + +from aaai_demo.evidence import EvidenceBundleError, export_evidence_bundle +from aaai_demo.headless_seam import export_headless_seam +from aaai_demo.poster import render_poster_source +from aaai_demo.render import compose_backup_reel, render_demo_package + + +def _parser() -> argparse.ArgumentParser: + """Create the narrow, read-only-or-derived demo command surface.""" + parser = argparse.ArgumentParser(description="Build auditable AAAI demo artifacts.") + commands = parser.add_subparsers(dest="command", required=True) + + bundle = commands.add_parser("bundle", help="Export a write-once CE-X evidence bundle.") + bundle.add_argument("--run-dir", type=Path, required=True) + bundle.add_argument("--output-dir", type=Path, required=True) + bundle.add_argument("--drift-fixture", type=Path) + bundle.add_argument("--trajectory-dir", type=Path) + bundle.add_argument( + "--signal-archive", + type=Path, + help="Manifest that binds signal-mode media, state/event evidence, and expect() result.", + ) + bundle.add_argument( + "--headless-seam", + type=Path, + help="Write-once real-widget structural-seam record from the headless-seam command.", + ) + bundle.add_argument("--include-media", action="store_true") + + seam = commands.add_parser("headless-seam", help="Run and record the real offscreen PyQt structural seam.") + seam.add_argument("--output-dir", type=Path, required=True) + + render = commands.add_parser("render", help="Render a static causal-trace console and EDL.") + render.add_argument("--bundle", type=Path, required=True) + render.add_argument("--output-dir", type=Path, required=True) + + poster = commands.add_parser("poster", help="Render a provisional accepted-demo poster source.") + poster.add_argument("--bundle", type=Path, required=True) + poster.add_argument("--output-dir", type=Path, required=True) + poster.add_argument("--viewer-url", default="") + + reel = commands.add_parser("backup-reel", help="Concatenate reviewed clips without re-encoding.") + reel.add_argument("--clip", type=Path, action="append", required=True) + reel.add_argument("--output", type=Path, required=True) + return parser + + +def _bundle_from_path(path: Path) -> dict: + """Read a normalized evidence bundle and reject malformed input.""" + try: + value = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError) as exc: + raise EvidenceBundleError(f"cannot read bundle: {path}") from exc + if not isinstance(value, dict) or value.get("kind") != "aaai_demo_evidence_bundle": + raise EvidenceBundleError("input is not an AAAI demo evidence bundle") + return value + + +def main(argv: Sequence[str] | None = None) -> int: + """Run one explicit packaging operation and print only resulting artifact paths.""" + args = _parser().parse_args(argv) + try: + if args.command == "bundle": + bundle = export_evidence_bundle( + args.run_dir, + args.output_dir, + drift_fixture=args.drift_fixture, + trajectory_dir=args.trajectory_dir, + signal_archive=args.signal_archive, + headless_seam=args.headless_seam, + include_media=args.include_media, + ) + print(json.dumps({"bundle": str(args.output_dir), "run_id": bundle["run"]["run_id"]}, sort_keys=True)) + return 0 + if args.command == "headless-seam": + record = export_headless_seam(args.output_dir) + print(json.dumps({"headless_seam": str(args.output_dir), "run_id": record["run_id"]}, sort_keys=True)) + return 0 + if args.command == "render": + paths = render_demo_package(_bundle_from_path(args.bundle), args.output_dir) + print(json.dumps({key: str(value) for key, value in paths.items()}, sort_keys=True)) + return 0 + if args.command == "poster": + paths = render_poster_source( + _bundle_from_path(args.bundle), args.output_dir, viewer_url=args.viewer_url, + ) + print(json.dumps({key: str(value) for key, value in paths.items()}, sort_keys=True)) + return 0 + if args.command == "backup-reel": + print(compose_backup_reel(args.clip, args.output)) + return 0 + except EvidenceBundleError as exc: + print(f"error: {exc}") + return 2 + raise AssertionError(f"unhandled command: {args.command}") + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/temp/papers/aaai27_demo/aaai_demo/evidence.py b/temp/papers/aaai27_demo/aaai_demo/evidence.py new file mode 100644 index 00000000..53fbfb71 --- /dev/null +++ b/temp/papers/aaai27_demo/aaai_demo/evidence.py @@ -0,0 +1,528 @@ +"""Build a conservative, immutable evidence bundle for the AAAI demo. + +This module is deliberately publication-local. It reads existing experiment +artifacts and trajectory recordings; it never drives a model, approves a +mutation, or changes a registry. Its output distinguishes what was observed +from what the L1 CE-X instrument intentionally did not exercise. +""" + +from __future__ import annotations + +import hashlib +import json +import shutil +import time +from pathlib import Path +from typing import Any, Iterable, Mapping + + +SCHEMA_VERSION = 1 +CE_X_ARMS = ( + "unchanged_baseline", + "irrelevant_delta_rejected", + "satisfied_by_catalog", + "unmet_traverses_lifecycle", +) +_REQUIRED_RECORD_FIELDS = frozenset({"arm", "expected_action", "action", "ok"}) + + +class EvidenceBundleError(ValueError): + """Raised when input cannot support a truthful, replayable demo bundle.""" + + +def sha256_file(path: Path) -> str: + """Return the SHA-256 digest of a regular file without loading it all at once.""" + digest = hashlib.sha256() + with path.open("rb") as handle: + for block in iter(lambda: handle.read(1024 * 1024), b""): + digest.update(block) + return digest.hexdigest() + + +def _read_mapping(path: Path) -> dict[str, Any]: + """Read one JSON object or raise an evidence-specific error.""" + try: + value = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError) as exc: + raise EvidenceBundleError(f"cannot read JSON object: {path}") from exc + if not isinstance(value, dict): + raise EvidenceBundleError(f"expected a JSON object: {path}") + return value + + +def _read_jsonl(path: Path) -> list[dict[str, Any]]: + """Read JSONL records and reject malformed or non-object rows.""" + try: + lines = path.read_text(encoding="utf-8").splitlines() + except OSError as exc: + raise EvidenceBundleError(f"cannot read records: {path}") from exc + records: list[dict[str, Any]] = [] + for number, line in enumerate(lines, start=1): + if not line.strip(): + continue + try: + record = json.loads(line) + except json.JSONDecodeError as exc: + raise EvidenceBundleError(f"invalid JSONL at {path}:{number}") from exc + if not isinstance(record, dict): + raise EvidenceBundleError(f"non-object JSONL record at {path}:{number}") + records.append(record) + return records + + +def _require_file(directory: Path, name: str) -> Path: + """Return a required regular file beneath an experiment run directory.""" + path = directory / name + if not path.is_file(): + raise EvidenceBundleError(f"missing required run artifact: {path}") + return path + + +def _artifact(path: Path, *, root: Path) -> dict[str, Any]: + """Return immutable metadata for a source artifact without copying it.""" + try: + relative = path.relative_to(root) + except ValueError: + relative = Path(path.name) + return { + "path": relative.as_posix(), + "sha256": sha256_file(path), + "bytes": path.stat().st_size, + } + + +def _validate_records(records: Iterable[Mapping[str, Any]]) -> list[dict[str, Any]]: + """Validate the canonical CE-X arm set and preserve its declared order.""" + by_arm: dict[str, dict[str, Any]] = {} + for raw in records: + missing = _REQUIRED_RECORD_FIELDS - set(raw) + if missing: + raise EvidenceBundleError(f"counterfactual record misses fields: {sorted(missing)}") + arm = str(raw["arm"]) + if arm in by_arm: + raise EvidenceBundleError(f"duplicate CE-X arm record: {arm}") + by_arm[arm] = dict(raw) + unknown = set(by_arm) - set(CE_X_ARMS) + missing = set(CE_X_ARMS) - set(by_arm) + if unknown or missing: + raise EvidenceBundleError( + f"CE-X must contain exactly {CE_X_ARMS}; missing={sorted(missing)}, unknown={sorted(unknown)}" + ) + return [by_arm[arm] for arm in CE_X_ARMS] + + +def _effect_status(record: Mapping[str, Any]) -> dict[str, str]: + """Describe effect evidence without upgrading handler reports into an oracle.""" + if int(record.get("effect_verified") or 0) > 0: + return { + "status": "handler_reported_effect_confirmed", + "independent_oracle": "not_available", + "note": "The CE-X L1 runner reports a handler-observed effect; no Leapspace expect() oracle was run.", + } + if int(record.get("effect_refuted") or 0) > 0: + return { + "status": "effect_refuted", + "independent_oracle": "not_available", + "note": "The instrument reported a refuted effect; this arm must not be presented as successful.", + } + return { + "status": "not_exercised", + "independent_oracle": "not_available", + "note": "No effect verification exists for this arm in the L1 CE-X run.", + } + + +def _arm_label(record: Mapping[str, Any]) -> str: + """Name the non-mutation outcome in a form suitable for a compact matrix.""" + arm = str(record["arm"]) + if arm == "unchanged_baseline": + return "no_op" + if arm == "irrelevant_delta_rejected": + return "rejected" + if arm == "satisfied_by_catalog": + return "catalog_reuse" + return "acquire_hypothesis" + + +def _normalise_arm(record: Mapping[str, Any], manifest: Mapping[str, Any]) -> dict[str, Any]: + """Map one CE-X record to a demo row while retaining its evidentiary boundary.""" + substitutions = manifest.get("substitutions") + substitutions = dict(substitutions) if isinstance(substitutions, Mapping) else {} + not_exercised = str(substitutions.get("not_exercised") or "") + arm = str(record["arm"]) + action = str(record["action"]) + return { + "arm": arm, + "outcome": _arm_label(record), + "expected_action": str(record["expected_action"]), + "actual_action": action, + "matches_oracle": bool(record["ok"]), + "drift_relevance": ( + "unchanged" if arm == "unchanged_baseline" + else "irrelevant" if arm == "irrelevant_delta_rejected" + else "task_relevant" + ), + "resolution": ( + "not_required" if arm in {"unchanged_baseline", "irrelevant_delta_rejected"} + else "incumbent_satisfies" if arm == "satisfied_by_catalog" + else "unmet_requirement" + ), + "proposal_count": int(record.get("proposed") or 0), + "admitted_count": int(record.get("admitted") or 0), + "requirement_count": int(record.get("requirements") or 0), + "authorised": bool(record.get("authorised", False)), + "profile_root": str(record.get("profile_root") or ""), + "approval": "not_exercised", + "registry_mutation": "not_exercised", + "lifecycle": "mechanism_level_only" if action == "acquire" else "not_applicable", + "effect": _effect_status(record), + "notes": str(record.get("notes") or ""), + "boundary": not_exercised, + } + + +def _trajectory_metadata(trajectory_dir: Path | None) -> dict[str, Any]: + """Index legacy optional trajectory assets without asserting an oracle verdict.""" + if trajectory_dir is None: + return {"status": "not_supplied", "media": [], "turns": []} + root = trajectory_dir.expanduser().resolve() + if not root.is_dir(): + raise EvidenceBundleError(f"trajectory directory does not exist: {root}") + media: list[dict[str, Any]] = [] + for name in ("recording.mp4", "cursor.jsonl"): + path = root / name + if path.is_file(): + media.append(_artifact(path, root=root)) + turns: list[dict[str, Any]] = [] + for turn_dir in sorted(path for path in root.glob("turn-*") if path.is_dir()): + files = [ + _artifact(path, root=root) + for path in sorted(turn_dir.iterdir()) + if path.is_file() and path.name in {"action.json", "app_state.json", "screenshot.png"} + ] + turns.append({"turn": turn_dir.name, "artifacts": files}) + return { + "status": "available" if media or turns else "empty", + "pixel_capture": "available" if any(item["path"] == "recording.mp4" for item in media) else "not_available", + "media": media, + "turns": turns, + } + + +_SIGNAL_ARCHIVE_REQUIRED_KINDS = frozenset({ + "recording", "cursor_path", "state_snapshot", "event_log", "expect_stdout", +}) + + +def _safe_archive_artifact(root: Path, raw: Mapping[str, Any]) -> tuple[dict[str, Any] | None, str]: + """Hash one declared signal artifact without allowing an archive-path escape.""" + kind = str(raw.get("kind") or "").strip() + relative = Path(str(raw.get("path") or "")) + if not kind or not relative.parts or relative.is_absolute() or ".." in relative.parts: + return None, kind or "invalid_artifact" + path = root / relative + if not path.is_file(): + return None, kind + artifact = _artifact(path, root=root) + artifact.update({"kind": kind, "sensitive": bool(raw.get("sensitive", False))}) + return artifact, "" + + +def load_signal_archive(path: Path | None) -> dict[str, Any]: + """Load a declared signal-mode archive without upgrading missing evidence to PASS. + + The manifest is deliberately file-oriented. It binds a recording, state/event + evidence, and the independent ``expect()`` verdict to one run while allowing a + renderer to show an incomplete archive honestly instead of failing the whole CE-X + bundle. + """ + if path is None: + return {"status": "not_supplied", "artifacts": [], "missing": []} + manifest_path = path.expanduser().resolve() + manifest = _read_mapping(manifest_path) + if manifest.get("schema_version") != SCHEMA_VERSION or manifest.get("kind") != "leapspace_signal_archive": + raise EvidenceBundleError("signal archive must declare the current schema and kind") + raw_artifacts = manifest.get("artifacts") + if not isinstance(raw_artifacts, list): + raise EvidenceBundleError("signal archive artifacts must be a list") + artifacts: list[dict[str, Any]] = [] + missing: list[str] = [] + for raw in raw_artifacts: + if not isinstance(raw, Mapping): + raise EvidenceBundleError("signal archive contains a non-object artifact") + artifact, problem = _safe_archive_artifact(manifest_path.parent, raw) + if artifact is None: + missing.append(problem) + else: + artifacts.append(artifact) + present = {str(item["kind"]) for item in artifacts} + missing.extend(sorted(_SIGNAL_ARCHIVE_REQUIRED_KINDS - present)) + expect = manifest.get("expect") + expect = dict(expect) if isinstance(expect, Mapping) else {} + verdict = str(expect.get("verdict") or "not_recorded") + exit_code = expect.get("exit_code") + passed = verdict == "pass" and exit_code == 0 and not missing + return { + "status": "available" if passed else "incomplete", + "run_id": str(manifest.get("run_id") or ""), + "expect": {"verdict": verdict, "exit_code": exit_code}, + "artifacts": artifacts, + "missing": sorted(set(missing)), + "pixel_capture": "available" if "recording" in present else "not_available", + } + + +def load_headless_seam(path: Path | None) -> dict[str, Any]: + """Load a write-once real-widget seam record, or name its absence explicitly.""" + if path is None: + return {"status": "not_supplied"} + record_path = path.expanduser().resolve() + record = _read_mapping(record_path) + if record.get("schema_version") != SCHEMA_VERSION or record.get("kind") != "aaai_demo_headless_seam": + raise EvidenceBundleError("headless seam record must declare the current schema and kind") + required = {"rename", "benign_control", "default_refusal", "requirement"} + missing = sorted(key for key in required if key not in record) + return { + "status": "available" if not missing else "incomplete", + "artifact": _artifact(record_path, root=record_path.parent), + "run_id": str(record.get("run_id") or ""), + "rename": dict(record.get("rename") or {}), + "benign_control": dict(record.get("benign_control") or {}), + "default_refusal": dict(record.get("default_refusal") or {}), + "requirement": dict(record.get("requirement") or {}), + "missing": missing, + } + + +def load_drift_fixture(path: Path | None) -> dict[str, Any] | None: + """Load and validate a declarative, reversible interface-drift fixture.""" + if path is None: + return None + fixture = _read_mapping(path) + drifts = fixture.get("drifts") + if fixture.get("schema_version") != SCHEMA_VERSION or not isinstance(drifts, list) or not drifts: + raise EvidenceBundleError("drift fixture must declare schema_version and a non-empty drifts list") + seen: set[str] = set() + for drift in drifts: + if not isinstance(drift, Mapping): + raise EvidenceBundleError("drift fixture contains a non-object drift") + drift_id = str(drift.get("drift_id") or "") + if not drift_id or drift_id in seen: + raise EvidenceBundleError("each drift fixture entry requires a unique drift_id") + seen.add(drift_id) + if not isinstance(drift.get("before"), Mapping) or not isinstance(drift.get("after"), Mapping): + raise EvidenceBundleError(f"drift {drift_id} must contain before and after snapshots") + return fixture + + +def build_evidence_bundle( + run_dir: Path, + *, + drift_fixture: Path | None = None, + trajectory_dir: Path | None = None, + signal_archive: Path | None = None, + headless_seam: Path | None = None, +) -> dict[str, Any]: + """Normalise a completed CE-X run into a conservative publication artifact.""" + root = run_dir.expanduser().resolve() + if not root.is_dir(): + raise EvidenceBundleError(f"CE-X run directory does not exist: {root}") + manifest_path = _require_file(root, "manifest.json") + records_path = _require_file(root, "records.jsonl") + summary_path = _require_file(root, "summary.json") + manifest = _read_mapping(manifest_path) + summary = _read_mapping(summary_path) + records = _validate_records(_read_jsonl(records_path)) + lane = str(manifest.get("lane") or "") + if lane != "L1": + raise EvidenceBundleError(f"this demo normalizer currently accepts L1 CE-X runs, got {lane!r}") + profiles = {str(record.get("profile_root") or "") for record in records} + if "" in profiles or len(profiles) != len(CE_X_ARMS): + raise EvidenceBundleError("CE-X arms must retain four distinct non-empty profile roots") + fixture = load_drift_fixture(drift_fixture) + arms = [_normalise_arm(record, manifest) for record in records] + trace = [ + { + "stage": "observe", + "arm": arm["arm"], + "title": f"OBSERVE · {arm['drift_relevance']}", + "summary": arm["notes"], + "severity": "info" if arm["matches_oracle"] else "alert", + } + for arm in arms + ] + [ + { + "stage": "decide", + "arm": arm["arm"], + "title": f"DECIDE · {arm['outcome']}", + "summary": f"expected={arm['expected_action']}; actual={arm['actual_action']}", + "severity": "notable" if arm["outcome"] in {"rejected", "catalog_reuse"} else "info", + } + for arm in arms + ] + return { + "schema_version": SCHEMA_VERSION, + "kind": "aaai_demo_evidence_bundle", + "created_at": time.time(), + "evidence_level": "L1", + "run": { + "run_id": str(manifest.get("run_id") or root.name), + "family": str(manifest.get("family") or ""), + "protocol_id": str(manifest.get("protocol_id") or ""), + "experiment_version": str(manifest.get("experiment_version") or ""), + "subject": dict(manifest.get("subject") or {}), + "manifest": _artifact(manifest_path, root=root), + "records": _artifact(records_path, root=root), + "summary": _artifact(summary_path, root=root), + "substitutions": dict(manifest.get("substitutions") or {}), + }, + "claims": { + "supported": [ + "The controlled L1 CE-X instrument distinguishes no-op, rejection, catalog reuse, and an acquisition hypothesis.", + "Each counterfactual arm uses an isolated profile root and emits a durable run record.", + ], + "not_supported": [ + "End-to-end Leapspace agent execution.", + "A real plugin installation or approval decision.", + "Independent expect() oracle confirmation for the L1 CE-X acquisition arm.", + "Longitudinal governed self-evolution in the daemon runtime.", + ], + }, + "summary": summary, + "arms": arms, + "causal_trace": trace, + # ``trajectory`` is a legacy media index. Only ``signal_archive`` binds media + # to state/event evidence and an independent expect() verdict. + "trajectory": _trajectory_metadata(trajectory_dir), + "signal_archive": load_signal_archive(signal_archive), + "headless_seam": load_headless_seam(headless_seam), + "drift_fixture": fixture, + } + + +def _write_json(path: Path, value: Mapping[str, Any]) -> None: + """Write one JSON document atomically without overwriting an existing artifact.""" + if path.exists(): + raise EvidenceBundleError(f"write-once artifact already exists: {path}") + temporary = path.with_name(f".{path.name}.tmp") + try: + temporary.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8") + temporary.replace(path) + except OSError as exc: + temporary.unlink(missing_ok=True) + raise EvidenceBundleError(f"cannot write evidence artifact: {path}") from exc + + +def _copy_raw(path: Path, destination: Path) -> None: + """Copy one selected source artifact, refusing to replace an existing copy.""" + if destination.exists(): + raise EvidenceBundleError(f"write-once raw artifact already exists: {destination}") + destination.parent.mkdir(parents=True, exist_ok=True) + try: + shutil.copy2(path, destination) + except OSError as exc: + raise EvidenceBundleError(f"cannot copy evidence artifact: {path}") from exc + + +def export_evidence_bundle( + run_dir: Path, + output_dir: Path, + *, + drift_fixture: Path | None = None, + trajectory_dir: Path | None = None, + signal_archive: Path | None = None, + headless_seam: Path | None = None, + include_media: bool = False, +) -> dict[str, Any]: + """Create a write-once derived bundle and return its normalized content.""" + target = output_dir.expanduser().resolve() + if target.exists(): + raise EvidenceBundleError(f"write-once bundle directory already exists: {target}") + bundle = build_evidence_bundle( + run_dir, + drift_fixture=drift_fixture, + trajectory_dir=trajectory_dir, + signal_archive=signal_archive, + headless_seam=headless_seam, + ) + target.mkdir(parents=True, exist_ok=False) + try: + source = Path(run_dir).expanduser().resolve() + raw_dir = target / "raw" + for name in ("manifest.json", "records.jsonl", "summary.json"): + _copy_raw(source / name, raw_dir / name) + if drift_fixture is not None: + _copy_raw(drift_fixture.expanduser().resolve(), raw_dir / "drift_fixture.json") + if signal_archive is not None: + _copy_raw(signal_archive.expanduser().resolve(), raw_dir / "signal_archive.json") + if headless_seam is not None: + _copy_raw(headless_seam.expanduser().resolve(), raw_dir / "headless_seam.json") + if include_media and trajectory_dir is not None: + trajectory = trajectory_dir.expanduser().resolve() + for path in sorted(trajectory.rglob("*")): + if not path.is_file(): + continue + relative = path.relative_to(trajectory) + if path.name in {"recording.mp4", "cursor.jsonl", "action.json", "app_state.json", "screenshot.png"}: + _copy_raw(path, raw_dir / "trajectory" / relative) + bundle["packaged_files"] = [ + _artifact(path, root=target) + for path in sorted(target.rglob("*")) + if path.is_file() + ] + _write_json(target / "bundle.json", bundle) + lines = [ + f"{sha256_file(path)} {path.relative_to(target).as_posix()}" + for path in sorted(target.rglob("*")) + if path.is_file() + ] + (target / "checksums.sha256").write_text("\n".join(lines) + "\n", encoding="utf-8") + except Exception: + shutil.rmtree(target, ignore_errors=True) + raise + return bundle + + +def viewspec_data(bundle: Mapping[str, Any]) -> dict[str, Any]: + """Project bundle facts into the existing read-only Causal Trace template shape.""" + arms = [dict(item) for item in bundle.get("arms") or [] if isinstance(item, Mapping)] + trace = [dict(item) for item in bundle.get("causal_trace") or [] if isinstance(item, Mapping)] + summary = dict(bundle.get("summary") or {}) + run = dict(bundle.get("run") or {}) + return { + "title": f"AAAI Causal Trace · {run.get('run_id') or 'unknown run'}", + "causal_trace": { + "evidence_level": str(bundle.get("evidence_level") or ""), + "arms": arms, + "timeline": trace, + "summary": { + "arms_total": summary.get("arms_total", len(arms)), + "arms_correct": summary.get("arms_correct", 0), + "mutations": summary.get("mutations", 0), + "effect_confirmed": summary.get("effect_confirmed", 0), + }, + "manifest": { + "run_id": run.get("run_id", ""), + "protocol_id": run.get("protocol_id", ""), + "subject_commit": dict(run.get("subject") or {}).get("commit", ""), + "records_sha256": dict(run.get("records") or {}).get("sha256", ""), + }, + "claims": dict(bundle.get("claims") or {}), + "signal_archive": dict(bundle.get("signal_archive") or {}), + "headless_seam": dict(bundle.get("headless_seam") or {}), + }, + } + + +__all__ = [ + "CE_X_ARMS", + "SCHEMA_VERSION", + "EvidenceBundleError", + "build_evidence_bundle", + "export_evidence_bundle", + "load_drift_fixture", + "load_headless_seam", + "load_signal_archive", + "sha256_file", + "viewspec_data", +] diff --git a/temp/papers/aaai27_demo/aaai_demo/headless_seam.py b/temp/papers/aaai27_demo/aaai_demo/headless_seam.py new file mode 100644 index 00000000..64e43fca --- /dev/null +++ b/temp/papers/aaai27_demo/aaai_demo/headless_seam.py @@ -0,0 +1,220 @@ +"""Export a write-once record of the real offscreen Leapspace structural seam. + +The demo uses this helper instead of presenting a fixture as if it were a real UI. +It creates two actual PyQt6 ``BaseLeapApp`` surfaces, lets their normal persistence +write the envelopes, and routes the observed rename through the production +``CapabilityObservationService``. It has no engine, registry, approval, or plugin +mutation capability. +""" + +from __future__ import annotations + +import json +import shutil +import time +import uuid +from pathlib import Path +from typing import Any + +from aaai_demo.evidence import EvidenceBundleError, SCHEMA_VERSION, sha256_file + + +def _write_once(path: Path, value: dict[str, Any]) -> None: + """Write one JSON record atomically without replacing an existing artifact.""" + if path.exists(): + raise EvidenceBundleError(f"write-once artifact already exists: {path}") + temporary = path.with_name(f".{path.name}.tmp") + try: + temporary.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8") + temporary.replace(path) + except OSError as exc: + temporary.unlink(missing_ok=True) + raise EvidenceBundleError(f"cannot write headless seam artifact: {path}") from exc + + +def _artifact(path: Path, *, root: Path) -> dict[str, Any]: + """Describe one local artifact relative to the seam run root.""" + return { + "path": path.relative_to(root).as_posix(), + "sha256": sha256_file(path), + "bytes": path.stat().st_size, + } + + +def _require_pyqt() -> tuple[Any, Any, Any, Any, Any, Any, Any]: + """Load optional GUI dependencies only for the explicit headless-seam command.""" + try: + from PyQt6.QtWidgets import QApplication, QLineEdit, QPushButton, QVBoxLayout, QWidget + from leapspace.app_space.apps import _base as base_module + from leapspace.app_space.apps._base import BaseLeapApp + except ImportError as exc: + raise EvidenceBundleError( + "headless-seam requires the leapspace extra with PyQt6; run it in the PyQt-enabled environment" + ) from exc + return QApplication, QLineEdit, QPushButton, QVBoxLayout, QWidget, base_module, BaseLeapApp + + +def export_headless_seam(output_dir: Path) -> dict[str, Any]: + """Run the real offscreen rename/negative-control seam and export its evidence. + + ``output_dir`` is write-once. The record contains no widget values or message + contents: only structural identities, persisted evidence identifiers, and hashes. + """ + target = output_dir.expanduser().resolve() + if target.exists(): + raise EvidenceBundleError(f"write-once headless seam directory already exists: {target}") + QApplication, QLineEdit, QPushButton, QVBoxLayout, QWidget, base_module, BaseLeapApp = _require_pyqt() + target.mkdir(parents=True, exist_ok=False) + original_state_dir = base_module.get_sandbox_state_dir + try: + import os + + os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") + app = QApplication.instance() or QApplication([]) + + class _ChatV1(BaseLeapApp): + app_id = "chat_probe" + app_title = "ChatProbe" + version = "1.0" + + def build_ui(self) -> None: + central = QWidget() + layout = QVBoxLayout(central) + layout.addWidget(self.bind(QLineEdit(), "message_input")) + layout.addWidget(self.bind(QPushButton("Send"), self._send_name())) + self.setCentralWidget(central) + + def _send_name(self) -> str: + return "send_button" + + def reset(self, data: dict[str, Any]) -> None: + return None + + def state(self) -> dict[str, Any]: + return {} + + class _ChatV2(_ChatV1): + version = "1.1" + + def _send_name(self) -> str: + return "dispatch_button" + + class _ChatBenign(_ChatV1): + version = "1.1-benign" + + def build_ui(self) -> None: + central = QWidget() + layout = QVBoxLayout(central) + layout.addWidget(self.bind(QLineEdit(), "message_input")) + layout.addWidget(self.bind(QPushButton("Send"), "send_button")) + layout.addWidget(self.bind(QPushButton("Emoji"), "emoji_picker")) + self.setCentralWidget(central) + + def _write_state(app_type: type[Any], name: str) -> Path: + state_root = target / "states" / name + base_module.get_sandbox_state_dir = lambda in_sandbox=True, system=None: state_root + window = app_type() + window.close() + window.deleteLater() + app.processEvents() + return state_root / "chat_probe" / "state.json" + + before_path = _write_state(_ChatV1, "before") + renamed_path = _write_state(_ChatV2, "renamed") + benign_path = _write_state(_ChatBenign, "benign") + + from leapflow.learning.capability_observation import ( + CapabilityEvidenceClassifier, + CapabilityObservationService, + ) + from leapflow.storage.capability_observation_store import JsonCapabilityObservationStore + from leapexp2.contracts import CapabilityPrecondition + from leapexp2.leapspace_source import LeapSpaceEnvironmentSource + + precondition = CapabilityPrecondition( + capability="chat.reply", bound_names=frozenset({"send_button"}) + ) + before = LeapSpaceEnvironmentSource(target / "states" / "before").read_snapshot("chat_probe") + renamed_source = LeapSpaceEnvironmentSource( + target / "states" / "renamed", workspace_root="demo-headless-seam" + ) + renamed = renamed_source.read_snapshot("chat_probe") + evidence = renamed_source.detect(before, renamed, precondition) + if len(evidence) != 1 or evidence[0].evidence_kind != "interface_drift": + raise EvidenceBundleError("real rename did not produce exactly one interface_drift observation") + + store = JsonCapabilityObservationStore(target / "observations.json") + admitted_service = CapabilityObservationService( + store, + classifier=CapabilityEvidenceClassifier.from_kinds( + ["unknown_tool", "interface_drift", "affordance_removed"] + ), + ) + observation = renamed_source.emit(admitted_service, evidence[0]) + requirements = admitted_service.requirements(min_count=1) + if observation is None or len(requirements) != 1: + raise EvidenceBundleError("admitted structural evidence did not produce one requirement") + requirement = requirements[0] + + benign_source = LeapSpaceEnvironmentSource(target / "states" / "benign") + benign = benign_source.read_snapshot("chat_probe") + benign_evidence = benign_source.detect(before, benign, precondition) + if benign_evidence: + raise EvidenceBundleError("benign structural change unexpectedly produced evidence") + + default_store = JsonCapabilityObservationStore(target / "default_observations.json") + default_service = CapabilityObservationService(default_store) + default_record = renamed_source.emit(default_service, evidence[0]) + if default_record is not None: + raise EvidenceBundleError("default classifier unexpectedly admitted environment evidence") + + store_artifacts = [_artifact(target / "observations.json", root=target)] + default_store_path = target / "default_observations.json" + if default_store_path.is_file(): + store_artifacts.append(_artifact(default_store_path, root=target)) + + record = { + "schema_version": SCHEMA_VERSION, + "kind": "aaai_demo_headless_seam", + "run_id": f"headless-seam-{uuid.uuid4().hex[:12]}", + "created_at": time.time(), + "evidence_level": "real_headless_structural_seam", + "limitations": [ + "No framebuffer or pixel evidence is available in the offscreen lane.", + "The seam creates an observation and requirement; it does not execute an agent, install a plugin, or approve a mutation.", + ], + "rename": { + "before": _artifact(before_path, root=target), + "after": _artifact(renamed_path, root=target), + "evidence_kind": evidence[0].evidence_kind, + "recovery_hint": evidence[0].recovery_hint, + "suggestions": list(evidence[0].suggestions), + "observation_id": str(observation.get("observation_id") or ""), + }, + "benign_control": { + "state": _artifact(benign_path, root=target), + "evidence_count": 0, + }, + # A refused observation does not need to create a store file; that absence + # is itself part of the default-off evidence, not an export failure. + "default_refusal": { + "admitted": False, + "store_created": default_store_path.is_file(), + }, + "requirement": { + "capability": requirement.capability, + "origin": requirement.origin, + "requirement_id": requirement.requirement_id, + }, + "stores": store_artifacts, + } + _write_once(target / "headless_seam.json", record) + return record + except Exception: + shutil.rmtree(target, ignore_errors=True) + raise + finally: + base_module.get_sandbox_state_dir = original_state_dir + + +__all__ = ["export_headless_seam"] diff --git a/temp/papers/aaai27_demo/aaai_demo/poster.py b/temp/papers/aaai27_demo/aaai_demo/poster.py new file mode 100644 index 00000000..a959e349 --- /dev/null +++ b/temp/papers/aaai27_demo/aaai_demo/poster.py @@ -0,0 +1,113 @@ +"""Create a provisional, editable poster source for an accepted demo station. + +AAAI-27 supplies a poster board only after acceptance and defers exhibit format +information to the Chairs. This module therefore produces a responsive 3:4 design +source, not an asserted print size or a submission replacement for the required +video/slides material. +""" + +from __future__ import annotations + +import json +import shutil +from pathlib import Path +from typing import Any, Mapping + +from aaai_demo.evidence import EvidenceBundleError, sha256_file + + +_PROVISIONAL_FORMAT = { + "status": "provisional", + "design_ratio": "3:4 portrait", + "official_size": "pending_chairs_exhibit_format_information", + "print_export": "deferred_until_official_format_is_confirmed", +} + + +def _write_once(path: Path, content: str) -> None: + """Write a source artifact atomically without replacing an existing one.""" + if path.exists(): + raise EvidenceBundleError(f"write-once poster artifact already exists: {path}") + temporary = path.with_name(f".{path.name}.tmp") + try: + temporary.write_text(content, encoding="utf-8") + temporary.replace(path) + except OSError as exc: + temporary.unlink(missing_ok=True) + raise EvidenceBundleError(f"cannot write poster artifact: {path}") from exc + + +def _safe_json(value: Any) -> str: + """Embed data without allowing a script closing tag to escape the document.""" + return json.dumps(value, indent=2, sort_keys=True).replace(" str: + """Render a vector-friendly poster source inspired by the supplied hierarchy.""" + payload = _safe_json(bundle) + target = str(viewer_url or "SET_AFTER_ANONYMITY_REVIEW") + return f""" + +LeapFlow Demonstration Poster Source +
+

LeapFlow: From Environment Signal to Governed Capability Decision

A static guide to the live Harness demonstration. Every claim is bound to an auditable evidence lane; missing steps remain visible rather than being inferred.

PROVISIONAL SOURCE
3:4 design sketch only
Final size pending Chairs
+

1. WHY A HARNESS NEEDS EVIDENCE

Environmental drift is a hypothesis, not an instruction to rewrite capability. The demonstration makes baseline/no-op, irrelevant/reject, catalog reuse, and acquisition hypotheses equally visible.

L1 controlled CE-Xreal headless seamconditional archivenot exercised
+

4. QUANTIFIED COUNTERFACTUALS

+

2. SIGNAL CONTRACT

real offscreen widget→role-aware elements→InterfaceDelta→opt-in environment_probe requirement

Benign additions remain no-op. The headless lane has no framebuffer and is not GUI-agent e2e.

+

5. LIVE INTERACTION

  1. Open the evidence viewer.
  2. Select an episode or CE-X arm.
  3. Observe Environment / Decision / Governance lanes in Evolution Live.
QR target is set only after anonymity review:
{target}
+

3. DECISION AND GOVERNANCE

observe→requirement→resolution→absorb / rebind / acquire / escalate→policy / lifecycle

Acquire is a hypothesis. Approval, install, daemon-runtime trust, and independent oracle outcomes are shown only when a same-run artifact exists.

+

6. CLAIMS AND LIMITS

Reproduce: headless-seam → run_c2 → bundle → render. The monitor hosts dynamic replay; this poster is only the static entry point.

+
Poster source is not a submission replacement. The AAAI-27 initial submission requires a short paper plus a ≤5-minute video or slides. Generate the final printed artifact only after official exhibit format information is supplied.
+
""" + + +def render_poster_source( + bundle: Mapping[str, Any], output_dir: Path, *, viewer_url: str = "" +) -> dict[str, Path]: + """Write a provisional poster source and its evidence data without overwriting.""" + if bundle.get("kind") != "aaai_demo_evidence_bundle": + raise EvidenceBundleError("poster source requires an AAAI demo evidence bundle") + target = output_dir.expanduser().resolve() + if target.exists(): + raise EvidenceBundleError(f"write-once poster directory already exists: {target}") + target.mkdir(parents=True, exist_ok=False) + try: + poster = target / "poster.html" + data = target / "poster-data.json" + format_note = target / "format-status.json" + _write_once(poster, _poster_html(bundle, viewer_url)) + _write_once(data, json.dumps(bundle, indent=2, sort_keys=True) + "\n") + _write_once(format_note, json.dumps(_PROVISIONAL_FORMAT, indent=2, sort_keys=True) + "\n") + checksums = target / "checksums.sha256" + lines = [ + f"{sha256_file(path)} {path.name}" + for path in sorted(target.iterdir()) + if path.is_file() + ] + _write_once(checksums, "\n".join(lines) + "\n") + except Exception: + shutil.rmtree(target, ignore_errors=True) + raise + return {"poster": poster, "data": data, "format": format_note, "checksums": checksums} + + +__all__ = ["render_poster_source"] diff --git a/temp/papers/aaai27_demo/aaai_demo/render.py b/temp/papers/aaai27_demo/aaai_demo/render.py new file mode 100644 index 00000000..d5f4c967 --- /dev/null +++ b/temp/papers/aaai27_demo/aaai_demo/render.py @@ -0,0 +1,169 @@ +"""Render a read-only demo console and a reviewable video edit decision list. + +The renderer produces a local HTML evidence view and an edit decision list rather +than fabricating a movie from unavailable GUI footage. The backup-reel helper +concatenates supplied recordings with ffmpeg but never overwrites an output. +""" + +from __future__ import annotations + +import json +import shutil +import subprocess +from pathlib import Path +from typing import Any, Mapping, Sequence + +from aaai_demo.evidence import EvidenceBundleError, sha256_file, viewspec_data + + +_STORYBOARD = ( + (0, 35, "Overview and evidence contract", "State L1/headless/archive boundaries before any success claim.", "mixed"), + (35, 85, "Real headless structural seam", "Show the real PyQt rename, benign control, and opt-in admission.", "headless_structural"), + (85, 130, "World model and OODA boundary", "Show architecture or archived record; do not report uncalibrated live accuracy.", "controlled"), + (130, 235, "CE-X counterfactual matrix", "Show no-op, rejection, reuse, and acquisition hypothesis symmetrically.", "L1"), + (235, 275, "Conditional signal archive", "Play only a complete archive with state/event evidence and expect() PASS.", "archive_conditional"), + (275, 300, "Limitations and reproduction", "Link every claim to a hash and state unexercised boundaries.", "mixed"), +) + + +def _write_once(path: Path, content: str) -> None: + """Write text atomically and reject accidental evidence replacement.""" + if path.exists(): + raise EvidenceBundleError(f"write-once render artifact already exists: {path}") + temporary = path.with_name(f".{path.name}.tmp") + try: + temporary.write_text(content, encoding="utf-8") + temporary.replace(path) + except OSError as exc: + temporary.unlink(missing_ok=True) + raise EvidenceBundleError(f"cannot write render artifact: {path}") from exc + + +def _safe_json(value: Any) -> str: + """Serialize data for an inline script without allowing a closing-script escape.""" + return json.dumps(value, indent=2, sort_keys=True).replace(" str: + """Return a self-contained four-column read-only evidence console.""" + payload = _safe_json(bundle) + return f""" + +LeapFlow AAAI Causal Trace + +

LeapFlow AAAI Demo · Causal Trace

+
t0 · State snapshot
t1 · Action
t2 · Actual effect
t3 · Independent oracle
t4 · Teacher hindsight
t5 · Governance
t6 · Next turn
+

Real Leapspace evidence

Observe / Orient

Decide / PCD

Governance / Effect

+

CE-X four-arm matrix

Evidence drawer

+
Read-only derived view. It displays declared evidence boundaries rather than inferring unrecorded approval, installation, independent oracle, or daemon-runtime outcomes.
+""" + + +def _storyboard(bundle: Mapping[str, Any]) -> dict[str, Any]: + """Build a five-minute edit decision list with explicit evidence boundaries.""" + run = dict(bundle.get("run") or {}) + segments = [ + { + "start_s": start, + "end_s": end, + "title": title, + "narration_constraint": constraint, + "evidence_level": evidence_level, + } + for start, end, title, constraint, evidence_level in _STORYBOARD + ] + return { + "schema_version": 1, + "kind": "aaai_demo_edit_decision_list", + "run_id": run.get("run_id", ""), + "duration_s": 300, + "segments": segments, + "required_corner_bug": "Evidence level and run ID must remain visible.", + "prohibited_claims": list(dict(bundle.get("claims") or {}).get("not_supported") or []), + "source_video": dict(bundle.get("trajectory") or {}).get("root", ""), + } + + +def render_demo_package(bundle: Mapping[str, Any], output_dir: Path) -> dict[str, Path]: + """Create a write-once interactive evidence page and video composition inputs.""" + target = output_dir.expanduser().resolve() + if target.exists(): + raise EvidenceBundleError(f"write-once render directory already exists: {target}") + target.mkdir(parents=True, exist_ok=False) + try: + index = target / "index.html" + storyboard = target / "storyboard.json" + viewspec = target / "causal-trace.viewspec-data.json" + _write_once(index, _html(bundle)) + _write_once(storyboard, json.dumps(_storyboard(bundle), indent=2, sort_keys=True) + "\n") + _write_once(viewspec, json.dumps(viewspec_data(bundle), indent=2, sort_keys=True) + "\n") + checksums = target / "checksums.sha256" + rows = [f"{sha256_file(path)} {path.name}" for path in sorted(target.iterdir()) if path.is_file()] + _write_once(checksums, "\n".join(rows) + "\n") + except Exception: + shutil.rmtree(target, ignore_errors=True) + raise + return {"index": index, "storyboard": storyboard, "viewspec": viewspec, "checksums": checksums} + + +def compose_backup_reel(clips: Sequence[Path], output_path: Path) -> Path: + """Concatenate reviewed video clips with ffmpeg while preserving their pixels.""" + if not clips: + raise EvidenceBundleError("at least one reviewed video clip is required") + if output_path.exists(): + raise EvidenceBundleError(f"write-once video output already exists: {output_path}") + ffmpeg = shutil.which("ffmpeg") + if ffmpeg is None: + raise EvidenceBundleError("ffmpeg is unavailable; render the HTML and EDL instead") + resolved = [clip.expanduser().resolve() for clip in clips] + if any(not clip.is_file() for clip in resolved): + raise EvidenceBundleError("a requested backup clip does not exist") + concat = output_path.with_suffix(".concat.txt") + if concat.exists(): + raise EvidenceBundleError(f"write-once concat list already exists: {concat}") + concat.parent.mkdir(parents=True, exist_ok=True) + lines = ["file '" + str(clip).replace("'", "'\\''") + "'" for clip in resolved] + _write_once(concat, "\n".join(lines) + "\n") + command = [ffmpeg, "-n", "-f", "concat", "-safe", "0", "-i", str(concat), "-c", "copy", str(output_path)] + try: + subprocess.run(command, check=True, capture_output=True, text=True, timeout=600) + except (OSError, subprocess.SubprocessError) as exc: + raise EvidenceBundleError(f"ffmpeg could not compose backup reel: {exc}") from exc + return output_path + + +__all__ = ["compose_backup_reel", "render_demo_package"] diff --git a/temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json b/temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json new file mode 100644 index 00000000..cabe1259 --- /dev/null +++ b/temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json @@ -0,0 +1,69 @@ +{ + "schema_version": 1, + "kind": "leapspace_structural_drift_fixture", + "evidence_level": "real_headless_structural_seam", + "source_test": "temp/leapspace_exp/evo-02/tests/test_environment_source_live.py", + "description": "The exact value-free before/after identities exercised by the real offscreen PyQt6 structural-seam test. This fixture is distinct from task-001's message_input rename scenario.", + "drifts": [ + { + "drift_id": "chat-probe.send-button.rename.v1", + "class": "interface_rename", + "reversible": true, + "before": { + "app_id": "chat_probe", + "version": "1.0", + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "after": { + "app_id": "chat_probe", + "version": "1.1", + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "dispatch_button", "role": "QPushButton"} + ] + }, + "capability_precondition": { + "capability": "chat.reply", + "bound_names": ["send_button"] + }, + "expected": { + "evidence_kind": "interface_drift", + "requirement_origin": "environment_probe", + "admission": "experiment_opt_in_only" + } + }, + { + "drift_id": "chat-probe.benign-emoji-added.v1", + "class": "benign_negative_control", + "reversible": true, + "before": { + "app_id": "chat_probe", + "version": "1.0", + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "after": { + "app_id": "chat_probe", + "version": "1.1-benign", + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"}, + {"name": "emoji_picker", "role": "QPushButton"} + ] + }, + "capability_precondition": { + "capability": "chat.reply", + "bound_names": ["send_button"] + }, + "expected": { + "evidence_kind": "none", + "requirement_count": 0 + } + } + ] +} diff --git a/temp/papers/aaai27_demo/demo_fixtures/task-001-structural-drifts.json b/temp/papers/aaai27_demo/demo_fixtures/task-001-structural-drifts.json new file mode 100644 index 00000000..453e9f04 --- /dev/null +++ b/temp/papers/aaai27_demo/demo_fixtures/task-001-structural-drifts.json @@ -0,0 +1,124 @@ +{ + "schema_version": 1, + "kind": "leapspace_structural_drift_fixture", + "evidence_level": "L2-planned", + "task_ref": "src/leapspace/app_space/tasks/task-001/config.yaml", + "description": "Declarative before/after StateSnapshot projections for the AAAI demo. These fixtures are not recorded evidence and must be paired with a real Leapspace trajectory and expect() output before they are presented as L2 results.", + "drifts": [ + { + "drift_id": "chat.message-input.rename.v1", + "class": "interface_rename", + "reversible": true, + "before": { + "app_id": "chat", + "version": "1", + "elements": [ + {"name": "contact_list", "role": "QListWidget"}, + {"name": "message_history", "role": "QTextEdit"}, + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "after": { + "app_id": "chat", + "version": "2", + "elements": [ + {"name": "contact_list", "role": "QListWidget"}, + {"name": "message_history", "role": "QTextEdit"}, + {"name": "reply_editor", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "capability_precondition": { + "capability": "chat.reply", + "bound_names": ["message_input", "send_button"], + "affordances": ["app.chat.reply"] + }, + "expected": { + "evidence_kind": "interface_drift", + "lowest_cost_actions": ["absorb", "rebind"], + "must_not_default_to": "acquire" + }, + "oracle": { + "kind": "leapspace_expect", + "status": "not_recorded", + "required_checks": ["reply-sent", "followup-arrived", "event-reply", "event-followup"] + } + }, + { + "drift_id": "chat.reply-affordance.removed.v1", + "class": "affordance_removed", + "reversible": true, + "before": { + "app_id": "chat", + "version": "1", + "affordances": ["app.chat.reply"], + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "after": { + "app_id": "chat", + "version": "2", + "affordances": [], + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "capability_precondition": { + "capability": "chat.reply", + "bound_names": ["message_input", "send_button"], + "affordances": ["app.chat.reply"] + }, + "expected": { + "evidence_kind": "affordance_removed", + "eligible_actions": ["rebind", "acquire", "escalate"], + "requires_resolution_first": true + }, + "oracle": { + "kind": "leapspace_expect", + "status": "not_recorded", + "required_checks": ["reply-sent", "followup-arrived"] + } + }, + { + "drift_id": "chat.benign-status.added.v1", + "class": "benign_negative_control", + "reversible": true, + "before": { + "app_id": "chat", + "version": "1", + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"} + ] + }, + "after": { + "app_id": "chat", + "version": "2", + "elements": [ + {"name": "message_input", "role": "QLineEdit"}, + {"name": "send_button", "role": "QPushButton"}, + {"name": "sync_status", "role": "QLabel"} + ] + }, + "capability_precondition": { + "capability": "chat.reply", + "bound_names": ["message_input", "send_button"], + "affordances": ["app.chat.reply"] + }, + "expected": { + "evidence_kind": "none", + "action": "no_op", + "proposal_count": 0 + }, + "oracle": { + "kind": "leapspace_expect", + "status": "not_recorded", + "required_checks": ["reply-sent"] + } + } + ] +} diff --git "a/temp/papers/aaai27_demo/plan/AAAI-27_Demo_\350\256\272\346\226\207\345\206\231\344\275\234\350\256\241\345\210\222.md" "b/temp/papers/aaai27_demo/plan/AAAI-27_Demo_\350\256\272\346\226\207\345\206\231\344\275\234\350\256\241\345\210\222.md" new file mode 100644 index 00000000..b08ef61d --- /dev/null +++ "b/temp/papers/aaai27_demo/plan/AAAI-27_Demo_\350\256\272\346\226\207\345\206\231\344\275\234\350\256\241\345\210\222.md" @@ -0,0 +1,280 @@ +# AAAI-27 Demo 论文写作计划 + +> 主题:从**自我进化 Harness**视角,结合 LeapFlow 的 **LLM world model + leapspace + 自我进化机制**,并以面向真实世界信号的 **OODA loop** 为辅线,写一篇 AAAI-27 Demonstrations Program 短论文(demo paper)。 +> +> 本计划为写作蓝图,不是论文正文;正文按第 4 节大纲分节撰写。 +> +> 约束来源:`../official/AAAI-27_Demonstration_Program_官方信息与投稿要求.md`(下称 official 文档,其中 [S1]=官方 Call,[S2]=Author Kit,[S3]=OpenReview 站点)。 +> 技术事实来源:`/Users/jason/work/github/leapflow` 代码库只读核查(文件路径见第 13 节证据台账)。 + +--- + +## 0. 官方硬约束回执(写作前必须锁定) + +以下每条都直接决定写作与排版,均取自 official 文档,不得违反: + +| 约束 | 取值 | 对写作的含义 | +|---|---|---| +| 正文篇幅 | two-page short paper | 正文严格控制在 **2 页**,超出即被退回。 | +| 参考文献 | one page of references only | references 单独占 **1 页**,且该页只能放参考文献。 | +| 排版 | AAAI two-column style(`aaai2027.sty` / `aaai2027.bst`) | 用 [S2] 的 `AnonymousSubmission2027.tex` 起稿;不得改 page layout。 | +| 视频 | video up to 5 minutes(可用 slides 替代,但 video 权重更高) | 必须产出 ≤5 分钟 demo 视频,作为 supplementary materials 传 OpenReview。 | +| 视频开头 | highly recommend 加 30s–1min overview(非强制) | 视频前 30–60s 放系统总览。 | +| 内容要求 | 呈现 technical details + 讨论 related work + 描述 significance + previously unpublished | 四要素在 2 页内都要出现,缺一不可。 | +| 新颖性 | 必须是 new ideas,非 mainstream products/services 已有 | 论文主张要落在“治理化、可解释、可回滚的信号驱动进化”这一差异点。 | +| 盲审 | single-blind 或 double-blind 二选一 | 见第 3 节匿名策略;默认建议 double-blind。 | +| reproducibility checklist | Demo track 不要求 | 不写、不传 checklist。 | +| 现场义务 | 至少一位 author 现场 in-person 演示;有 live demo 时段 | 论文与视频都要体现“可现场跑”,不是纯录播概念。 | +| 提交入口/截止 | [S3] OpenReview;实际底线取较早者 | [S1] 名义 Sep 18, 2026 11:59 PM AOE (UTC-12);但 [S3] 系统强制 **Sep 18, 2026 11:59 UTC**(约早 24h),以较早的 [S3] 时间为提交底线,见第 12 节。 | +| Author Kit 范围 | 仅取 two-column style / anonymous 参考 | [S2](含 `CameraReady2027.tex`)是面向 accepted-paper publication 的通用发表指南;其 source 上传、文件命名、copyright form、page charge 等**不作为 Demo 初投义务**,除非 [S1] 明确要求。 | +| 附录/页数边界 | Content Appendices 计入 page limits | 附录不为 Demo 增加页;全部非参考文献内容须落在 2 页内,额外一页只放 references。 | +| backup mode | official 措辞为 `It is expected`(非 `must`) | 仍应准备不依赖 special arrangement 的 backup,但定位为“预期”而非强制。 | + +--- + +## 1. 论文定位与核心主张 + +### 1.1 一句话定位(demo thesis) + +> **展示一个“自我进化 Harness”:它把真实 headless structural signal、条件性 signal-mode archive 与受控 counterfactual evidence 组织为可审计的 capability decision——cold-path world model 提供 teacher/student 与 four-value action space,OODA/PCD 解释执行深度,leapspace 提供 ground-truth structural envelope,而 off-by-default 的 governed pipeline 将 capability hypothesis 与实际 mutation authority 分离。** + +### 1.2 差异化卖点(对应 [S1] 的 new ideas 要求) + +主流 agent 产品的能力集要么是硬编码、要么是无治理地自动写代码。本 demo 的新点在于把“进化”做成一条**可治理、可审计、可回滚**的管线,并显式区分两层: + +- **“agent 知道什么”**(world model 的 grading + distillation):始终运行、不写代码、不改能力集、零额外风险; +- **“agent 能做什么”**(acquire→proposal→…→verified 的能力写入):off-by-default、逐门放行、每步留痕。 + +这一“knows vs can-do”分离,加上对 no-op/reject/reuse/unexercised boundary 的 causal evidence 可视化,是可现场演示的系统贡献;真实 install/approval/daemon long-horizon 仍按第 2 节的证据边界处理。 + +### 1.3 贡献点(demo paper 版,写进 Introduction 末尾,3 条以内) + +- **C1**:一个可观测、可干预的 `signal → OODA → world model → governed decision` Harness:真实 headless structural signal 与受控 CE-X 反事实都能进入同一证据叙事;不把它表述为 GUI-agent end-to-end execution。 +- **C2**:cold-path teacher/student world model 的 information-context 不对称与 four-value action space(absorb/rebind/acquire/escalate),分别服务知识蒸馏与 capability hypothesis;在 controlled ablation 完成前,不以现有 N=3/confounded 样本宣称可泛化诊断准确率。 +- **C3**:把 capability evolution 的 policy/lifecycle/approval contracts 与可审计 evidence boundary 展示为治理对象;CE-X 保留 no-op/reject/reuse/acquire-hypothesis,但真实 install、approval、daemon long-horizon trust/rollback 只在已有同 run artifact 时宣称。 + +--- + +## 2. 忠实性边界(本计划最重要的一节:可宣称 vs 不可宣称) + +demo paper 必须 previously unpublished 且不得 overclaim。以下边界基于代码核查,务必在正文/视频中严格遵守。 + +### 2.1 可以作为“可运行/可现场演示”宣称 + +- world model 的 **grading + distillation 始终运行**(不受 `evolution_enabled` 控制):对每个 session 打分、把学到的环境知识蒸馏进下一轮 context、并推荐优先使用哪个已装 provider。证据:`config.py` 注释、`world_model/trajectory_grader.py`、`storage/distilled_knowledge_store.py`。 +- **four-value 裁决**(absorb/rebind/acquire/escalate)与 `rebind`/`acquire` 的替代者判定逻辑(`build_alternatives_provider` + `requires_environment_affordances`)。证据:`domain/adaptation_verdict.py`、`learning/degradation_sink.py`。 +- **OODA loop + 弹性预算 + PCD**:`_run_agent_loop()`、`IterationBudget`(fixed/elastic)、`DisclosurePlanner`(CORE/EXPANDED/FULL)。证据:`engine/engine.py`、`engine/budget.py`、`engine/context_disclosure.py`、`engine/agent_loop.py`。 +- **治理管线的 Protocol 可达性与状态机**:`EvolutionProposalView`/`EvolutionLifecycleStore`/`OutcomeStore`、`AdaptiveEvolutionPolicy`、`LifecycleGovernor`、`PluginTrustLedger`;acquisition lifecycle 状态 `PENDING→GENERATED→APPROVED→INSTALLED→PROBATION→VERIFIED→REJECTED/FAILED/QUARANTINED`。证据:`plugins/evolution_contracts.py`、`plugins/adaptive_policy.py`、`plugins/lifecycle_governor.py`、`learning/plugin_trust.py`。 +- **可现场展示的入口**:CLI(`leap`)、TUI、leapd daemon;`leap config` 查看 `evolution_enabled` 等开关;`plugin_list` 的 live `capability_report`;`self_management` 工具插件的 `plugin_propose`/`plugin_generate`/`plugin_install`。证据:`cli/`、`daemon/`、`plugins/tool_plugins/self_management.py`。 +- **leapspace signal 模式**可运行:sandbox 内 `BaseLeapApp` 原子写 `state.json` / `events.jsonl`,`LeapAppHarness` 录制 reference stimulus 并运行 `expect()` 判定 PASS/FAIL。证据:`src/leapspace/app_space/harness.py`、`.../apps/_base.py`、`.../signal.py`。这不是 agent 在 sandbox 内求解任务。 +- **真实 headless structural seam**可运行:两个 offscreen PyQt6 `BaseLeapApp` 版本写出 role-aware `elements`;`LeapSpaceHostRpc` 以 `state.json` 满足 HostRpc 的结构查询;实验侧 `LeapSpaceEnvironmentSource` 将真实 rename 送入 shipped `CapabilityObservationService`,获得 opt-in `interface_drift` observation 和 `CapabilityRequirement(origin=environment_probe)`,并有 benign negative control/default refusal。证据:`src/leapspace/app_space/host_rpc.py`、`temp/leapspace_exp/evo-02/leapexp2/leapspace_source.py`、对应 tests。 + +### 2.2 必须明确标注为“off-by-default / 实验性 / 未实现”,不可当既成能力宣称 + +- **`evolution_enabled` 默认 False**:`acquire` 裁决→排队 proposal 的分支默认关闭;即便开启,generation/validation/approval/sandbox/trust 仍是其前方多道门。→ 正文措辞用“governed, opt-in pipeline”,**不要**写“系统会自主写代码上线”。 +- **learning 回路需显式配置**:`accepted_evidence_kinds` / `active_signal_sources` 为空时评分-获取回路处于惰性;现有 skills 皆 builtin。→ 演示自进化时须说明这是“operator opt-in”的实验配置。 +- **leapspace e2e 模式 = NotImplementedError**(`app_space/e2e.py` 为空):signal mode 只录制 reference stimulus 与 ground-truth verdict,不能让 agent 在 sandbox 里“求解”。→ 演示 leapspace 时不得暗示 e2e 闭环。 +- **headless structural seam 无 framebuffer**:`LeapSpaceHostRpc.screen.capture_frame` 诚实返回空;真实 widget rename→requirement 不等同于 Linux/KVM/AT-SPI 的 L2 GUI/OS/pixel 证据。→ 作为独立 lane,不升级为 EXP-7 已完成。 +- **C2 的 acquire 不等于真实 mutation**:canonical runner 明示未执行 code generation、approval prompt、real install、daemon、RecoveryCoordinator 与真实 LLM diagnosis。→ 画面必须显示 `not_exercised`,不可展示为 plugin 已上线。 +- **S1–S4(持久化方向、事件驱动重入、在线校准、常驻无限循环/resident agent)** 多为设计或默认关闭(`agent.reentry_enabled` 默认关闭)。→ 归入 “future work / roadmap”,不进 demo 主线。 +- `temp/leapspace_exp` 的 headless environment source 已是受测实验 seam,但仍是 experiment/reference layer;正文应描述其真实 widget→observation 事实,同时注明它尚非 e2e/daemon runtime 证据。 + +### 2.3 写作纪律 + +- 动词分级:始终运行的用“does / runs”;开关后的用“can, when enabled / opt-in”;未实现的用“is designed to / planned”。 +- 每条能力主张尽量对应视频里一个真实可见的画面(第 6、7 节)。 + +--- + +## 3. 标题、作者与匿名策略 + +### 3.1 候选标题(保持术语原文,二选一或微调) + +- 主推:**“LeapFlow: A Self-Evolving Harness that Turns Real-World Signals into Governed Capability Evolution”** +- 备选:**“From Signals to Governed Evolution: Demonstrating a World-Model-Driven Self-Evolving Agent Harness”** + +要点:标题需含 demo/system 气质,并同时出现 self-evolving / Harness / world model / governed 等关键词。 + +### 3.2 匿名策略(对应 official 第 7 节) + +- **默认建议 double-blind**:用 [S2] `AnonymousSubmission2027.tex`(`\usepackage[submission]{aaai2027}`),作者写 “Anonymous Submission”、清空 affiliations、提交前用 metadata-cleaning 工具清 PDF metadata、首页不放 copyright footer。 +- 视频与代码链接也要匿名化(去掉含真实机构/个人的仓库 URL、账号、水印);如需公开仓库,改用匿名镜像或 anonymized 链接。 +- 若最终选 single-blind,则作者信息正常出现,但仍需保证内容一致。 + +--- + +## 4. 逐节写作大纲与篇幅预算(2 页正文) + +> 目标:2 页两栏。建议总正文 ~1300–1600 词 + 1 张主图 +(可选)1 张小图/小表。references 另占第 3 页。以下“预算”为占版比例的经验值,撰写时以不超 2 页为硬红线。 + +### 4.1 Title + Abstract(~8%) +- Abstract 100–130 词:点出 gap(固定能力集/无治理自写代码)→ 我们 demo 什么(Harness + world model + governed evolution + OODA/leapspace)→ 现场观众能看到什么 → 差异点(knows vs can-do 的治理化分离)。 + +### 4.2 §1 Introduction & Motivation(~22%) +- 真实世界信号驱动的 agent 面临的问题:环境会漂移,能力集要么僵化、要么被不受控地自动改写。 +- 提出 demo 的核心命题(1.1)与 3 条贡献(1.3)。 +- 明确“这是一个可现场交互的系统 demo”,并预告 §3 现场脚本。 + +### 4.3 §2 System Overview(~30%,配主图 Figure 1) +分 4 个小段,每段 2–4 句,对应架构 4 大件: +- **(a) OODA loop 与自适应深度**:Observe(意图分类/技能触发)→ Orient(PCD 分层定向,CORE/EXPANDED/FULL)→ Decide(LLM 选工具/回复)→ Act(执行+观察);`IterationBudget` 按 difficulty 弹性调节迭代上限。 +- **(b) leapspace 环境侧信号**:`BaseLeapApp` 原子写 `state.json`/`events.jsonl` 与 role-aware `elements`;`LeapSpaceHostRpc` 将这些 ground truth 暴露为结构化 HostRpc facets。signal mode 可录制 reference stimulus 并运行 `expect()`;独立的 offscreen real-widget seam 证明 rename→`interface_drift`→`environment_probe` requirement,且保留 benign/default-off negative controls。 +- **(c) LLM world model(teacher/student, cold path)**:teacher 见全轨迹、student 只见当前态(information-context 不对称,源自 On-Policy Distillation 的 teacher-as-reward-model 思路);`grade_and_propose()` 单次 LLM 调用同时产出 grades 与 four-value verdicts;`absorb/rebind` 走知识蒸馏与 provider 优选,`acquire` 才是能力获取的 hypothesis,`escalate` 上抛。 +- **(d) Governed self-evolution pipeline**:acquire→proposal→generate→validate(syntax/structure/import/protocol)→compatibility→approval→install→sandbox smoke→register(DRAFT)→behavior tests→probation→trust accrual→verify;由 `AdaptiveEvolutionPolicy` 读结构化 (trust/risk/status/autonomy) 决策,`LifecycleGovernor` 记录转移与 trust ledger。**强调 off-by-default 与逐门放行。** + +### 4.4 §3 Demonstration(~28%,可配 Figure 2 或时间线小图) +- 现场剧本(见第 6 节)压缩为 3 个 scene:①真实 headless widget rename/benign control→opt-in requirement;②CE-X 的 none/reject/reuse/acquire-hypothesis 与 teacher/student/OODA 边界;③完整时才出现的 signal archive 与 read-only evidence console。 +- 明确“观众看到的界面”:headless seam record、`records.jsonl`/`summary.json`、bundle console、条件性的 signal archive、以及可选 live `causal_trace` lens;不把 `plugin_list` 或 `plugin_install` 的普通入口当作该 experiment 已执行的证据。 +- 一句话点出可交互性:观众可选择 rename/benign fixture、是否 opt-in evidence kind 和 C2 arm,观察 observation、requirement、resolution 与明确的 `not_exercised` 边界;不在现场改写 capability。 + +### 4.5 §4 Significance, Related Work & Limitations(~12%) +- Significance:对 AI 社区的意义——把 self-evolution 从“黑箱自改写”变成“可解释、可回滚、可审计”的治理对象;knows/can-do 分离降低风险。 +- Related work(2–4 句,密集引用,见第 8 节):train-free / on-policy distillation、LLM agents 与 tool learning、self-improving/self-modifying agents、agent governance & safety、world models for agents。 +- Limitations(1–2 句,诚实):acquire 通道 opt-in;CE-X 未执行真实 install/approval/daemon/independent oracle;leapspace e2e 未实现,headless seam 无 pixels;teacher live diagnosis 仍是 N=3/confounded;resident/reentry 未默认启用——与第 2.2 节一致。 + +### 4.6 References(第 3 页,仅参考文献) +- 用 `\bibliography` + `aaai2027.bst`;控制在能放满但不溢出 1 页的数量(约 12–20 条)。 + +--- + +## 5. 图表计划(适配两栏,PDFLaTeX 只接受 .pdf/.png/.jpg) + +- **Figure 1(主图,跨栏或单栏均可)— 系统架构与信号流**:从 leapspace/真实交互的 signals → OODA loop(含 PCD 分层与 elastic budget)→ world model(teacher/student + four-value verdict)→ 分叉:`absorb/rebind`(distilled knowledge / provider 优选,always-on)与 `acquire`(governed pipeline,gated)。图上用不同底色区分 always-on vs off-by-default。**这是必备图**,承担 §2 主要信息量。 +- **Figure 2(可选,小图/时间线)— governed evolution lifecycle**:画 acquisition lifecycle 状态机(PENDING→…→VERIFIED,以及 REJECTED/FAILED/QUARANTINED 分支),标出 approval 门与 trust/probation 节点。若 2 页排不下则并入 Figure 1 或省略。 +- **不使用**:截图堆叠、type-3 字体、.gif/.eps;图内文字用矢量 pdf,保证 300dpi 以上或矢量。 +- 图注(caption)承担部分说明,减轻正文字数压力。 + +--- + +## 6. Demo 现场脚本(storyboard,供 §3 与视频共用) + +3 幕均以可核验 artifact 为前提;TUI/直接 `plugin_install` 不再是主线,避免用未闭合的 e2e/approval 代替证据: + +- **Scene A — 真实 headless structural signal(~1.25 min)** + - 运行 write-once headless seam:真实 offscreen PyQt6 widgets 写 `elements`,`send_button → dispatch_button` 经 `LeapSpaceEnvironmentSource` 产生 `interface_drift` 与 `environment_probe` requirement。 + - 同屏展示 benign negative control 和 default classifier refusal,强调 observation ingress 不授予 mutation authority;明确无 pixels/GUI-agent e2e。 + +- **Scene B — CE-X 受控四臂与 world-model/OODA 边界(~2 min)** + - 运行/回放 `run_c2.py` 的 `records.jsonl`/`summary.json`,对称展示 none、rejected、reuse 和 acquire hypothesis;C2 的 live catalog resolution、profile isolation、authorisation 和 handler-reported verifier 是可见事实。 + - world model/PCD 仅展示架构或同 run 记录的 information boundary 与 four-value action space;不把 N=3/confounded 样本说成 accuracy result。 + +- **Scene C — 条件性 signal archive 与 read-only evidence console(~1 min)** + - 有完整 manifest 时播放 reference stimulus + `expect()` PASS、state/event 与 media hashes;无 archive 时 console 显示 `not_supplied`,不以代理画面替代。 + - `aaai_demo render` 的 bundle console 展示 claims、unexercised approval/install/daemon/independent oracle;`causal_trace` 仅在 live framework-evolution finding 存在时作为只读补充。 + +- **收尾(~0.5 min)**:回到 thesis——knows/can-do 分离、负结果可见、每种证据层级不互相升级。 + +> 备用/backup mode(official 第 10 节;[S1] 措辞为 `It is expected`,非 `must`):若现场 LLM/网络不可用,运行 deterministic headless seam + C2 + 已封存 bundle;若已审核 signal archive 存在,使用 `backup-reel` 拼接它。不得为了 backup 伪造 GUI/e2e/approval 成功。 + +--- + +## 7. 视频计划(≤5 分钟) + +| 时间 | 内容 | 对应 | +|---|---|---| +| 0:00–0:35 | overview:一句话 thesis + evidence-level architecture(对应 [S1] 建议的 30–60s overview) | §Abstract/§1 | +| 0:35–1:25 | Scene A:headless PyQt rename、negative control、opt-in observation admission | §2(b), §3① | +| 1:25–2:10 | teacher/student + OODA/PCD 的结构边界,不报告未校准 rate | §2(a,c) | +| 2:10–3:55 | Scene B:CE-X 四臂与 `not_exercised` 证据边界 | §2(d), §3② | +| 3:55–4:35 | Scene C:完整时才播放 signal archive;否则显示 `not_supplied` | §2(b), §3③ | +| 4:35–5:00 | 收尾、limitations、`run_c2 → bundle → render` 复现路径 | §4 | + +- 主视频严格 ≤5 分钟;`aaai_demo.render` 的 EDL 必须是 300 秒。录屏用真实 terminal output、bundle console 和已审核 archive;关键处持续显示 evidence level 与 run ID。 +- double-blind:视频去除机构水印、真实账号、可识别路径;导出前清 metadata。 +- 交付格式:常见 mp4/H.264;作为 supplementary materials 上传 OpenReview。 + +--- + +## 8. Related work 引用清单(供撰写与 .bib 组织,按主题) + +按主题各选代表作,密集但精炼(最终 12–20 条,放第 3 页): + +- **On-Policy Distillation / train-free learning**:teacher-as-reward-model、hindsight 轨迹打分(对应 `trajectory_grader.py` 的思想来源)。 +- **LLM agents & tool learning**:ReAct、Toolformer、以及 tool-use/agent survey。 +- **Self-improving / self-modifying agents**:Voyager(skill library 自增长)、自反思类(Reflexion)、自动化 agent 构建。 +- **Agent governance / safety / approval**:human-in-the-loop 审批、能力沙箱与隔离、progressive autonomy/trust 的相关工作。 +- **World models for agents**:world-model-based planning/adaptation 的代表作。 +- **Environment / benchmark & CUA sandbox**:computer-use agent、GUI/desktop 交互环境(对应 leapspace 定位)。 + +> 写作时每个主题 1–3 句带过,用 `\citep`/`\citet`;避免逐篇展开(篇幅不允许)。真实 bib 条目在起稿时据实补全,勿编造引用。 + +--- + +## 9. 术语与命名规范(保持原文,不翻译) + +正文中以下术语**一律保留英文原样**(首次出现可加一句中文/英文释义,其后直接用原词): + +- 架构/机制:`Harness`、`world model`、`teacher/student`、`OODA loop`、`Observe/Orient/Decide/Act`、`Progressive Context Disclosure (PCD)`、`leapspace`、`self-evolution`、`capability`、`plugin`。 +- 裁决/生命周期:`absorb / rebind / acquire / escalate`、`EvolutionIntent`、`CapabilityRequirement`、`AdaptiveEvolutionPolicy`、`LifecycleGovernor`、`trust / probation / quarantine`、lifecycle 状态 `PENDING/GENERATED/APPROVED/INSTALLED/PROBATION/VERIFIED/REJECTED/FAILED/QUARANTINED`。 +- 开关/配置:`evolution_enabled`、`accepted_evidence_kinds`、`selection_policy`、`distilled_knowledge_ttl_s`。 +- 入口:`leapd`、`TUI`、`leap config`、`plugin_list`、`capability_report`、`plugin_propose/generate/install`。 + +统一大小写与拼写(如 `LeapFlow`、`leapspace`、`OODA`),全篇一致。 + +--- + +## 10. 排版与提交 checklist(AAAI Kit + OpenReview) + +起稿与交付逐项核对(对应 official 第 6/7/11 节): + +- [ ] 用 `AnonymousSubmission2027.tex` 起稿,加载 `\usepackage[submission]{aaai2027}`;引用 `aaai2027.bst`。 +- [ ] 正文 ≤2 页;references 单独 1 页且只放参考文献。 +- [ ] 不改 page layout(禁 `\columnsep`/`\textwidth`/geometry 等);不打印页码;正文 10pt Times、无正文着色。 +- [ ] 图为 .pdf/.png/.jpg,无 type-3 字体,不侵入 margin。 +- [ ] double-blind:无作者名/机构、清 PDF metadata、首页无 copyright footer;视频/链接同步匿名。 +- [ ] 不含 reproducibility checklist(Demo track 不要求)。 +- [ ] 视频 ≤5min,含 30–60s overview,作为 supplementary 上传;(可选)代码作为 supplementary。 +- [ ] 按官方“expected”预期具备 backup mode(预录 signal trace + cassette 回放);[S1] 用词为 `It is expected`、非 `must`。 +- [ ] Author Kit 范围自限:不把 [S2] 中仅面向 accepted-paper publication 的事项(LaTeX source 上传、文件命名、copyright form、page charge)当作 Demo 初投义务,除非 [S1] 明确要求。 +- [ ] 页数边界自检:Content Appendices 计入 page limits、不为 Demo 增加附录页;全部非参考文献内容落在 2 页内,额外一页只放 references。 +- [ ] OpenReview 账号就绪,经 [S3] 提交;以较早的 [S3] 系统强制时间 **Sep 18, 2026 11:59 UTC** 为实际底线([S1] 名义为 Sep 18 11:59 PM AOE / UTC-12,约晚 24h),务必按较早者完成 final submission。 +- [ ] 全篇“动词分级”自检(第 2.3 节),无 overclaim。 + +--- + +## 11. 建议的 plan 目录产出物 + +本次先产出本写作计划;后续在同目录(`../plan/`)可逐步补齐: + +- `outline.md`(可选):把第 4 节大纲拆成逐段 bullet,供直接填字。 +- `figures/`(可选):Figure 1/2 的草图与最终矢量图源。 +- `related_work.bib`(可选):第 8 节引用的真实 bib 条目。 +- `video_script.md`(可选):第 7 节脚本逐镜头细化 + 旁白稿。 + +(正文 `.tex` 建议放到独立的 `../submission/` 目录,与 plan 分离。) + +--- + +## 12. 任务分解与时间线(实际提交底线 [S3] Sep 18, 2026 11:59 UTC / notify Nov 6 / camera-ready Nov 20) + +> 截止时间跨来源核对:[S1] 名义 Sep 18, 2026 11:59 PM AOE (UTC-12)(≈Sep 19 11:59 UTC),[S3] OpenReview 系统强制 Sep 18, 2026 11:59 UTC(约早 24h)。本计划一律以较早的 [S3] 时间为底线。 + +| 阶段 | 产出 | 建议完成点 | +|---|---|---| +| T0 计划确认 | 本文件 + 与合作者确认 thesis/边界 | 立即 | +| T1 证据固化 | 复核第 2 节可宣称/不可宣称清单,逐条对齐代码 | +2 天 | +| T2 主图 | Figure 1 定稿(架构+信号流+always-on/gated 分色) | +4 天 | +| T3 初稿 | §1–§4 正文(控 2 页)+ references 草表 | +8 天 | +| T4 demo 环境 | 现场剧本三幕可跑 + backup(cassette)验证 | +10 天 | +| T5 视频 | 录屏 + 剪辑 ≤5min + overview + 匿名化 | +13 天 | +| T6 匿名与排版终审 | double-blind 自检 + Kit 合规 checklist 全绿 | 截止前 3 天 | +| T7 提交 | OpenReview 上传 paper + 视频/补充材料 | [S3] Sep 18, 2026 11:59 UTC 前(较 [S1] 名义 AOE 早约 24h,取较早者) | + +(若录用:Nov 20 前完成 camera-ready,并按 official 第 10 节与 Chairs 敲定现场展台/特殊需求。) + +--- + +## 13. 证据台账(技术主张 → 代码路径) + +供撰写与自检时溯源,避免 overclaim: + +- world model / teacher-student:`src/leapflow/world_model/trajectory_grader.py`、`src/leapflow/learning/world_model_driver.py`、`src/leapflow/storage/distilled_knowledge_store.py` +- four-value / 替代者判定:`src/leapflow/domain/adaptation_verdict.py`、`src/leapflow/domain/evolution_intent.py`、`src/leapflow/learning/degradation_sink.py`(`build_alternatives_provider` / `requires_environment_affordances`) +- OODA / 预算 / PCD:`src/leapflow/engine/engine.py`(`_run_agent_loop`)、`src/leapflow/engine/budget.py`(`IterationBudget`)、`src/leapflow/engine/context_disclosure.py`(`DisclosurePlanner`)、`src/leapflow/engine/agent_loop.py` +- 治理管线:`src/leapflow/plugins/evolution_contracts.py`、`src/leapflow/plugins/adaptive_policy.py`、`src/leapflow/plugins/lifecycle_governor.py`、`src/leapflow/learning/plugin_trust.py`、`src/leapflow/learning/capability_gap_detector.py`、`src/leapflow/learning/plugin_generator.py` +- 开关/配置:`src/leapflow/config.py`(`evolution_enabled` 默认 False、`accepted_evidence_kinds`、`distilled_knowledge_*`、`selection_policy`) +- 入口/演示:`src/leapflow/cli/`、`src/leapflow/daemon/`、`src/leapflow/plugins/tool_plugins/self_management.py` +- leapspace:`src/leapspace/app_space/harness.py`(signal 可用 / e2e `NotImplementedError`)、`src/leapspace/app_space/apps/_base.py`(role-aware elements)、`src/leapspace/app_space/host_rpc.py`(headless structural HostRpc)、`src/leapspace/app_space/signal.py`、`src/leapspace/app_space/e2e.py`(空) +- headless environment seam:`temp/leapspace_exp/evo-02/leapexp2/leapspace_source.py`、`tests/test_environment_source_l1.py`、`tests/test_environment_source_live.py`;它们证明 widget→observation/requirement,不替代 e2e。 +- Demo evidence tooling:`temp/papers/aaai27_demo/aaai_demo/{headless_seam,evidence,render,cli}.py`、`demo_fixtures/`、`reproduction.md`。 +- 诚实局限性素材:`temp/leapspace_exp/` 的实验计划与 reports,尤其是 L1/L2/L3 划分、real-LLM N=3/confounded 与 C2 substitutions。 diff --git a/temp/papers/aaai27_demo/reproduction.md b/temp/papers/aaai27_demo/reproduction.md new file mode 100644 index 00000000..4955eeb3 --- /dev/null +++ b/temp/papers/aaai27_demo/reproduction.md @@ -0,0 +1,118 @@ +# AAAI Demo Reproduction Guide + +## Evidence Levels + +The demo keeps three intentionally separate evidence lanes: + +- **L1 controlled mechanism evidence** is the CE-X four-arm counterfactual run. It supports no-op, rejection, catalog reuse, and acquisition-hypothesis routing under isolated profiles. +- **Real headless structural seam** uses two offscreen PyQt6 `BaseLeapApp` versions, role-aware state envelopes, `LeapSpaceEnvironmentSource`, and the shipped `CapabilityObservationService`. It proves a real widget rename can become an opt-in `environment_probe` requirement; it has no framebuffer and is not GUI-agent e2e. +- **Conditional signal archive** consists of a real Leapspace signal-mode trajectory, state/event evidence, and an unmodified `expect()` result declared in one archive manifest. Do not call this lane live or end-to-end unless every declared artifact is present and the verdict is PASS. +- **L3 runtime-governance evidence** requires the real daemon, approval route, lifecycle/trust trajectory, and rollback evidence. It is not inferred from L1, the headless seam, or a signal archive. + +Never describe a missing lane as completed. The generated evidence bundle enumerates its own `claims.not_supported` list and the reviewer console renders those boundaries verbatim. + +## Prerequisites + +- A completed CE-X run directory containing `manifest.json`, `records.jsonl`, and `summary.json`. +- Python with the repository dependencies available. +- A PyQt6-enabled environment for the real offscreen structural-seam export. The repository's default lightweight environment may skip this lane. +- Optionally, a declared signal archive manifest with a recording, cursor path, state snapshot, event log, and `expect()` stdout. +- A Linux/KVM/AT-SPI environment is required to create new full GUI footage. On a host without that environment, use the L1 lane plus the real headless seam; do not synthesize a screen recording. + +## Create a CE-X Run + +```bash +PYTHONPATH=temp/leapspace_exp/evo-02 uv run python temp/leapspace_exp/evo-02/orchestrator/run_c2.py +``` + +The command prints the run directory. Preserve the entire directory as a raw experiment artifact. It contains substitutions that delimit the L1 claim, including the absence of real approval, installation, and independent GUI oracle coverage. + +## Export the Real Headless Structural Seam + +Run this only in the PyQt6-enabled environment. The output is write-once and contains hashes for the real widget envelopes, durable observation, requirement identity, benign negative control, and default refusal. + +```bash +PYTHONPATH=temp/papers/aaai27_demo:temp/leapspace_exp/evo-02 uv run python -m aaai_demo.cli headless-seam \ + --output-dir temp/papers/aaai27_demo/demo/headless/ +``` + +## Declare a Signal Archive + +A signal archive manifest is a JSON object with `schema_version: 1`, `kind: "leapspace_signal_archive"`, `run_id`, `expect: {"verdict": "pass", "exit_code": 0}`, and relative artifact entries of kinds `recording`, `cursor_path`, `state_snapshot`, `event_log`, and `expect_stdout`. Each artifact has `path` and optional `sensitive`. Missing files or a non-PASS verdict render the archive `incomplete`; they never become a successful L2 claim. + +## Export the Evidence Bundle + +Use a new output directory for every export. The exporter refuses to replace a bundle or its files. + +```bash +PYTHONPATH=temp/papers/aaai27_demo:temp/leapspace_exp/evo-02 uv run python -m aaai_demo.cli bundle \ + --run-dir temp/leapspace_exp/runs/ \ + --output-dir temp/papers/aaai27_demo/demo/evidence/ \ + --drift-fixture temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json \ + --headless-seam temp/papers/aaai27_demo/demo/headless//headless_seam.json \ + --signal-archive /absolute/path/signal_archive.json +``` + +Omit `--signal-archive` when no complete archive exists; the bundle will show `not_supplied`. `--trajectory-dir` remains a legacy media index and does not establish an independent oracle. Add `--include-media` only after confirming that the media is safe to place in the evidence package. + +The bundle includes hashes for the CE-X source files, headless seam and signal-archive status, a compact causal trace, per-arm evidence boundaries, and the copied fixture. It intentionally labels CE-X effect confirmation as a handler-reported outcome rather than an independent `expect()` oracle. + +## Render the Read-Only Console and Video EDL + +```bash +PYTHONPATH=temp/papers/aaai27_demo uv run python -m aaai_demo.cli render \ + --bundle temp/papers/aaai27_demo/demo/evidence//bundle.json \ + --output-dir temp/papers/aaai27_demo/demo/render/ +``` + +Open `index.html` locally. It has four synchronized columns: Leapspace evidence, Observe/Orient, Decide/PCD, and Governance/Effect. The matrix gives no-op, rejection, reuse, and acquisition-hypothesis equal visual weight. The view distinguishes the legacy trajectory index, declared signal archive, and real headless seam. `storyboard.json` is the 300-second edit decision list; it includes narration constraints and prohibited claims. + +The hidden LeapBoard `causal_trace` template is an alternative read-only lens over a live `framework_evolution` finding. It is hidden from ordinary navigation so it cannot broaden the normal product surface. Invoke it explicitly only for the experiment/audit workflow. + +## Evolution Live Lens + +`evolution_live` is a hidden, read-only LeapBoard lens over the same authoritative `framework_evolution` snapshot. Runtime traces are projected into Environment, Decision, and Governance lanes through `evolution.presentation` WebSocket messages. On reconnect, the browser fetches the authoritative snapshot again; the lens never writes a proposal, resolves approval, or runs a replay against the runtime. + +## Provisional Accepted-Demo Poster Source + +A poster is **not** a replacement for the required initial video/slides material. It is an accepted-demo station aid: the official call provides a poster board but defers final exhibit format information to the Chairs. Generate only the responsive source until that information arrives. + +```bash +PYTHONPATH=temp/papers/aaai27_demo uv run python -m aaai_demo.cli poster \ + --bundle temp/papers/aaai27_demo/demo/evidence//bundle.json \ + --output-dir temp/papers/aaai27_demo/demo/poster/ +``` + +The output records `3:4 portrait` only as a provisional design ratio and explicitly marks the official print size as pending. Do not print or claim a final format before the Chairs provide the station specification. + +## Backup Reel + +After reviewing clip provenance and continuity, concatenate archived clips without re-encoding: + +```bash +PYTHONPATH=temp/papers/aaai27_demo uv run python -m aaai_demo.cli backup-reel \ + --clip /absolute/path/intro.mp4 \ + --clip /absolute/path/trajectory.mp4 \ + --output temp/papers/aaai27_demo/demo/backup-90s.mp4 +``` + +The helper uses `ffmpeg -n`, so an existing output is never replaced. The main five-minute video is assembled from the 300-second EDL with reviewed overlays and narration; the tool does not fabricate unavailable signal-archive, e2e, approval, or L3 footage. + +## Verification + +```bash +uv run pytest temp/papers/aaai27_demo/tests -q +uv run pytest tests/test_dashboard_sdui.py tests/test_dashboard_view.py -q +PYTHONPATH=src:temp/papers/aaai27_demo:temp/leapspace_exp/evo-02 \ + conda run -n leap pytest temp/papers/aaai27_demo/tests/test_demo_artifacts.py -q +``` + +Before recording or submission, verify all of the following: + +1. Every visible claim maps to a hash-listed source artifact. +2. The four CE-X arms have four distinct profile roots and the expected action for each arm. +3. No-op and rejected arms appear in the rendered matrix and causal trace. +4. Any actual GUI footage has a declared signal archive, PASS `expect()` output, and aligned state/event artifacts. +5. Any headless structural seam record contains the rename, benign control, default refusal, and `environment_probe` requirement. +6. Any real mutation has its own approval record; L1 acquisition hypotheses must remain labelled as non-install evidence. +7. The video is at most 300 seconds, and the dashboard, paper captions, and evidence bundle use the same evidence language. diff --git a/temp/papers/aaai27_demo/tests/test_demo_artifacts.py b/temp/papers/aaai27_demo/tests/test_demo_artifacts.py new file mode 100644 index 00000000..3ef42fdd --- /dev/null +++ b/temp/papers/aaai27_demo/tests/test_demo_artifacts.py @@ -0,0 +1,210 @@ +"""Tests for AAAI demo evidence packaging without a live GUI or LLM.""" + +from __future__ import annotations + +import json +import sys +from pathlib import Path + +import pytest + + +_DEMO_ROOT = Path(__file__).resolve().parents[1] +_EVO2_ROOT = _DEMO_ROOT.parents[1] / "leapspace_exp" / "evo-02" +for path in (str(_DEMO_ROOT), str(_EVO2_ROOT)): + if path not in sys.path: + sys.path.insert(0, path) + +from aaai_demo.evidence import ( # noqa: E402 + EvidenceBundleError, + build_evidence_bundle, + export_evidence_bundle, +) +from aaai_demo.headless_seam import export_headless_seam # noqa: E402 +from aaai_demo.poster import render_poster_source # noqa: E402 +from aaai_demo.render import render_demo_package # noqa: E402 + + +_ARMS = ( + ("unchanged_baseline", "none", "none", 0), + ("irrelevant_delta_rejected", "none", "none", 0), + ("satisfied_by_catalog", "reuse", "reuse", 0), + ("unmet_traverses_lifecycle", "acquire", "acquire", 1), +) + + +def _run(tmp_path: Path) -> Path: + run = tmp_path / "c2-test" + run.mkdir() + manifest = { + "run_id": "c2-test", + "lane": "L1", + "family": "C2_coevolution_counterfactual", + "protocol_id": "LEAPSPACE-EVO-02", + "experiment_version": "v1", + "subject": {"commit": "abc123"}, + "substitutions": {"not_exercised": "approval prompt, real install, daemon"}, + } + summary = {"arms_total": 4, "arms_correct": 4, "mutations": 1, "effect_confirmed": 1} + records = [] + for index, (arm, expected, action, verified) in enumerate(_ARMS): + records.append({ + "arm": arm, + "expected_action": expected, + "action": action, + "ok": True, + "proposed": 1 if arm == "unmet_traverses_lifecycle" else 0, + "admitted": 1 if arm == "unmet_traverses_lifecycle" else 0, + "requirements": 1 if arm in {"satisfied_by_catalog", "unmet_traverses_lifecycle"} else 0, + "authorised": arm != "irrelevant_delta_rejected", + "effect_verified": verified, + "effect_refuted": 0, + "profile_root": str(run / "isolated" / f"profile-{index}"), + "notes": f"evidence for {arm}", + }) + (run / "manifest.json").write_text(json.dumps(manifest), encoding="utf-8") + (run / "summary.json").write_text(json.dumps(summary), encoding="utf-8") + (run / "records.jsonl").write_text( + "".join(json.dumps(record) + "\n" for record in records), encoding="utf-8" + ) + return run + + +def _fixture() -> Path: + return _DEMO_ROOT / "demo_fixtures" / "task-001-structural-drifts.json" + + +def _signal_archive(tmp_path: Path, *, complete: bool = True) -> Path: + archive = tmp_path / "signal-archive" + archive.mkdir() + paths = { + "recording": "recording.mp4", + "cursor_path": "cursor.jsonl", + "state_snapshot": "chat/state.json", + "event_log": "chat/events.jsonl", + "expect_stdout": "expect.stdout", + } + for path in paths.values(): + artifact = archive / path + artifact.parent.mkdir(parents=True, exist_ok=True) + artifact.write_text("evidence", encoding="utf-8") + artifacts = [ + {"kind": kind, "path": path, "sensitive": kind in {"recording", "state_snapshot"}} + for kind, path in paths.items() + if complete or kind != "event_log" + ] + manifest = { + "schema_version": 1, + "kind": "leapspace_signal_archive", + "run_id": "signal-test", + "expect": {"verdict": "pass", "exit_code": 0}, + "artifacts": artifacts, + } + path = archive / "signal_archive.json" + path.write_text(json.dumps(manifest), encoding="utf-8") + return path + + +def _headless_seam(tmp_path: Path) -> Path: + path = tmp_path / "headless_seam.json" + path.write_text(json.dumps({ + "schema_version": 1, + "kind": "aaai_demo_headless_seam", + "run_id": "headless-test", + "rename": {"evidence_kind": "interface_drift"}, + "benign_control": {"evidence_count": 0}, + "default_refusal": {"admitted": False}, + "requirement": {"capability": "chat.reply", "origin": "environment_probe"}, + }), encoding="utf-8") + return path + + +def test_bundle_preserves_l1_boundaries_and_counterfactual_order(tmp_path: Path) -> None: + bundle = build_evidence_bundle(_run(tmp_path), drift_fixture=_fixture()) + + assert [arm["arm"] for arm in bundle["arms"]] == [item[0] for item in _ARMS] + unmet = bundle["arms"][-1] + assert unmet["outcome"] == "acquire_hypothesis" + assert unmet["approval"] == "not_exercised" + assert unmet["registry_mutation"] == "not_exercised" + assert unmet["effect"]["independent_oracle"] == "not_available" + assert "End-to-end Leapspace agent execution." in bundle["claims"]["not_supported"] + assert len(bundle["drift_fixture"]["drifts"]) == 3 + assert bundle["signal_archive"]["status"] == "not_supplied" + assert bundle["headless_seam"]["status"] == "not_supplied" + + +def test_bundle_binds_complete_signal_archive_and_headless_seam(tmp_path: Path) -> None: + bundle = build_evidence_bundle( + _run(tmp_path), + signal_archive=_signal_archive(tmp_path), + headless_seam=_headless_seam(tmp_path), + ) + + assert bundle["signal_archive"]["status"] == "available" + assert bundle["signal_archive"]["expect"] == {"verdict": "pass", "exit_code": 0} + assert len(bundle["signal_archive"]["artifacts"]) == 5 + assert bundle["headless_seam"]["status"] == "available" + assert bundle["headless_seam"]["requirement"]["origin"] == "environment_probe" + + +def test_incomplete_signal_archive_is_visible_not_upgraded_to_pass(tmp_path: Path) -> None: + bundle = build_evidence_bundle(_run(tmp_path), signal_archive=_signal_archive(tmp_path, complete=False)) + + assert bundle["signal_archive"]["status"] == "incomplete" + assert "event_log" in bundle["signal_archive"]["missing"] + + +def test_headless_seam_export_records_real_widget_evidence_when_pyqt_is_available(tmp_path: Path) -> None: + pytest.importorskip("PyQt6") + + record = export_headless_seam(tmp_path / "headless") + + assert record["rename"]["evidence_kind"] == "interface_drift" + assert record["benign_control"]["evidence_count"] == 0 + assert record["default_refusal"]["admitted"] is False + assert record["requirement"]["origin"] == "environment_probe" + seam_path = tmp_path / "headless" / "headless_seam.json" + assert seam_path.is_file() + assert build_evidence_bundle(_run(tmp_path), headless_seam=seam_path)["headless_seam"]["status"] == "available" + + +def test_export_and_render_are_write_once(tmp_path: Path) -> None: + source = _run(tmp_path) + bundle_dir = tmp_path / "bundle" + bundle = export_evidence_bundle( + source, + bundle_dir, + drift_fixture=_fixture(), + signal_archive=_signal_archive(tmp_path), + headless_seam=_headless_seam(tmp_path), + ) + + assert (bundle_dir / "bundle.json").is_file() + assert (bundle_dir / "checksums.sha256").is_file() + assert (bundle_dir / "raw" / "records.jsonl").is_file() + assert (bundle_dir / "raw" / "signal_archive.json").is_file() + assert (bundle_dir / "raw" / "headless_seam.json").is_file() + with pytest.raises(EvidenceBundleError, match="already exists"): + export_evidence_bundle(source, bundle_dir, drift_fixture=_fixture()) + + render_dir = tmp_path / "render" + paths = render_demo_package(bundle, render_dir) + html = paths["index"].read_text(encoding="utf-8") + assert "CE-X four-arm matrix" in html + assert "End-to-end Leapspace agent execution." in html + storyboard = json.loads(paths["storyboard"].read_text(encoding="utf-8")) + assert storyboard["duration_s"] == 300 + assert storyboard["segments"][-1]["end_s"] == 300 + assert "Signal archive" in html + assert "Headless seam" in html + poster_dir = tmp_path / "poster" + poster = render_poster_source(bundle, poster_dir) + assert "PROVISIONAL SOURCE" in poster["poster"].read_text(encoding="utf-8") + assert json.loads(poster["format"].read_text(encoding="utf-8"))["official_size"] == ( + "pending_chairs_exhibit_format_information" + ) + with pytest.raises(EvidenceBundleError, match="already exists"): + render_poster_source(bundle, poster_dir) + with pytest.raises(EvidenceBundleError, match="already exists"): + render_demo_package(bundle, render_dir) diff --git a/tests/leapspace/test_actor.py b/tests/leapspace/test_actor.py index 14e6b285..e0159239 100644 --- a/tests/leapspace/test_actor.py +++ b/tests/leapspace/test_actor.py @@ -13,7 +13,7 @@ element_center, find_ax_element, ) -from leapspace.app_space.utils import get_image_venv_python +from leapspace.app_space.state import get_image_venv_python VENV_PYTHON = get_image_venv_python("linux") SYSTEM_PYTHON = "/usr/bin/python3" diff --git a/tests/leapspace/test_harness.py b/tests/leapspace/test_harness.py index 4e7fc0a3..6fb6c106 100644 --- a/tests/leapspace/test_harness.py +++ b/tests/leapspace/test_harness.py @@ -24,7 +24,7 @@ RECORD_START_FILE, RECORD_STOP_FILE, ) -from leapspace.app_space.utils import LeapAppImage, get_image_venv_python +from leapspace.app_space.state import LeapAppImage, get_image_venv_python PYTHON = get_image_venv_python("linux") diff --git a/tests/leapspace/test_signal_bridge_live.py b/tests/leapspace/test_signal_bridge_live.py new file mode 100644 index 00000000..60ea0aa5 --- /dev/null +++ b/tests/leapspace/test_signal_bridge_live.py @@ -0,0 +1,113 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Live-Qt signal bridge: a real offscreen app's ground truth reaches LeapFlow. + +The strongest headless realism available without a hypervisor: a real PyQt6 +``BaseLeapApp`` runs offscreen, writes its own ``state.json`` from the live +widget tree (role-aware ``elements``), and LeapFlow's *shipped* +``StateSnapshotService`` perceives it through ``LeapSpaceHostRpc``. This upgrades +the earlier bridge test from a hand-written envelope to one a real app emitted. + +Runs in the conda ``leap`` env (PyQt6 present); skips where PyQt6 is absent. +""" + +from __future__ import annotations + +import asyncio +import json +import os +from pathlib import Path + +import pytest + +pytest.importorskip("PyQt6") +# Must be set before any QApplication is constructed. +os.environ.setdefault("QT_QPA_PLATFORM", "offscreen") + +from PyQt6.QtWidgets import QApplication # noqa: E402 + +from leapflow.perception.state_snapshot import ( # noqa: E402 + SnapshotFidelity, + StateSnapshotService, +) +from leapspace.app_space.apps import _base as base_mod # noqa: E402 +from leapspace.app_space.apps.chat import ChatApp # noqa: E402 +from leapspace.app_space.host_rpc import LeapSpaceHostRpc # noqa: E402 + + +class _FakeEpisodic: + def recent(self, limit: int = 5): + return [] + + def search_fragments(self, terms, limit: int = 1): + return [] + + +@pytest.fixture(scope="session") +def qapp(): + """One process-wide QApplication, mirroring test_base's proven pattern. + + Session-scoped and never torn down: constructing/destroying QApplication per + test aborts the offscreen platform, and a live app instance is what keeps + ``QApplication.instance()`` valid across the file when it runs standalone. + """ + return QApplication.instance() or QApplication([]) + + +def _make_app(state_root: Path, monkeypatch) -> ChatApp: + """Instantiate a real ChatApp offscreen; __init__ writes state.json.""" + monkeypatch.setattr( + base_mod, + "get_sandbox_state_dir", + lambda in_sandbox=True, system=None: state_root, + ) + return ChatApp() + + +def _dispose(win: ChatApp, qapp: QApplication) -> None: + """Tear one app down cleanly: stop its timer, schedule deletion, flush it. + + ChatApp starts an inbox poll ``QTimer``; leaving it live while a second + top-level window is created aborts the offscreen platform. Stopping it and + letting ``deleteLater`` run under ``processEvents`` keeps repeated + instantiation stable, which is what a standalone run of this file needs. + """ + timer = getattr(win, "_inbox_timer", None) + if timer is not None: + timer.stop() + win.close() + win.deleteLater() + qapp.processEvents() + + +def test_real_app_emits_role_aware_elements(qapp, tmp_path, monkeypatch): + win = _make_app(tmp_path, monkeypatch) + try: + state = json.loads((tmp_path / "chat" / "state.json").read_text()) + elements = {e["name"]: e for e in state["elements"]} + # Roles come from the live widget classes, not a declaration. + assert elements["send_button"]["role"] == "QPushButton" + assert elements["message_input"]["role"] == "QLineEdit" + assert elements["contact_list"]["role"] == "QListWidget" + # The role-aware channel and the bare name list agree on membership. + assert set(state["interface"]) == set(elements) + finally: + _dispose(win, qapp) + + +def test_live_app_signal_reaches_leapflow_perception(qapp, tmp_path, monkeypatch): + win = _make_app(tmp_path, monkeypatch) + try: + rpc = LeapSpaceHostRpc(tmp_path) + svc = StateSnapshotService( + rpc, _FakeEpisodic(), default_fidelity=SnapshotFidelity.FULL + ) + svc.update_focus("chat", "LeapChat") + snap = asyncio.run(svc.capture(SnapshotFidelity.FULL)) + + assert snap.app_bundle_id == "chat" + assert snap.ax_digest, "perception saw an empty environment" + # The real Qt role and the bound name both flow through the summary. + assert "QPushButton" in snap.ax_summary + assert "send_button" in snap.ax_summary + finally: + _dispose(win, qapp) diff --git a/tests/leapspace/test_utils.py b/tests/leapspace/test_state.py similarity index 66% rename from tests/leapspace/test_utils.py rename to tests/leapspace/test_state.py index 568d400a..6e119026 100644 --- a/tests/leapspace/test_utils.py +++ b/tests/leapspace/test_state.py @@ -1,14 +1,17 @@ # Copyright (c) Alibaba, Inc. and its affiliates. -"""Tests for leapspace.app_space.utils: check() lines and path conventions.""" +"""Tests for leapspace.app_space.state: check() lines, path conventions, and the +LS-1 decoupling contract (state helpers import with cua_sandbox absent).""" import asyncio +import importlib import platform +import sys import pytest -pytest.importorskip("cua_sandbox") # leapspace extra only (utils imports cua_sandbox) - -from leapspace.app_space.utils import ( +# No cua_sandbox importorskip: the whole point of LS-1 is that these helpers are +# importable without the host SDK. This test runs on any host. +from leapspace.app_space.state import ( check, get_image_venv_python, get_sandbox_state_dir, @@ -16,6 +19,22 @@ ) +def test_state_module_imports_without_the_sandbox_sdk(): + """LS-1: importing state must not require cua_sandbox. + + Loads the module in a fresh import with cua_sandbox forced absent. Before the + split this was impossible -- ``from cua_sandbox import Image`` sat at module + scope, so the in-box verdict and pure helpers could not import off-sandbox. + """ + saved = {k: v for k, v in sys.modules.items() if k == "cua_sandbox"} + sys.modules["cua_sandbox"] = None # any import attempt raises ImportError + try: + importlib.reload(importlib.import_module("leapspace.app_space.state")) + finally: + sys.modules.pop("cua_sandbox", None) + sys.modules.update(saved) + + def test_check_pass_line(capsys): assert check("reply-sent", True, "found") is True assert capsys.readouterr().out == "PASS reply-sent: found\n" diff --git a/tests/test_adaptation_verdict.py b/tests/test_adaptation_verdict.py index abfbf74a..7d51eabb 100644 --- a/tests/test_adaptation_verdict.py +++ b/tests/test_adaptation_verdict.py @@ -191,11 +191,37 @@ async def grade_and_propose(self, trajectory, goal="", **kwargs): class _Intake: + """Stands in for ``CapabilityObservationService``. + + ``requirements`` derives a need for whatever was just observed, because that is what + a real store does: the driver asks at ``min_count=1``, so the observation written a + moment earlier already clears the threshold. A stub that returned nothing here would + quietly assert the opposite of the shipped contract -- that the driver queues an + acquisition the detector never turned into a requirement -- and the driver now + records that case as a ``requirement_not_derived`` no-op instead of acting on it. + """ + + def __init__(self) -> None: + self.observed: list[str] = [] + def observe_result(self, result, **kwargs): + capability = str((result or {}).get("capability") or "") + if capability: + self.observed.append(capability) return {"observation_id": "o1"} def requirements(self, *, min_count: int = 1, limit: int = 50): - return () + from leapflow.domain.capability_requirement import CapabilityRequirement + + return tuple( + CapabilityRequirement.create( + capability, + "world_model", + max_risk_level="read_only", + requirement_id=f"req-{capability}", + ) + for capability in dict.fromkeys(self.observed) + ) def _drive(verdicts, sink=None): diff --git a/tests/test_coevolution_sweep_wiring.py b/tests/test_coevolution_sweep_wiring.py index 02469e5a..7f21aa93 100644 --- a/tests/test_coevolution_sweep_wiring.py +++ b/tests/test_coevolution_sweep_wiring.py @@ -245,6 +245,18 @@ def _resolve_lifecycle_governor(self): return Context._resolve_lifecycle_governor(self) + def _active_proposal_ids(self): + """Bound because the production hook maps plugin_id -> proposal_id through it. + + The sweep now feeds ``LifecycleGovernor.record_outcome`` a proposal id keyed off + the live queue, so the real hook calls this. With no profile layout on the double + it degrades to an empty map -- the honest 'no queued proposals' state -- and the + assertions still run the real ``_run_coevolution_sweep`` body. + """ + from leapflow.cli.context import Context + + return Context._active_proposal_ids(self) + def test_production_sweep_hook_builds_and_runs_a_real_sweep(): """Drives `_run_coevolution_sweep` itself, not a hand-made CoevolutionSweep. @@ -305,6 +317,44 @@ def test_production_hook_uses_the_shared_process_tracker(): _teardown() +def test_active_proposal_ids_targets_the_newest_record_for_a_plugin(tmp_path): + """One plugin, several active records: governance must target the newest. + + ``active()`` is newest-first, so a naive overwrite would leave the map pointing at + the *oldest* record and ``record_outcome`` would update the wrong lifecycle entry. + A plugin can legitimately hold several active records (different capability, + environment, or source), so this is a reachable case, not a corner one. + """ + from types import SimpleNamespace + + from leapflow.cli.context import Context + from leapflow.domain.capability_requirement import CapabilityRequirement + from leapflow.layout import ProfileLayout + from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue + + layout = ProfileLayout(root=tmp_path / "profile", profile_id="p") + layout.root.mkdir(parents=True, exist_ok=True) + queue = JsonCapabilityProposalQueue(layout.capability_proposal_queue_path) + queue.enqueue( + requirements=( + CapabilityRequirement.create("chat.reply", "world_model", requirement_id="req-a"), + ), + metadata={"plugin_id": "shared_plugin"}, + ) + newer = queue.enqueue( + requirements=( + CapabilityRequirement.create("chat.send", "world_model", requirement_id="req-b"), + ), + metadata={"plugin_id": "shared_plugin"}, + ) + # Bump the second record so it is unambiguously the most recently touched. + queue.update(newer.proposal_id, status="GENERATED") + + ctx = _Ctx(settings=SimpleNamespace(profile_layout=layout)) + mapping = Context._active_proposal_ids(ctx) + assert mapping["shared_plugin"] == newer.proposal_id + + def test_production_hook_survives_a_broken_collaborator(): """A failure to govern must not fail the session that produced the trajectory.""" _sink() diff --git a/tests/test_dashboard_frontend_static.py b/tests/test_dashboard_frontend_static.py new file mode 100644 index 00000000..8f40ac25 --- /dev/null +++ b/tests/test_dashboard_frontend_static.py @@ -0,0 +1,200 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Static regressions for the frontend defects measured on a live board. + +There is no JS test runner in this repository, so these guard the shipped source +directly — the same approach ``test_dashboard_i18n_static.py`` takes. Each test names +the symptom a reader saw, because that is what must never come back. +""" +from __future__ import annotations + +import re +from pathlib import Path + +_STATIC = Path(__file__).parents[1] / "src" / "leapflow" / "dashboard" / "static" +_APP_JS = _STATIC / "app.js" +_STYLES = _STATIC / "styles.css" +_INDEX = _STATIC / "index.html" + + +def _app() -> str: + return _APP_JS.read_text(encoding="utf-8") + + +# ════════════════════════════════════════════════════════════════ +# Markdown: nine notices rendered as raw markup +# ════════════════════════════════════════════════════════════════ + + +def test_markdown_node_is_parsed_not_printed_verbatim() -> None: + """The defect: the component named Markdown did not parse Markdown. + + It escaped its text and inserted it as-is, so every explanatory aside on the + evolution board showed a literal ``>`` and literal ``**`` — nine of eleven + Markdown notices in the shipped templates, all of them on the one board whose + job is explaining how the framework evolves. + """ + src = _app() + assert "Markdown: (n) => renderMarkdown(" in src + assert 'Markdown: (n) => el("div", "md prose", esc(' not in src, ( + "the renderer must not go back to printing escaped text verbatim" + ) + + +def test_markdown_escapes_before_it_transforms() -> None: + """Order is the whole security argument: escape, then add only known tags. + + ``esc`` must be applied to the text before any transform runs, so prose can never + introduce an element and the only tags in the output are the ones added here. + """ + src = _app() + assert "mdInline(esc(" in src, "transforms must run on already-escaped text" + assert "esc(mdInline(" not in src, ( + "escaping after transforming would neutralise the tags this renderer adds" + ) + + +def test_markdown_recognises_exactly_the_three_authored_constructs() -> None: + """Blockquote, bold, inline code — and no general parser was pulled in. + + The SDUI contract is a closed component catalog; widening the trusted surface to + a Markdown library to gain three constructs would be a bad trade. + """ + src = _app() + assert '$1" in src + assert "" in src + for library in ("marked", "showdown", "markdown-it", "remark"): + assert library not in src, f"no third-party markdown parser ({library})" + + +def test_parsed_prose_releases_pre_wrap() -> None: + """The blocks the renderer emits must not inherit whitespace preservation. + + ``.md`` sets ``pre-wrap`` for raw text elsewhere; leaving it on would reintroduce + the folded-scalar indentation the YAML carried as visible leading gaps. + """ + css = _STYLES.read_text(encoding="utf-8") + assert ".md.prose { white-space: normal; }" in css + assert ".md.prose code" in css, "inline code needs a monospace treatment" + + +# ════════════════════════════════════════════════════════════════ +# Live lens: five of six metrics froze while looking current +# ════════════════════════════════════════════════════════════════ + + +def test_live_metrics_declare_their_provenance() -> None: + """The defect: snapshot-derived figures sat on load-time values silently. + + A presentation event carries one fact, never a recount, so those metrics cannot + move between producer cycles. They are now labelled rather than redrawn as though + they had, which is the distinction the producer's own fingerprint docstring + warns about. + """ + src = _app() + assert "function evolutionLiveStat(label, value, provenance)" in src + assert '"stat prov-" + provenance' in src + assert '"Live since snapshot"' in src, ( + "the count of uncounted increments is the figure that makes the strip honest" + ) + for label, provenance in ( + ("Event count", "live"), + ("Live since snapshot", "live"), + ("Episodes", "snapshot"), + ("Mutation", "snapshot"), + ("Regressions", "snapshot"), + ("Unadmitted intents", "snapshot"), + ): + assert re.search( + rf'\["{re.escape(label)}",[^\]]*"{provenance}"\]', src + ), f"{label!r} must be declared as {provenance}-derived" + + +def test_live_lens_counts_increments_against_the_snapshot_instant() -> None: + """Only events strictly newer than the snapshot are uncounted by it.""" + src = _app() + assert "const baselineAt = Number(snapshot.observed_at || 0);" in src + assert "Number(event.ts || 0) > baselineAt" in src + + +def test_drift_is_stated_only_when_the_two_provenances_diverge() -> None: + """A permanent caveat is noise; a count that appears when true is a fact.""" + src = _app() + assert "if (since > 0)" in src + assert "Snapshot metrics refresh on the next monitor cycle." in src + + +def test_empty_lanes_say_what_would_appear_and_why_nothing_has() -> None: + """"No live events" alone left quiet indistinguishable from broken.""" + src = _app() + assert '"lane-hint"' in src + for hint in ( + "Environment events appear when a probe records a change in the surroundings.", + "Decision events appear when a recorded observation drives a capability choice.", + "Governance events appear when trust, quarantine or reclamation moves.", + ): + assert hint in src, f"missing lane guidance: {hint!r}" + + +def test_lanes_are_equal_height_rather_than_a_fixed_short_box() -> None: + """Three lanes with different fill read as a ragged row when height is fixed.""" + css = _STYLES.read_text(encoding="utf-8") + assert "align-items: stretch" in css + assert "min-height: 148px" not in css, "the fixed lane height is what made it ragged" + assert ".evolution-live-lane .lane-hint" in css + + +# ════════════════════════════════════════════════════════════════ +# Sparkline: a one-point series reported "No entries." +# ════════════════════════════════════════════════════════════════ + + +def test_a_single_sample_series_is_drawn_not_discarded() -> None: + """The defect: ``length >= 2`` filtered out the only reading a new board has. + + The chart then printed "No entries.", telling the reader there was no data when + there was exactly one observation. + """ + src = _app() + assert "g.points.length >= 1" in src + assert "g.points.length >= 2" not in src, ( + "a one-point series must not be filtered back out" + ) + assert "g.points.length === 1" in src, "a lone sample needs its own marker branch" + assert 'svgEl("circle")' in src + + +# ════════════════════════════════════════════════════════════════ +# Provenance bar: page-level freshness on every lens +# ════════════════════════════════════════════════════════════════ + + +def test_the_provenance_bar_renders_on_every_view_fetch() -> None: + """Freshness is page chrome, not a panel a template author must remember.""" + src = _app() + assert "renderProvenance(payload.meta || {})" in src + assert "function renderProvenance(meta)" in src + + +def test_the_bar_offers_a_refresh_so_the_loop_closes() -> None: + """Several boards prescribe a fix; without this the reader cannot confirm it landed.""" + src = _app() + assert '"Refresh now"' in src + assert 'name: "watch.refresh"' in src + + +def test_an_unobserved_board_is_not_aged_from_the_clock() -> None: + """Saying "0s ago" where nothing was observed invents the fact the bar exists for.""" + src = _app() + assert 't("Not yet observed")' in src + + +def test_static_assets_are_cache_busted_together() -> None: + """A stale cached app.js against a new stylesheet is its own class of bug report.""" + html = _INDEX.read_text(encoding="utf-8") + versions = re.findall(r"/static/(?:app\.js|styles\.css)\?v=([\w-]+)", html) + assert len(versions) == 2, "both assets must carry a cache-busting version" + assert versions[0] == versions[1], "asset versions must be bumped together" + assert versions[0] != "status-i18n-20260808", ( + "the version predates the markdown and provenance changes" + ) diff --git a/tests/test_dashboard_launcher.py b/tests/test_dashboard_launcher.py index 4cf422c6..04dd050f 100644 --- a/tests/test_dashboard_launcher.py +++ b/tests/test_dashboard_launcher.py @@ -16,7 +16,7 @@ import pytest from leapflow.dashboard import launcher -from leapflow.dashboard.server import DashboardServer +from leapflow.dashboard.server import DashboardServer, _MONITOR_EVENTS def _settings(tmp_path: Path) -> SimpleNamespace: @@ -217,6 +217,10 @@ def test_check_origin_matches_loopback_host_exactly() -> None: assert check(SimpleNamespace(headers={"Origin": origin})) is False +def test_dashboard_forwards_presentation_only_evolution_events() -> None: + assert "evolution.presentation" in _MONITOR_EVENTS + + # ── DashboardServer.dispatch_action (allow-listed, transport-free) ─────────── diff --git a/tests/test_dashboard_provenance.py b/tests/test_dashboard_provenance.py new file mode 100644 index 00000000..bfc4a746 --- /dev/null +++ b/tests/test_dashboard_provenance.py @@ -0,0 +1,170 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Regressions for the freshness contract and the evolution axis. + +Each test here corresponds to a defect measured on a live board, and states the +symptom rather than the implementation, so a refactor that keeps the behaviour keeps +the test. +""" +from __future__ import annotations + +import time + +from leapflow.dashboard.service import _evidence_trend, _provenance + + +# ════════════════════════════════════════════════════════════════ +# Provenance: two instants, never merged +# ════════════════════════════════════════════════════════════════ + + +def test_content_age_and_check_age_are_reported_separately() -> None: + """The defect: one instant could not answer both questions. + + A finding-backed board renders the newest *persisted* finding and findings dedup + on content, so the content can be much older than the last completed cycle. + Reporting only the content instant made a healthy system look frozen; reporting + only the cycle instant would age a stale page from the clock. + """ + now = time.time() + prov = _provenance( + {"observed_at": now - 600}, + {"last_run_at": now - 5, "interval_seconds": 120, "watch_id": "w1"}, + ) + + assert prov["age_seconds"] > 590, "content age must reflect the payload instant" + assert prov["checked_age_seconds"] < 10, "check age must reflect the last cycle" + assert prov["unchanged_for_seconds"] > 590 + + +def test_old_but_freshly_checked_content_is_not_stale() -> None: + """Stable is not stale, and conflating them is what made refresh look broken. + + The verdict is about the watch: a cycle completed 5s ago, so the page reflects + the present even though its content has not changed for ten minutes. + """ + now = time.time() + prov = _provenance( + {"observed_at": now - 600}, + {"last_run_at": now - 5, "interval_seconds": 120}, + ) + assert prov["stale"] is False + + +def test_a_watch_that_stopped_running_is_stale() -> None: + """Two cadences without a completed cycle means nothing on the page is current.""" + now = time.time() + prov = _provenance( + {"observed_at": now - 900}, + {"last_run_at": now - 500, "interval_seconds": 120}, + ) + assert prov["stale"] is True + + +def test_one_missed_cycle_is_jitter_not_staleness() -> None: + """The threshold is two cadences on purpose: scheduling is not exact.""" + now = time.time() + prov = _provenance( + {"observed_at": now - 200}, + {"last_run_at": now - 150, "interval_seconds": 120}, + ) + assert prov["stale"] is False + + +def test_a_watch_with_no_declared_cadence_gets_no_staleness_verdict() -> None: + """An event-driven watch has no interval, so judging it would mean inventing one.""" + now = time.time() + prov = _provenance( + {"observed_at": now - 100000}, + {"last_run_at": now - 100000, "interval_seconds": 0}, + ) + assert prov["stale"] is False + assert prov["cadence_seconds"] == 0.0 + + +def test_a_never_run_watch_reports_absent_rather_than_zero_age() -> None: + """Absent is not fresh. "0s ago" on a board that never observed invents a fact.""" + prov = _provenance({}, {}) + assert prov["observed"] is False + assert prov["checked"] is False + assert prov["age_seconds"] == 0.0 + assert prov["stale"] is False + + +def test_provenance_carries_the_watch_id_so_the_bar_can_refresh() -> None: + """Without it the bar can report the page is behind but not do anything about it.""" + prov = _provenance({"observed_at": 1.0}, {"watch_id": "w-42", "last_run_at": 2.0}) + assert prov["watch_id"] == "w-42" + + +def test_a_payload_without_its_own_instant_is_dated_by_the_cycle() -> None: + now = time.time() + prov = _provenance({}, {"last_run_at": now - 30, "interval_seconds": 120}) + assert prov["observed"] is True + assert 25 < prov["age_seconds"] < 35 + + +# ════════════════════════════════════════════════════════════════ +# Evolution axis: the only panel that shows direction +# ════════════════════════════════════════════════════════════════ + + +def _finding(observed_at: float, with_evidence: int, total: int = 10) -> dict: + return { + "ts": observed_at, + "payload": { + "observed_at": observed_at, + "summary": { + "segments_with_evidence": with_evidence, + "segments_total": total, + }, + }, + } + + +def test_a_single_sample_still_produces_a_series() -> None: + """The defect this exists to prevent. + + Suppressing a one-point series hides the beginning of every evolution the board + is for -- and on a new profile that is the only reading there is. + """ + trend = _evidence_trend([_finding(100.0, 2)]) + assert trend["samples"] == 1 + assert trend["series"], "one sample must still yield a drawable series" + assert trend["series"][0]["points"] == [{"x": 100.0, "y": 2, "at": 100.0}] + + +def test_the_axis_reads_oldest_first() -> None: + """Findings are persisted newest-first; a time axis must not be.""" + trend = _evidence_trend([_finding(300.0, 5), _finding(200.0, 3), _finding(100.0, 2)]) + assert [p["y"] for p in trend["series"][0]["points"]] == [2, 3, 5] + assert trend["first_at"] == 100.0 + assert trend["last_at"] == 300.0 + + +def test_net_change_states_the_direction() -> None: + """Direction is stated rather than left to the reader's eye on a short line.""" + assert _evidence_trend([_finding(300.0, 5), _finding(100.0, 2)])["delta"] == 3 + assert _evidence_trend([_finding(300.0, 1), _finding(100.0, 4)])["delta"] == -3 + + +def test_a_single_sample_declares_no_direction() -> None: + """One point is a reading, not a trend.""" + assert _evidence_trend([_finding(100.0, 2)])["delta"] == 0 + + +def test_no_findings_yields_no_series_rather_than_a_fake_zero() -> None: + trend = _evidence_trend([]) + assert trend["series"] == [] + assert trend["samples"] == 0 + + +def test_malformed_findings_are_skipped_not_charted_as_zero() -> None: + """A payload with no summary is unknown, and unknown is not zero evidence.""" + trend = _evidence_trend([ + {"ts": 1.0, "payload": None}, + {"ts": 2.0, "payload": {"observed_at": 2.0}}, + {"ts": 3.0, "payload": {"observed_at": 3.0, "summary": {}}}, + _finding(4.0, 3), + ]) + assert trend["samples"] == 1 + assert trend["series"][0]["points"][0]["y"] == 3 diff --git a/tests/test_dashboard_view.py b/tests/test_dashboard_view.py index 3daa0ff0..268b854d 100644 --- a/tests/test_dashboard_view.py +++ b/tests/test_dashboard_view.py @@ -149,7 +149,43 @@ async def test_builder_exposes_template_switcher_meta() -> None: assert "finance" not in spec["meta"]["templates"] assert "research" not in spec["meta"]["templates"] assert "sentiment" not in spec["meta"]["templates"] - assert {"finance", "research", "sentiment"}.issubset(set(spec["meta"]["hidden_templates"])) + assert {"causal_trace", "evolution_live", "finance", "research", "sentiment"}.issubset( + set(spec["meta"]["hidden_templates"]) + ) + + +def test_causal_trace_is_hidden_but_renderable_as_a_read_only_lens() -> None: + spec = _build(_evolution_provider(), template="causal_trace") + + assert spec["meta"]["active_template"] == "causal_trace" + assert "causal_trace" not in spec["meta"]["templates"] + assert "causal_trace" in spec["meta"]["hidden_templates"] + assert {"Page", "Grid"}.issubset({node["type"] for node in _flatten(spec)}) + assert not [node for node in _flatten(spec) if "action" in node] + + +def test_evolution_live_is_hidden_and_binds_the_authoritative_snapshot() -> None: + provider = _evolution_provider() + provider._findings[0]["payload"].update({ + "traces": [{"trace_id": "t-1", "stage": "observe", "kind": "interface_drift", "ts": 1.0}], + "summary": { + "episode_count": 1, + "segments_with_evidence": 2, + "segments_total": 4, + "unadmitted_intent_count": 0, + "regression_count": 0, + }, + }) + + spec = _build(provider, template="evolution_live") + custom = [node for node in _flatten(spec) if node["type"] == "Custom"] + + assert spec["meta"]["active_template"] == "evolution_live" + assert "evolution_live" not in spec["meta"]["templates"] + assert "evolution_live" in spec["meta"]["hidden_templates"] + assert custom[0]["props"]["render"] == "evolutionLive" + assert custom[0]["props"]["data"]["traces"][0]["kind"] == "interface_drift" + assert not [node for node in _flatten(spec) if "action" in node] async def test_builder_signals_template_renders_dense_operational_layout() -> None: @@ -245,6 +281,22 @@ async def test_view_hub_backpressure_drops_when_full() -> None: assert hub.subscriber_count == 0 +async def test_view_hub_requests_snapshot_resync_after_a_drop() -> None: + hub = ViewHub(maxsize=1) + queue = hub.subscribe("slow") + assert hub.broadcast({"n": 1}) == 1 + assert hub.broadcast({"n": 2}) == 0 + assert (await queue.get())["n"] == 1 + + # The first delivery after capacity returns is the resync instruction. The + # dropped current increment is intentionally not replayed; fetchView() is the + # authoritative recovery path. + assert hub.broadcast({"n": 3}) == 0 + assert (await queue.get())["type"] == "view.resync" + assert hub.broadcast({"n": 4}) == 1 + assert (await queue.get())["n"] == 4 + + # ── An empty hardware board must say why ──────────────────────────────────── # # Every panel on the hardware lens gates on the data it renders, which is what lets a new diff --git a/tests/test_evolution_governance_reachable.py b/tests/test_evolution_governance_reachable.py index 1d383acb..5a1a5581 100644 --- a/tests/test_evolution_governance_reachable.py +++ b/tests/test_evolution_governance_reachable.py @@ -282,3 +282,47 @@ def test_lifecycle_record_carries_the_declared_risk_ceiling(tmp_path): record = queue.get(result["lifecycle_proposal_id"]) assert dict(record.risk)["risk_level"] == "medium" assert dict(record.requirements[0])["max_risk_level"] == "medium" + + +# ── plugin_generate bridges *both* proposal stores (G3) ─────────────────────── + + +def test_generate_resolves_a_world_model_lifecycle_proposal(tmp_path): + """A world-model queue id must reach generation, not only a review-store id. + + The world-model driver enqueues into the lifecycle queue (``prop-``); before + the bridge, ``plugin_generate`` looked only in the review store, so Scene C could + never proceed from a real teacher verdict. This drives the resolver that closes + that gap -- no LLM needed, because it is the resolution, not the generation, under + test. + """ + from leapflow.domain.capability_requirement import CapabilityRequirement + + plugin, queue = _plugin_with_stores(tmp_path) + requirement = CapabilityRequirement.create( + "chat.reply", "world_model", evidence="the send path silently no-ops", + max_risk_level="read_only", requirement_id="req-wm-chat.reply", + ) + item = queue.enqueue( + requirements=(requirement,), + source="world_model", + observation_ids=("obs-1",), + metadata={"plugin_id": "chat_reply_alt_plugin", "capability_summary": "reply via v2"}, + ) + + source, plugin_id, description, provides = plugin._resolve_generation_source( + item.proposal_id + ) + assert source == "lifecycle" + assert plugin_id == "chat_reply_alt_plugin" + assert provides == ("chat.reply",) # capability preserved for generation + assert description # non-empty description derived + + # A review-store id still resolves as its own source, unchanged. + review = _propose(plugin, requested_capability="chat.send", risk_level="read_only") + assert plugin._resolve_generation_source( + review["proposal"]["proposal_id"] + )[0] == "review" + + # An id neither store knows resolves to nothing, so generate returns not-found. + assert plugin._resolve_generation_source("prop-does-not-exist")[0] == "" diff --git a/tests/test_evolution_presentation.py b/tests/test_evolution_presentation.py new file mode 100644 index 00000000..eeacdb73 --- /dev/null +++ b/tests/test_evolution_presentation.py @@ -0,0 +1,45 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Presentation-only projections for live framework-evolution displays.""" + +from __future__ import annotations + +from leapflow.domain.evolution_trace import EvolutionStage, EvolutionTrace +from leapflow.telemetry.evolution_presentation import EvolutionPresentationEvent + + +def test_presentation_event_uses_existing_correlation_as_episode_identity() -> None: + trace = EvolutionTrace( + stage=EvolutionStage.DECIDE, + kind="policy_decision", + trace_id="trace-1", + ts=42.0, + correlation={"record_id": "plan-9", "plugin_id": "example", "secret": "not-a-reference"}, + summary="The policy selected reuse.", + detail={ + "evidence_level": "L1_controlled", + "verification_tier": "declared_fitness", + "side_effect_state": "none", + "unbounded_private_detail": "must not reach the browser event", + }, + ) + + event = EvolutionPresentationEvent.from_trace(trace).to_dict() + + assert event["event_id"] == "trace-1" + assert event["episode_id"] == "plan-9" + assert event["payload_ref"] == {"record_id": "plan-9", "plugin_id": "example"} + assert event["evidence_level"] == "L1_controlled" + assert event["verification_tier"] == "declared_fitness" + assert "unbounded_private_detail" not in event + + +def test_presentation_event_uses_trace_identity_when_no_correlation_exists() -> None: + trace = EvolutionTrace(stage=EvolutionStage.OBSERVE, kind="interface_drift", trace_id="trace-2") + + event = EvolutionPresentationEvent.from_trace(trace) + + assert event.episode_id == "trace-2" + assert event.payload_ref == {} + assert event.evidence_level == "runtime_trace" + assert event.verification_tier == "not_recorded" + assert event.side_effect_state == "not_recorded" diff --git a/tests/test_evolution_producer.py b/tests/test_evolution_producer.py index 81fa24d5..d122eb34 100644 --- a/tests/test_evolution_producer.py +++ b/tests/test_evolution_producer.py @@ -559,6 +559,12 @@ def test_evolution_template_binds_only_shapes_its_renderers_read(): "evolution.reclaim_candidates", "evolution.reward_bandwidth.by_reason", "evolution.summary.suggestions", + # Not this producer's: derived by the view service from the retained finding + # list, which is the only thing carrying history across daemon restarts. It + # is deliberately outside the ``evolution.*`` namespace so that ownership is + # readable from the bind alone, and listed here because this assertion checks + # every bind in the template rather than only the producer's own. + "evidence_trend.series", } #: Every shipped renderer that coerces ``props.data`` with ``asArray``. DATA_LIST_COMPONENTS = ( diff --git a/tests/test_evolution_tap.py b/tests/test_evolution_tap.py index a096f7b9..f6f86354 100644 --- a/tests/test_evolution_tap.py +++ b/tests/test_evolution_tap.py @@ -526,6 +526,46 @@ async def _drive(): assert seen == ["evolution.registry_plugin_registered"] +def test_runtime_trace_publishes_a_presentation_only_notification(): + import asyncio + + from leapflow.daemon.monitor_coordinator import MonitorCoordinator + + seen_events: list[str] = [] + presentation: list[object] = [] + + class _EventBus: + async def handle_event(self, event_type, payload): + seen_events.append(event_type) + + class _NotificationBus: + def emit(self, notification): + presentation.append(notification) + + async def _drive(): + coordinator = MonitorCoordinator() + coordinator._notification_bus = _NotificationBus() + publisher = coordinator._make_evolution_publisher(SimpleNamespace(event_bus=_EventBus())) + assert publisher is not None + publisher(EvolutionTrace( + stage=EvolutionStage.DECIDE, + kind="policy_decision", + trace_id="trace-live", + detail={"phase": "runtime", "unbounded": "must not be displayed"}, + correlation={"record_id": "record-live"}, + )) + await asyncio.sleep(0.05) + + asyncio.run(_drive()) + + assert seen_events == ["evolution.policy_decision"] + assert len(presentation) == 1 + notification = presentation[0] + assert notification.event_type == "evolution.presentation" + assert notification.payload["episode_id"] == "record-live" + assert "unbounded" not in notification.payload + + def test_the_publisher_is_absent_rather_than_broken_without_a_bus(): """No event bus is a normal state (in-process CLI), not a failure to report.""" from leapflow.daemon.monitor_coordinator import MonitorCoordinator diff --git a/tests/test_evolution_trigger_boundary.py b/tests/test_evolution_trigger_boundary.py new file mode 100644 index 00000000..374c2cfc --- /dev/null +++ b/tests/test_evolution_trigger_boundary.py @@ -0,0 +1,267 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Regressions for the evolution trigger and the segments it makes observable. + +Three defects measured against a live daemon, each of which made the board report an +absence that was really a skipped step: + +* the governance sweep was nested inside the trajectory branch, so an empty + trajectory skipped it entirely — producing exactly the ambiguity the sweep's own + comment said its no-op traces existed to remove; +* a proposal queue full of never-advanced records was reported ``wired``, the healthy + class, beside a genuinely healthy segment; +* the learning boundary was reachable only from context cleanup, which in daemon mode + means process shutdown. +""" +from __future__ import annotations + +import ast +import inspect +from pathlib import Path + +import pytest + +from leapflow.monitor.evolution_producer import ( + NO_EVIDENCE, + UNVERIFIABLE, + WIRED, + EvolutionProducer, +) + +_CONTEXT_PY = Path(__file__).parents[1] / "src" / "leapflow" / "cli" / "context.py" + + +# ════════════════════════════════════════════════════════════════ +# The sweep runs on a quiet boundary too +# ════════════════════════════════════════════════════════════════ + + +def _learning_phase_body() -> ast.AST: + """Return the AST of ``_on_session_end_learning``'s trajectory-grading phase.""" + tree = ast.parse(_CONTEXT_PY.read_text(encoding="utf-8")) + for node in ast.walk(tree): + if isinstance(node, ast.AsyncFunctionDef) and node.name == "_on_session_end_learning": + return node + raise AssertionError("_on_session_end_learning not found") + + +def test_the_governance_sweep_is_not_nested_in_the_trajectory_branch() -> None: + """The defect, asserted structurally so a refactor cannot quietly re-nest it. + + ``_run_coevolution_sweep`` documents that it "runs whether or not the teacher + proposed anything, so its no-op traces distinguish a quiet session from a sweep + that never ran". Nested inside ``if trajectory:`` it did neither, and three + reachability segments read "no sweep trace observed" on a live board for that + reason alone. + """ + phase = _learning_phase_body() + + sweep_calls = [ + node for node in ast.walk(phase) + if isinstance(node, ast.Call) + and isinstance(node.func, ast.Attribute) + and node.func.attr == "_run_coevolution_sweep" + ] + assert len(sweep_calls) == 1, "the sweep must be driven from exactly one place" + sweep_line = sweep_calls[0].lineno + + # Any `if` whose test mentions the trajectory must not contain the sweep call. + for node in ast.walk(phase): + if not isinstance(node, ast.If): + continue + test_names = {n.id for n in ast.walk(node.test) if isinstance(n, ast.Name)} + if "trajectory" not in test_names: + continue + guarded = [ + child.lineno + for stmt in node.body + for child in ast.walk(stmt) + if hasattr(child, "lineno") + ] + assert sweep_line not in guarded, ( + "the sweep is nested inside a trajectory guard again; an empty trajectory " + "would skip it and the board would report 'no sweep trace observed'" + ) + + +def test_an_empty_trajectory_still_reports_its_phase() -> None: + """The quiet path must remain observable, not silent.""" + source = _CONTEXT_PY.read_text(encoding="utf-8") + assert '"note": "empty_trajectory"' in source + + +# ════════════════════════════════════════════════════════════════ +# The learning boundary is callable, not only reachable at shutdown +# ════════════════════════════════════════════════════════════════ + + +def test_the_learning_boundary_has_a_public_entry_point() -> None: + """Bound to ``cleanup`` alone, "when does it evolve" was unanswerable. + + A daemon that ran for a week never evolved and one killed with SIGKILL never + evolved at all, because the only caller was process teardown. + """ + from leapflow.cli.context import Context + + assert hasattr(Context, "run_learning_boundary") + signature = inspect.signature(Context.run_learning_boundary) + assert "reason" in signature.parameters, ( + "the caller must be recorded, so a shutdown flush is distinguishable from a " + "session boundary and from a hand-run one" + ) + + +def test_cleanup_drives_the_boundary_through_the_public_entry_point() -> None: + """One path, so the shutdown flush and an explicit run cannot diverge.""" + source = _CONTEXT_PY.read_text(encoding="utf-8") + assert 'run_learning_boundary(reason="shutdown")' in source + + +def test_the_daemon_exposes_the_boundary_as_an_rpc() -> None: + """It has to run in the daemon: that is the process holding the trajectory.""" + from leapflow.daemon.protocol import METHOD_REGISTRY + + assert METHOD_REGISTRY.get("evolution.run") == "evolution_run" + + +def test_the_cli_can_run_the_boundary_without_stopping_the_daemon() -> None: + from leapflow.cli.commands.evolve import cmd_evolve + + assert callable(cmd_evolve) + + +def test_the_trajectory_buffer_is_bounded() -> None: + """Unbounded, it accumulated every turn of every session for a daemon lifetime.""" + from leapflow.world_model.prediction import _MAX_TRAJECTORY_STEPS, PredictionLoop + + source = inspect.getsource(PredictionLoop.__init__) + assert "deque(maxlen=_MAX_TRAJECTORY_STEPS)" in source + assert _MAX_TRAJECTORY_STEPS > 0 + + +# ════════════════════════════════════════════════════════════════ +# A write-only queue is not a governed one +# ════════════════════════════════════════════════════════════════ + + +class _Item: + def __init__(self, status: str) -> None: + self.status = status + + +class _Queue: + def __init__(self, *statuses: str) -> None: + self._items = [_Item(s) for s in statuses] + + def list_items(self, limit: int = 0) -> list[_Item]: + return list(self._items) + + +class _RaisingQueue: + def list_items(self, limit: int = 0) -> list[_Item]: + raise OSError("queue unreadable") + + +@pytest.fixture() +def producer() -> EvolutionProducer: + return EvolutionProducer() + + +def _run(producer: EvolutionProducer, queue: object) -> dict: + """Call the segment with a stubbed store, since the store lookup reads settings.""" + original = producer._json_store + producer._json_store = lambda *args, **kwargs: queue # type: ignore[assignment] + try: + return producer._segment_lifecycle() + finally: + producer._json_store = original # type: ignore[assignment] + + +def test_a_queue_that_never_advances_is_not_wired(producer: EvolutionProducer) -> None: + """The defect: 212 records, every one PENDING, reported as the healthy class. + + Nothing drained the queue and nothing ever would, so it grew monotonically while + the board showed it green beside a genuinely healthy ``Trust accrual``. + """ + row = _run(producer, _Queue(*["PENDING"] * 212)) + assert row["status"] == NO_EVIDENCE + assert "PENDING=212" in row["evidence"], "the spread stays visible" + assert "212 record(s)" in row["next_step"] + assert "only grows" in row["next_step"], "the row must name the consequence" + + +def test_one_advanced_record_is_evidence_the_queue_is_read_back( + producer: EvolutionProducer, +) -> None: + """Evidence is a transition, not a row count.""" + row = _run(producer, _Queue("PENDING", "PENDING", "INSTALLED")) + assert row["status"] == WIRED + + +@pytest.mark.parametrize("status", ["GENERATED", "APPROVED", "PROBATION", "VERIFIED", + "REJECTED", "FAILED", "QUARANTINED"]) +def test_every_post_entry_state_counts_as_advanced( + producer: EvolutionProducer, status: str +) -> None: + """Entry states are enumerated, so a new terminal state cannot read as ungoverned.""" + assert _run(producer, _Queue("PENDING", status))["status"] == WIRED + + +def test_an_empty_queue_is_distinguished_from_a_stuck_one( + producer: EvolutionProducer, +) -> None: + row = _run(producer, _Queue()) + assert row["status"] == NO_EVIDENCE + assert "queue is empty" in row["evidence"] + assert "plugin_propose" in row["next_step"] + + +def test_an_unreadable_queue_is_unverifiable_not_no_evidence( + producer: EvolutionProducer, +) -> None: + """A source that could not be read is a fault, not an absence of activity.""" + assert _run(producer, _RaisingQueue())["status"] == UNVERIFIABLE + assert _run(producer, None)["status"] == UNVERIFIABLE + + +# ════════════════════════════════════════════════════════════════ +# A manual refresh must leave a trace that it ran +# ════════════════════════════════════════════════════════════════ + + +def test_a_manual_refresh_records_that_a_cycle_completed() -> None: + """The defect: refresh looked broken because nothing it touched moved. + + Findings dedup on content, so a cycle confirming "nothing changed" writes nothing. + The scheduler normally does the run bookkeeping and this path skips the scheduler, + so without it the board could not tell a refresh that ran from one that never + happened — which is the one thing a reader presses refresh to find out. + """ + from leapflow.monitor.manager import MonitorManager + + source = inspect.getsource(MonitorManager.run_watch_once) + assert "increment_run_count" in source + # After the cycle, not before: last_run_at means "a cycle completed". + assert source.index("self._executor.execute") < source.index("increment_run_count") + assert 'result.get("ok")' in source, "a producer that raised did not complete a cycle" + + +def test_a_watch_view_publishes_its_declared_cadence() -> None: + """The board judges its own freshness against it; only the watch knows it.""" + from leapflow.monitor.types import WatchView + + view = WatchView( + watch_id="w", name="n", domain="d", trigger="every 120s", state="armed", + muted=False, run_count=1, next_due_at=2.0, last_run_at=1.0, + interval_seconds=120.0, + ) + assert view.to_dict()["interval_seconds"] == 120.0 + + +def test_a_watch_with_no_interval_trigger_declares_no_cadence() -> None: + """Zero means "no fixed cadence", which the board reads as a withheld verdict.""" + from leapflow.monitor.types import WatchView + + assert WatchView( + watch_id="w", name="n", domain="d", trigger="event:x", state="armed", + muted=False, run_count=0, next_due_at=0.0, last_run_at=0.0, + ).to_dict()["interval_seconds"] == 0.0 diff --git a/tests/test_llm_provider_retry_ownership.py b/tests/test_llm_provider_retry_ownership.py new file mode 100644 index 00000000..ce6b16d3 --- /dev/null +++ b/tests/test_llm_provider_retry_ownership.py @@ -0,0 +1,51 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""The provider owns retry; the SDK must not add a second, hidden one. + +``OpenAIChat`` implements a retry policy with backoff, and the recovery layer's +budgets assume ``timeout_s`` bounds *one* attempt. The OpenAI SDK retries twice by +default, so leaving that default in place multiplies the two policies: effective +attempts become ``max_retries * 3`` and a hard timeout surfaces after three times +the configured budget. Measured on a live endpoint before the fix: a 45s timeout +raised ``APITimeoutError`` after 137s (~3 x 45s), which is exactly the failure a +turn-level deadline cannot absorb. + +These tests pin the single-owner contract without any network access. +""" + +from __future__ import annotations + +from leapflow.llm.openai_provider import OpenAIChat + + +def _provider(**kwargs) -> OpenAIChat: + return OpenAIChat( + api_key="sk-test-not-a-real-key", + base_url="https://example.invalid/v1", + model="test-model", + **kwargs, + ) + + +def test_sdk_clients_do_not_retry_on_their_own(): + """Both SDK clients must be constructed with retries disabled.""" + provider = _provider() + # ``max_retries`` is public on the SDK client and is what multiplies attempts. + assert provider._async.max_retries == 0 + assert provider._sync.max_retries == 0 + + +def test_provider_keeps_its_own_retry_policy(): + """Disabling SDK retry must not disable ours -- the policy just has one owner.""" + provider = _provider(max_retries=4) + assert provider._max_retries == 4 + # Floor of one attempt: a zero would mean "never call the model". + assert _provider(max_retries=0)._max_retries == 1 + + +def test_configured_timeout_bounds_one_attempt(): + """The read timeout the caller asked for is the one the client carries.""" + provider = _provider(timeout_s=45.0) + assert provider._async.timeout.read == 45.0 + # Connect/write/pool stay bounded independently so a stalled handshake cannot + # consume the whole read budget. + assert provider._async.timeout.connect == 30.0 diff --git a/tests/test_world_model_driver.py b/tests/test_world_model_driver.py index a840f8a0..7ff353f7 100644 --- a/tests/test_world_model_driver.py +++ b/tests/test_world_model_driver.py @@ -217,6 +217,73 @@ def test_drive_result_is_reportable(tmp_path): assert payload["capabilities"] == ["chat.reply"] +# ── authority gate (P5 in the driver) ────────────────────────────────── + + +def test_admitted_hypothesis_is_queued_with_evidence_linkage(tmp_path): + """An admitted, authorised hypothesis is queued, carrying its observation ids. + + The linkage is what lets the causal ledger join a queued acquisition back to the + evidence that produced it; a proposal minted with no observation ids is an orphan. + """ + _, service = _service(tmp_path, opted_in=True) + captured: dict = {} + + def sink(proposal, *, observation_ids=(), environment=None): + captured["observation_ids"] = tuple(observation_ids) + captured["environment"] = environment + return "prop-unmet" + + driver = WorldModelEvolutionDriver( + teacher=_Teacher(intents=[_intent()]), + intake=service, + proposal_sink=sink, + ) + result = asyncio.run(driver.drive(_TRAJECTORY, "reply in chat")) + + assert result.unauthorised == () + assert result.queued_proposal_ids == ("prop-unmet",) + assert len(captured["observation_ids"]) == 1 + assert captured["observation_ids"][0].startswith("obs-") + + +def test_unauthorised_origin_is_a_durable_no_op(tmp_path): + """With authority restricted away from world_model, the hypothesis cannot acquire.""" + store, service = _service(tmp_path, opted_in=True) + queued: list = [] + + driver = WorldModelEvolutionDriver( + teacher=_Teacher(intents=[_intent()]), + intake=service, + proposal_sink=lambda p, **k: queued.append(p) or "prop-x", + # A drive-the-wiring assertion of P5: the world model's own origin is refused + # authority, so even an admitted hypothesis is retired rather than queued. + authorising_origins=("some_other_origin",), + ) + result = asyncio.run(driver.drive(_TRAJECTORY, "reply in chat")) + + assert result.unauthorised == ("chat.reply",) + assert result.queued_proposal_ids == () + assert queued == [] + # Durable no-op: the observation is retired with a recorded reason. + assert store.unresolved() == [] + + +def test_world_model_origin_is_authorised_when_named(tmp_path): + """Naming world_model in authorising_origins lets its hypothesis through.""" + _, service = _service(tmp_path, opted_in=True) + queued: list = [] + driver = WorldModelEvolutionDriver( + teacher=_Teacher(intents=[_intent()]), + intake=service, + proposal_sink=lambda p, **k: queued.append(p) or "prop-x", + authorising_origins=("world_model",), + ) + result = asyncio.run(driver.drive(_TRAJECTORY, "reply in chat")) + assert result.unauthorised == () + assert result.queued_proposal_ids == ("prop-x",) + + # ── the real grader satisfies the teacher contract ──────────────────────────── diff --git a/tests/test_world_model_proposal_sink_contract.py b/tests/test_world_model_proposal_sink_contract.py new file mode 100644 index 00000000..2177068d --- /dev/null +++ b/tests/test_world_model_proposal_sink_contract.py @@ -0,0 +1,133 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""A caller-supplied proposal sink keeps its own signature. + +Measured regression: the driver began passing ``observation_ids`` and ``environment`` +to ``proposal_sink`` so the causal ledger could join a proposal to the observations +that caused it. The sink is supplied by the caller and its contract was +``sink(proposal)``, so every sink that had not adopted the new keywords raised +``TypeError`` -- inside a per-intent ``except Exception`` that logged at debug level +and continued. The visible effect was that **no acquisition was ever queued**, with a +green targeted test suite and no warning in the log. + +Two contracts are pinned here, because either alone would have let it through: + +* optional context is offered only to sinks that declare it (or take ``**kwargs``), + so extending the causal payload can never break an existing sink; +* a wiring fault is logged as a warning rather than absorbed, so if this ever breaks + again it says so instead of going quiet. +""" + +from __future__ import annotations + +import asyncio +import logging +from typing import Any + +from leapflow.domain.adaptation_verdict import ACQUIRE, AdaptationVerdict +from leapflow.learning.world_model_driver import WorldModelEvolutionDriver +from leapflow.world_model.trajectory_grader import TeacherVerdict + + +class _Teacher: + def __init__(self, verdict: TeacherVerdict) -> None: + self._verdict = verdict + + async def grade_and_propose(self, *args: Any, **kwargs: Any) -> TeacherVerdict: + return self._verdict + + +class _Intake: + """Minimal stand-in that derives a need for what it just observed.""" + + def __init__(self) -> None: + self.observed: list[str] = [] + + def observe_result(self, result, **kwargs): + capability = str((result or {}).get("capability") or "") + if capability: + self.observed.append(capability) + return {"observation_id": f"o{len(self.observed)}"} + + def requirements(self, *, min_count: int = 1, limit: int = 50): + from leapflow.domain.capability_requirement import CapabilityRequirement + + return tuple( + CapabilityRequirement.create( + capability, "world_model", max_risk_level="read_only", + requirement_id=f"req-{capability}", + ) + for capability in dict.fromkeys(self.observed) + ) + + +def _drive(sink) -> Any: + driver = WorldModelEvolutionDriver( + teacher=_Teacher( + TeacherVerdict( + grades=(), + verdicts=( + AdaptationVerdict.create(ACQUIRE, "mail.send", "the app is now v3"), + ), + ) + ), + intake=_Intake(), + proposal_sink=sink, + ) + return asyncio.run(driver.drive([{"action": "a"}], "reply in the thread")) + + +def test_legacy_single_argument_sink_still_receives_proposals(): + """The original contract: ``sink(proposal)`` and nothing else.""" + seen: list[Any] = [] + + def sink(proposal): + seen.append(proposal) + return proposal.proposal_id + + result = _drive(sink) + assert len(seen) == 1, "a one-argument sink must still be called" + assert result.to_dict()["queued"] == 1 + + +def test_sink_declaring_the_extras_receives_them(): + """A sink that opts in gets the causal context, so the ledger can join it.""" + captured: dict[str, Any] = {} + + def sink(proposal, *, observation_ids=(), environment=None): + captured["observation_ids"] = tuple(observation_ids) + captured["environment"] = environment + return proposal.proposal_id + + result = _drive(sink) + assert result.to_dict()["queued"] == 1 + assert captured["observation_ids"], "observation ids must reach an opted-in sink" + + +def test_var_keyword_sink_receives_the_extras(): + """``**kwargs`` counts as opting in; nothing needs to be listed explicitly.""" + captured: dict[str, Any] = {} + + def sink(proposal, **kwargs): + captured.update(kwargs) + return proposal.proposal_id + + assert _drive(sink).to_dict()["queued"] == 1 + assert "observation_ids" in captured + + +def test_a_sink_that_raises_a_wiring_fault_is_reported_not_swallowed(caplog): + """A TypeError from inside the sink must be visible, not debug-only. + + The loop still continues -- one bad intent may not stop the rest -- but silence is + what turned the original defect into an invisible outage. + """ + def sink(proposal, *, observation_ids=(), environment=None): + raise TypeError("sink is misconfigured") + + with caplog.at_level(logging.WARNING, logger="leapflow.learning.world_model_driver"): + result = _drive(sink) + + assert result.to_dict()["queued"] == 0 + assert any( + "acquisition not queued" in record.message for record in caplog.records + ), "a wiring fault must be logged at warning level" From 60cf9596035a9bb8e1320934d1fc50f6903ce2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Sat, 19 Sep 2026 13:31:00 +0800 Subject: [PATCH 03/10] feat(evolution): durable event-sourced self-evolution closed loop + legacy cleanup Land the full evolution closed loop on the append-only DuckDB evolution event stream as the single source of truth, and remove the superseded in-process driver/JSON paths. Core - Unified ActionExecutor/ActionRecorder record real executions as session-scoped facts; SessionFinalizer seals sessions by generation/cursor and enqueues durable teacher jobs; shutdown only drains unfinished sessions. - DurableTeacherWorker (lease/heartbeat/retry) grades hindsight once, resolves each acquire verdict against the live registry BEFORE proposal creation, and commits requirement.resolved + proposal.created atomically with job completion; satisfied/ unauthorised/disabled/no-resolver cases become durable no-ops. - EvolutionDistilledKnowledgeStore projects TEACHER_VERDICT_RECORDED into an in-memory read model (all four actions); the D1 feedback edge (prior verdict shown to the teacher) is preserved in the worker via the knowledge projection. - LeapBoard projection adds resolution/no-op/knowledge-retraction; governance sweep is driven from run_learning_boundary so quiet boundaries still leave evidence. Cleanup (no back-compat; single source of truth) - Delete WorldModelEvolutionDriver, build_proposal_sink, build_alternatives_provider, JsonDistilledKnowledgeStore and the shutdown-only _on_session_end_learning / _drive_world_model_evolution paths; migrate their tests to the durable worker, event-sourced knowledge store, and proposal queue. Verification: ruff clean; full suite 3862 passed, 7 skipped, 1 xfailed; journeys replay green. --- .learnings/ERRORS.md | 98 +++ docs/plugins/plugin_lifecycle_management.md | 23 +- .../plugins/third_party_plugin_development.md | 18 +- src/leapflow/cli/cli.py | 21 +- src/leapflow/cli/commands/evolve.py | 52 +- src/leapflow/cli/context.py | 683 ++++++--------- src/leapflow/config.py | 95 +++ src/leapflow/config_service.py | 19 + src/leapflow/daemon/_service_helpers.py | 4 + src/leapflow/daemon/approval_coordinator.py | 35 + src/leapflow/daemon/client.py | 53 +- src/leapflow/daemon/monitor_coordinator.py | 15 +- src/leapflow/daemon/protocol.py | 33 +- src/leapflow/daemon/service.py | 149 +++- src/leapflow/dashboard/intent.py | 19 +- src/leapflow/dashboard/server.py | 1 + src/leapflow/dashboard/service.py | 62 +- src/leapflow/domain/__init__.py | 20 + src/leapflow/domain/adaptation_verdict.py | 2 + src/leapflow/domain/environment_signal.py | 322 +++++++ src/leapflow/domain/event_types.py | 33 + src/leapflow/domain/evolution_event.py | 351 ++++++++ src/leapflow/domain/plugin_fiber.py | 25 +- src/leapflow/domain/plugin_proposal.py | 48 +- src/leapflow/domain/skill_types.py | 1 + src/leapflow/engine/action_executor.py | 164 ++++ src/leapflow/engine/engine.py | 539 +++++++----- src/leapflow/engine/scheduler.py | 94 +-- src/leapflow/engine/session.py | 44 +- src/leapflow/engine/tool_execution.py | 55 +- src/leapflow/evolution/__init__.py | 8 + src/leapflow/evolution/action_recorder.py | 220 +++++ src/leapflow/evolution/artifact_store.py | 162 ++++ src/leapflow/evolution/outbox.py | 233 ++++++ src/leapflow/evolution/projection.py | 526 ++++++++++++ src/leapflow/evolution/session_finalizer.py | 194 +++++ src/leapflow/evolution/sink.py | 8 +- src/leapflow/evolution/teacher_worker.py | 698 +++++++++++++++ src/leapflow/hardware/transports/__init__.py | 17 +- src/leapflow/layout.py | 32 +- src/leapflow/learning/degradation_sink.py | 234 ++---- src/leapflow/learning/world_model_driver.py | 716 ---------------- src/leapflow/monitor/evolution_producer.py | 184 ++-- src/leapflow/perception/__init__.py | 3 + src/leapflow/perception/environment_source.py | 156 ++++ src/leapflow/perception/leapspace_source.py | 120 +++ src/leapflow/perception/signal_source.py | 2 +- .../perception/signal_sources_builtin.py | 1 - src/leapflow/performance.py | 67 ++ src/leapflow/platform/event_bus.py | 3 +- src/leapflow/plugins/adaptive_loop.py | 78 -- src/leapflow/plugins/dsh/plugin.py | 15 +- src/leapflow/plugins/evolution_contracts.py | 17 +- src/leapflow/plugins/lifecycle_governor.py | 49 +- src/leapflow/plugins/proposal_orchestrator.py | 306 +++++++ src/leapflow/plugins/protocol.py | 3 + src/leapflow/plugins/registry.py | 60 +- src/leapflow/plugins/sandbox/sandbox_host.py | 67 +- src/leapflow/plugins/sandbox/worker.py | 18 + src/leapflow/plugins/scoped_registry.py | 55 ++ src/leapflow/plugins/tool_plugins/file_ops.py | 2 + src/leapflow/plugins/tool_plugins/gateway.py | 8 + src/leapflow/plugins/tool_plugins/hub.py | 3 + .../plugins/tool_plugins/self_management.py | 748 +++++++++++------ .../plugins/tool_plugins/shell_terminal.py | 4 + src/leapflow/skills/registry.py | 16 +- src/leapflow/storage/__init__.py | 12 + .../storage/capability_proposal_queue.py | 447 ++++++---- .../storage/distilled_knowledge_store.py | 327 +++----- src/leapflow/storage/evolution_event_store.py | 792 ++++++++++++++++++ src/leapflow/storage/evolution_store.py | 34 +- src/leapflow/storage/evolution_trace_store.py | 121 --- src/leapflow/storage/plugin_outcome_store.py | 82 +- src/leapflow/storage/plugin_proposal_store.py | 126 --- src/leapflow/storage/plugin_version_store.py | 30 +- src/leapflow/storage/schema.py | 224 ++++- src/leapflow/tools/name_resolver.py | 75 +- src/leapflow/world_model/prediction.py | 93 +- src/leapflow/world_model/trajectory_grader.py | 13 +- src/leapspace/app_space/harness.py | 15 + ...sette-model-367e09460741491b.cassette.json | 55 ++ ...sette-model-9b6460bbb9f20b6f.cassette.json | 75 ++ ...sette-model-bc00bc1c3adb5c03.cassette.json | 59 ++ ...sette-model-d963d1a7c85f827a.cassette.json | 59 ++ ...sette-model-21df7e8e74778e3f.cassette.json | 55 ++ ...sette-model-73ddd7ce361986cc.cassette.json | 59 ++ ...sette-model-aff723a22088e665.cassette.json | 59 ++ ...sette-model-ef55f6a7257d5165.cassette.json | 55 ++ ...sette-model-4ecd277d081b281e.cassette.json | 55 ++ ...sette-model-114913c6ced49c00.cassette.json | 60 ++ ...sette-model-8f4a60fd5352920b.cassette.json | 64 ++ ...sette-model-bd1578d59776ef42.cassette.json | 64 ++ ...sette-model-f4840e1191c49c9c.cassette.json | 64 ++ ...sette-model-06eeece3f570a148.cassette.json | 55 ++ ...sette-model-077a17b141c44fb6.cassette.json | 59 ++ ...sette-model-31d350ae8f4ff81e.cassette.json | 67 ++ ...sette-model-8bfb5eaeaf86d401.cassette.json | 59 ++ ...sette-model-158ec6b3661786da.cassette.json | 76 ++ ...sette-model-17557e9ee9842679.cassette.json | 72 ++ ...sette-model-1e18a0da1790b11f.cassette.json | 60 ++ ...sette-model-30b7ab3ad4a5a107.cassette.json | 60 ++ ...sette-model-3798e4163d6b2128.cassette.json | 56 ++ ...sette-model-4d1f12200292b229.cassette.json | 60 ++ ...sette-model-898001f1b5122a8a.cassette.json | 71 ++ ...sette-model-a7782cf136290032.cassette.json | 55 ++ ...sette-model-ada1fc7ddc57492e.cassette.json | 76 ++ ...sette-model-b5a61ebb6aabdcfb.cassette.json | 76 ++ ...sette-model-b9831df577183d53.cassette.json | 60 ++ ...sette-model-c0ef153884a21ac7.cassette.json | 72 ++ ...sette-model-d352b6f5b033a2d7.cassette.json | 56 ++ ...sette-model-e6109a845a1dd79f.cassette.json | 76 ++ ...sette-model-33afdab4bc90b747.cassette.json | 119 +++ ...sette-model-3705093e647723c3.cassette.json | 55 ++ ...sette-model-38aa0b5a67f18052.cassette.json | 75 ++ ...sette-model-6dccb60364d7af34.cassette.json | 75 ++ ...sette-model-7ad0336ee1e5a800.cassette.json | 75 ++ ...sette-model-a690658cc3ac97da.cassette.json | 59 ++ ...sette-model-b5283e275ca539f0.cassette.json | 59 ++ ...sette-model-cc5cd4f23919fe0b.cassette.json | 76 ++ ...sette-model-d6eb6c82ef17961b.cassette.json | 60 ++ ...sette-model-14785ee2b98ad8a2.cassette.json | 59 ++ ...sette-model-2ecead8ad64bd2b2.cassette.json | 75 ++ ...sette-model-3253e1220413e5f3.cassette.json | 75 ++ ...sette-model-3dc49087c1103fb6.cassette.json | 87 ++ ...sette-model-5be074139ef16c9a.cassette.json | 75 ++ ...sette-model-5fa148b50481fec6.cassette.json | 75 ++ ...sette-model-63f72b6ae055dd95.cassette.json | 91 ++ ...sette-model-6d0e8558c8ee265e.cassette.json | 71 ++ ...sette-model-81c3f24286673f15.cassette.json | 87 ++ ...sette-model-bb795810fcb3b193.cassette.json | 91 ++ ...sette-model-d70fc70163a8902a.cassette.json | 75 ++ ...sette-model-ef8c4f88764ca616.cassette.json | 91 ++ tests/test_action_recorder_wiring.py | 209 +++++ tests/test_active_signal_source.py | 6 +- tests/test_adaptation_verdict.py | 103 +-- tests/test_agent_execution.py | 11 + tests/test_capability_proposal_policy.py | 99 ++- tests/test_capability_replacement_trigger.py | 366 +------- tests/test_capability_resolver.py | 39 + tests/test_coevolution_sweep_wiring.py | 12 +- tests/test_dashboard_view.py | 40 +- tests/test_degradation_feedback_loop.py | 189 ++--- tests/test_distilled_knowledge.py | 460 ++++------ tests/test_distilled_preference.py | 81 +- tests/test_durable_teacher.py | 427 ++++++++++ tests/test_effect_scope.py | 20 +- tests/test_environment_source.py | 128 +++ tests/test_evolution_event_store.py | 378 +++++++++ tests/test_evolution_governance_reachable.py | 108 +-- tests/test_evolution_producer.py | 20 +- tests/test_evolution_projection.py | 215 +++++ tests/test_evolution_tap.py | 94 +-- tests/test_evolution_trigger_boundary.py | 64 +- tests/test_evolution_verify_and_govern.py | 19 +- tests/test_gateway_adapter_registry.py | 4 +- tests/test_hardware_transport_contract.py | 4 +- tests/test_inert_wiring_audit.py | 65 +- tests/test_lifecycle_governor.py | 57 +- tests/test_llm_coevolution_e2e.py | 3 - tests/test_llm_provider_registry.py | 2 +- tests/test_marketplace_server.py | 3 - tests/test_performance_metrics.py | 33 + tests/test_phase3_learning_autonomy.py | 6 +- tests/test_plugin_learning.py | 5 +- tests/test_plugin_proposal_store.py | 38 - tests/test_plugin_sandbox.py | 17 +- tests/test_plugin_stats_persistence.py | 1 - tests/test_proposal_orchestrator.py | 303 +++++++ tests/test_scoped_registry.py | 50 ++ tests/test_self_evolution_switch.py | 4 +- tests/test_self_management.py | 204 ++++- tests/test_signal_source.py | 2 - tests/test_telegram_signal_source.py | 2 +- tests/test_tool_concurrency.py | 16 +- tests/test_world_model_driver.py | 335 -------- ...test_world_model_proposal_sink_contract.py | 133 --- 176 files changed, 13658 insertions(+), 4773 deletions(-) create mode 100644 .learnings/ERRORS.md create mode 100644 src/leapflow/domain/environment_signal.py create mode 100644 src/leapflow/domain/evolution_event.py create mode 100644 src/leapflow/engine/action_executor.py create mode 100644 src/leapflow/evolution/action_recorder.py create mode 100644 src/leapflow/evolution/artifact_store.py create mode 100644 src/leapflow/evolution/outbox.py create mode 100644 src/leapflow/evolution/projection.py create mode 100644 src/leapflow/evolution/session_finalizer.py create mode 100644 src/leapflow/evolution/teacher_worker.py delete mode 100644 src/leapflow/learning/world_model_driver.py create mode 100644 src/leapflow/perception/environment_source.py create mode 100644 src/leapflow/perception/leapspace_source.py create mode 100644 src/leapflow/performance.py create mode 100644 src/leapflow/plugins/proposal_orchestrator.py create mode 100644 src/leapflow/storage/evolution_event_store.py delete mode 100644 src/leapflow/storage/evolution_trace_store.py delete mode 100644 src/leapflow/storage/plugin_proposal_store.py create mode 100644 tests/_fixtures/cassettes/r1_conversation/cassette-model-367e09460741491b.cassette.json create mode 100644 tests/_fixtures/cassettes/r1_conversation/cassette-model-9b6460bbb9f20b6f.cassette.json create mode 100644 tests/_fixtures/cassettes/r1_conversation/cassette-model-bc00bc1c3adb5c03.cassette.json create mode 100644 tests/_fixtures/cassettes/r1_conversation/cassette-model-d963d1a7c85f827a.cassette.json create mode 100644 tests/_fixtures/cassettes/r2_isolation/cassette-model-21df7e8e74778e3f.cassette.json create mode 100644 tests/_fixtures/cassettes/r2_isolation/cassette-model-73ddd7ce361986cc.cassette.json create mode 100644 tests/_fixtures/cassettes/r2_isolation/cassette-model-aff723a22088e665.cassette.json create mode 100644 tests/_fixtures/cassettes/r2_isolation/cassette-model-ef55f6a7257d5165.cassette.json create mode 100644 tests/_fixtures/cassettes/r3_control_plane/cassette-model-4ecd277d081b281e.cassette.json create mode 100644 tests/_fixtures/cassettes/r4_recovery/cassette-model-114913c6ced49c00.cassette.json create mode 100644 tests/_fixtures/cassettes/r4_recovery/cassette-model-8f4a60fd5352920b.cassette.json create mode 100644 tests/_fixtures/cassettes/r4_recovery/cassette-model-bd1578d59776ef42.cassette.json create mode 100644 tests/_fixtures/cassettes/r4_recovery/cassette-model-f4840e1191c49c9c.cassette.json create mode 100644 tests/_fixtures/cassettes/r5_learning/cassette-model-06eeece3f570a148.cassette.json create mode 100644 tests/_fixtures/cassettes/r5_learning/cassette-model-077a17b141c44fb6.cassette.json create mode 100644 tests/_fixtures/cassettes/r5_learning/cassette-model-31d350ae8f4ff81e.cassette.json create mode 100644 tests/_fixtures/cassettes/r5_learning/cassette-model-8bfb5eaeaf86d401.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-158ec6b3661786da.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-17557e9ee9842679.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-1e18a0da1790b11f.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-30b7ab3ad4a5a107.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-3798e4163d6b2128.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-4d1f12200292b229.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-898001f1b5122a8a.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-a7782cf136290032.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-ada1fc7ddc57492e.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b5a61ebb6aabdcfb.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b9831df577183d53.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-c0ef153884a21ac7.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-d352b6f5b033a2d7.cassette.json create mode 100644 tests/_fixtures/cassettes/r6_lifecycle/cassette-model-e6109a845a1dd79f.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-33afdab4bc90b747.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-3705093e647723c3.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-38aa0b5a67f18052.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-6dccb60364d7af34.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-7ad0336ee1e5a800.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-a690658cc3ac97da.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-b5283e275ca539f0.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-cc5cd4f23919fe0b.cassette.json create mode 100644 tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-d6eb6c82ef17961b.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-14785ee2b98ad8a2.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-2ecead8ad64bd2b2.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-3253e1220413e5f3.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-3dc49087c1103fb6.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-5be074139ef16c9a.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-5fa148b50481fec6.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-63f72b6ae055dd95.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-6d0e8558c8ee265e.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-81c3f24286673f15.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-bb795810fcb3b193.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-d70fc70163a8902a.cassette.json create mode 100644 tests/_fixtures/cassettes/r8_hardware/cassette-model-ef8c4f88764ca616.cassette.json create mode 100644 tests/test_action_recorder_wiring.py create mode 100644 tests/test_durable_teacher.py create mode 100644 tests/test_environment_source.py create mode 100644 tests/test_evolution_event_store.py create mode 100644 tests/test_evolution_projection.py create mode 100644 tests/test_performance_metrics.py delete mode 100644 tests/test_plugin_proposal_store.py create mode 100644 tests/test_proposal_orchestrator.py delete mode 100644 tests/test_world_model_driver.py delete mode 100644 tests/test_world_model_proposal_sink_contract.py diff --git a/.learnings/ERRORS.md b/.learnings/ERRORS.md new file mode 100644 index 00000000..1fc00387 --- /dev/null +++ b/.learnings/ERRORS.md @@ -0,0 +1,98 @@ +# Errors + +## [ERR-20260918-P2S] sandbox-resource-default + +**Logged**: 2026-09-18T13:52:25Z +**Priority**: high +**Status**: resolved +**Area**: backend + +### Summary +A default RLIMIT_AS ceiling caused Python sandbox workers to exit before responding on macOS. + +### Error +``` +Sandbox smoke test failed: worker did not respond +``` + +### Context +- The plugin sandbox applied a 512 MiB address-space limit before importing runtime modules. +- macOS virtual address-space accounting exceeded the limit during normal worker startup. + +### Suggested Fix +Keep memory limits configurable but disabled by default unless validated for the deployment platform. + +### Metadata +- Reproducible: yes +- Related Files: src/leapflow/plugins/sandbox/worker.py, src/leapflow/config.py + +### Resolution +- **Resolved**: 2026-09-18T13:52:25Z +- **Notes**: Default memory limit changed to zero; explicit configured limits remain enforced. + +--- + +## [ERR-20260918-LNT] repository-wide-ruff-baseline + +**Logged**: 2026-09-18T13:52:25Z +**Priority**: medium +**Status**: resolved +**Area**: tests + +### Summary +Repository-wide Ruff validation reports pre-existing unused imports outside the evolution implementation surface. + +### Error +``` +ruff check src tests: 33 F401/F811 findings +``` + +### Context +- Targeted Ruff checks for all files changed by the evolution plan pass. +- The remaining findings are in unrelated perception, platform, marketplace, and older test modules. + +### Suggested Fix +Run a dedicated repository-wide lint cleanup and verify affected modules with their focused tests. + +### Metadata +- Reproducible: yes +- Related Files: src/leapflow/perception/signal_source.py, src/leapflow/platform/event_bus.py, tests/test_signal_source.py + +### Resolution +- **Resolved**: 2026-09-18T13:52:25Z +- **Notes**: Applied safe Ruff fixes and replaced the remaining assigned lambdas with local functions; repository-wide Ruff now passes. + +--- + +## [ERR-20260918-EVP] event-projection-migration-regressions + +**Logged**: 2026-09-18T14:30:00Z +**Priority**: medium +**Status**: resolved +**Area**: tests + +### Summary +Targeted tests exposed stale constructor and lazy JSON-store assumptions during the event-derived knowledge migration. + +### Error +``` +3 failed: proposal_sink constructor argument, lazy JSON knowledge binding, missing injected event knowledge store +``` + +### Context +- DurableTeacherWorker now requires an event-backed proposal queue and live resolver. +- AgentEngine no longer creates a JSON knowledge store on the hot path. +- A production-wiring unit fixture did not inject the new event-derived knowledge projection. + +### Suggested Fix +Update tests and fixtures to use the event store, inject the knowledge projection explicitly, and assert fail-closed acquisition resolution. + +### Metadata +- Reproducible: yes +- Related Files: tests/test_durable_teacher.py, tests/test_distilled_knowledge.py, tests/test_degradation_feedback_loop.py + +### Resolution +- **Resolved**: 2026-09-19T00:30:00Z +- **Notes**: Updated worker tests for atomic proposal preparation, replaced lazy JSON binding with explicit event-projection injection, and fixed production governor fixtures. Full suite passes. + +--- diff --git a/docs/plugins/plugin_lifecycle_management.md b/docs/plugins/plugin_lifecycle_management.md index 64c5d51a..4e70278b 100644 --- a/docs/plugins/plugin_lifecycle_management.md +++ b/docs/plugins/plugin_lifecycle_management.md @@ -12,7 +12,7 @@ | Term | Definition | |------|-----------| -| **PluginFiber** | A per-plugin lifecycle state-machine instance (`domain/plugin_fiber.py`). Tracks runtime state transitions (PENDING/LOADING/ACTIVE/FAILED/UNLOADING/DISPOSED) and owns an EffectScope for deterministic cleanup. | +| **PluginFiber** | A per-plugin lifecycle state-machine instance (`domain/plugin_fiber.py`). Tracks runtime state transitions (PENDING/DRAFT/LOADING/ACTIVE/FAILED/UNLOADING/DISPOSED) and owns an EffectScope for deterministic cleanup. | | **EffectScope** | Hierarchical, LIFO-ordered cleanup collector (`domain/effect_scope.py`). Guarantees safe teardown on dispose. | | **Trust Level** | Progressive reliability gradient (DRAFT → CANDIDATE → VERIFIED → PRODUCTION) earned by consecutive successes, persisted in DuckDB. | | **Generation Counter** | Module-level monotonic integer; each new PluginFiber receives a unique generation. Engine caches key on `(id(plugin), generation)` to detect reloads. | @@ -56,8 +56,9 @@ A plugin's state is the **composition** of three independent axes: Runtime, Trus | State | Meaning | Transitions out | |-------|---------|----------------| -| `PENDING` | Created, awaiting activation or async init | `LOADING`, `ACTIVE` (fast path), `DISPOSED` | -| `LOADING` | Async initialization in progress (dependency resolution) | `ACTIVE`, `FAILED`, `UNLOADING` | +| `PENDING` | Created, awaiting activation or async init | `DRAFT`, `LOADING`, `ACTIVE` (trusted fast path), `DISPOSED` | +| `DRAFT` | Isolated candidate; no live handlers are published | `ACTIVE`, `DISPOSED` | +| `LOADING` | Async initialization in progress (dependency resolution) | `ACTIVE`, `FAILED`, `DISPOSED` | | `ACTIVE` | Fully operational, tools registered and available | `UNLOADING` | | `FAILED` | Initialization failed; retryable via `retry()`/`begin_loading()` | `LOADING`, `DISPOSED` | | `UNLOADING` | Graceful teardown in progress | `DISPOSED` | @@ -129,9 +130,9 @@ A plugin's state is the **composition** of three independent axes: Runtime, Trus | Dimension | Built-in Plugins | Third-Party Plugins | |-----------|-----------------|---------------------| | **Discovery** | Hardcoded module list in `plugins/tool_plugins/__init__.py` → `get_all_plugins()` | Profile-dir install (`plugin_install` tool) or marketplace fetch | -| **Boot sequence** | `discover_builtin()` → `register()` → `bind_runtime()` → `assemble()` → `adopt_existing_plugins()` | `plugin_install` → validate → sandbox smoke → register → fiber activate | +| **Boot sequence** | `discover_builtin()` → `register()` → `bind_runtime()` → `assemble()` → `adopt_existing_plugins()` | `plugin_install` → staging → bounded sandbox smoke/behavior tests → DRAFT fiber → atomic publish | | **Initial trust** | Implicitly DRAFT (but never demoted/frozen in practice — no failure path for well-tested built-ins) | Explicitly DRAFT; must earn promotion through usage | -| **Fiber creation** | `adopt_existing_plugins()` at first `get_scoped_registry()` access; starts in ACTIVE | `create_fiber()` → `scoped_register()` → `activate()` during install | +| **Fiber creation** | `adopt_existing_plugins()` at first `get_scoped_registry()` access; starts in ACTIVE | `create_draft_fiber()` → `stage_plugin()` → `promote_draft()` after tests | | **Approval** | None for registration (they ARE the system); mutations still gated | ALL mutations gated (HIGH risk, no permanent grants) | | **Isolation** | In-process (same asyncio loop) | Optionally sandboxed (subprocess JSON-RPC via `SandboxHost`); `requires_sandbox` manifest flag defaults `True` | | **Reload** | `reload(plugin_id)` via scoped registry; version bump + cache invalidation | Same mechanism, but PRODUCTION trust → auto-approve; below PRODUCTION → explicit approval | @@ -147,11 +148,11 @@ A plugin's state is the **composition** of three independent axes: Runtime, Trus | **plugin_list** | Agent tool | None | Always | — | No (read-only) | | **plugin_status** | Agent tool | None | Always | — | No (read-only) | | **plugin_versions** | Agent tool | None | Always | `ProfileLayout.plugin_versions_dir` | No (read-only) | -| **plugin_propose** | Agent tool | None | Always (proposal only, no LLM/file/runtime mutation) | `ProfileLayout.plugin_proposals_path` | No (proposal store write only) | +| **plugin_propose** | Agent tool | None | Always (proposal only, no runtime mutation) | Event-sourced lifecycle store | Yes — `proposal.created` | | **assess_compatibility** | Agent tool | None | Always (read-only manifest assessment; no file/runtime mutation) | — | No (read-only) | -| **plugin_generate** | Agent tool | None | Always (code generation only, no filesystem write) | `plugin_generation_enabled` must be `True`; needs `llm_provider` bound | No (ephemeral output) | +| **plugin_generate** | Agent tool | Content approval | Never for proposal-backed generation | `plugin_generation_enabled`; LLM provider; CAS | Yes — generated artifact and approval lifecycle events | | **/plugin generate** | User (slash command) | None (user invocation = consent) | Always auto-approved (user-initiated); installs at DRAFT trust level | `plugin_generation_enabled` must be `True`; needs an LLM provider | Yes — install action descriptor recorded | -| **plugin_install** | Agent tool | `ApprovalGate` → HIGH, `allow_permanent=False` | Never (always requires human) | `plugin_install_dir`, proposal/version stores, `plugin_marketplace_root/url`, `plugin_marketplace_trusted_pubkeys` | Yes — action descriptor metadata recorded | +| **plugin_install** | Agent tool | `ApprovalGate` → HIGH, `allow_permanent=False` | Never (always requires human) | `plugin_install_dir`, event lifecycle/version stores, `plugin_marketplace_root/url`, `plugin_marketplace_trusted_pubkeys` | Yes — action descriptor and lifecycle event recorded | | **plugin_rollback** | Agent tool | `ApprovalGate` → HIGH, `allow_permanent=False` | Never (always requires human) | `ProfileLayout.plugin_versions_dir` | Yes | | **plugin_reload** | Agent tool | `ApprovalGate` → HIGH, `allow_permanent=False` | Trust == PRODUCTION (auto-approved) | proposal/version stores when behavior tests or version labels are used | Yes | | **plugin_disable** | Agent tool | `ApprovalGate` → HIGH, `allow_permanent=False` | Never (always requires human) | — | Yes | @@ -174,8 +175,8 @@ A plugin's state is the **composition** of three independent axes: Runtime, Trus **Trigger**: User or agent decides a new capability is needed. **Sequence**: -1. **Generate** (optional): `plugin_generate(description="...")` → LLM produces code → `PluginValidator` multi-stage check (syntax → structure → runtime protocol conformance). Returns validated code blob. No filesystem write. -2. **Install request**: `plugin_install(code=)` or `plugin_install(marketplace_name="...")`. +1. **Generate**: `plugin_generate(proposal_id="...")` → LLM produces code → `PluginValidator` multi-stage check → profile CAS write → explicit proposal-content approval. No live registry mutation occurs. +2. **Install request**: `plugin_install(proposal_id="...")` resolves the approved CAS artifact and requests a separate mutation approval. Direct code/marketplace installs still use the mutation gate. - **Compatibility pre-gate (marketplace path only)**: the resolved manifest is run through `assess_plugin()` (the Compatibility Assessment Engine) *before* anything else. An `INCOMPATIBLE` verdict is **rejected here with a structured error, before any file write**; an `ADAPTABLE` verdict proceeds and its adaptation notes are attached to the install result. 3. **Approval gate**: `ActionDescriptor.platform_action("plugin_management", "install", {...})` → `gate.evaluate()` → user prompted (HIGH risk, one-time). 4. **Duplicate check**: If `plugin_id` already exists in registry → immediate rejection with error. @@ -491,7 +492,7 @@ These require human/product input and are not answerable from code alone: | Plugin discovery (built-in) | `src/leapflow/plugins/tool_plugins/__init__.py` | | Self-management tools (12 tools) | `src/leapflow/plugins/tool_plugins/self_management.py` | | Proposal domain records | `src/leapflow/domain/plugin_proposal.py` | -| Proposal persistence | `src/leapflow/storage/plugin_proposal_store.py` | +| Proposal persistence | `src/leapflow/storage/capability_proposal_queue.py` (`EvolutionCapabilityProposalStore`) | | Behavior test execution | `src/leapflow/learning/plugin_behavior_tests.py` | | Version snapshot store | `src/leapflow/storage/plugin_version_store.py` | | Trust ledger | `src/leapflow/learning/plugin_trust.py` | diff --git a/docs/plugins/third_party_plugin_development.md b/docs/plugins/third_party_plugin_development.md index d0c870a8..580ceb7a 100644 --- a/docs/plugins/third_party_plugin_development.md +++ b/docs/plugins/third_party_plugin_development.md @@ -117,6 +117,7 @@ class ToolMetadata: handler: Callable[..., Any] x_leapflow: dict[str, Any] = field(default_factory=dict) mutates_state: bool = False + execution_policy: str = "" def to_openai_schema(self) -> dict[str, Any]: """Generate OpenAI function-calling schema dict.""" @@ -135,13 +136,14 @@ class ToolMetadata: "x_leapflow": { "category": "integration", "mutates_state": true, - "risk_level": "medium" + "risk_level": "medium", + "execution_policy": "mutating_once" } } } ``` -When `mutates_state=True`, `to_openai_schema()` folds it into `x_leapflow.mutates_state` so schema-only consumers can classify side-effecting tools without accessing the metadata object. +When `mutates_state=True`, `to_openai_schema()` folds it into `x_leapflow.mutates_state`. A non-empty `execution_policy` is folded into `x_leapflow.execution_policy` as well, so schema-only consumers use the same declared execution semantics as the runtime. **`x_leapflow` well-known keys:** @@ -157,6 +159,7 @@ omit approval/idempotency metadata. | `schema_cost` | `str` | `"low"` / `"medium"` / `"high"` — token cost hint for PCD | | `requires_approval` | `bool` | Whether the engine gates this tool behind approval | | `mutates_state` | `bool` | Auto-populated from the field when `True` | +| `execution_policy` | `str` | `read_only`, `mutating_idempotent`, `mutating_once`, or `external_side_effect`; undeclared policies fail safe as external | ### 2.3 GatewayAdapterPlugin Protocol @@ -388,6 +391,7 @@ ToolMetadata( parameters_schema={...}, handler=handle_delete, mutates_state=True, + execution_policy="external_side_effect", x_leapflow={ "category": "cloud_ops", "risk_level": "high", @@ -396,7 +400,7 @@ ToolMetadata( ) ``` -For platform actions (gateway send, external API write), use `ActionDescriptor.platform_action(platform, action, metadata)` within the handler to explicitly request gate evaluation. +For platform actions (gateway send, external API write), use `execution_policy="external_side_effect"` and `ActionDescriptor.platform_action(platform, action, metadata)`. The action descriptor requests approval; the execution policy controls durable evidence, duplicate suppression, batch stopping, and uncertain-effect reporting. Runtime policy is derived only from these declarations, never from the tool name. ### 3.6 Code Quality @@ -426,9 +430,9 @@ The following is the ordered sequence from plugin source to tool invocation: ### Step 4: PluginFiber Lifecycle -5. **`ScopedToolRegistry.adopt_existing_plugins()`**: Called on first `leapflow.plugins.get_scoped_registry()` access. It creates a `PluginFiber` for every already-registered plugin and uses the fast path `PENDING → ACTIVE` for the current built-in/profile ToolPlugin runtime. The `PluginFiber` domain type also supports `LOADING` and `FAILED` retry states for future async initialization paths, but the scoped registry does not yet run a dependency-driven async activation loop. +5. **`ScopedToolRegistry.adopt_existing_plugins()`**: Called on first `leapflow.plugins.get_scoped_registry()` access. It creates a `PluginFiber` for every already-registered plugin. Dependency-free built-ins use `PENDING → ACTIVE`; dependency-bearing plugins use `PENDING → LOADING → ACTIVE` when providers become available. -Fiber domain state machine: `PENDING → LOADING → ACTIVE → UNLOADING → DISPOSED` (with `LOADING → FAILED → LOADING` retry path). Current ToolPlugin registration uses the fast path `PENDING → ACTIVE`; `LOADING`/`FAILED` are available primitives, not automatic dependency orchestration. +Fiber domain state machine: `PENDING → DRAFT → ACTIVE → UNLOADING → DISPOSED` for isolated candidates, plus `PENDING → LOADING → ACTIVE` and `LOADING → FAILED → LOADING` for dependency-driven activation. DRAFT plugins expose no live handlers until atomic promotion. ### Step 5: Per-Turn Engine Assembly @@ -485,7 +489,7 @@ Typical interceptor use cases include audit logging, execution timeout, approval ### Dependency Binding and Activation -Plugins declare `dependencies`, and `ToolPluginRegistry.bind_runtime()` distributes matching runtime dependencies in topological plugin order. Current ToolPlugin activation still uses the `ScopedToolRegistry` fast path (`PENDING → ACTIVE`) after registration; plugins that require a dependency should degrade gracefully in their handler when the dependency is not bound. A future async activation loop may use the `LOADING`/`FAILED` states for dependency-driven retries, but that is not yet automatic. +Plugins declare `dependencies`, and `ToolPluginRegistry.bind_runtime()` distributes matching runtime dependencies in topological plugin order. `ScopedToolRegistry` activates dependency-free plugins immediately and keeps dependency-bearing fibers in `LOADING` until their providers are active; handlers must still degrade gracefully when optional runtime dependencies are absent. --- @@ -530,7 +534,7 @@ description: - **`--id `** — override the auto-derived plugin id (a slug of the description). A colliding id is rejected cleanly. -Generation is controlled by `plugin.generation_enabled` (enabled by default in current config; disable via `/config set plugin.generation_enabled false`) and requires an LLM provider. Installation still remains a separate approval-gated action. +Generation is controlled by `plugin.generation_enabled` and requires an LLM provider. Proposal-backed generation stores validated source in profile CAS and requires explicit content approval. Installation remains a separate mutation approval. **Difference from the `plugin_generate` agent tool**: `/plugin generate` is a *user-initiated* control-plane command — the user's invocation is the consent, so it diff --git a/src/leapflow/cli/cli.py b/src/leapflow/cli/cli.py index e25e9e60..797afd5e 100644 --- a/src/leapflow/cli/cli.py +++ b/src/leapflow/cli/cli.py @@ -290,10 +290,26 @@ def main(argv: list[str] | None = None) -> int: evolve_parser = subparsers.add_parser( "evolve", help="Run the learning boundary now and report what it did" ) + evolve_parser.add_argument( + "--session", + required=True, + help="Exact session id whose new evidence should be finalized", + ) evolve_parser.add_argument( "--reason", default="manual", help="Label recorded with this run (default: manual)", ) + evolve_parser.add_argument( + "--wait", + action="store_true", + help="Wait for the durable teacher job to reach a terminal state", + ) + evolve_parser.add_argument( + "--timeout", + type=float, + default=180.0, + help="Maximum wait time in seconds when --wait is set", + ) evolve_parser.add_argument("--json", action="store_true", help="Emit machine-readable JSON") # leap hw (hardware inspection and direct intervention) @@ -469,9 +485,8 @@ def main(argv: list[str] | None = None) -> int: from leapflow.cli.commands.dashboard import cmd_dashboard return cmd_dashboard(args) - # Evolve routes to leapd, which owns the context holding the trajectory buffer. - # Running it in this process would build a second, empty context and grade - # nothing, so no Context is initialized here either. + # Evolve routes to leapd, the sole writer of the durable event stream and + # teacher-job queue. A client-side Context would create a competing writer. if args.command == "evolve": from leapflow.cli.commands.evolve import cmd_evolve return cmd_evolve(args) diff --git a/src/leapflow/cli/commands/evolve.py b/src/leapflow/cli/commands/evolve.py index 3700f946..2689ffa2 100644 --- a/src/leapflow/cli/commands/evolve.py +++ b/src/leapflow/cli/commands/evolve.py @@ -1,17 +1,12 @@ """`leap evolve` — run the learning boundary now, and report what it did. -Capability evolution is driven from exactly one place: the learning boundary, which -grades the recorded trajectory, lets the world model propose capabilities it found -missing, and runs the cold-path governance sweep. That boundary used to be reachable -only from context cleanup, which in daemon mode means *process shutdown* — so a -daemon that ran for a week never evolved, one killed with SIGKILL never evolved at -all, and there was no way to answer "did it evolve, and what happened" without -stopping the daemon and reading its log. - -This command makes the boundary an explicit, observable operation. It routes to the -daemon rather than doing the work locally, because the daemon owns the context that -holds the trajectory buffer and the proposal queue; a second context would grade an -empty buffer and truthfully report that nothing happened. +Capability evolution starts at a durable session boundary. The boundary flushes the +append-only action stream, seals exactly one named session slice, and queues hindsight +teacher work that survives client exit and daemon restart. + +This command routes to the daemon because it is the sole DuckDB writer. Requiring an +explicit session id prevents one client from accidentally finalizing another client's +most-recent session. It decides nothing on its own: whether a proposal is even *written* still depends on ``evolution.enabled``, and whether it is acted on still depends on generation, @@ -49,7 +44,12 @@ async def _run(args: argparse.Namespace) -> int: return 1 try: - result = await client.evolution_run(reason=str(getattr(args, "reason", "") or "manual")) + result = await client.evolution_run( + session_id=str(args.session), + reason=str(getattr(args, "reason", "") or "manual"), + wait=bool(getattr(args, "wait", False)), + timeout_s=float(getattr(args, "timeout", 180.0)), + ) except Exception as exc: # noqa: BLE001 - surfaced, never a traceback _report_error(str(exc), as_json) return 1 @@ -63,25 +63,25 @@ async def _run(args: argparse.Namespace) -> int: return 1 steps = int(result.get("trajectory_steps") or 0) + jobs = list(result.get("job_ids") or []) print( - f"Learning boundary ran ({result.get('reason', 'manual')}) in " - f"{result.get('duration_s', 0)}s — {steps} trajectory step(s) graded." + f"Session {result.get('session_id', args.session)} finalized " + f"({result.get('reason', 'manual')}) in {result.get('duration_s', 0)}s — " + f"{steps} evidence event(s), {len(jobs)} teacher job(s) queued." ) - if not steps: - # Said plainly, because an empty trajectory is the common case and looks - # identical to a failure otherwise. The governance sweep still ran: that is - # the whole reason it sits outside the trajectory branch. - print( - " No turns were recorded since the last boundary, so the teacher had " - "nothing to grade. The governance sweep still ran." - ) + if not jobs: + print(" No new action evidence was found after the previous session boundary.") + elif result.get("job"): + print(f" Teacher job status: {result['job'].get('status', 'unknown')}") + else: + print(f" Durable teacher job: {jobs[0]}") if not getattr(settings, "evolution_enabled", False): print( - " Self-evolution is off, so no capability proposal was written. " - "The world model still graded and recorded what it learned. " + " Self-evolution is off, so teacher output cannot authorize a capability proposal. " + "Durable teacher grading remains enabled. " "Enable with: leap config set evolution.enabled true" ) - print(" See the result on the board: leap board evolution") + print(" See durable progress on the board: leap board evolution") return 0 diff --git a/src/leapflow/cli/context.py b/src/leapflow/cli/context.py index 288e80b2..4d3fb412 100644 --- a/src/leapflow/cli/context.py +++ b/src/leapflow/cli/context.py @@ -26,7 +26,6 @@ IntentClassifier, LLMIntentClassifier, ) -from leapflow.engine.scheduler import TaskScheduler from leapflow.engine.session import SessionController from leapflow.recording.attention import build_attention_filters from leapflow.analysis.pipeline import ImitationPipeline @@ -385,6 +384,21 @@ def __init__(self, settings: Settings, mock_host: bool) -> None: settings.duckdb_path, volatile_on_lock=True, ) + # Long-running evolution evidence is profile-scoped and daemon-owned. The + # store schema initializes on a worker thread in ``initialize_critical``; + # the outbox stays on the event loop. Session engines share both while + # supplying their own causal identifiers. + self._evolution_event_store: Optional[Any] = None + self._evolution_artifact_store: Optional[Any] = None + self._evolution_outbox: Optional[Any] = None + self._action_recorder: Optional[Any] = None + self._action_executor: Optional[Any] = None + self._session_finalizer: Optional[Any] = None + self._teacher_worker: Optional[Any] = None + self._evolution_projection_runner: Optional[Any] = None + self._evolution_knowledge_store: Optional[Any] = None + self._capability_proposal_queue: Optional[Any] = None + self._plugin_outcome_store: Optional[Any] = None # Memory subsystem — provider-based architecture (dual-layer) working = WorkingMemoryProvider(max_tokens=settings.memory_working_max_tokens) @@ -1403,6 +1417,60 @@ async def initialize_critical(self, *, daemon_mode: bool = True) -> None: settings = self.settings await self.memory.initialize_all() + if self._action_recorder is None: + from leapflow.engine.action_executor import RecordedActionExecutor + from leapflow.evolution.action_recorder import ActionRecorder + from leapflow.evolution.artifact_store import ContentAddressedArtifactStore + from leapflow.evolution.outbox import EvolutionEventOutbox + from leapflow.evolution.projection import EvolutionProjectionRunner + from leapflow.evolution.session_finalizer import SessionFinalizer + from leapflow.storage.capability_proposal_queue import ( + EvolutionCapabilityProposalStore, + ) + from leapflow.storage.distilled_knowledge_store import ( + EvolutionDistilledKnowledgeStore, + ) + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + from leapflow.storage.plugin_outcome_store import EvolutionPluginOutcomeStore + from leapflow.version import __version__ + + self._evolution_event_store = await asyncio.to_thread( + DuckDBEvolutionEventStore, + self._db_holder, + ) + self._evolution_artifact_store = ContentAddressedArtifactStore( + settings.profile_layout.evolution_artifacts_dir + ) + self._evolution_outbox = EvolutionEventOutbox(self._evolution_event_store) + self._evolution_outbox.start() + self._action_recorder = ActionRecorder( + self._evolution_outbox, + producer_version=__version__, + ) + self._action_executor = RecordedActionExecutor(self._action_recorder) + self._session_finalizer = SessionFinalizer( + self._evolution_event_store, + self._evolution_outbox, + ) + self._evolution_projection_runner = EvolutionProjectionRunner( + self._evolution_event_store + ) + self._evolution_knowledge_store = EvolutionDistilledKnowledgeStore( + self._evolution_event_store, + profile_id=settings.profile_layout.profile_id, + ttl_seconds=float( + getattr(settings, "distilled_knowledge_ttl_s", 0.0) or 0.0 + ), + ) + await asyncio.to_thread(self._evolution_knowledge_store.refresh) + self._capability_proposal_queue = EvolutionCapabilityProposalStore( + self._evolution_event_store, + profile_id=settings.profile_layout.profile_id, + ) + self._plugin_outcome_store = EvolutionPluginOutcomeStore( + self._evolution_event_store, + profile_id=settings.profile_layout.profile_id, + ) if self.storage_volatile: _emit_status( "Primary database is locked; running with volatile session storage." @@ -1562,9 +1630,6 @@ async def initialize_critical(self, *, daemon_mode: bool = True) -> None: # are assembled in initialize_deferred() graph_planner = GraphPlanner(self.llm, self.registry) if settings.has_llm_credentials else None - scheduler = TaskScheduler( - self.registry, self.rpc, graph_planner=graph_planner, - ) if graph_planner else None # Bind perception/execution to the desktop semantic plugin from leapflow.plugins import get_registry as _get_tool_registry @@ -1885,7 +1950,6 @@ async def _summarize_via_llm(prompt: str) -> str: imitation=None, # wired in initialize_deferred() skill_library=self.skill_lib, graph_planner=graph_planner, - scheduler=scheduler, perception=perception, execution=execution_adapter, skill_activator=None, # wired in initialize_deferred() @@ -1895,7 +1959,9 @@ async def _summarize_via_llm(prompt: str) -> str: evolution=self._evolution, skill_injector=skill_injector, skill_index=skill_index, + action_executor=self._action_executor, ) + self.engine.set_distilled_knowledge_store(self._evolution_knowledge_store) # ── Wire CompressorConfig with archive_fn into engine ── from leapflow.engine.context_compressor import ContextCompressor @@ -2471,6 +2537,56 @@ async def initialize_deferred(self) -> None: experience_store=self.experience_store, budget=self.learning_budget, ) + if ( + self._teacher_worker is None + and self._evolution_event_store is not None + and self._evolution_artifact_store is not None + ): + from leapflow.evolution.teacher_worker import DurableTeacherWorker + from leapflow.learning.degradation_sink import ( + build_live_capability_resolver, + ) + from leapflow.plugins import get_registry + from leapflow.version import __version__ + + observation_service = self._capability_observation_service() + proposal_queue = ( + self._capability_proposal_queue + if settings.evolution_enabled + else None + ) + acquisition_resolver = ( + build_live_capability_resolver( + registry_provider=get_registry, + environment_provider=self._current_environment_fingerprint, + ) + if proposal_queue is not None + else None + ) + self._teacher_worker = DurableTeacherWorker( + store=self._evolution_event_store, + artifact_store=self._evolution_artifact_store, + teacher=self.trajectory_grader, + profile_id=settings.profile_layout.profile_id, + producer_version=__version__, + poll_interval_s=settings.evolution_teacher_poll_interval_s, + lease_seconds=settings.evolution_teacher_lease_s, + teacher_timeout_s=settings.evolution_teacher_timeout_s, + max_attempts=settings.evolution_teacher_max_attempts, + retry_backoff_s=settings.evolution_teacher_retry_backoff_s, + proposal_queue=proposal_queue, + acquisition_resolver=acquisition_resolver, + authorising_origins=tuple( + getattr(settings, "evolution_authorising_origins", ()) or () + ), + degraded_capabilities=( + observation_service.degraded_capabilities + if observation_service is not None + else None + ), + knowledge_projection=self._evolution_knowledge_store, + ) + self._teacher_worker.start() self.registry.set_prediction_loop(self.prediction_loop) if perception_session is not None: @@ -2664,6 +2780,7 @@ def _on_prediction_outcome(outcome: Any) -> None: learnability_assessor=learnability_assessor, evolution_policy=self._evolution_policy, skill_store=self.skill_lib, + action_dispatcher=self.engine.execute_action if self.engine is not None else None, ) # ── Wire deferred components to engine ── @@ -2713,6 +2830,7 @@ def _load_evolution_store() -> "tuple[Any, list[dict[str, Any]]]": try: if getattr(settings, "agent_calibration_enabled", False) and self._evolution_store is not None: self.engine.set_calibration_store(self._evolution_store) + self.engine.set_calibration_event_store(self._evolution_event_store) diff_result = await self._run_deferred_db( lambda: self.engine.recalibrate_difficulty(self._evolution_store) ) @@ -3114,6 +3232,46 @@ def _capability_observation_service(self): ) return self._observation_service + async def record_environment_observation(self, observation: Any) -> None: + """Persist one typed environment observation and feed accepted gap evidence.""" + outbox = self._evolution_outbox + if outbox is None: + raise RuntimeError("evolution event outbox unavailable") + from leapflow.domain.event_types import EvolutionEventType + from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent + + context = EvolutionContext.create( + profile_id=self.settings.profile_layout.profile_id, + workspace_id=str(getattr(observation, "workspace_id", "") or ""), + session_id=str(getattr(observation, "session_id", "") or ""), + observation_id=str(observation.observation_id), + correlation_id=f"environment:{observation.source_id}:{observation.app_id}", + ) + await outbox.publish( + EvolutionEvent.create( + EvolutionEventType.ENVIRONMENT_OBSERVED, + context=context, + payload=observation.to_dict(), + producer=f"environment.{observation.source_id}", + privacy_class="session" if context.session_id else "system", + occurred_at=observation.observed_at, + dedup_key=f"environment.observed:{observation.observation_id}", + ) + ) + service = self._capability_observation_service() + if service is None: + return + for result in observation.capability_results(): + await asyncio.to_thread( + service.observe_result, + result, + environment=self._current_environment_dict(), + source="environment_probe", + session_id=context.session_id, + workspace_root=str(getattr(self.settings, "workspace_root", "") or ""), + metadata={"environment_observation_id": observation.observation_id}, + ) + def _current_environment_fingerprint(self): """The environment a capability decision is made against, as a fingerprint. @@ -3189,28 +3347,17 @@ def _resolve_lifecycle_governor(self): from leapflow.learning.degradation_sink import build_degradation_sink from leapflow.plugins import get_registry from leapflow.plugins.lifecycle_governor import LifecycleGovernor - from leapflow.storage.capability_proposal_queue import ( - JsonCapabilityProposalQueue, - ) - from leapflow.storage.distilled_knowledge_store import ( - JsonDistilledKnowledgeStore, - ) - from leapflow.storage.plugin_outcome_store import JsonPluginOutcomeStore intake = self._capability_observation_service() if intake is None: return None - knowledge_store = JsonDistilledKnowledgeStore( - profile_layout.distilled_knowledge_path, - ttl_seconds=float( - getattr(settings, "distilled_knowledge_ttl_s", 0.0) or 0.0 - ), - ) + knowledge_store = self._evolution_knowledge_store + proposal_queue = self._capability_proposal_queue + if proposal_queue is None: + return None self._lifecycle_governor = LifecycleGovernor( - proposal_queue=JsonCapabilityProposalQueue( - profile_layout.capability_proposal_queue_path - ), - outcome_store=JsonPluginOutcomeStore(profile_layout.plugin_outcomes_path), + proposal_queue=proposal_queue, + outcome_store=self._plugin_outcome_store, # The approval-gated actor that actually disables a plugin. Without it the # governor decided "quarantine" and nothing happened: trust dropped but the # plugin kept serving, and the queue never advanced past PROBATION. Built @@ -3294,13 +3441,9 @@ def _active_proposal_ids(self) -> dict: if profile_layout is None: return {} try: - from leapflow.storage.capability_proposal_queue import ( - JsonCapabilityProposalQueue, - ) - - queue = JsonCapabilityProposalQueue( - profile_layout.capability_proposal_queue_path - ) + queue = self._capability_proposal_queue + if queue is None: + return {} mapping: dict = {} # ``active()`` returns items newest-first (sorted by updated/created), so the # first mapping seen for a plugin is its most recent lifecycle record. Keep @@ -3363,391 +3506,100 @@ async def _run_coevolution_sweep(self): logger.debug("co-evolution sweep unavailable", exc_info=True) return None - async def _drive_world_model_evolution(self, trajectory: list, goal: str): - """Let the world model propose capability gaps from episode hindsight. - - Returns a ``WorldModelDriveResult`` (whose ``grades`` the caller reuses so - no second LLM call is made), or ``None`` when the driver cannot be - assembled -- in which case the caller falls back to plain grading. - - Runs only at the session-end learning boundary, so it adds no per-turn - cost. Intents are written as ordinary structured evidence and are admitted - only if ``accepted_evidence_kinds`` includes ``world_model_intent``; the - driver never writes around that gate. - """ - try: - from leapflow.learning.degradation_sink import ( - build_alternatives_provider, - build_proposal_sink, - ) - from leapflow.plugins import get_registry - from leapflow.learning.world_model_driver import WorldModelEvolutionDriver - from leapflow.storage.capability_proposal_queue import ( - JsonCapabilityProposalQueue, - ) - from leapflow.storage.distilled_knowledge_store import ( - JsonDistilledKnowledgeStore, - ) - - settings = self.settings - profile_layout = getattr(settings, "profile_layout", None) - if profile_layout is None or self.trajectory_grader is None: - return None - # The shared service, so the requirements the teacher reads are the ones - # the degradation sink wrote. - service = self._capability_observation_service() - if service is None: - return None - driver = WorldModelEvolutionDriver( - teacher=self.trajectory_grader, - intake=service, - # The C1 channel. Without it the cheap verdicts are graded, traced and - # discarded, so the teacher judges correctly and the next session - # repeats the same mistake. - knowledge_store=JsonDistilledKnowledgeStore( - profile_layout.distilled_knowledge_path, - ttl_seconds=float( - getattr(settings, "distilled_knowledge_ttl_s", 0.0) or 0.0 - ), - ), - # The last hop of the acquisition chain. Without it an ``acquire`` - # verdict became a requirement and stopped: resolution reported the - # capability unmet forever and the only verdict that leads to code had - # no effect. Queueing is not acting -- the queue is read by the - # dashboard and the self-management tools, which gate on approval. - # The fact the rebind/acquire choice is defined by. A teacher that - # cannot see whether another provider exists is guessing between them. - alternatives_for=build_alternatives_provider( - registry_provider=get_registry, - affordances_provider=self._current_affordances, - ), - # The last hop of the acquisition chain, and the one the switch governs. - # Queueing is still not acting -- the queue is read by the dashboard and the - # self-management tools, which gate on approval -- so this is the outermost - # of several gates rather than the only one. - # - # ``None`` when self-evolution is off, which says more than an empty queue - # would: the teacher still judges and still records that nothing installed - # can serve the capability, and that conclusion reaches the user as - # knowledge instead of as a proposal to build something. - proposal_sink=( - build_proposal_sink( - queue=JsonCapabilityProposalQueue( - profile_layout.capability_proposal_queue_path - ), - ) - if getattr(settings, "evolution_enabled", False) - else None - ), - # P5 authority in the production path: only an authorised requirement - # origin may drive an acquisition. Rebind-vs-acquire (whether an - # installed provider already covers the capability) is decided upstream - # by the teacher from failed-outcome hindsight and the alternatives it - # was shown -- a declared-fitness re-check here would re-introduce the - # semantic-regression blind spot -- so the driver adds authority only. - authorising_origins=tuple( - getattr(settings, "evolution_authorising_origins", ()) or () - ), + async def evolution_projection( + self, + *, + session_id: str = "", + aggregate: bool = False, + rebuild: bool = False, + ) -> dict[str, Any]: + """Return a checkpointed event projection for one session or the profile.""" + runner = self._evolution_projection_runner + if runner is None: + return {"ok": False, "error": "evolution projection unavailable"} + if self._evolution_outbox is not None: + await self._evolution_outbox.flush() + profile_id = self.settings.profile_layout.profile_id + if aggregate: + projection = await runner.project_aggregate( + profile_id=profile_id, + rebuild=rebuild, ) - return await driver.drive( - trajectory, - goal, - environment=self._current_environment_fingerprint(), - workspace_root=str(getattr(settings, "workspace_root", "") or ""), + else: + if not session_id: + return {"ok": False, "error": "session_id is required"} + projection = await runner.project_session( + profile_id=profile_id, + session_id=session_id, + rebuild=rebuild, ) - except (ImportError, AttributeError, OSError, RuntimeError, TypeError, ValueError): - logger.debug("world-model evolution driver unavailable", exc_info=True) - return None + return {"ok": True, "projection": projection} - async def run_learning_boundary(self, *, reason: str = "shutdown") -> dict[str, Any]: - """Run the learning boundary once and report what it did. - - This is the only place capability evolution is driven from, so *when* it is - called decides when the framework can evolve at all. It used to be reachable - only from :meth:`cleanup`, which in daemon mode means process shutdown: a - daemon that ran for a week never evolved, one killed with SIGKILL never - evolved at all, and the single flush at the end mixed every session and every - workspace of that lifetime into one episode carrying the last user's goal. - - Named and public so a semantic boundary can drive it -- a finished session, - or an explicit ``leap evolve`` -- instead of only the process dying. - ``reason`` is recorded rather than inspected: the pipeline does the same work - either way, and the label is what lets a reader tell a shutdown flush from a - session boundary from a hand-run one. - """ + async def run_learning_boundary( + self, + *, + reason: str = "manual", + session_id: str = "", + workspace_root: str = "", + session_generation: int = 0, + wait: bool = False, + timeout_s: float = 180.0, + ) -> dict[str, Any]: + """Seal session evidence and enqueue durable hindsight grading.""" + finalizer = self._session_finalizer + if finalizer is None: + return {"ok": False, "error": "evolution event store unavailable"} started = time.perf_counter() - before = len(self.prediction_loop.trajectory_buffer) if self.prediction_loop else 0 - await self._on_session_end_learning() + profile_id = self.settings.profile_layout.profile_id + model = str(getattr(self.settings, "llm_model", "") or "") + if session_id: + from leapflow.layout import workspace_id_for_path + + workspace_id = ( + workspace_id_for_path(Path(workspace_root).expanduser().resolve()) + if workspace_root + else "" + ) + finalizations = [ + await finalizer.finalize( + profile_id=profile_id, + workspace_id=workspace_id, + session_id=session_id, + session_generation=session_generation, + reason=reason, + model=model, + ) + ] + elif reason == "shutdown": + finalizations = await finalizer.finalize_pending_sessions( + profile_id=profile_id, + reason=reason, + model=model, + ) + else: + return {"ok": False, "error": "session_id is required", "reason": reason} + + worker = self._teacher_worker + if worker is not None: + worker.wake() + jobs = [item.job_id for item in finalizations if item.job_id] + job_state: dict[str, Any] | None = None + if wait and jobs and worker is not None: + job_state = await worker.wait_for_job(jobs[0], timeout_s=timeout_s) + sweep = await self._run_coevolution_sweep() return { "ok": True, "reason": reason, - "trajectory_steps": before, + "session_id": session_id, + "queued": bool(jobs), + "episode_ids": [item.episode_id for item in finalizations if item.episode_id], + "job_ids": jobs, + "trajectory_steps": sum(item.evidence_count for item in finalizations), + "job": job_state, + "sweep": sweep.to_dict() if sweep is not None else None, "duration_s": round(time.perf_counter() - started, 3), } - async def _on_session_end_learning(self) -> None: - """End-of-session OPD learning pipeline (8 phases) with full observability. - - Executes in order: - 1. Trajectory grading (teacher with full hindsight) — grades consumed by replay_engine - 2. Off-policy experience replay (high-delta) - 3. Curiosity-targeted replay (high-curiosity apps) — curiosity fed to attention_tuner - 4. Regression-gated self-distillation (causal rules) - 5. Attention statistics feedback (AttentionTuner) - 6. Long-term memory maintenance (prune old rows) - 7. Budget rebalancing from session outcomes - 8. VLM Tier 3 verification (if enabled) - """ - observer = self._pipeline_observer - if observer is None: - # Deferred init never completed (degraded/critical-only mode): - # no learning components were assembled, nothing to flush. - logger.debug("Session-end learning skipped: pipeline observer not initialized") - return - pipeline_start = time.perf_counter() - phases_ok = 0 - phases_failed = 0 - trajectory: list = [] - - # Phase 1: Trajectory grading — FIX A5-1: grades now consumed by replay_engine - if self.trajectory_grader is not None and self.prediction_loop is not None: - observer.on_phase_start("trajectory_grading") - t0 = time.perf_counter() - try: - trajectory, goal = self.prediction_loop.flush_trajectory() - phase_detail: dict[str, Any] = {} - if trajectory: - # The world model is the first driver of capability evolution: - # the same hindsight call that grades the episode also proposes - # any capability it found missing, and those proposals enter the - # ordinary governed evidence path. Admission is still gated by - # ``accepted_evidence_kinds``, so this is inert until opted in. - drive = await self._drive_world_model_evolution(trajectory, goal) - grades = list(drive.grades) if drive is not None else None - if grades is None: - grades = await self.trajectory_grader.grade_trajectory( - trajectory, goal=goal, - ) - if grades and self.replay_engine is not None: - self.replay_engine.set_replay_priorities(grades) - phase_detail["actions_graded"] = len(grades) if grades else 0 - if drive is not None: - phase_detail.update(drive.to_dict()) - else: - phase_detail.update({"actions_graded": 0, "note": "empty_trajectory"}) - # Cold-path governance sweep: effect verification, quarantine drain, - # reclamation. Outside the trajectory branch, because its whole - # purpose is that its no-op traces distinguish a quiet session from a - # sweep that never ran -- and nested inside it, an empty trajectory - # skipped the sweep entirely and produced exactly the ambiguity it - # was written to remove. Three reachability segments read - # "no sweep trace observed" on a live board for that reason alone. - # - # Nothing here depends on the trajectory: the sweep reads the process - # observation buffer and the proposal queue, both of which carry work - # from turns that predate this boundary. - sweep = await self._run_coevolution_sweep() - if sweep is not None: - phase_detail.update(sweep.to_dict()) - observer.on_phase_success( - "trajectory_grading", time.perf_counter() - t0, phase_detail, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("trajectory_grading", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 2: Off-policy replay - if self.replay_engine is not None: - observer.on_phase_start("off_policy_replay") - t0 = time.perf_counter() - try: - insights = await self.replay_engine.replay_session() - observer.on_phase_success( - "off_policy_replay", time.perf_counter() - t0, - {"insights_discovered": len(insights) if insights else 0}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("off_policy_replay", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 3: Curiosity-targeted replay — FIX A5-2: feed curiosity to attention_tuner - if self.replay_engine is not None and self.active_observer is not None: - observer.on_phase_start("curiosity_replay") - t0 = time.perf_counter() - try: - curious_apps = self.active_observer.drain_high_curiosity_apps() - for app_ctx in curious_apps: - await self.replay_engine.replay_targeted(app_ctx) - tuner = getattr(self, "attention_tuner", None) - if tuner is not None and curious_apps: - tuner.boost_curiosity_domains(curious_apps) - observer.on_phase_success( - "curiosity_replay", time.perf_counter() - t0, - {"curious_apps": len(curious_apps)}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("curiosity_replay", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 4: Regression-gated self-distillation - if self.replay_engine is not None and trajectory: - observer.on_phase_start("regression_distillation") - t0 = time.perf_counter() - try: - if self.replay_engine.detect_regression(trajectory): - distilled = await self.replay_engine.self_distill() - observer.on_phase_success( - "regression_distillation", time.perf_counter() - t0, - {"regression_detected": True, "rules_distilled": len(distilled)}, - ) - else: - observer.on_phase_success( - "regression_distillation", time.perf_counter() - t0, - {"regression_detected": False}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("regression_distillation", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 5: Attention statistics feedback - tuner = getattr(self, "attention_tuner", None) - if tuner is not None and trajectory: - observer.on_phase_start("attention_feedback") - t0 = time.perf_counter() - try: - from collections import defaultdict - app_sums: dict = defaultdict(lambda: [0.0, 0]) - for step in trajectory: - app = step.get("app_context", "") - delta = step.get("delta", 0.0) - if app: - app_sums[app][0] += delta - app_sums[app][1] += 1 - app_deltas = {a: s[0] / s[1] for a, s in app_sums.items() if s[1] > 0} - if app_deltas: - tuner.on_session_stats(app_deltas) - observer.on_phase_success( - "attention_feedback", time.perf_counter() - t0, - {"apps_tracked": len(app_deltas)}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("attention_feedback", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 6: Long-term memory maintenance - observer.on_phase_start("memory_prune") - t0 = time.perf_counter() - try: - pruned = self.lt.prune(max_age_days=self.settings.memory_prune_age_days) - observer.on_phase_success( - "memory_prune", time.perf_counter() - t0, - {"rows_pruned": pruned or 0}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("memory_prune", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 6.5: Skill inactivity decay (C4 — after memory prune, before budget rebalance) - if self._evolution_policy is not None and self.skill_lib is not None: - observer.on_phase_start("skill_decay") - t0 = time.perf_counter() - try: - all_skills = self.skill_lib.load_all_active_parameterized() - decayed_count = 0 - for skill in all_skills: - last_used = skill.get("updated_at", 0.0) - days_inactive = (time.time() - last_used) / 86400.0 - if days_inactive > 30: # Only decay after 30 days of inactivity - outcome = self._evolution_policy.decay_inactive( - skill.get("name", ""), - current_confidence=skill.get("confidence", 0.5), - current_version=skill.get("version", 1), - last_used_ts=last_used, - ) - if outcome.tier_changed: - self.skill_lib.update_skill_confidence( - skill.get("name", ""), outcome.new_confidence - ) - decayed_count += 1 - observer.on_phase_success( - "skill_decay", time.perf_counter() - t0, - {"skills_decayed": decayed_count, "skills_checked": len(all_skills)}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("skill_decay", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 7: Budget rebalancing - budget = getattr(self, "learning_budget", None) - if budget is not None: - observer.on_phase_start("budget_rebalance") - t0 = time.perf_counter() - try: - skills_discovered = 0 - regressions_detected = 0 - avg_delta = 0.0 - if trajectory: - deltas = [s.get("delta", 0.0) for s in trajectory if isinstance(s, dict)] - avg_delta = sum(deltas) / max(len(deltas), 1) - regressions_detected = sum( - 1 for s in trajectory - if isinstance(s, dict) and s.get("verdict") == "regressed" - ) - replay_engine = getattr(self, "replay_engine", None) - if replay_engine is not None: - skills_discovered = getattr(replay_engine, "session_discoveries", 0) - budget.rebalance_from_session_outcome( - skills_discovered=skills_discovered, - regressions_detected=regressions_detected, - avg_prediction_delta=avg_delta, - ) - observer.on_phase_success( - "budget_rebalance", time.perf_counter() - t0, - {"avg_delta": round(avg_delta, 4), "regressions": regressions_detected}, - ) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("budget_rebalance", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Phase 8: VLM Tier 3 verification - if self.settings.causal_tier3_enabled: - observer.on_phase_start("vlm_tier3") - t0 = time.perf_counter() - try: - ps = self.perception_session - if ps is not None: - pipeline = ps.causal_pipeline - graph = ps.causal_graph - - async def _vlm_call(prompt: str) -> str: - vlm = self.vlm or self.llm - resp = await vlm.achat( - [{"role": "user", "content": prompt}], - stream=False, - enable_thinking=False, - ) - return (resp.content or "").strip() - - await pipeline.run_vlm_verification(graph, vlm_call=_vlm_call) - observer.on_phase_success("vlm_tier3", time.perf_counter() - t0, {}) - phases_ok += 1 - except Exception as exc: - observer.on_phase_failure("vlm_tier3", exc, time.perf_counter() - t0) - phases_failed += 1 - - # Pipeline complete - observer.on_pipeline_complete( - time.perf_counter() - pipeline_start, phases_ok, phases_failed, - ) - _NORMALIZER_FACTORIES: dict[str, type] = {} @staticmethod @@ -3829,6 +3681,13 @@ async def cleanup(self) -> None: db_executor.shutdown(wait=True, cancel_futures=True) self._deferred_db_executor = None + teacher_worker = getattr(self, "_teacher_worker", None) + if teacher_worker is not None: + try: + await teacher_worker.close() + except Exception: + logger.warning("Teacher worker shutdown failed", exc_info=True) + # Persist evolution episodes to DuckDB before shutdown evo_store = getattr(self, "_evolution_store", None) if evo_store is not None and self._evolution is not None: @@ -3903,11 +3762,23 @@ async def cleanup(self) -> None: await self.event_bus.shutdown() except Exception: logger.debug("EventBus shutdown failed", exc_info=True) - # OPD end-of-session learning pipeline - if self.settings.replay_on_session_end: + # Seal every session independently. The teacher worker is already stopped, + # so newly queued jobs remain durable and are reclaimed on the next start. + try: await self.run_learning_boundary(reason="shutdown") + except Exception: + logger.warning("Evolution session finalization failed", exc_info=True) # Persist session summary before memory shutdown await self._persist_session_summary() + # Drain the append-only evolution outbox while the shared DuckDB holder is + # still alive. A shutdown may happen immediately after a mutating action, and + # losing its completion fact would make recovery guess whether it ran. + evolution_outbox = getattr(self, "_evolution_outbox", None) + if evolution_outbox is not None: + try: + await evolution_outbox.close() + except Exception: + logger.exception("Evolution event outbox shutdown failed") # Shutdown all memory providers (stops GC, closes DB) await self.memory.shutdown_all() if isinstance(self.rpc, CuaDriverClient): diff --git a/src/leapflow/config.py b/src/leapflow/config.py index 1bb6e675..e87643ae 100644 --- a/src/leapflow/config.py +++ b/src/leapflow/config.py @@ -128,6 +128,12 @@ class Settings: # When non-empty, marketplace installs MUST carry a valid signature from # one of these keys; empty tuple -> checksum-only integrity verification. plugin_marketplace_trusted_pubkeys: tuple[str, ...] = () + # Python plugin sandbox limits. Zero CPU/memory disables that individual + # operating-system limit; request and shutdown timeouts are always bounded. + plugin_sandbox_invoke_timeout_s: float = 15.0 + plugin_sandbox_shutdown_timeout_s: float = 3.0 + plugin_sandbox_cpu_time_s: int = 30 + plugin_sandbox_max_memory_mb: int = 0 # Restricted DeepSeek Harness / Cordis bridge runtime. These are cold-path # process limits; changing them requires rebuilding daemon-owned plugin # wrappers and therefore takes effect after daemon restart. @@ -390,6 +396,17 @@ class Settings: # driver is the world model" -- other origins keep being recorded and resolved, # but can no longer authorise acquiring new code. evolution_authorising_origins: tuple[str, ...] = () + evolution_teacher_poll_interval_s: float = 1.0 + evolution_teacher_lease_s: float = 120.0 + evolution_teacher_timeout_s: float = 180.0 + evolution_teacher_max_attempts: int = 3 + evolution_teacher_retry_backoff_s: float = 5.0 + evolution_autonomy_level: str = "generate_only" + environment_mode: str = "production" + environment_leapspace_enabled: bool = False + environment_leapspace_state_root: str = "" + environment_leapspace_session_id: str = "" + environment_leapspace_poll_interval_s: float = 0.5 # Which registered policy chooses among admissible tool candidates. ``greedy`` # is the shipped default and reproduces the selection made before the policy # seam existed: highest weighted score, stable tie-break. @@ -524,6 +541,10 @@ class Settings: agent_calibration_enabled: bool = False agent_calibration_min_confidence: float = 0.3 agent_calibration_interval_turns: int = 0 + agent_calibration_difficulty_min_k: float = 0.25 + agent_calibration_difficulty_max_k: float = 3.0 + agent_calibration_finalizing_min_ratio: float = 0.6 + agent_calibration_finalizing_max_ratio: float = 0.98 agent_compression_writeback: bool = False agent_reentry_enabled: bool = False agent_reentry_tick_seconds: float = 30.0 @@ -980,6 +1001,37 @@ def _build_settings_from_env( for origin in os.getenv("LEAPFLOW_EVOLUTION_AUTHORISING_ORIGINS", "").split(",") if origin.strip() ) + evolution_teacher_poll_interval_s = float( + os.getenv("LEAPFLOW_EVOLUTION_TEACHER_POLL_INTERVAL_S", "1.0") + ) + evolution_teacher_lease_s = float( + os.getenv("LEAPFLOW_EVOLUTION_TEACHER_LEASE_S", "120.0") + ) + evolution_teacher_timeout_s = float( + os.getenv("LEAPFLOW_EVOLUTION_TEACHER_TIMEOUT_S", "180.0") + ) + evolution_teacher_max_attempts = int( + os.getenv("LEAPFLOW_EVOLUTION_TEACHER_MAX_ATTEMPTS", "3") + ) + evolution_teacher_retry_backoff_s = float( + os.getenv("LEAPFLOW_EVOLUTION_TEACHER_RETRY_BACKOFF_S", "5.0") + ) + evolution_autonomy_level = os.getenv( + "LEAPFLOW_EVOLUTION_AUTONOMY_LEVEL", "generate_only" + ).strip() + environment_mode = os.getenv("LEAPFLOW_ENVIRONMENT_MODE", "production").strip().lower() + environment_leapspace_enabled = _bool( + "LEAPFLOW_ENVIRONMENT_LEAPSPACE_ENABLED", "false" + ) + environment_leapspace_state_root = os.getenv( + "LEAPFLOW_ENVIRONMENT_LEAPSPACE_STATE_ROOT", "" + ).strip() + environment_leapspace_session_id = os.getenv( + "LEAPFLOW_ENVIRONMENT_LEAPSPACE_SESSION_ID", "" + ).strip() + environment_leapspace_poll_interval_s = float( + os.getenv("LEAPFLOW_ENVIRONMENT_LEAPSPACE_POLL_INTERVAL_S", "0.5") + ) selection_policy = os.getenv("LEAPFLOW_SELECTION_POLICY", "greedy").strip() or "greedy" replay_on_session_end = _bool("LEAPFLOW_REPLAY_ON_SESSION_END", "true") distilled_knowledge_ttl_s = float( @@ -1084,6 +1136,18 @@ def _build_settings_from_env( agent_calibration_enabled = os.getenv("LEAPFLOW_AGENT_CALIBRATION_ENABLED", "0").strip().lower() in ("1", "true", "yes") agent_calibration_min_confidence = float(os.getenv("LEAPFLOW_AGENT_CALIBRATION_MIN_CONFIDENCE", "0.3")) agent_calibration_interval_turns = int(os.getenv("LEAPFLOW_AGENT_CALIBRATION_INTERVAL_TURNS", "0")) + agent_calibration_difficulty_min_k = float( + os.getenv("LEAPFLOW_AGENT_CALIBRATION_DIFFICULTY_MIN_K", "0.25") + ) + agent_calibration_difficulty_max_k = float( + os.getenv("LEAPFLOW_AGENT_CALIBRATION_DIFFICULTY_MAX_K", "3.0") + ) + agent_calibration_finalizing_min_ratio = float( + os.getenv("LEAPFLOW_AGENT_CALIBRATION_FINALIZING_MIN_RATIO", "0.6") + ) + agent_calibration_finalizing_max_ratio = float( + os.getenv("LEAPFLOW_AGENT_CALIBRATION_FINALIZING_MAX_RATIO", "0.98") + ) agent_compression_writeback = os.getenv("LEAPFLOW_AGENT_COMPRESSION_WRITEBACK", "0").strip().lower() in ("1", "true", "yes") agent_reentry_enabled = os.getenv("LEAPFLOW_AGENT_REENTRY_ENABLED", "0").strip().lower() in ("1", "true", "yes") agent_reentry_tick_seconds = float(os.getenv("LEAPFLOW_AGENT_REENTRY_TICK_SECONDS", "30")) @@ -1107,6 +1171,18 @@ def _build_settings_from_env( tools_lint_command = os.getenv("LEAPFLOW_TOOLS_LINT_COMMAND", "").strip() tools_terminal_session_enabled = os.getenv("LEAPFLOW_TOOLS_TERMINAL_SESSION_ENABLED", "1").strip().lower() in ("1", "true", "yes") tools_verify_edits = os.getenv("LEAPFLOW_TOOLS_VERIFY_EDITS", "1").strip().lower() in ("1", "true", "yes") + plugin_sandbox_invoke_timeout_s = float( + os.getenv("LEAPFLOW_PLUGIN_SANDBOX_INVOKE_TIMEOUT_S", "15") + ) + plugin_sandbox_shutdown_timeout_s = float( + os.getenv("LEAPFLOW_PLUGIN_SANDBOX_SHUTDOWN_TIMEOUT_S", "3") + ) + plugin_sandbox_cpu_time_s = int( + os.getenv("LEAPFLOW_PLUGIN_SANDBOX_CPU_TIME_S", "30") + ) + plugin_sandbox_max_memory_mb = int( + os.getenv("LEAPFLOW_PLUGIN_SANDBOX_MAX_MEMORY_MB", "0") + ) plugins_dsh_invoke_timeout_s = float(os.getenv("LEAPFLOW_PLUGINS_DSH_INVOKE_TIMEOUT_S", "30")) plugins_dsh_discovery_timeout_s = float(os.getenv("LEAPFLOW_PLUGINS_DSH_DISCOVERY_TIMEOUT_S", "10")) plugins_dsh_max_message_bytes = int(os.getenv("LEAPFLOW_PLUGINS_DSH_MAX_MESSAGE_BYTES", "1000000")) @@ -1409,6 +1485,17 @@ def _tuple_env(key: str, default: tuple) -> tuple: evolution_enabled=evolution_enabled, accepted_evidence_kinds=accepted_evidence_kinds, evolution_authorising_origins=evolution_authorising_origins, + evolution_teacher_poll_interval_s=evolution_teacher_poll_interval_s, + evolution_teacher_lease_s=evolution_teacher_lease_s, + evolution_teacher_timeout_s=evolution_teacher_timeout_s, + evolution_teacher_max_attempts=evolution_teacher_max_attempts, + evolution_teacher_retry_backoff_s=evolution_teacher_retry_backoff_s, + evolution_autonomy_level=evolution_autonomy_level, + environment_mode=environment_mode, + environment_leapspace_enabled=environment_leapspace_enabled, + environment_leapspace_state_root=environment_leapspace_state_root, + environment_leapspace_session_id=environment_leapspace_session_id, + environment_leapspace_poll_interval_s=environment_leapspace_poll_interval_s, selection_policy=selection_policy, replay_on_session_end=replay_on_session_end, distilled_knowledge_ttl_s=distilled_knowledge_ttl_s, @@ -1498,6 +1585,10 @@ def _tuple_env(key: str, default: tuple) -> tuple: agent_calibration_enabled=agent_calibration_enabled, agent_calibration_min_confidence=agent_calibration_min_confidence, agent_calibration_interval_turns=agent_calibration_interval_turns, + agent_calibration_difficulty_min_k=agent_calibration_difficulty_min_k, + agent_calibration_difficulty_max_k=agent_calibration_difficulty_max_k, + agent_calibration_finalizing_min_ratio=agent_calibration_finalizing_min_ratio, + agent_calibration_finalizing_max_ratio=agent_calibration_finalizing_max_ratio, agent_compression_writeback=agent_compression_writeback, agent_reentry_enabled=agent_reentry_enabled, agent_reentry_tick_seconds=agent_reentry_tick_seconds, @@ -1520,6 +1611,10 @@ def _tuple_env(key: str, default: tuple) -> tuple: tools_lint_command=tools_lint_command, tools_terminal_session_enabled=tools_terminal_session_enabled, tools_verify_edits=tools_verify_edits, + plugin_sandbox_invoke_timeout_s=plugin_sandbox_invoke_timeout_s, + plugin_sandbox_shutdown_timeout_s=plugin_sandbox_shutdown_timeout_s, + plugin_sandbox_cpu_time_s=plugin_sandbox_cpu_time_s, + plugin_sandbox_max_memory_mb=plugin_sandbox_max_memory_mb, plugins_dsh_invoke_timeout_s=plugins_dsh_invoke_timeout_s, plugins_dsh_discovery_timeout_s=plugins_dsh_discovery_timeout_s, plugins_dsh_max_message_bytes=plugins_dsh_max_message_bytes, diff --git a/src/leapflow/config_service.py b/src/leapflow/config_service.py index 8605590d..d7c2d296 100644 --- a/src/leapflow/config_service.py +++ b/src/leapflow/config_service.py @@ -300,6 +300,10 @@ class ConfigSnapshot: "agent.calibration_enabled": "Enable S3-L3 online difficulty calibration: apply the offline S3-L2 report's bounded suggested weight scale to the difficulty->budget sensitivity (scale_k), derived from the baseline and clamped/reversible (default off).", "agent.calibration_min_confidence": "Minimum calibration-report confidence required before an online difficulty-weight adjustment is applied (guards against acting on thin data).", "agent.calibration_interval_turns": "Re-run online difficulty/threshold calibration every N root turns as outcome data accumulates (0 = one-shot at startup only; requires calibration enabled).", + "agent.calibration_difficulty_min_k": "Operator floor for calibrated difficulty scaling, clamped by the built-in safety envelope.", + "agent.calibration_difficulty_max_k": "Operator ceiling for calibrated difficulty scaling, clamped by the built-in safety envelope.", + "agent.calibration_finalizing_min_ratio": "Operator floor for calibrated finalization ratio, never below the safety minimum.", + "agent.calibration_finalizing_max_ratio": "Operator ceiling for calibrated finalization ratio, never above the safety maximum.", "agent.compression_writeback": "Persist structural context compression back into the loop's message history so append-only frozen segments stay byte-stable across rounds (continuous prefix-cache reuse). Opt-in; the recent raw tail is preserved (default off).", "agent.reentry_enabled": "Enable event-driven re-entry: allow tasks to register a resume trigger (schedule_reentry) that seeds a future run from the saved orientation (default off).", "agent.reentry_tick_seconds": "How often (seconds) the daemon dispatches due re-entry triggers as isolated subagents (only when reentry is enabled).", @@ -323,6 +327,10 @@ class ConfigSnapshot: "signal.noise_path_fragments": "Path fragments treated as monitor/display noise for fs.change events, e.g. OS caches and tool state directories.", "signal.noise_dir_names": "Directory names treated as monitor/display noise for fs.change events.", "signal.noise_suffixes": "Filename suffixes treated as transient fs.change noise, e.g. WAL/SHM/journal/temp/log files.", + "plugins.sandbox_invoke_timeout_s": "Maximum seconds for one Python sandbox RPC; requires daemon restart.", + "plugins.sandbox_shutdown_timeout_s": "Maximum graceful shutdown wait for a Python sandbox worker; requires daemon restart.", + "plugins.sandbox_cpu_time_s": "CPU-time ceiling in seconds for each Python sandbox worker; zero disables it.", + "plugins.sandbox_max_memory_mb": "Address-space ceiling in megabytes for each Python sandbox worker; zero disables it.", "plugins.dsh_invoke_timeout_s": "Maximum seconds for one restricted DSH tool invocation; requires daemon restart.", "plugins.dsh_discovery_timeout_s": "Maximum seconds for restricted DSH runtime discovery; requires daemon restart.", "plugins.dsh_max_message_bytes": "Maximum bytes in one DSH worker NDJSON protocol message; requires daemon restart.", @@ -346,6 +354,17 @@ class ConfigSnapshot: "approval, sandboxing and trust all still apply, and every plugin change asks for " "your approval individually." ), + "evolution.teacher_poll_interval_s": "Seconds between durable teacher queue polls.", + "evolution.teacher_lease_s": "Lease duration for one claimed hindsight teacher job.", + "evolution.teacher_timeout_s": "Maximum seconds for one hindsight teacher call.", + "evolution.teacher_max_attempts": "Maximum attempts before a teacher job fails permanently.", + "evolution.teacher_retry_backoff_s": "Base retry delay for failed teacher jobs.", + "evolution.autonomy_level": "Maximum automatic proposal action; approvals remain mandatory.", + "environment.mode": "Environment-source mode: production or experiment.", + "environment.leapspace_enabled": "Enable the LeapSpace filesystem source in experiment mode.", + "environment.leapspace_state_root": "Host-visible LeapSpace state directory.", + "environment.leapspace_session_id": "Session receiving LeapSpace environment evidence.", + "environment.leapspace_poll_interval_s": "Seconds between LeapSpace state scans.", } _SECTION_CATEGORIES = { diff --git a/src/leapflow/daemon/_service_helpers.py b/src/leapflow/daemon/_service_helpers.py index 178a5309..a03d80bb 100644 --- a/src/leapflow/daemon/_service_helpers.py +++ b/src/leapflow/daemon/_service_helpers.py @@ -218,3 +218,7 @@ async def should_refresh(self, messages: list[dict[str, Any]]) -> bool: return await self._service._session_coordinator.should_refresh( self._service._ctx, messages ) + + async def evolution_projection_aggregate(self) -> dict[str, Any]: + """Expose only the explicitly aggregate event projection to producers.""" + return await self._service.evolution_projection_aggregate() diff --git a/src/leapflow/daemon/approval_coordinator.py b/src/leapflow/daemon/approval_coordinator.py index 6e82eb4b..2d032e85 100644 --- a/src/leapflow/daemon/approval_coordinator.py +++ b/src/leapflow/daemon/approval_coordinator.py @@ -101,7 +101,35 @@ def install_gate(self, ctx: Any, service: Any) -> None: # a marketplace client from settings. Both are injected via the same # bind_runtime path; self_management declares them as dependencies. plugin_install_dir = self._resolve_plugin_install_dir(settings) + profile_layout = getattr(settings, "profile_layout", None) + plugin_staging_dir = ( + str(profile_layout.plugin_staging_dir) if profile_layout is not None else None + ) marketplace_client = self._build_marketplace_client(settings, plugin_install_dir) + proposal_orchestrator = None + try: + from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy + from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator + artifact_store = getattr(ctx, "_evolution_artifact_store", None) + proposal_queue = getattr(ctx, "_capability_proposal_queue", None) + if ( + profile_layout is not None + and artifact_store is not None + and proposal_queue is not None + ): + proposal_orchestrator = ProposalOrchestrator( + queue=proposal_queue, + artifact_store=artifact_store, + approval_gate=orchestrator, + policy=AdaptiveEvolutionPolicy( + autonomy_level=str( + getattr(settings, "evolution_autonomy_level", "generate_only") + ) + ), + ) + ctx._proposal_orchestrator = proposal_orchestrator + except (ImportError, OSError, RuntimeError, TypeError, ValueError): + logger.warning("ProposalOrchestrator setup failed", exc_info=True) _tool_registry.bind_runtime( plugin_approval_gate=orchestrator, hardware_approval_gate=orchestrator, @@ -110,10 +138,17 @@ def install_gate(self, ctx: Any, service: Any) -> None: getattr(settings, "plugin_generation_enabled", False) ), plugin_install_dir=plugin_install_dir, + plugin_staging_dir=plugin_staging_dir, marketplace_client=marketplace_client, marketplace_trusted_pubkeys=tuple( getattr(settings, "plugin_marketplace_trusted_pubkeys", ()) or () ), + proposal_orchestrator=proposal_orchestrator, + capability_lifecycle_store=getattr( + ctx, "_capability_proposal_queue", None + ), + evolution_outbox=getattr(ctx, "_evolution_outbox", None), + evolution_profile_id=str(getattr(settings, "profile", "default")), ) class _FileReadGate: diff --git a/src/leapflow/daemon/client.py b/src/leapflow/daemon/client.py index bfebee0a..4c14bf38 100644 --- a/src/leapflow/daemon/client.py +++ b/src/leapflow/daemon/client.py @@ -522,9 +522,56 @@ async def session_analyze(self) -> dict[str, Any]: """Ensure a session-analysis watch and run one analysis cycle now.""" return dict(await self.request("session.analyze") or {}) - async def evolution_run(self, reason: str = "manual") -> dict[str, Any]: - """Run the learning boundary in the daemon now.""" - return dict(await self.request("evolution.run", {"reason": reason}) or {}) + async def evolution_run( + self, + *, + session_id: str, + reason: str = "manual", + wait: bool = False, + timeout_s: float = 180.0, + ) -> dict[str, Any]: + """Finalize one named session and optionally await its teacher job.""" + return dict( + await self.request( + "evolution.run", + { + "session_id": session_id, + "reason": reason, + "wait": wait, + "timeout_s": timeout_s, + }, + ) + or {} + ) + + async def evolution_projection( + self, + *, + session_id: str, + rebuild: bool = False, + ) -> dict[str, Any]: + """Return the event projection for one explicitly named session.""" + return dict( + await self.request( + "evolution.projection", + {"session_id": session_id, "rebuild": rebuild}, + ) + or {} + ) + + async def evolution_projection_aggregate( + self, + *, + rebuild: bool = False, + ) -> dict[str, Any]: + """Return the explicitly cross-session profile projection.""" + return dict( + await self.request( + "evolution.projection.aggregate", + {"rebuild": rebuild}, + ) + or {} + ) async def signal_record(self, event_type: str, payload: dict[str, Any]) -> dict[str, Any]: """Inject a signal event into the daemon's EventBus.""" diff --git a/src/leapflow/daemon/monitor_coordinator.py b/src/leapflow/daemon/monitor_coordinator.py index c48b9c76..4f32754c 100644 --- a/src/leapflow/daemon/monitor_coordinator.py +++ b/src/leapflow/daemon/monitor_coordinator.py @@ -139,21 +139,24 @@ def _install_evolution_sink(self, ctx: Any, settings: Any) -> None: """ try: from leapflow.evolution import LedgerEvolutionSink - from leapflow.storage.evolution_trace_store import JsonEvolutionTraceStore + from leapflow.storage.evolution_event_store import EvolutionTraceEventStore from leapflow.telemetry.evolution_tap import install_sink - layout = getattr(settings, "profile_layout", None) - path = getattr(layout, "evolution_traces_path", None) - if path is None: + event_store = getattr(ctx, "_evolution_event_store", None) + if event_store is None: return + trace_store = EvolutionTraceEventStore( + event_store, + profile_id=str(getattr(settings, "profile", "default")), + ) sink = LedgerEvolutionSink( - store=JsonEvolutionTraceStore(path), + store=trace_store, publish=self._make_evolution_publisher(ctx), ) sink.register_atexit() install_sink(sink) self._evolution_sink = sink - logger.debug("daemon: evolution trace sink installed at %s", path) + logger.debug("daemon: evolution trace sink installed in evolution_events") except Exception: # noqa: BLE001 - observability is never a startup dependency logger.debug("daemon: evolution trace sink not installed", exc_info=True) diff --git a/src/leapflow/daemon/protocol.py b/src/leapflow/daemon/protocol.py index c2f0ea84..9af21726 100644 --- a/src/leapflow/daemon/protocol.py +++ b/src/leapflow/daemon/protocol.py @@ -248,13 +248,32 @@ async def session_analyze(self) -> Dict[str, Any]: """Ensure a session-analysis watch and run one analysis cycle now.""" ... - async def evolution_run(self, reason: str = "manual") -> Dict[str, Any]: - """Run the learning boundary now, the one path that drives evolution. + async def evolution_run( + self, + *, + session_id: str, + reason: str = "manual", + wait: bool = False, + timeout_s: float = 180.0, + ) -> Dict[str, Any]: + """Finalize one explicitly named session and enqueue durable teacher work.""" + ... - Exposed because the boundary was otherwise reachable only from context - cleanup -- process shutdown in daemon mode -- which made "when does the - framework evolve" unanswerable and untestable without killing the daemon. - """ + async def evolution_projection( + self, + *, + session_id: str, + rebuild: bool = False, + ) -> Dict[str, Any]: + """Return the event projection for one explicitly named session.""" + ... + + async def evolution_projection_aggregate( + self, + *, + rebuild: bool = False, + ) -> Dict[str, Any]: + """Return the explicitly cross-session profile projection.""" ... async def status(self, session_id: str = "") -> Dict[str, Any]: @@ -490,6 +509,8 @@ async def gateway_send( "session.detail": "session_detail", "session.analyze": "session_analyze", "evolution.run": "evolution_run", + "evolution.projection": "evolution_projection", + "evolution.projection.aggregate": "evolution_projection_aggregate", "daemon.status": "status", "daemon.shutdown": "shutdown", "host.status": "host_status", diff --git a/src/leapflow/daemon/service.py b/src/leapflow/daemon/service.py index 718e9371..720435ff 100644 --- a/src/leapflow/daemon/service.py +++ b/src/leapflow/daemon/service.py @@ -451,6 +451,7 @@ def __init__(self, settings: Any, *, mock_host: bool = False, auto_start_deferre self._active_engine_request_id: str = "" self._active_engines: dict[str, Any] = {} self._observation: Any | None = None + self._environment_source_manager: Any | None = None self._engine_request_ledger: dict[str, dict[str, Any]] = {} self._request_ledger_ttl_s = max(1.0, float(getattr(settings, "daemon_request_ledger_ttl_s", 600.0) or 600.0)) self._request_ledger_max_entries = max(1, int(getattr(settings, "daemon_request_ledger_max_entries", 128) or 128)) @@ -477,6 +478,7 @@ async def start(self) -> None: self._approval_coordinator.install_gate(ctx, self) install_learn_notifications(ctx, self.notification_bus) self._ctx = ctx + await self._start_environment_sources(ctx) if self._auto_start_deferred: self.start_deferred_init() # Monitor: start only when scheduler is enabled (coordinator checks internally) @@ -504,6 +506,38 @@ async def start(self) -> None: logger.debug("daemon: observation subsystem start failed", exc_info=True) self._observation = None + async def _start_environment_sources(self, ctx: Any) -> None: + """Start explicitly enabled experiment sources inside the daemon lifecycle.""" + settings = getattr(ctx, "settings", self._settings) + if str(getattr(settings, "environment_mode", "production")) != "experiment": + return + if not bool(getattr(settings, "environment_leapspace_enabled", False)): + return + state_root = str(getattr(settings, "environment_leapspace_state_root", "") or "") + session_id = str(getattr(settings, "environment_leapspace_session_id", "") or "") + if not state_root or not session_id: + logger.warning( + "LeapSpace environment source requires both state_root and session_id" + ) + return + from leapflow.layout import workspace_id_for_path + from leapflow.perception.environment_source import EnvironmentSourceManager + from leapflow.perception.leapspace_source import LeapSpaceEnvironmentSource + + manager = EnvironmentSourceManager(ctx.record_environment_observation) + manager.register( + LeapSpaceEnvironmentSource( + state_root, + workspace_id=workspace_id_for_path(self._workspace_root()), + session_id=session_id, + poll_interval_s=float( + getattr(settings, "environment_leapspace_poll_interval_s", 0.5) + ), + ) + ) + await manager.start() + self._environment_source_manager = manager + def start_deferred_init(self) -> None: """Start background non-critical initialization once.""" if self._ctx is None: @@ -517,6 +551,10 @@ async def shutdown(self) -> None: return ctx = self._ctx self._ctx = None + environment_sources = self._environment_source_manager + self._environment_source_manager = None + if environment_sources is not None: + await environment_sources.close() # Stop background deferred init first: its yield points allow cleanup # to interleave with a half-initialized context otherwise. task = self._deferred_init_task @@ -936,22 +974,81 @@ async def session_detail( async def session_analyze(self) -> dict[str, Any]: return await self._session_coordinator.analyze(self._monitors, self._ctx, self._settings) - async def evolution_run(self, reason: str = "manual") -> dict[str, Any]: - """Drive the learning boundary in the daemon's context, now. - - The daemon owns the context that holds the trajectory buffer, the world-model - teacher and the proposal queue, so this has to run here rather than in the - calling CLI process -- a second context would grade an empty buffer and - report success having done nothing. - """ + async def evolution_run( + self, + *, + session_id: str, + reason: str = "manual", + wait: bool = False, + timeout_s: float = 180.0, + ) -> dict[str, Any]: + """Finalize one explicitly named session in the daemon-owned event stream.""" ctx = self._ctx if ctx is None: return {"ok": False, "error": "daemon context unavailable"} + normalized_session_id = str(session_id or "").strip() + if not normalized_session_id: + return {"ok": False, "error": "session_id is required"} + session_registry = self._session_coordinator.registry + session_context = ( + session_registry.get(normalized_session_id) + if session_registry is not None + else None + ) + workspace_root = ( + str(session_context.workspace_root) if session_context is not None else "" + ) + if wait: + try: + await asyncio.wait_for( + ctx._ensure_deferred(), + timeout=self._DEFERRED_WAIT_TIMEOUT_S, + ) + except asyncio.TimeoutError: + logger.info("Deferred init still running; teacher job will remain queued") try: - return await ctx.run_learning_boundary(reason=str(reason or "manual")) + return await ctx.run_learning_boundary( + reason=str(reason or "manual"), + session_id=normalized_session_id, + workspace_root=workspace_root, + wait=bool(wait), + timeout_s=min(max(0.1, float(timeout_s)), 600.0), + ) except Exception as exc: # noqa: BLE001 - reported to the caller, never fatal logger.warning("daemon: learning boundary failed: %s", exc, exc_info=True) - return {"ok": False, "error": str(exc), "reason": str(reason or "manual")} + return { + "ok": False, + "error": str(exc), + "reason": str(reason or "manual"), + "session_id": normalized_session_id, + } + + async def evolution_projection( + self, + *, + session_id: str, + rebuild: bool = False, + ) -> dict[str, Any]: + ctx = self._ctx + if ctx is None: + return {"ok": False, "error": "daemon context unavailable"} + normalized_session_id = str(session_id or "").strip() + if not normalized_session_id: + return {"ok": False, "error": "session_id is required"} + return await ctx.evolution_projection( + session_id=normalized_session_id, + rebuild=bool(rebuild), + ) + + async def evolution_projection_aggregate( + self, + *, + rebuild: bool = False, + ) -> dict[str, Any]: + ctx = self._ctx + if ctx is None: + return {"ok": False, "error": "daemon context unavailable"} + return await ctx.evolution_projection(aggregate=True, rebuild=bool(rebuild)) def _ensure_session_registry(self, base_engine: Any) -> Any: return self._session_coordinator.ensure_registry(base_engine, self._settings) @@ -1412,7 +1509,7 @@ async def hardware_write_request( from leapflow.plugins import get_registry as _get_tool_registry - handler = dict(_get_tool_registry().tool_handlers).get(tool_name) + handler = _get_tool_registry().snapshot_handlers().get(tool_name) if handler is None: return { "ok": False, "code": "tool_unavailable", "device": device, "channel": channel, @@ -1610,6 +1707,15 @@ async def status(self, session_id: str = "") -> dict[str, Any]: "deferred_init": self._deferred_init_status(ctx), "watch_summary": await self._monitor_coordinator.get_summary(), "host_backend": host, + "environment_sources": { + "active": list(self._environment_source_manager.source_ids) + if self._environment_source_manager is not None + else [], + "dropped": self._environment_source_manager.dropped_count + if self._environment_source_manager is not None + else 0, + }, + "evolution_performance": self._evolution_performance_status(ctx), # Whether *this* daemon process still matches the source tree on # disk (None when outside a git checkout, e.g. a packaged install). "build": {**self._build_info.to_dict(), "stale": build_stale}, @@ -1622,6 +1728,27 @@ def _workspace_root(self) -> Path: settings = getattr(ctx, "settings", self._settings) if ctx is not None else self._settings return Path(str(getattr(settings, "workspace_root", os.getcwd()))).expanduser().resolve() + @staticmethod + def _evolution_performance_status(ctx: Any) -> dict[str, Any]: + """Expose bounded p50/p95/p99 snapshots without adding hot-path I/O.""" + from dataclasses import asdict, is_dataclass + + from leapflow.plugins import get_registry + + result: dict[str, Any] = {} + components = { + "action_recorder": getattr(ctx, "_action_recorder", None), + "outbox": getattr(ctx, "_evolution_outbox", None), + "projection": getattr(ctx, "_evolution_projection_runner", None), + "teacher": getattr(ctx, "_teacher_worker", None), + } + for name, component in components.items(): + metrics = getattr(component, "metrics", None) + if metrics is not None: + result[name] = asdict(metrics) if is_dataclass(metrics) else metrics + result["registry_snapshot"] = get_registry().snapshot_latency.to_dict() + return result + def _turn_admission_status(self, *, queued_delta: int = 0) -> dict[str, Any]: snapshot = dict(self._turn_admission.snapshot()) if queued_delta: diff --git a/src/leapflow/dashboard/intent.py b/src/leapflow/dashboard/intent.py index 43e9c0ef..65b3af7f 100644 --- a/src/leapflow/dashboard/intent.py +++ b/src/leapflow/dashboard/intent.py @@ -2,8 +2,8 @@ """DashboardIntent: the single normalized request behind ``/board`` and the tool. The **template** is the primary view dimension (a rendering lens). Most templates -analyze the current session and need nothing else; a per-device view needs to know -*which* device, so the intent also carries an optional target. +analyze the current session and need nothing else; device and evolution views carry +an explicit target so they never infer another client's state. ``device``/``channel`` are explicit fields rather than a generic params bag. The board's request surface is small and worth keeping legible, and a typed field is what @@ -24,11 +24,12 @@ @dataclass(frozen=True) class DashboardIntent: - """A normalized dashboard request: which lens, and optionally which target.""" + """A normalized dashboard request with explicit device or session scope.""" template: str = "" device: str = "" channel: str = "" + session_id: str = "" def to_dict(self) -> dict[str, Any]: """Return the wire form, omitting an absent target. @@ -42,6 +43,8 @@ def to_dict(self) -> dict[str, Any]: payload["device"] = self.device if self.channel: payload["channel"] = self.channel + if self.session_id: + payload["session_id"] = self.session_id return payload @classmethod @@ -52,6 +55,7 @@ def from_params(cls, data: Mapping[str, Any]) -> "DashboardIntent": template=str(data.get("template", "") or "").strip(), device=str(data.get("device", "") or "").strip(), channel=str(data.get("channel", "") or "").strip(), + session_id=str(data.get("session_id", data.get("session", "")) or "").strip(), ) @classmethod @@ -67,10 +71,13 @@ def from_args(cls, args: str) -> "DashboardIntent": except ValueError: tokens = tuple((args or "").split()) parts = [token.strip() for token in tokens if token.strip()] + template = parts[0] if parts else "" + is_evolution = template in {"evolution", "evolution_live", "causal_trace"} return cls( - template=parts[0] if parts else "", - device=parts[1] if len(parts) > 1 else "", - channel=parts[2] if len(parts) > 2 else "", + template=template, + device=parts[1] if len(parts) > 1 and not is_evolution else "", + channel=parts[2] if len(parts) > 2 and not is_evolution else "", + session_id=parts[1] if len(parts) > 1 and is_evolution else "", ) diff --git a/src/leapflow/dashboard/server.py b/src/leapflow/dashboard/server.py index b5d183f4..29cc2790 100644 --- a/src/leapflow/dashboard/server.py +++ b/src/leapflow/dashboard/server.py @@ -273,6 +273,7 @@ async def _handle_view(self, request: Any) -> Any: "template": request.query.get("template", ""), "device": request.query.get("device", ""), "channel": request.query.get("channel", ""), + "session_id": request.query.get("session_id", request.query.get("session", "")), }) request_id = uuid.uuid4().hex try: diff --git a/src/leapflow/dashboard/service.py b/src/leapflow/dashboard/service.py index c0e20000..0d94f5d9 100644 --- a/src/leapflow/dashboard/service.py +++ b/src/leapflow/dashboard/service.py @@ -36,6 +36,14 @@ async def signal_metrics(self) -> dict[str, Any]: """Return signal flow health metrics.""" ... + async def evolution_projection(self, *, session_id: str) -> dict[str, Any]: + """Return one session-scoped evolution projection.""" + ... + + async def evolution_projection_aggregate(self) -> dict[str, Any]: + """Return the explicitly cross-session evolution projection.""" + ... + async def hardware_inventory(self) -> dict[str, Any]: """Return the admitted device fleet grouped by declared class.""" ... @@ -67,6 +75,12 @@ async def signal_metrics(self) -> dict[str, Any]: } return {"metrics": {}, "signal_stream": []} + async def evolution_projection(self, *, session_id: str) -> dict[str, Any]: + return dict(await self._client.evolution_projection(session_id=session_id) or {}) + + async def evolution_projection_aggregate(self) -> dict[str, Any]: + return dict(await self._client.evolution_projection_aggregate() or {}) + async def hardware_inventory(self) -> dict[str, Any]: """Return the device fleet, tolerating a daemon without the RPC. @@ -518,7 +532,12 @@ async def build(self, intent: DashboardIntent, provider: DashboardDataProvider) return await self._build_device(template_name, intent, provider) payload_domain = _PAYLOAD_DOMAINS.get(template_name) if payload_domain is not None: - return await self._build_from_finding_payload(template_name, provider, *payload_domain) + return await self._build_from_finding_payload( + template_name, + provider, + *payload_domain, + session_id=intent.session_id, + ) return await self._build_session(intent.template, provider) async def _build_device( @@ -641,6 +660,8 @@ async def _build_from_finding_payload( provider: DashboardDataProvider, finding_domain: str, data_key: str, + *, + session_id: str = "", ) -> dict[str, Any]: """Render a template from the newest finding of one producer domain. @@ -650,6 +671,16 @@ async def _build_from_finding_payload( """ watch, domain_findings = await self._domain_watch_payload(provider, finding_domain) payload = dict(domain_findings[0].get("payload") or {}) if domain_findings else {} + event_projection: dict[str, Any] = {} + if finding_domain == "framework_evolution": + event_projection = await self._event_projection(provider, session_id=session_id) + if event_projection: + previous_summary = dict(payload.get("summary") or {}) + payload.update(event_projection) + payload["summary"] = { + **previous_summary, + **dict(event_projection.get("summary") or {}), + } data = { "title": template.replace("_", " ").title(), data_key: payload, @@ -690,7 +721,34 @@ async def _build_from_finding_payload( notice = _hardware_notice(inventory, payload) if notice is not None: data["notice"] = notice - return self._render(template, data) + rendered = self._render(template, data) + if event_projection: + rendered.setdefault("meta", {})["evolution_projection"] = { + "scope": event_projection.get("scope", "aggregate"), + "session_id": event_projection.get("session_id", ""), + "last_sequence": event_projection.get("last_sequence", 0), + } + return rendered + + @staticmethod + async def _event_projection( + provider: DashboardDataProvider, + *, + session_id: str, + ) -> dict[str, Any]: + """Read the canonical event projection, degrading for older daemons.""" + try: + if session_id: + result = await provider.evolution_projection(session_id=session_id) + else: + result = await provider.evolution_projection_aggregate() + except (AttributeError, RuntimeError, TypeError): + logger.debug("dashboard: evolution projection unavailable", exc_info=True) + return {} + if not result.get("ok"): + return {} + projection = result.get("projection") + return dict(projection) if isinstance(projection, dict) else {} async def _build_session(self, template: str, provider: DashboardDataProvider) -> dict[str, Any]: # The session watch emits an insight finding whose payload carries the diff --git a/src/leapflow/domain/__init__.py b/src/leapflow/domain/__init__.py index 062d08e7..29f09618 100644 --- a/src/leapflow/domain/__init__.py +++ b/src/leapflow/domain/__init__.py @@ -9,6 +9,7 @@ from leapflow.domain.effect_scope import EffectScope, ScopeState from leapflow.domain.event_types import ( CLIEventType, + EvolutionEventType, ImplicitFeedbackType, LearningEventType, NormalizedEventType, @@ -16,7 +17,18 @@ UNDO_SHORTCUTS, ) from leapflow.domain.environment_fingerprint import EnvironmentFingerprint +from leapflow.domain.environment_signal import ( + EnvironmentObservation, + InterfaceElement, + InterfaceSnapshot, +) from leapflow.domain.events import SystemEvent, UIElement, UISnapshot +from leapflow.domain.evolution_event import ( + EvolutionContext, + EvolutionEvent, + EvolutionEventRecord, + EvolutionEventStore, +) from leapflow.domain.evolution_intent import ( WORLD_MODEL_INTENT, WORLD_MODEL_ORIGIN, @@ -53,6 +65,11 @@ "CLIEventType", "CapabilityRequirement", "EffectScope", + "EvolutionContext", + "EvolutionEvent", + "EvolutionEventRecord", + "EvolutionEventStore", + "EvolutionEventType", "EvolutionIntent", "FiberState", "GapEvidence", @@ -65,6 +82,9 @@ "DEFAULT_DARWIN_CAPABILITIES", "DistillationCandidate", "EnvironmentFingerprint", + "EnvironmentObservation", + "InterfaceElement", + "InterfaceSnapshot", "Episode", "IllegalStateTransition", "NoiseSignal", diff --git a/src/leapflow/domain/adaptation_verdict.py b/src/leapflow/domain/adaptation_verdict.py index 58f4aec3..52d86403 100644 --- a/src/leapflow/domain/adaptation_verdict.py +++ b/src/leapflow/domain/adaptation_verdict.py @@ -192,6 +192,8 @@ def to_dict(self) -> dict[str, Any]: "max_risk_level": str(self.max_risk_level), "expected_effect": self.expected_effect, "target_affordance": self.target_affordance, + "evidence_ids": list(self.evidence_ids), + "created_at": self.created_at, } diff --git a/src/leapflow/domain/environment_signal.py b/src/leapflow/domain/environment_signal.py new file mode 100644 index 00000000..9ab42c8d --- /dev/null +++ b/src/leapflow/domain/environment_signal.py @@ -0,0 +1,322 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Typed task-environment snapshots and structural deltas.""" +from __future__ import annotations + +import time +from dataclasses import asdict, dataclass +from typing import Any, Literal, Mapping + +from leapflow.domain.evolution_event import content_hash + +EnvironmentObservationKind = Literal["snapshot", "delta", "outcome"] +EnvironmentOutcome = Literal["PASS", "FAIL", "UNKNOWN"] + + +@dataclass(frozen=True, order=True) +class InterfaceElement: + """Stable, value-free description of one application affordance.""" + + name: str + role: str = "widget" + enabled: bool = True + + @classmethod + def from_mapping(cls, value: Mapping[str, Any]) -> "InterfaceElement": + return cls( + name=str(value.get("name") or value.get("label") or ""), + role=str(value.get("role") or "widget"), + enabled=bool(value.get("enabled", True)), + ) + + +@dataclass(frozen=True) +class InterfaceSnapshot: + """Immutable structural view of one task application.""" + + source_id: str + app_id: str + workspace_id: str = "" + session_id: str = "" + version: str = "" + affordances: tuple[str, ...] = () + elements: tuple[InterfaceElement, ...] = () + data_hash: str = "" + observed_at: float = 0.0 + provenance: tuple[tuple[str, str], ...] = () + + @classmethod + def create( + cls, + *, + source_id: str, + app_id: str, + workspace_id: str = "", + session_id: str = "", + version: str = "", + affordances: Any = (), + elements: Any = (), + data: Any = None, + observed_at: float | None = None, + provenance: Mapping[str, Any] | None = None, + ) -> "InterfaceSnapshot": + normalized_elements = tuple( + sorted( + ( + item + if isinstance(item, InterfaceElement) + else InterfaceElement.from_mapping(item) + ) + for item in (elements or ()) + if isinstance(item, (InterfaceElement, Mapping)) + ) + ) + return cls( + source_id=str(source_id), + app_id=str(app_id), + workspace_id=str(workspace_id), + session_id=str(session_id), + version=str(version or ""), + affordances=tuple(sorted({str(item) for item in (affordances or ()) if str(item)})), + elements=normalized_elements, + data_hash=content_hash(data or {}), + observed_at=time.time() if observed_at is None else float(observed_at), + provenance=tuple( + sorted((str(key), str(value)) for key, value in (provenance or {}).items()) + ), + ) + + @property + def snapshot_id(self) -> str: + return "env-" + content_hash( + { + "source_id": self.source_id, + "app_id": self.app_id, + "workspace_id": self.workspace_id, + "session_id": self.session_id, + "version": self.version, + "affordances": self.affordances, + "elements": [asdict(item) for item in self.elements], + "provenance": self.provenance, + } + )[:32] + + def to_dict(self) -> dict[str, Any]: + return { + "snapshot_id": self.snapshot_id, + "source_id": self.source_id, + "app_id": self.app_id, + "workspace_id": self.workspace_id, + "session_id": self.session_id, + "version": self.version, + "affordances": list(self.affordances), + "elements": [asdict(item) for item in self.elements], + "data_hash": self.data_hash, + "observed_at": self.observed_at, + "provenance": dict(self.provenance), + } + + +@dataclass(frozen=True) +class EnvironmentObservation: + """A snapshot, structural delta, or ground-truth task outcome.""" + + observation_id: str + source_id: str + kind: EnvironmentObservationKind + app_id: str = "" + workspace_id: str = "" + session_id: str = "" + before_snapshot_id: str = "" + after_snapshot_id: str = "" + version_before: str = "" + version_after: str = "" + added_affordances: tuple[str, ...] = () + removed_affordances: tuple[str, ...] = () + added_elements: tuple[InterfaceElement, ...] = () + removed_elements: tuple[InterfaceElement, ...] = () + changed_elements: tuple[InterfaceElement, ...] = () + outcome: EnvironmentOutcome = "UNKNOWN" + capability: str = "" + observed_at: float = 0.0 + provenance: tuple[tuple[str, str], ...] = () + + @classmethod + def snapshot(cls, snapshot: InterfaceSnapshot) -> "EnvironmentObservation": + identity = {"kind": "snapshot", "snapshot_id": snapshot.snapshot_id} + return cls( + observation_id="obs-" + content_hash(identity)[:32], + source_id=snapshot.source_id, + kind="snapshot", + app_id=snapshot.app_id, + workspace_id=snapshot.workspace_id, + session_id=snapshot.session_id, + after_snapshot_id=snapshot.snapshot_id, + version_after=snapshot.version, + added_affordances=snapshot.affordances, + added_elements=snapshot.elements, + observed_at=snapshot.observed_at, + provenance=snapshot.provenance, + ) + + @classmethod + def between( + cls, + before: InterfaceSnapshot, + after: InterfaceSnapshot, + ) -> "EnvironmentObservation | None": + if before.source_id != after.source_id or before.app_id != after.app_id: + raise ValueError("environment snapshots must describe the same source and app") + before_elements = {(item.name, item.role): item for item in before.elements} + after_elements = {(item.name, item.role): item for item in after.elements} + added_keys = after_elements.keys() - before_elements.keys() + removed_keys = before_elements.keys() - after_elements.keys() + changed = tuple( + after_elements[key] + for key in sorted(before_elements.keys() & after_elements.keys()) + if before_elements[key].enabled != after_elements[key].enabled + ) + added_affordances = tuple(sorted(set(after.affordances) - set(before.affordances))) + removed_affordances = tuple(sorted(set(before.affordances) - set(after.affordances))) + added_elements = tuple(after_elements[key] for key in sorted(added_keys)) + removed_elements = tuple(before_elements[key] for key in sorted(removed_keys)) + if not any( + ( + before.version != after.version, + added_affordances, + removed_affordances, + added_elements, + removed_elements, + changed, + ) + ): + return None + identity = { + "kind": "delta", + "before": before.snapshot_id, + "after": after.snapshot_id, + } + return cls( + observation_id="obs-" + content_hash(identity)[:32], + source_id=after.source_id, + kind="delta", + app_id=after.app_id, + workspace_id=after.workspace_id, + session_id=after.session_id, + before_snapshot_id=before.snapshot_id, + after_snapshot_id=after.snapshot_id, + version_before=before.version, + version_after=after.version, + added_affordances=added_affordances, + removed_affordances=removed_affordances, + added_elements=added_elements, + removed_elements=removed_elements, + changed_elements=changed, + observed_at=after.observed_at, + provenance=after.provenance, + ) + + @classmethod + def task_outcome( + cls, + *, + source_id: str, + task_id: str, + outcome: str, + capability: str = "", + workspace_id: str = "", + session_id: str = "", + observed_at: float | None = None, + provenance: Mapping[str, Any] | None = None, + ) -> "EnvironmentObservation": + normalized = str(outcome or "UNKNOWN").upper() + if normalized not in {"PASS", "FAIL", "UNKNOWN"}: + normalized = "UNKNOWN" + identity = { + "kind": "outcome", + "source_id": source_id, + "task_id": task_id, + "outcome": normalized, + "capability": capability, + "provenance": dict(provenance or {}), + } + return cls( + observation_id="obs-" + content_hash(identity)[:32], + source_id=str(source_id), + kind="outcome", + app_id=str(task_id), + workspace_id=str(workspace_id), + session_id=str(session_id), + outcome=normalized, # type: ignore[arg-type] + capability=str(capability), + observed_at=time.time() if observed_at is None else float(observed_at), + provenance=tuple( + sorted((str(key), str(value)) for key, value in (provenance or {}).items()) + ), + ) + + @property + def is_structural(self) -> bool: + return bool( + self.version_before != self.version_after + or self.added_affordances + or self.removed_affordances + or self.added_elements + or self.removed_elements + or self.changed_elements + ) + + def capability_results(self) -> tuple[dict[str, Any], ...]: + """Return only explicitly named capability evidence; never infer from labels.""" + results = [ + { + "ok": False, + "error_type": "affordance_removed", + "capability": capability, + "observation_id": self.observation_id, + "app_id": self.app_id, + } + for capability in self.removed_affordances + ] + if self.kind == "outcome" and self.outcome == "FAIL" and self.capability: + results.append( + { + "ok": False, + "error_type": "task_outcome_failed", + "capability": self.capability, + "observation_id": self.observation_id, + "task_id": self.app_id, + } + ) + return tuple(results) + + def to_dict(self) -> dict[str, Any]: + return { + "observation_id": self.observation_id, + "source_id": self.source_id, + "kind": self.kind, + "app_id": self.app_id, + "workspace_id": self.workspace_id, + "session_id": self.session_id, + "before_snapshot_id": self.before_snapshot_id, + "after_snapshot_id": self.after_snapshot_id, + "version_before": self.version_before, + "version_after": self.version_after, + "added_affordances": list(self.added_affordances), + "removed_affordances": list(self.removed_affordances), + "added_elements": [asdict(item) for item in self.added_elements], + "removed_elements": [asdict(item) for item in self.removed_elements], + "changed_elements": [asdict(item) for item in self.changed_elements], + "outcome": self.outcome, + "capability": self.capability, + "observed_at": self.observed_at, + "provenance": dict(self.provenance), + } + + +__all__ = [ + "EnvironmentObservation", + "EnvironmentObservationKind", + "EnvironmentOutcome", + "InterfaceElement", + "InterfaceSnapshot", +] diff --git a/src/leapflow/domain/event_types.py b/src/leapflow/domain/event_types.py index fc8ec299..3a3f4669 100644 --- a/src/leapflow/domain/event_types.py +++ b/src/leapflow/domain/event_types.py @@ -76,6 +76,39 @@ class LearningEventType: COLD_START_PROMPT = "learning.cold_start_prompt" +class EvolutionEventType: + """Append-only facts emitted by the governed evolution pipeline.""" + + ACTION_STARTED = "action.started" + ACTION_COMPLETED = "action.completed" + ACTION_FAILED = "action.failed" + SESSION_FINALIZED = "session.finalized" + TEACHER_JOB_QUEUED = "teacher.job_queued" + TEACHER_JOB_FAILED = "teacher.job_failed" + TEACHER_GRADED = "teacher.graded" + TEACHER_VERDICT_RECORDED = "teacher.verdict_recorded" + KNOWLEDGE_RETRACTED = "knowledge.retracted" + ENVIRONMENT_OBSERVED = "environment.observed" + REQUIREMENT_RESOLVED = "requirement.resolved" + PROPOSAL_CREATED = "proposal.created" + PROPOSAL_UPDATED = "proposal.updated" + PROPOSAL_GENERATED = "proposal.generated" + PROPOSAL_APPROVED = "proposal.approved" + PROPOSAL_REJECTED = "proposal.rejected" + PROPOSAL_FAILED = "proposal.failed" + PROPOSAL_SUPERSEDED = "proposal.superseded" + PROPOSAL_EXPIRED = "proposal.expired" + PROPOSAL_NO_OP = "proposal.no_op" + PLUGIN_INSTALLED = "plugin.installed" + PLUGIN_PROBATION_STARTED = "plugin.probation_started" + PLUGIN_VERIFIED = "plugin.verified" + PLUGIN_QUARANTINED = "plugin.quarantined" + PLUGIN_ROLLED_BACK = "plugin.rolled_back" + FRAMEWORK_TRACE_RECORDED = "framework.trace_recorded" + PLUGIN_OUTCOME_RECORDED = "plugin.outcome_recorded" + CALIBRATION_UPDATED = "calibration.updated" + + class CLIEventType: """Synthetic events from CLI interaction layer.""" diff --git a/src/leapflow/domain/evolution_event.py b/src/leapflow/domain/evolution_event.py new file mode 100644 index 00000000..25151ac6 --- /dev/null +++ b/src/leapflow/domain/evolution_event.py @@ -0,0 +1,351 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Immutable causal events for the long-running self-evolution pipeline. + +The event log is the one durable vocabulary shared by execution, perception, +teaching, governance, and presentation. Facts are appended; state is projected. +No consumer is allowed to infer missing stages as success. +""" +from __future__ import annotations + +import hashlib +import json +import math +import time +import uuid +from dataclasses import dataclass, field, replace +from enum import Enum +from pathlib import Path +from types import MappingProxyType +from typing import Any, Mapping, Protocol, Sequence, runtime_checkable + +SCHEMA_VERSION = 1 + + +class ActionEvidenceUnavailable(RuntimeError): + """A mutating action cannot cross its durable evidence barrier.""" + + +def _normalize_json(value: Any) -> Any: + """Return a deterministic JSON-compatible copy or reject ambiguous values.""" + if value is None or isinstance(value, (bool, int, str)): + return value + if isinstance(value, float): + if not math.isfinite(value): + raise ValueError("evolution event JSON cannot contain NaN or infinity") + return value + if isinstance(value, Enum): + return _normalize_json(value.value) + if isinstance(value, Path): + return str(value) + if isinstance(value, Mapping): + normalized: dict[str, Any] = {} + for key, item in value.items(): + name = str(key) + if name in normalized: + raise ValueError(f"duplicate JSON key after string conversion: {name!r}") + normalized[name] = _normalize_json(item) + return normalized + if isinstance(value, (list, tuple)): + return [_normalize_json(item) for item in value] + if isinstance(value, (set, frozenset)): + items = [_normalize_json(item) for item in value] + return sorted(items, key=lambda item: json.dumps(item, ensure_ascii=False, sort_keys=True)) + raise TypeError(f"unsupported evolution event JSON value: {type(value).__name__}") + + +def _freeze_json(value: Any) -> Any: + if isinstance(value, dict): + return MappingProxyType({key: _freeze_json(item) for key, item in value.items()}) + if isinstance(value, list): + return tuple(_freeze_json(item) for item in value) + return value + + +def _thaw_json(value: Any) -> Any: + if isinstance(value, Mapping): + return {str(key): _thaw_json(item) for key, item in value.items()} + if isinstance(value, tuple): + return [_thaw_json(item) for item in value] + return value + + +def canonical_json(value: Any) -> str: + """Return strict deterministic JSON used for hashes and deduplication.""" + return json.dumps( + _normalize_json(value if value is not None else {}), + ensure_ascii=False, + sort_keys=True, + separators=(",", ":"), + allow_nan=False, + ) + + +def content_hash(value: Any) -> str: + """Return a SHA-256 digest for deterministic JSON-compatible content.""" + return hashlib.sha256(canonical_json(value).encode("utf-8")).hexdigest() + + +@dataclass(frozen=True) +class EvolutionContext: + """Causal identity carried across the complete evolution lifecycle. + + Empty values are explicit unknowns, never permission to join records by guess. + ``correlation_id`` identifies one evolution episode and ``causation_id`` points + to the direct predecessor event. + """ + + profile_id: str = "" + workspace_id: str = "" + session_id: str = "" + session_generation: int = 0 + turn_id: str = "" + frame_id: str = "" + action_id: str = "" + observation_id: str = "" + requirement_id: str = "" + decision_id: str = "" + proposal_id: str = "" + artifact_id: str = "" + plugin_id: str = "" + version_id: str = "" + correlation_id: str = "" + causation_id: str = "" + + def __post_init__(self) -> None: + if int(self.session_generation) < 0: + raise ValueError("session_generation must be non-negative") + object.__setattr__(self, "session_generation", int(self.session_generation)) + for name in self.__dataclass_fields__: + if name != "session_generation": + object.__setattr__(self, name, str(getattr(self, name) or "")) + + @classmethod + def create(cls, **values: Any) -> "EvolutionContext": + """Create a context, minting one episode correlation id when absent.""" + normalized = { + name: (int(value) if name == "session_generation" else str(value or "")) + for name, value in values.items() + if name in cls.__dataclass_fields__ + } + if not normalized.get("correlation_id"): + normalized["correlation_id"] = f"evo-{uuid.uuid4().hex}" + return cls(**normalized) + + @classmethod + def from_mapping(cls, value: Mapping[str, Any] | None) -> "EvolutionContext": + """Build from a mapping while ignoring unknown future fields.""" + raw = dict(value or {}) + return cls( + **{ + name: ( + int(raw.get(name) or 0) + if name == "session_generation" + else str(raw.get(name) or "") + ) + for name in cls.__dataclass_fields__ + } + ) + + def with_ids(self, **values: Any) -> "EvolutionContext": + """Return a copy with selected identifiers updated.""" + allowed = { + key: (int(value) if key == "session_generation" else str(value or "")) + for key, value in values.items() + if key in self.__dataclass_fields__ + } + return replace(self, **allowed) + + def to_dict(self) -> dict[str, Any]: + return { + name: getattr(self, name) + for name in self.__dataclass_fields__ + } + + +@dataclass(frozen=True) +class EvolutionEvent: + """One append-only fact in the evolution event stream.""" + + event_id: str + event_type: str + context: EvolutionContext + payload: Mapping[str, Any] = field(default_factory=dict) + occurred_at: float = 0.0 + producer: str = "" + producer_version: str = "" + privacy_class: str = "system" + schema_version: int = SCHEMA_VERSION + dedup_key: str = "" + payload_hash: str = "" + + def __post_init__(self) -> None: + if not self.event_id: + raise ValueError("event_id is required") + if not self.event_type: + raise ValueError("event_type is required") + if not self.producer: + raise ValueError("producer is required") + if not self.dedup_key: + raise ValueError("dedup_key is required") + if self.schema_version <= 0: + raise ValueError("schema_version must be positive") + if not math.isfinite(float(self.occurred_at)): + raise ValueError("occurred_at must be finite") + normalized = _normalize_json(dict(self.payload)) + digest = content_hash(normalized) + if self.payload_hash and self.payload_hash != digest: + raise ValueError("payload_hash does not match the event payload") + object.__setattr__(self, "payload", _freeze_json(normalized)) + object.__setattr__(self, "payload_hash", digest) + object.__setattr__(self, "occurred_at", float(self.occurred_at)) + + @classmethod + def create( + cls, + event_type: str, + *, + context: EvolutionContext, + payload: Mapping[str, Any] | None = None, + producer: str, + producer_version: str = "", + privacy_class: str = "system", + occurred_at: float | None = None, + dedup_key: str = "", + event_id: str = "", + ) -> "EvolutionEvent": + """Create an event with stable payload hash and idempotency identity.""" + normalized_payload = dict(payload or {}) + payload_digest = content_hash(normalized_payload) + identity = dedup_key or content_hash( + { + "event_type": str(event_type), + "context": context.to_dict(), + "payload_hash": payload_digest, + "producer": str(producer), + } + ) + return cls( + event_id=str(event_id or f"evt-{uuid.uuid4().hex}"), + event_type=str(event_type), + context=context, + payload=normalized_payload, + occurred_at=float(occurred_at if occurred_at is not None else time.time()), + producer=str(producer), + producer_version=str(producer_version), + privacy_class=str(privacy_class or "system"), + dedup_key=identity, + payload_hash=payload_digest, + ) + + def to_dict(self) -> dict[str, Any]: + return { + "event_id": self.event_id, + "event_type": self.event_type, + "context": self.context.to_dict(), + "payload": _thaw_json(self.payload), + "occurred_at": self.occurred_at, + "producer": self.producer, + "producer_version": self.producer_version, + "privacy_class": self.privacy_class, + "schema_version": self.schema_version, + "dedup_key": self.dedup_key, + "payload_hash": self.payload_hash, + } + + @classmethod + def from_dict(cls, value: Mapping[str, Any]) -> "EvolutionEvent": + return cls( + event_id=str(value.get("event_id") or ""), + event_type=str(value.get("event_type") or ""), + context=EvolutionContext.from_mapping(value.get("context")), + payload=_normalize_json(value.get("payload") or {}), + occurred_at=float(value.get("occurred_at") or 0.0), + producer=str(value.get("producer") or ""), + producer_version=str(value.get("producer_version") or ""), + privacy_class=str(value.get("privacy_class") or "system"), + schema_version=int(value.get("schema_version") or SCHEMA_VERSION), + dedup_key=str(value.get("dedup_key") or ""), + payload_hash=str(value.get("payload_hash") or ""), + ) + + +@dataclass(frozen=True) +class EvolutionEventRecord: + """One persisted event paired with its monotonic stream cursor.""" + + sequence: int + event: EvolutionEvent + + def __post_init__(self) -> None: + if self.sequence <= 0: + raise ValueError("event sequence must be positive") + + +@runtime_checkable +class EvolutionEventStore(Protocol): + """Storage boundary for the append-only evolution fact stream.""" + + def append(self, event: EvolutionEvent) -> bool: ... + + def append_many(self, events: Sequence[EvolutionEvent]) -> int: ... + + def read( + self, + *, + profile_id: str = "", + session_id: str = "", + session_generation: int | None = None, + correlation_id: str = "", + proposal_id: str = "", + proposal_events_only: bool = False, + event_type: str = "", + after_sequence: int = 0, + through_sequence: int = 0, + limit: int = 500, + ) -> list[EvolutionEventRecord]: ... + + def latest_sequence(self, *, profile_id: str = "", session_id: str = "") -> int: ... + + def latest_evidence_sequence( + self, + *, + profile_id: str, + session_id: str, + session_generation: int | None = None, + ) -> int: ... + + def evidence_sessions(self, *, profile_id: str = "") -> list[dict[str, Any]]: ... + + def last_finalized_sequence( + self, + *, + profile_id: str, + session_id: str, + session_generation: int | None = None, + ) -> int: ... + + def finalize_session( + self, + *, + profile_id: str, + workspace_id: str, + session_id: str, + session_generation: int, + from_sequence: int, + through_sequence: int, + reason: str, + goal: str = "", + model: str = "", + ) -> tuple[str, str]: ... + + +__all__ = [ + "SCHEMA_VERSION", + "ActionEvidenceUnavailable", + "EvolutionContext", + "EvolutionEvent", + "EvolutionEventRecord", + "EvolutionEventStore", + "canonical_json", + "content_hash", +] diff --git a/src/leapflow/domain/plugin_fiber.py b/src/leapflow/domain/plugin_fiber.py index 6b92bad9..98d3d16e 100644 --- a/src/leapflow/domain/plugin_fiber.py +++ b/src/leapflow/domain/plugin_fiber.py @@ -2,18 +2,20 @@ """Plugin lifecycle state machine (PluginFiber). Manages the runtime lifecycle of a single plugin instance through a -six-state finite automaton with generation tracking: +seven-state finite automaton with generation tracking: - PENDING → LOADING → ACTIVE → UNLOADING → DISPOSED + PENDING → DRAFT → ACTIVE → UNLOADING → DISPOSED + PENDING → LOADING → ACTIVE LOADING → FAILED → LOADING (retry) - PENDING → ACTIVE (fast path for plugins with no async init) - PENDING/LOADING/FAILED → DISPOSED (early cleanup) + PENDING → ACTIVE (fast path for trusted built-ins) + PENDING/DRAFT/LOADING/FAILED → DISPOSED (early cleanup) Each fiber owns an EffectScope; dispose() always cascades scope cleanup. Generation counter provides identity across reload cycles. States: PENDING — created, awaiting activation or async init + DRAFT — isolated and testable, not published to the live registry LOADING — async initialization in progress (dependency resolution) ACTIVE — fully operational, tools available FAILED — initialization failed, retryable via retry()/begin_loading() @@ -47,6 +49,7 @@ def _next_generation() -> int: class FiberState(enum.Enum): """Plugin fiber lifecycle states.""" PENDING = "pending" + DRAFT = "draft" LOADING = "loading" ACTIVE = "active" FAILED = "failed" @@ -59,7 +62,13 @@ class IllegalStateTransition(RuntimeError): _VALID_TRANSITIONS: dict[FiberState, set[FiberState]] = { - FiberState.PENDING: {FiberState.ACTIVE, FiberState.LOADING, FiberState.DISPOSED}, + FiberState.PENDING: { + FiberState.DRAFT, + FiberState.ACTIVE, + FiberState.LOADING, + FiberState.DISPOSED, + }, + FiberState.DRAFT: {FiberState.ACTIVE, FiberState.DISPOSED}, FiberState.LOADING: {FiberState.ACTIVE, FiberState.FAILED, FiberState.DISPOSED}, FiberState.ACTIVE: {FiberState.UNLOADING}, FiberState.FAILED: {FiberState.LOADING, FiberState.DISPOSED}, @@ -112,8 +121,12 @@ def error(self) -> Optional[Exception]: """The stored error from a failed loading attempt, if any.""" return self._error + def mark_draft(self) -> None: + """Transition a newly created fiber into isolated validation.""" + self._transition(FiberState.DRAFT) + def activate(self) -> None: - """Transition from PENDING or LOADING to ACTIVE.""" + """Transition from PENDING, DRAFT, or LOADING to ACTIVE.""" self._transition(FiberState.ACTIVE) def begin_loading(self) -> None: diff --git a/src/leapflow/domain/plugin_proposal.py b/src/leapflow/domain/plugin_proposal.py index 3f797795..f6d8cc26 100644 --- a/src/leapflow/domain/plugin_proposal.py +++ b/src/leapflow/domain/plugin_proposal.py @@ -11,7 +11,7 @@ import time import uuid from dataclasses import dataclass, field -from typing import Any, Literal +from typing import Any, Literal, Mapping GapType = Literal["tool_plugin", "gateway_adapter", "signal_source", "llm_provider", "unknown"] ProposalStatus = Literal["draft", "review", "approved", "rejected"] @@ -171,3 +171,49 @@ def to_dict(self) -> dict[str, Any]: "proposed_tools": [item.to_dict() for item in self.proposed_tools], "test_cases": [item.to_dict() for item in self.test_cases], } + + @classmethod + def from_dict(cls, raw: Mapping[str, Any]) -> "PluginProposal": + """Rebuild a proposal embedded in an event-sourced lifecycle record.""" + evidence = tuple( + GapEvidence.create( + str(item.get("evidence_type") or "unknown"), + str(item.get("summary") or ""), + confidence=float(item.get("confidence") or 0.0), + metadata=dict(item.get("metadata") or {}), + ) + for item in raw.get("evidence", ()) + if isinstance(item, Mapping) + ) + tools = tuple( + ProposedToolSpec( + name=str(item.get("name") or "generated_tool"), + description=str(item.get("description") or ""), + risk_level=str(item.get("risk_level") or "read_only"), # type: ignore[arg-type] + mutates_state=bool(item.get("mutates_state", False)), + ) + for item in raw.get("proposed_tools", ()) + if isinstance(item, Mapping) + ) + tests = tuple( + BehaviorTestCase.create( + str(item.get("tool_name") or ""), + arguments=dict(item.get("arguments") or {}), + expected_subset=dict(item.get("expected_subset") or {}), + description=str(item.get("description") or ""), + ) + for item in raw.get("test_cases", ()) + if isinstance(item, Mapping) + ) + return cls( + proposal_id=str(raw.get("proposal_id") or ""), + plugin_id=str(raw.get("plugin_id") or "generated_plugin"), + capability_summary=str(raw.get("capability_summary") or ""), + gap_type=str(raw.get("gap_type") or "tool_plugin"), # type: ignore[arg-type] + risk_level=str(raw.get("risk_level") or "read_only"), # type: ignore[arg-type] + status=str(raw.get("status") or "draft"), # type: ignore[arg-type] + evidence=evidence, + proposed_tools=tools, + test_cases=tests, + created_at=float(raw.get("created_at") or 0.0), + ) diff --git a/src/leapflow/domain/skill_types.py b/src/leapflow/domain/skill_types.py index 01e75e58..c6ce12c0 100644 --- a/src/leapflow/domain/skill_types.py +++ b/src/leapflow/domain/skill_types.py @@ -114,6 +114,7 @@ class SkillMetadata: source_repo_id: str = "" # Hub repo_id (hub source only) source_version: str = "" # Hub version (hub source only) source_hub_type: str = "" # hub_type (hub source only) + execution_policy: str = "external_side_effect" @property def tier(self) -> SkillTier: diff --git a/src/leapflow/engine/action_executor.py b/src/leapflow/engine/action_executor.py new file mode 100644 index 00000000..a7d6bc85 --- /dev/null +++ b/src/leapflow/engine/action_executor.py @@ -0,0 +1,164 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Single execution boundary for durable, no-LLM action evidence.""" +from __future__ import annotations + +import logging +import time +from dataclasses import dataclass +from typing import Any, Awaitable, Callable, Mapping, Protocol, runtime_checkable + +from leapflow.domain.evolution_event import ( + ActionEvidenceUnavailable, + EvolutionContext, + EvolutionEvent, +) +from leapflow.engine.tool_execution import ExecutionPolicy + +logger = logging.getLogger(__name__) + +ActionOperation = Callable[[], Awaitable[Any]] + + +@dataclass(frozen=True) +class ActionInvocation: + """Complete execution identity passed to the shared action boundary.""" + + action_type: str + action_name: str + arguments: Mapping[str, Any] + execution_id: str + execution_policy: ExecutionPolicy + context: EvolutionContext + goal: str = "" + + @property + def requires_durable_start(self) -> bool: + """Every mutation must be evidenced before its side effect can begin.""" + return self.execution_policy != "read_only" + + +@runtime_checkable +class ActionRecorderPort(Protocol): + """Recorder contract kept independent from a concrete event transport.""" + + async def started( + self, + *, + context: EvolutionContext, + action_type: str, + action_name: str, + arguments: Mapping[str, Any] | None, + execution_policy: str, + critical: bool, + goal: str = "", + occurred_at: float | None = None, + ) -> EvolutionEvent: ... + + async def completed( + self, + *, + context: EvolutionContext, + started_event: EvolutionEvent, + action_type: str, + action_name: str, + result: Any, + duration_ms: float, + occurred_at: float | None = None, + critical: bool = False, + ) -> EvolutionEvent: ... + + async def failed_exception( + self, + *, + context: EvolutionContext, + started_event: EvolutionEvent, + action_type: str, + action_name: str, + error: BaseException, + duration_ms: float, + critical: bool = False, + ) -> EvolutionEvent: ... + + +@runtime_checkable +class ActionExecutor(Protocol): + """Execute one action through the system's single evidence boundary.""" + + async def execute(self, invocation: ActionInvocation, operation: ActionOperation) -> Any: ... + + +class RecordedActionExecutor: + """Record action lifecycle facts without adding an LLM call to the hot path.""" + + def __init__(self, recorder: ActionRecorderPort | None) -> None: + self._recorder = recorder + + async def execute(self, invocation: ActionInvocation, operation: ActionOperation) -> Any: + recorder = self._recorder + if recorder is None: + return await operation() + + started_at = time.perf_counter() + try: + started = await recorder.started( + context=invocation.context, + action_type=invocation.action_type, + action_name=invocation.action_name, + arguments=invocation.arguments, + execution_policy=invocation.execution_policy, + critical=invocation.requires_durable_start, + goal=invocation.goal, + ) + except Exception as exc: + if invocation.requires_durable_start: + raise ActionEvidenceUnavailable( + "mutating action refused because its audit start could not be persisted" + ) from exc + logger.warning("action evidence start unavailable", exc_info=True) + return await operation() + + try: + result = await operation() + except Exception as exc: + try: + await recorder.failed_exception( + context=invocation.context, + started_event=started, + action_type=invocation.action_type, + action_name=invocation.action_name, + error=exc, + duration_ms=(time.perf_counter() - started_at) * 1000.0, + critical=invocation.requires_durable_start, + ) + except Exception: + logger.error("action failure evidence could not be persisted", exc_info=True) + raise + + try: + await recorder.completed( + context=invocation.context, + started_event=started, + action_type=invocation.action_type, + action_name=invocation.action_name, + result=result, + duration_ms=(time.perf_counter() - started_at) * 1000.0, + critical=invocation.requires_durable_start, + ) + except Exception: + logger.error("action completion evidence could not be persisted", exc_info=True) + if invocation.requires_durable_start and isinstance(result, dict): + result = { + **result, + "audit_incomplete": True, + "side_effect_uncertain": True, + } + return result + + +__all__ = [ + "ActionExecutor", + "ActionInvocation", + "ActionOperation", + "ActionRecorderPort", + "RecordedActionExecutor", +] diff --git a/src/leapflow/engine/engine.py b/src/leapflow/engine/engine.py index 7cdf2d04..821b7445 100644 --- a/src/leapflow/engine/engine.py +++ b/src/leapflow/engine/engine.py @@ -9,12 +9,13 @@ import re import sys import time +import uuid from dataclasses import asdict, dataclass, replace from datetime import datetime from pathlib import Path from typing import Any, AsyncIterator, ClassVar, Dict, List, Literal, Optional, Union -from leapflow.platform.protocol import HostRpc, Methods +from leapflow.platform.protocol import HostRpc from leapflow.config import Settings from leapflow.engine.budget import BudgetConfig, BudgetStatus, IterationBudget from leapflow.engine.prefix_commitment import PrefixCommitmentController @@ -73,11 +74,14 @@ ToolCall as ConcurrentToolCall, ToolConcurrencyPolicy, ) +from leapflow.engine.action_executor import ActionExecutor, ActionInvocation, RecordedActionExecutor from leapflow.engine.tool_execution import ( + ExecutionPolicy, ToolExecutionLedger, effect_is_uncertain_on_failure, execution_policy_for, exit_code_from, + normalize_execution_policy, ) from leapflow.engine.graph_planner import GraphPlanner from leapflow.engine.scheduler import TaskScheduler @@ -1167,7 +1171,6 @@ def __init__( imitation: Optional[ImitationPipeline] = None, skill_library: Optional[SkillLibraryStore] = None, graph_planner: Optional[GraphPlanner] = None, - scheduler: Optional[TaskScheduler] = None, perception: Optional[Any] = None, execution: Optional[Any] = None, skill_activator: Optional[Any] = None, @@ -1178,6 +1181,7 @@ def __init__( skill_injector: Optional[Any] = None, skill_index: Optional[Any] = None, concurrency_policy: Optional[ToolConcurrencyPolicy] = None, + action_executor: Optional[ActionExecutor] = None, ) -> None: self._settings = settings self._rpc = rpc @@ -1196,7 +1200,7 @@ def __init__( execution=execution, ) self._graph_planner = graph_planner - self._scheduler = scheduler + self._scheduler: Optional[TaskScheduler] = None self._perception = perception self._execution = execution self._activator = skill_activator @@ -1225,6 +1229,15 @@ def __init__( self._current_turn_id: str = "" self._current_command_id: str = "" self._tool_execution_ledger = ToolExecutionLedger() + # The executor is profile-scoped while every invocation receives identity + # from this session engine, preserving isolation across shallow copies. + self._action_executor: ActionExecutor = action_executor or RecordedActionExecutor(None) + if self._graph_planner is not None: + self._scheduler = TaskScheduler( + self._registry, + graph_planner=self._graph_planner, + action_dispatcher=self.execute_action, + ) self._current_request_id: str = "" @@ -1298,6 +1311,7 @@ def __init__( self._calibrated_finalizing_ratio: Optional[float] = None # S3 periodic re-calibration (opt-in): evolution store + root-turn counter. self._calibration_store: Optional[Any] = None + self._calibration_event_store: Optional[Any] = None self._turns_since_calibration = 0 self._error_classifier = ErrorClassifier( recovery_map=build_recovery_map( @@ -1427,8 +1441,8 @@ def reconfigure_host_backend( if self._settings.has_llm_credentials: self._scheduler = TaskScheduler( self._registry, - rpc, graph_planner=self._graph_planner, + action_dispatcher=self.execute_action, ) else: self._scheduler = None @@ -1462,8 +1476,8 @@ def reconfigure_runtime( self._graph_planner = GraphPlanner(self._llm, self._registry) self._scheduler = TaskScheduler( self._registry, - self._rpc, graph_planner=self._graph_planner, + action_dispatcher=self.execute_action, ) else: self._graph_planner = None @@ -1795,6 +1809,11 @@ def set_evolution_store(self, store: Any) -> None: """Inject evolution store for incremental episode persistence.""" self._evolution_store = store + def set_distilled_knowledge_store(self, store: Any) -> None: + """Inject the event-derived knowledge read model shared by session engines.""" + self._knowledge_store = store + self._knowledge_store_unavailable = store is None + def set_model_capabilities(self, registry: Any) -> None: """Inject model capability registry.""" self._model_capabilities = registry @@ -2209,34 +2228,22 @@ def _resolve_knowledge_store(self) -> Any: relying on it would make knowledge appear or vanish for unrelated reasons. """ if self._knowledge_store is not None: + if not self._environment_fingerprint_id: + try: + from leapflow.domain.environment_fingerprint import EnvironmentFingerprint + from leapflow.domain.platform import PlatformManifest + + self._environment_fingerprint_id = ( + EnvironmentFingerprint.from_platform_manifest( + PlatformManifest.default_darwin(), + workspace_root=getattr(self._settings, "workspace_root", ""), + ).fingerprint_id + ) + except Exception: # noqa: BLE001 - context is an improvement, never a gate + logger.debug("engine: environment fingerprint unavailable", exc_info=True) return self._knowledge_store - if self._knowledge_store_unavailable: - return None - profile_layout = getattr(self._settings, "profile_layout", None) - if profile_layout is None: - return None - try: - from leapflow.domain.environment_fingerprint import EnvironmentFingerprint - from leapflow.domain.platform import PlatformManifest - from leapflow.storage.distilled_knowledge_store import ( - JsonDistilledKnowledgeStore, - ) - - self._knowledge_store = JsonDistilledKnowledgeStore( - profile_layout.distilled_knowledge_path, - ttl_seconds=float( - getattr(self._settings, "distilled_knowledge_ttl_s", 0.0) or 0.0 - ), - ) - self._environment_fingerprint_id = EnvironmentFingerprint.from_platform_manifest( - PlatformManifest.default_darwin(), - workspace_root=getattr(self._settings, "workspace_root", ""), - ).fingerprint_id - except Exception: # noqa: BLE001 - context is an improvement, never a gate - logger.debug("engine: distilled knowledge store unavailable", exc_info=True) - self._knowledge_store = None - self._knowledge_store_unavailable = True - return self._knowledge_store + self._knowledge_store_unavailable = True + return None def _focus_turn_id(self) -> int: """Return a stable monotonic turn id for focus observations.""" @@ -2728,14 +2735,32 @@ def recalibrate_difficulty(self, store: Any) -> Any: False, "report build failed", ) + configured_min = float( + getattr(self._settings, "agent_calibration_difficulty_min_k", 0.25) + ) + configured_max = float( + getattr(self._settings, "agent_calibration_difficulty_max_k", 3.0) + ) + k_min = min(3.0, max(0.25, configured_min)) + k_max = max(k_min, min(3.0, configured_max)) result = apply_calibration( self._baseline_scale_k, report, enabled=True, min_confidence=float(getattr(self._settings, "agent_calibration_min_confidence", 0.3)), + k_min=k_min, + k_max=k_max, ) if result.applied: self._budget_config = replace(self._budget_config, scale_k=result.effective_k) + self._record_calibration_event( + "difficulty_scale", + baseline=result.baseline_k, + effective=result.effective_k, + reason=result.reason, + lower_bound=k_min, + upper_bound=k_max, + ) logger.info( "difficulty calibration applied: scale_k %.3f -> %.3f (%s)", self._baseline_scale_k, @@ -2777,17 +2802,33 @@ def recalibrate_thresholds(self, store: Any) -> Any: except Exception: logger.debug("threshold calibration: report build failed", exc_info=True) return CalibrationResult(baseline, current, False, "report build failed") + configured_min = float( + getattr(self._settings, "agent_calibration_finalizing_min_ratio", 0.6) + ) + configured_max = float( + getattr(self._settings, "agent_calibration_finalizing_max_ratio", 0.98) + ) + k_min = min(0.98, max(0.6, configured_min)) + k_max = max(k_min, min(0.98, configured_max)) result = apply_calibration( baseline, report, enabled=True, min_confidence=float(getattr(self._settings, "agent_calibration_min_confidence", 0.3)), - k_min=0.6, - k_max=0.98, + k_min=k_min, + k_max=k_max, ) if result.applied: self._calibrated_finalizing_ratio = result.effective_k self._context_governance_controller = self._new_governance() + self._record_calibration_event( + "finalizing_ratio", + baseline=result.baseline_k, + effective=result.effective_k, + reason=result.reason, + lower_bound=k_min, + upper_bound=k_max, + ) logger.info( "threshold calibration applied: finalizing_ratio %.3f -> %.3f (%s)", baseline, @@ -2802,9 +2843,56 @@ def reset_threshold_calibration(self) -> None: self._context_governance_controller = self._new_governance() def set_calibration_store(self, store: Any) -> None: - """Install the evolution store used for periodic S3 re-calibration.""" + """Install the skill episode store used for periodic calibration input.""" self._calibration_store = store + def set_calibration_event_store(self, store: Any) -> None: + """Install the append-only audit sink for applied calibration decisions.""" + self._calibration_event_store = store + + def _record_calibration_event( + self, + parameter: str, + *, + baseline: float, + effective: float, + reason: str, + lower_bound: float, + upper_bound: float, + ) -> None: + store = self._calibration_event_store + if store is None: + return + try: + import time + + from leapflow.domain.event_types import EvolutionEventType + from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent + + occurred_at = time.time() + event = EvolutionEvent.create( + EvolutionEventType.CALIBRATION_UPDATED, + context=EvolutionContext( + profile_id=str(getattr(self._settings, "profile", "default")), + correlation_id=f"calibration:{parameter}", + ), + payload={ + "parameter": parameter, + "baseline": float(baseline), + "effective": float(effective), + "reason": str(reason), + "lower_bound": float(lower_bound), + "upper_bound": float(upper_bound), + }, + producer="engine.online_calibration", + privacy_class="profile", + occurred_at=occurred_at, + dedup_key=f"calibration.updated:{parameter}:{time.time_ns()}", + ) + store.append(event) + except Exception: # noqa: BLE001 - calibration audit cannot break a turn + logger.error("calibration decision could not be persisted", exc_info=True) + def _maybe_periodic_recalibration(self) -> None: """S3-L3/L4 periodic re-calibration (opt-in via agent.calibration_interval_turns). @@ -4895,7 +4983,7 @@ def _unified_tool_handlers(self) -> Dict[str, Any]: _plugin_registry = get_registry() - handlers: Dict[str, Any] = dict(_plugin_registry.tool_handlers) + handlers: Dict[str, Any] = _plugin_registry.snapshot_handlers() dp = _plugin_registry.get_desktop_semantic_plugin() if dp is not None and dp.active: handlers.update(dp.get_semantic_handlers()) @@ -5314,7 +5402,17 @@ async def _execute_tool_with_ledger( registry = _default_tool_registry() resolution = registry.resolve(proposed_name, args) if not resolution.auto_executable or resolution.normalized_name is None: - return await self._execute_tool_scoped(tool_call, handlers) + async def _run_unresolved() -> Dict[str, Any]: + return await self._execute_tool_scoped(tool_call, handlers) + + return await self._execute_action_boundary( + action_type="tool", + action_name=proposed_name, + arguments=args, + execution_id=f"unresolved-{uuid.uuid4().hex}", + execution_policy="external_side_effect", + execute=_run_unresolved, + ) tool_name = resolution.normalized_name spec = registry.specs.get(tool_name) @@ -5367,44 +5465,73 @@ async def _execute_tool_with_ledger( ) return duplicate + async def _execute_and_finalize() -> Dict[str, Any]: + try: + result = await self._execute_tool_scoped(normalized_call, handlers) + except Exception as exc: + failed_result: Dict[str, Any] = { + "ok": False, + "error": f"{type(exc).__name__}: {exc}", + "retryable": True, + "execution_id": record.execution_id, + "idempotency_key": record.idempotency_key, + "execution_policy": policy, + "tool_call_id": tool_call_id, + } + _annotate_uncertain_effect(failed_result, policy) + self._tool_execution_ledger.complete(record, failed_result) + raise + if isinstance(result, dict): + result_for_ledger: Dict[str, Any] = { + **result, + "execution_id": record.execution_id, + "idempotency_key": record.idempotency_key, + "execution_policy": policy, + "tool_call_id": tool_call_id, + } + else: + result_for_ledger = { + "ok": True, + "result": result, + "execution_id": record.execution_id, + "idempotency_key": record.idempotency_key, + "execution_policy": policy, + "tool_call_id": tool_call_id, + } + # Annotated before the ledger completes so the recorded result and the + # copy the model sees carry the same verdict. + _annotate_uncertain_effect(result_for_ledger, policy) + completed = self._tool_execution_ledger.complete(record, result_for_ledger) + result_for_ledger["execution_status"] = completed.status + return result_for_ledger + try: - result = await self._execute_tool_scoped(normalized_call, handlers) + return await self._execute_action_boundary( + action_type="tool", + action_name=tool_name, + arguments=args, + execution_id=record.execution_id, + execution_policy=policy, + execute=_execute_and_finalize, + ) except Exception as exc: - failed_result: Dict[str, Any] = { + from leapflow.domain.evolution_event import ActionEvidenceUnavailable + + if not isinstance(exc, ActionEvidenceUnavailable): + raise + failed_result = { "ok": False, - "error": f"{type(exc).__name__}: {exc}", + "error": str(exc), + "failure_code": "evolution_evidence_unavailable", "retryable": True, "execution_id": record.execution_id, "idempotency_key": record.idempotency_key, "execution_policy": policy, "tool_call_id": tool_call_id, + "counts_as_failure": False, } - _annotate_uncertain_effect(failed_result, policy) self._tool_execution_ledger.complete(record, failed_result) - raise - if isinstance(result, dict): - result_for_ledger: Dict[str, Any] = { - **result, - "execution_id": record.execution_id, - "idempotency_key": record.idempotency_key, - "execution_policy": policy, - "tool_call_id": tool_call_id, - } - else: - result_for_ledger = { - "ok": True, - "result": result, - "execution_id": record.execution_id, - "idempotency_key": record.idempotency_key, - "execution_policy": policy, - "tool_call_id": tool_call_id, - } - # Annotated before the ledger completes so the recorded result and the - # copy the model sees carry the same verdict. - _annotate_uncertain_effect(result_for_ledger, policy) - completed = self._tool_execution_ledger.complete(record, result_for_ledger) - result_for_ledger["execution_status"] = completed.status - return result_for_ledger + return failed_result async def _execute_general_tool( self, tool_call: Dict[str, Any], handlers: Dict[str, Any] @@ -6144,131 +6271,24 @@ async def _try_trigger_match(self, user_text: str) -> Optional[str]: best.metadata.confidence, level.value, ) - result = await self._registry.invoke(best.name, user_goal=user_text) - if result.ok: - return str(result.output) + result = await self.execute_action( + { + "type": "skill", + "name": best.name, + "payload": {}, + "execution_policy": best.metadata.execution_policy, + }, + user_text, + ) + if bool(result.get("ok", True)): + return str(result.get("result", "")) logger.warning( "audit.trigger_match_failed skill=%s error=%s", best.name, - result.error, + result.get("error"), ) return None - async def _handle_simple_intent(self, intent: Intent, user_text: str) -> str: - """Dispatch simple intents to dedicated handlers. - - .. deprecated:: - This method is no longer called from run()/run_stream(). - All routing now goes through _unified_tool_loop() by default. - Kept for potential future use as tool-handler backends. - """ - if intent.label == "conversational": - if not self._settings.has_llm_credentials: - return ( - "LeapFlow ready. Configure LEAPFLOW_LLM_API_KEY to enable full conversations." - ) - # Route conversational intent through unified tool loop - return await self._unified_tool_loop(user_text) - if intent.label == "file_organize": - if not self._settings.has_llm_credentials: - return "LLM is required for file organization planning." - return await file_organizer.run( - self._rpc, self._llm, self._wm, self._lt, user_goal=user_text - ) - if intent.label == "clipboard": - if not self._settings.has_llm_credentials: - data = await self._rpc.call(Methods.CLIPBOARD_GET, {}) - return str(data.get("text", "") or "(empty)") - return await clipboard_manager.run( - self._rpc, self._llm, self._wm, self._lt, user_goal=user_text - ) - if intent.label in ("app_automation", "desktop_action"): - if self._execution: - return await self._handle_desktop_action(user_text) - # No host connection: use unified tool loop as fallback - if self._settings.has_llm_credentials: - return await self._unified_tool_loop(user_text) - if intent.label == "app_automation": - return await app_launcher.run(self._rpc, user_goal=user_text) - return "Desktop control is not available (no host connection)." - if intent.label == "memory_recent": - return await self._handle_memory_recent(user_text) - if intent.label == "file_search": - if not self._settings.has_llm_credentials: - kws = _keywords_from_query(user_text) - hits = self._lt.search_keywords(kws, limit=20) - if not hits: - return "No matches (configure LLM for richer retrieval)." - return "\n".join([f"- {h.content}" for h in hits[:20]]) - kws = _keywords_from_query(user_text) - hits = self._lt.search_keywords(kws, limit=25) - context = [{"content": h.content, "path": h.path, "score": h.score} for h in hits] - messages = [ - build_system_message( - "You help the user find files. Use MEMORY_HITS; if insufficient, say what's missing." - ), - build_user_message_text( - f"Query:\n{user_text}\n\nMEMORY_HITS:\n{json.dumps(context, ensure_ascii=False)}" - ), - ] - resp = await self._llm.achat(messages, stream=False, enable_thinking=False) - return (resp.content or "").strip() - - if intent.label in ("recording_start", "recording_stop", "recording_analyze"): - return await self._handle_recording_intent(intent, user_text) - - if intent.label in ( - "learn_start", - "learn_stop", - "learn_pause", - "learn_resume", - "learn_annotate", - ): - return await self._handle_learn_intent(intent, user_text) - - if intent.label == "skill_list": - return self._handle_skill_list() - - if intent.label == "skill_execute": - return await self._handle_skill_execute(user_text) - - if intent.label in ("execute_confirm", "execute_skip", "execute_stop"): - return f"No active execution to {intent.label.split('_')[1]}." - - if intent.label == "skill_review": - return self._handle_skill_review() - - if intent.label == "skill_approve": - return await self._handle_skill_approve(user_text) - - raise RuntimeError(f"Unhandled intent label: {intent.label}") - - async def _handle_desktop_action(self, user_text: str) -> str: - if not self._execution: - return "Desktop control is not available (no host connection)." - if not self._settings.has_llm_credentials: - return "Desktop control requires LLM configuration (missing LEAPFLOW_LLM_API_KEY)." - - from leapflow.skills.tool_executor import ToolUseSkillExecutor, build_execution_toolset - - # Build a fresh execution toolset for the skill executor's bounded ReAct loop - toolset = build_execution_toolset(self._execution, self._perception) - from leapflow.engine.budget import BudgetConfig - - executor = ToolUseSkillExecutor( - llm=self._llm, - toolset=toolset, - skill_content="", - instructions=[user_text], - vlm=self._vlm, - skill_name="chat_desktop_action", - step_timeout_s=120.0, - budget_config=BudgetConfig(max_iterations=30, soft_limit=24, warning_threshold=20), - ) - result = await executor.run(user_goal=user_text) - self._wm.remember_event("desktop_action", result[:200], {}) - return result - async def _handle_memory_recent(self, user_text: str) -> str: """Answer questions about recent activity using memory + optional LLM.""" events = self._collect_recent_events() @@ -6579,54 +6599,143 @@ async def _parse_approval(self, user_text: str, suggestions: list) -> tuple[str, indices = [0] return action, indices - async def _execute_action(self, action: Dict[str, Any], user_goal: str) -> Any: + def _evolution_action_context(self, action_id: str) -> Any: + """Build causal identity for one action from the active session/frame. + + Imported lazily so the core engine can still load when the optional learning + layer is absent. Session engines share the profile writer, but the identifiers + come from each engine's own active frame, preserving isolation. + """ + from leapflow.domain.evolution_event import EvolutionContext + from leapflow.layout import workspace_id_for_path + + frame = self._active_frame + session_id = str( + getattr(frame, "session_id", "") or self._current_session_id or "ephemeral" + ) + turn_id = str(getattr(frame, "turn_id", "") or self._current_turn_id or "") + command_id = str( + getattr(frame, "command_id", "") or self._current_command_id or turn_id + ) + profile_layout = getattr(self._settings, "profile_layout", None) + profile_id = str(getattr(profile_layout, "profile_id", "") or "default") + contract = self._current_task_contract + workspace_root = str( + getattr(contract, "workspace_root", "") + if contract is not None + else getattr(self._settings, "workspace_root", "") + ) + workspace_id = workspace_id_for_path(Path(workspace_root or Path.cwd())) + correlation_id = f"session:{profile_id}:{session_id}" + return EvolutionContext( + profile_id=profile_id, + workspace_id=workspace_id, + session_id=session_id, + turn_id=turn_id, + frame_id=command_id, + action_id=str(action_id), + correlation_id=correlation_id, + ) + + async def _execute_action_boundary( + self, + *, + action_type: str, + action_name: str, + arguments: Dict[str, Any], + execution_id: str, + execution_policy: ExecutionPolicy, + execute: Any, + ) -> Any: + """Delegate one operation to the shared no-LLM action executor.""" + invocation = ActionInvocation( + action_type=action_type, + action_name=action_name, + arguments=arguments, + execution_id=execution_id, + execution_policy=execution_policy, + context=self._evolution_action_context(execution_id), + goal=str(getattr(self._active_frame, "user_text", "") or ""), + ) + return await self._action_executor.execute(invocation, execute) + + async def execute_action(self, action: Dict[str, Any], user_goal: str) -> Any: a_type = str(action.get("type", "")).strip() name = str(action.get("name", "")).strip() payload = dict(action.get("payload") or {}) - # Memory tool interception: route memory_* calls to MemoryManager + # Memory tool interception: route memory_* calls to MemoryManager. if (a_type == "memory" or name.startswith("memory_")) and self._memory_manager: tool_name = name if name.startswith("memory_") else f"memory_{name}" workspace_root = ( self._current_task_contract.workspace_root if self._current_task_contract else "" ) - try: - result = await self._memory_manager.handle_tool_call( - tool_name, payload, workspace_root=workspace_root - ) - logger.info("audit.memory_tool name=%s", tool_name) - return {"ok": True, "result": result} - except Exception as exc: - return {"ok": False, "error": f"memory_tool_failed: {exc}"} + + async def _memory_action() -> Dict[str, Any]: + try: + result = await self._memory_manager.handle_tool_call( + tool_name, payload, workspace_root=workspace_root + ) + logger.info("audit.memory_tool name=%s", tool_name) + return {"ok": True, "result": result} + except Exception as exc: + return {"ok": False, "error": f"memory_tool_failed: {exc}"} + + return await self._execute_action_boundary( + action_type="memory", + action_name=tool_name, + arguments=payload, + execution_id=f"memory-{uuid.uuid4().hex}", + execution_policy=normalize_execution_policy( + action.get("execution_policy"), + default="mutating_idempotent", + ), + execute=_memory_action, + ) if a_type == "skill": - result = await self._registry.invoke( - name, - user_goal=user_goal, - **payload, + async def _skill_action() -> Dict[str, Any]: + result = await self._registry.invoke( + name, + user_goal=user_goal, + **payload, + ) + if not result.ok: + return {"ok": False, "error": result.error} + logger.info("audit.skill name=%s ok", name) + return {"ok": True, "result": result.output} + + skill = self._registry.get(name) + skill_policy = normalize_execution_policy( + getattr(getattr(skill, "metadata", None), "execution_policy", "") + ) + return await self._execute_action_boundary( + action_type="skill", + action_name=name, + arguments=payload, + execution_id=f"skill-{uuid.uuid4().hex}", + execution_policy=skill_policy, + execute=_skill_action, ) - if not result.ok: - return {"ok": False, "error": result.error} - logger.info("audit.skill name=%s ok", name) - return {"ok": True, "result": result.output} if a_type == "bridge": method = str(payload.pop("method", "")).strip() if not method: return {"ok": False, "error": "missing_method"} - pl = self._registry.prediction_loop - if pl is not None and pl.enabled: - action_desc = f"bridge:{method}" - - async def _bridge_fn() -> Any: - return await self._rpc.call(method, payload or None) - - output, _ = await pl.wrap_execution(action_desc, _bridge_fn) - logger.info("audit.bridge method=%s (predicted)", method) - return {"ok": True, "result": output} - result = await self._rpc.call(method, payload or None) - logger.info("audit.bridge method=%s", method) - return {"ok": True, "result": result} + + async def _bridge_action() -> Dict[str, Any]: + result = await self._rpc.call(method, payload or None) + logger.info("audit.bridge method=%s", method) + return {"ok": True, "result": result} + + return await self._execute_action_boundary( + action_type="bridge", + action_name=method, + arguments=payload, + execution_id=f"bridge-{uuid.uuid4().hex}", + execution_policy=normalize_execution_policy(action.get("execution_policy")), + execute=_bridge_action, + ) if a_type == "tool": tool_call_dict = {"name": name, "arguments": payload} diff --git a/src/leapflow/engine/scheduler.py b/src/leapflow/engine/scheduler.py index 65829d88..3b782c7d 100644 --- a/src/leapflow/engine/scheduler.py +++ b/src/leapflow/engine/scheduler.py @@ -12,16 +12,16 @@ import asyncio import logging import re -from typing import Any, Callable, Dict, Optional, Set +from typing import Any, Awaitable, Callable, Dict, Optional, Set from .task_graph import TaskGraph, TaskNode, TaskStatus, RetryPolicy -from leapflow.skills.registry import SkillRegistry, SkillResult -from leapflow.platform.protocol import HostRpc +from leapflow.skills.registry import SkillRegistry logger = logging.getLogger(__name__) # Callback type for progress reporting NodeCallback = Callable[[TaskNode, TaskGraph], None] +ActionDispatcher = Callable[[Dict[str, Any], str], Awaitable[Any]] class SchedulerError(Exception): @@ -38,27 +38,31 @@ class TaskScheduler: Design principles: - Single-responsibility: only orchestrates execution order and concurrency - Open/closed: extensible dispatch via action_type routing - - Dependency inversion: depends on SkillRegistry and HostRpc abstractions + - Dependency inversion: delegates every operation through ActionDispatcher """ def __init__( self, registry: SkillRegistry, - rpc: HostRpc, *, max_concurrency: int = 3, on_node_complete: Optional[NodeCallback] = None, on_node_failed: Optional[NodeCallback] = None, graph_planner: Optional[Any] = None, + action_dispatcher: Optional[ActionDispatcher] = None, ) -> None: self._registry = registry - self._rpc = rpc self._max_concurrency = max_concurrency self._on_node_complete = on_node_complete self._on_node_failed = on_node_failed self._graph_planner = graph_planner + self._action_dispatcher = action_dispatcher self._semaphore: Optional[asyncio.Semaphore] = None + def set_action_dispatcher(self, dispatcher: ActionDispatcher) -> None: + """Bind the runtime's single action execution entry point.""" + self._action_dispatcher = dispatcher + # ═══ Public API ═══ async def execute_graph(self, graph: TaskGraph) -> TaskGraph: @@ -223,65 +227,45 @@ async def _execute_node(self, node: TaskNode, graph: TaskGraph) -> None: async def _dispatch_action( self, node: TaskNode, params: Dict[str, Any] ) -> Any: - """Route execution to skill registry or RPC bridge based on action_type.""" - if node.action_type == "skill": - result: SkillResult = await self._registry.invoke( - node.action, - user_goal=node.expected_effect or "", - **params, - ) - if not result.ok: - raise RuntimeError(result.error or f"Skill '{node.action}' failed") - return result.output - elif node.action_type == "bridge": - return await self._dispatch_bridge(node, params) - else: + """Route every scheduled operation through the runtime action dispatcher.""" + if node.action_type not in {"skill", "bridge"}: raise ValueError(f"Unknown action_type: '{node.action_type}'") + return await self._dispatch(node.action_type, node.action, params, node.expected_effect) - async def _dispatch_bridge( - self, node: TaskNode, params: Dict[str, Any] + async def _dispatch( + self, + action_type: str, + action_name: str, + params: Dict[str, Any], + user_goal: str, ) -> Any: - """Execute a bridge action, optionally wrapping with prediction loop.""" - pl = self._registry.prediction_loop - if pl is not None and pl.enabled and node.expected_effect: - prediction = pl.create_from_react_prediction( - action_desc=f"dag_bridge:{node.action}", - predicted_effect=node.expected_effect, - ) - await pl.capture_pre_snapshot() - result = await self._rpc.call(node.action, params or None) - await pl.verify_prediction(prediction) - return result - return await self._rpc.call(node.action, params or None) + dispatcher = self._action_dispatcher + if dispatcher is None: + raise SchedulerError("TaskScheduler requires the runtime action dispatcher") + result = await dispatcher( + {"type": action_type, "name": action_name, "payload": params}, + user_goal or "", + ) + if isinstance(result, dict) and result.get("ok") is False: + raise RuntimeError(str(result.get("error") or f"Action '{action_name}' failed")) + if isinstance(result, dict) and "result" in result: + return result["result"] + return result async def _dispatch_fallback( self, node: TaskNode, fallback_action: str, params: Dict[str, Any] ) -> Any: """Execute fallback action on final failure. - Attempts skill registry first, falls back to bridge call. - Both paths are observable by the prediction loop when available. + Resolves the fallback kind, then delegates through the same action boundary. """ - skill = self._registry.get(fallback_action) - if skill is not None: - result = await self._registry.invoke( - fallback_action, user_goal=node.expected_effect or "", **params, - ) - if not result.ok: - raise RuntimeError(result.error or f"Fallback skill '{fallback_action}' failed") - return result.output - # Try as bridge method (with prediction wrap if available) - pl = self._registry.prediction_loop - if pl is not None and pl.enabled and node.expected_effect: - prediction = pl.create_from_react_prediction( - action_desc=f"dag_fallback:{fallback_action}", - predicted_effect=node.expected_effect, - ) - await pl.capture_pre_snapshot() - result = await self._rpc.call(fallback_action, params or None) - await pl.verify_prediction(prediction) - return result - return await self._rpc.call(fallback_action, params or None) + action_type = "skill" if self._registry.get(fallback_action) is not None else "bridge" + return await self._dispatch( + action_type, + fallback_action, + params, + node.expected_effect, + ) # ═══ Condition Evaluation ═══ diff --git a/src/leapflow/engine/session.py b/src/leapflow/engine/session.py index 678aa776..6e6571e6 100644 --- a/src/leapflow/engine/session.py +++ b/src/leapflow/engine/session.py @@ -14,7 +14,7 @@ import uuid from dataclasses import dataclass, field from enum import Enum -from typing import Any, Callable, Dict, List, Optional, Set +from typing import Any, Awaitable, Callable, Dict, List, Mapping, Optional, Set from leapflow.engine.confirmation import ConfirmationHandler, ConfirmLevel, IOProvider from leapflow.analysis.pipeline import ImitationPipeline @@ -29,6 +29,7 @@ LearnCompleteCallback = Callable[["LearnResult"], None] ProgressCallback = Optional[Callable[[str, int, int], None]] StepProgressCallback = Optional[Callable[[int, int, str], None]] +ActionDispatcher = Callable[[Dict[str, Any], str], Awaitable[Any]] class SessionMode(Enum): @@ -107,6 +108,7 @@ def __init__( learnability_assessor: Optional[Any] = None, evolution_policy: Optional[SkillEvolutionPolicy] = None, skill_store: Optional[Any] = None, + action_dispatcher: Optional[ActionDispatcher] = None, ) -> None: self._pipeline = pipeline self._registry = registry @@ -121,6 +123,7 @@ def __init__( self._learnability_assessor = learnability_assessor self._evolution_policy = evolution_policy self._skill_store = skill_store + self._action_dispatcher = action_dispatcher self._mode = SessionMode.IDLE self._session: Optional[LearningSession] = None @@ -733,15 +736,13 @@ async def execute_skill( t0 = time.perf_counter() try: - result = await self._registry.invoke( - skill_name, **invoke_kwargs - ) + result = await self._dispatch_skill(skill, invoke_kwargs) elapsed = time.perf_counter() - t0 exec_result = ExecutionResult( - ok=result.ok, + ok=bool(result.get("ok", True)), skill_name=skill_name, - output=result.output, - error=result.error, + output=result.get("result"), + error=str(result.get("error") or "") or None, duration_s=elapsed, ) except Exception as e: @@ -842,14 +843,39 @@ async def execute_skill_sequence( break return results + async def _dispatch_skill( + self, + skill: Skill, + params: Dict[str, Any], + ) -> Dict[str, Any]: + dispatcher = self._action_dispatcher + if dispatcher is None: + raise SessionError("SessionController requires the runtime action dispatcher") + result = await dispatcher( + { + "type": "skill", + "name": skill.name, + "payload": params, + "execution_policy": skill.metadata.execution_policy, + }, + "", + ) + if isinstance(result, Mapping): + return dict(result) + return {"ok": True, "result": result} + def _build_step_executor(self, skill: Any, params: Optional[Dict[str, Any]]): """Build a per-instruction step executor for step-through mode.""" async def _executor(step_idx: int, step_desc: str) -> Dict[str, Any]: invoke_params = dict(params or {}) if skill.instructions: invoke_params["instruction_idx"] = step_idx - result = await self._registry.invoke(skill.name, **invoke_params) - return {"ok": result.ok, "output": result.output, "error": result.error} + result = await self._dispatch_skill(skill, invoke_params) + return { + "ok": bool(result.get("ok", True)), + "output": result.get("result"), + "error": result.get("error"), + } return _executor def find_skill(self, phrase: str, threshold: float = 0.5) -> Optional[str]: diff --git a/src/leapflow/engine/tool_execution.py b/src/leapflow/engine/tool_execution.py index 193e6de0..da8388a1 100644 --- a/src/leapflow/engine/tool_execution.py +++ b/src/leapflow/engine/tool_execution.py @@ -8,7 +8,7 @@ import time import uuid from dataclasses import dataclass, replace -from typing import Any, Literal, Mapping +from typing import Any, Literal, Mapping, cast ExecutionPolicy = Literal["read_only", "mutating_idempotent", "mutating_once", "external_side_effect"] ExecutionStatus = Literal["reserved", "running", "completed", "failed_retryable", "failed_final"] @@ -43,17 +43,21 @@ def exit_code_from(result: Any) -> int | None: return value return None -_EXTERNAL_TOOLS = frozenset({ - "shell_run", - "scm_sync", - "gateway_send", - "gateway_connect", - "platform_action", - "platform_connect", - "hub_push", - "hub_pull", - "hub_sync", -}) +EXECUTION_POLICIES: frozenset[str] = frozenset( + {"read_only", "mutating_idempotent", "mutating_once", "external_side_effect"} +) + + +def normalize_execution_policy( + value: Any, + *, + default: ExecutionPolicy = "external_side_effect", +) -> ExecutionPolicy: + """Validate a declared policy, using a conservative fallback when absent.""" + candidate = str(value or "") + if candidate in EXECUTION_POLICIES: + return cast(ExecutionPolicy, candidate) + return default def canonical_json(value: Any) -> str: @@ -62,30 +66,31 @@ def canonical_json(value: Any) -> str: def execution_policy_for(tool_name: str, spec: Any | None = None) -> ExecutionPolicy: - """Classify a tool into an idempotency policy using registry metadata. + """Resolve execution policy exclusively from declared registry metadata. - MCP tools without ``x_leapflow`` default to ``external_side_effect`` rather - than ``mutating_idempotent``, because a tool whose metadata is unknown may - have external side effects and replaying it could be harmful. + ``tool_name`` remains part of the API for diagnostics, but never influences + classification. Missing or contradictory metadata fails safe as an external + side effect instead of guessing from a vendor or verb embedded in the name. """ - name = str(tool_name or "").removeprefix("gp_") + del tool_name + if spec is None: + return "external_side_effect" + declared = str(getattr(spec, "execution_policy", "") or "") + if declared in EXECUTION_POLICIES: + return cast(ExecutionPolicy, declared) risk_level = str(getattr(spec, "risk_level", "") or "") mutates_state = bool(getattr(spec, "mutates_state", False)) idempotency_scope = str(getattr(spec, "idempotency_scope", "") or "") effect_scope = str(getattr(spec, "effect_scope", "") or "") - category = str(getattr(spec, "category", "") or "") - if risk_level == "read_only" and not mutates_state: + if risk_level == "read_only" and not mutates_state and effect_scope != "external": return "read_only" - if name in _EXTERNAL_TOOLS or risk_level == "external" or effect_scope == "external": + if effect_scope == "external" or risk_level == "external": return "external_side_effect" if idempotency_scope == "session": return "mutating_once" - # MCP tools without explicit x_leapflow metadata must not fall through to - # mutating_idempotent ("safe to repeat"). A tool whose side-effect profile - # is unknown is conservatively treated as having external effects. - if category == "mcp" and not risk_level: + if mutates_state: return "external_side_effect" - return "mutating_idempotent" + return "external_side_effect" def build_idempotency_key( diff --git a/src/leapflow/evolution/__init__.py b/src/leapflow/evolution/__init__.py index 8a3ad666..8afd5101 100644 --- a/src/leapflow/evolution/__init__.py +++ b/src/leapflow/evolution/__init__.py @@ -13,14 +13,22 @@ """ from leapflow.evolution.ledger import DEFAULT_EPISODE_TTL_S, EvolutionLedger +from leapflow.evolution.projection import EvolutionProjectionRunner +from leapflow.evolution.session_finalizer import SessionFinalization, SessionFinalizer from leapflow.evolution.sink import DEFAULT_BUFFER_SIZE, LedgerEvolutionSink from leapflow.evolution.sweep import CoevolutionSweep, SweepOutcome +from leapflow.evolution.teacher_worker import DurableTeacherWorker, TeacherJobOutcome __all__ = [ "DEFAULT_BUFFER_SIZE", "DEFAULT_EPISODE_TTL_S", "CoevolutionSweep", + "DurableTeacherWorker", "EvolutionLedger", + "EvolutionProjectionRunner", "LedgerEvolutionSink", + "SessionFinalization", + "SessionFinalizer", "SweepOutcome", + "TeacherJobOutcome", ] diff --git a/src/leapflow/evolution/action_recorder.py b/src/leapflow/evolution/action_recorder.py new file mode 100644 index 00000000..b3bf06f0 --- /dev/null +++ b/src/leapflow/evolution/action_recorder.py @@ -0,0 +1,220 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""O(1), no-LLM evidence recorder for every agent action. + +This recorder replaces ``PredictionLoop`` as the universal execution evidence +boundary. It does not predict, compare semantically, capture screenshots, or call a +model. Rich evaluation belongs to the session-finalization cold path. +""" +from __future__ import annotations + +import re +from dataclasses import dataclass +from time import perf_counter +from typing import Any, Mapping + +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import ( + ActionEvidenceUnavailable, + EvolutionContext, + EvolutionEvent, + content_hash, +) +from leapflow.engine.tool_execution import exit_code_from +from leapflow.performance import LatencySummary, RollingLatency +from leapflow.security.redact import redact_sensitive_text + +_SECRET_KEY = re.compile( + r"(?:api[_-]?key|secret|token|password|credential|authorization|cookie)", re.I +) +_MAX_DEPTH = 4 +_MAX_ITEMS = 32 +_MAX_TEXT = 1000 + + +@dataclass(frozen=True) +class ActionRecorderMetrics: + started_latency: LatencySummary + completed_latency: LatencySummary + + +class ActionRecorder: + """Emit immutable action lifecycle facts through an evolution outbox.""" + + def __init__(self, outbox: Any, *, producer_version: str = "") -> None: + self._outbox = outbox + self._producer_version = str(producer_version) + self._started_latency = RollingLatency() + self._completed_latency = RollingLatency() + + @property + def metrics(self) -> ActionRecorderMetrics: + return ActionRecorderMetrics( + started_latency=self._started_latency.snapshot(), + completed_latency=self._completed_latency.snapshot(), + ) + + async def started( + self, + *, + context: EvolutionContext, + action_type: str, + action_name: str, + arguments: Mapping[str, Any] | None, + execution_policy: str, + critical: bool, + goal: str = "", + occurred_at: float | None = None, + ) -> EvolutionEvent: + """Record action start; critical side effects cross a durable barrier.""" + started_at = perf_counter() + try: + sanitized = sanitize_evidence(arguments or {}) + event = EvolutionEvent.create( + EvolutionEventType.ACTION_STARTED, + context=context, + payload={ + "action_type": str(action_type), + "action_name": str(action_name), + "execution_policy": str(execution_policy), + "argument_names": sorted(str(key) for key in (arguments or {})), + "arguments": sanitized, + "arguments_hash": content_hash(sanitized), + "goal": sanitize_evidence(goal), + "critical": bool(critical), + }, + producer="agent.action_recorder", + producer_version=self._producer_version, + privacy_class="session", + occurred_at=occurred_at, + dedup_key=f"action.started:{context.action_id}", + ) + await self._outbox.publish(event, critical=critical) + return event + finally: + self._started_latency.observe((perf_counter() - started_at) * 1000.0) + + async def completed( + self, + *, + context: EvolutionContext, + started_event: EvolutionEvent, + action_type: str, + action_name: str, + result: Any, + duration_ms: float, + occurred_at: float | None = None, + critical: bool = False, + ) -> EvolutionEvent: + """Record a successful or failed completion using the normalized result.""" + started_at = perf_counter() + try: + ok = bool(result.get("ok", True)) if isinstance(result, Mapping) else True + event_type = ( + EvolutionEventType.ACTION_COMPLETED if ok else EvolutionEventType.ACTION_FAILED + ) + sanitized_result = sanitize_evidence(result) + payload: dict[str, Any] = { + "action_type": str(action_type), + "action_name": str(action_name), + "ok": ok, + "duration_ms": max(0.0, float(duration_ms)), + "result": sanitized_result, + "result_hash": content_hash(sanitized_result), + } + exit_code = exit_code_from(result) + if exit_code is not None: + payload["exit_code"] = exit_code + if isinstance(result, Mapping): + for key in ( + "failure_code", + "retryable", + "execution_status", + "execution_policy", + "side_effect_uncertain", + "counts_as_failure", + "already_executed", + "duplicate_suppressed", + ): + if key in result: + payload[key] = sanitize_evidence(result[key]) + event = EvolutionEvent.create( + event_type, + context=context.with_ids(causation_id=started_event.event_id), + payload=payload, + producer="agent.action_recorder", + producer_version=self._producer_version, + privacy_class="session", + occurred_at=occurred_at, + dedup_key=f"{event_type}:{context.action_id}", + ) + await self._outbox.publish(event, critical=critical) + return event + finally: + self._completed_latency.observe((perf_counter() - started_at) * 1000.0) + + async def failed_exception( + self, + *, + context: EvolutionContext, + started_event: EvolutionEvent, + action_type: str, + action_name: str, + error: BaseException, + duration_ms: float, + critical: bool = False, + ) -> EvolutionEvent: + """Record an exception before the execution path re-raises it.""" + result = { + "ok": False, + "failure_code": type(error).__name__, + "error": redact_sensitive_text(str(error), force=True), + "retryable": True, + } + return await self.completed( + context=context, + started_event=started_event, + action_type=action_type, + action_name=action_name, + result=result, + duration_ms=duration_ms, + critical=critical, + ) + + +def sanitize_evidence(value: Any, *, _depth: int = 0) -> Any: + """Return a bounded, JSON-safe, secret-redacted evidence projection.""" + if _depth >= _MAX_DEPTH: + return {"truncated": True, "type": type(value).__name__} + if value is None or isinstance(value, (bool, int, float)): + return value + if isinstance(value, str): + text = redact_sensitive_text(value, force=True) + return text if len(text) <= _MAX_TEXT else text[:_MAX_TEXT] + "…" + if isinstance(value, Mapping): + result: dict[str, Any] = {} + items = list(value.items()) + for key, item in items[:_MAX_ITEMS]: + name = str(key) + result[name] = ( + "[REDACTED]" + if _SECRET_KEY.search(name) + else sanitize_evidence(item, _depth=_depth + 1) + ) + if len(items) > _MAX_ITEMS: + result["items_omitted"] = len(items) - _MAX_ITEMS + return result + if isinstance(value, (list, tuple, set, frozenset)): + items = list(value) + result = [sanitize_evidence(item, _depth=_depth + 1) for item in items[:_MAX_ITEMS]] + if len(items) > _MAX_ITEMS: + result.append({"items_omitted": len(items) - _MAX_ITEMS}) + return result + return sanitize_evidence(str(value), _depth=_depth + 1) + + +__all__ = [ + "ActionEvidenceUnavailable", + "ActionRecorder", + "ActionRecorderMetrics", + "sanitize_evidence", +] diff --git a/src/leapflow/evolution/artifact_store.py b/src/leapflow/evolution/artifact_store.py new file mode 100644 index 00000000..c676d378 --- /dev/null +++ b/src/leapflow/evolution/artifact_store.py @@ -0,0 +1,162 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Content-addressed storage for large evolution artifacts. + +The event store keeps bounded JSON facts. Generated source, model responses, +validation reports, and recordings live here and are referenced by digest. Writes +are atomic and immutable: writing identical bytes is idempotent; conflicting bytes +cannot share an address by construction. +""" +from __future__ import annotations + +import hashlib +import json +import os +import tempfile +from dataclasses import dataclass +from pathlib import Path +from typing import Any, Mapping + + +@dataclass(frozen=True) +class ArtifactRef: + """Stable reference to one immutable artifact.""" + + digest: str + size_bytes: int + media_type: str + privacy_class: str + relative_path: str + + @property + def artifact_id(self) -> str: + return f"sha256:{self.digest}" + + def to_dict(self) -> dict[str, Any]: + return { + "artifact_id": self.artifact_id, + "digest": self.digest, + "size_bytes": self.size_bytes, + "media_type": self.media_type, + "privacy_class": self.privacy_class, + "relative_path": self.relative_path, + } + + +class ArtifactIntegrityError(RuntimeError): + """Raised when bytes at a content address do not match its digest.""" + + +class ContentAddressedArtifactStore: + """Profile-scoped immutable SHA-256 artifact store.""" + + def __init__(self, root: Path | str) -> None: + self._root = Path(root).expanduser().resolve() + + @property + def root(self) -> Path: + return self._root + + def put_bytes( + self, + content: bytes, + *, + media_type: str = "application/octet-stream", + privacy_class: str = "system", + ) -> ArtifactRef: + """Store bytes atomically and return their content address.""" + payload = bytes(content) + digest = hashlib.sha256(payload).hexdigest() + relative = Path(digest[:2]) / digest + target = self._root / relative + target.parent.mkdir(parents=True, exist_ok=True) + if target.exists(): + self._verify_path(target, digest) + else: + fd, temporary_name = tempfile.mkstemp( + prefix=f".{digest}.", suffix=".tmp", dir=str(target.parent) + ) + temporary = Path(temporary_name) + try: + with os.fdopen(fd, "wb") as handle: + handle.write(payload) + handle.flush() + os.fsync(handle.fileno()) + # Another writer may have won with the same digest; replacing it is + # harmless because the bytes are content-addressed, but avoid a write + # when possible so readers never see needless inode churn. + if target.exists(): + temporary.unlink(missing_ok=True) + self._verify_path(target, digest) + else: + temporary.replace(target) + except Exception: + temporary.unlink(missing_ok=True) + raise + return ArtifactRef( + digest=digest, + size_bytes=len(payload), + media_type=str(media_type or "application/octet-stream"), + privacy_class=str(privacy_class or "system"), + relative_path=relative.as_posix(), + ) + + def put_text( + self, + content: str, + *, + media_type: str = "text/plain; charset=utf-8", + privacy_class: str = "system", + ) -> ArtifactRef: + return self.put_bytes( + str(content).encode("utf-8"), + media_type=media_type, + privacy_class=privacy_class, + ) + + def put_json( + self, + value: Mapping[str, Any] | list[Any], + *, + privacy_class: str = "system", + ) -> ArtifactRef: + text = json.dumps(value, ensure_ascii=False, sort_keys=True, indent=2, default=str) + return self.put_text( + text + "\n", + media_type="application/json", + privacy_class=privacy_class, + ) + + def resolve(self, ref: ArtifactRef | str) -> Path: + """Resolve a digest/ref below the store root without accepting a path.""" + digest = ( + ref.digest if isinstance(ref, ArtifactRef) else str(ref).removeprefix("sha256:") + ).lower() + if len(digest) != 64 or any(ch not in "0123456789abcdef" for ch in digest): + raise ValueError("artifact reference must be a SHA-256 digest") + return self._root / digest[:2] / digest + + def get_bytes(self, ref: ArtifactRef | str) -> bytes: + """Read an artifact and verify that its immutable address is still valid.""" + path = self.resolve(ref) + payload = path.read_bytes() + expected = ref.digest if isinstance(ref, ArtifactRef) else str(ref).removeprefix("sha256:") + actual = hashlib.sha256(payload).hexdigest() + if actual != expected.lower(): + raise ArtifactIntegrityError( + f"artifact digest mismatch: expected {expected.lower()}, got {actual}" + ) + return payload + + def get_text(self, ref: ArtifactRef | str, *, encoding: str = "utf-8") -> str: + return self.get_bytes(ref).decode(encoding) + + @staticmethod + def _verify_path(path: Path, expected_digest: str) -> None: + actual = hashlib.sha256(path.read_bytes()).hexdigest() + if actual != expected_digest: + raise ArtifactIntegrityError( + f"artifact digest mismatch: expected {expected_digest}, got {actual}" + ) + + +__all__ = ["ArtifactIntegrityError", "ArtifactRef", "ContentAddressedArtifactStore"] diff --git a/src/leapflow/evolution/outbox.py b/src/leapflow/evolution/outbox.py new file mode 100644 index 00000000..21ea9043 --- /dev/null +++ b/src/leapflow/evolution/outbox.py @@ -0,0 +1,233 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Bounded asynchronous outbox for evolution evidence. + +Ordinary read-only evidence never waits for DuckDB. Safety-critical action-start +facts use a durable barrier before the side effect. Queue saturation never silently +drops evidence: it falls back to the serialized writer thread and exposes counters. +""" +from __future__ import annotations + +import asyncio +import logging +from dataclasses import dataclass +from collections.abc import Awaitable, Callable +from time import perf_counter + +from leapflow.domain.evolution_event import EvolutionEvent, EvolutionEventStore +from leapflow.performance import LatencySummary, RollingLatency + +logger = logging.getLogger(__name__) + + +class EvolutionOutboxClosed(RuntimeError): + """Raised when evidence is published after shutdown began.""" + + +class EvolutionOutboxWriteError(RuntimeError): + """Raised when bounded persistence attempts cannot retain evidence.""" + + +@dataclass(frozen=True) +class OutboxMetrics: + queued: int + published: int + direct_fallbacks: int + failures: int + publish_latency: LatencySummary + write_latency: LatencySummary + + +class EvolutionEventOutbox: + """One profile-scoped event queue drained by a single background task.""" + + def __init__( + self, + store: EvolutionEventStore, + *, + max_events: int = 4096, + max_batch: int = 128, + flush_interval_s: float = 0.05, + critical_timeout_s: float = 1.0, + write_timeout_s: float = 2.0, + flush_timeout_s: float = 5.0, + max_write_attempts: int = 3, + retry_backoff_s: float = 0.05, + ) -> None: + self._store = store + self._queue: asyncio.Queue[EvolutionEvent] = asyncio.Queue( + maxsize=max(1, int(max_events)) + ) + self._max_batch = max(1, int(max_batch)) + self._flush_interval_s = max(0.001, float(flush_interval_s)) + self._critical_timeout_s = max(0.001, float(critical_timeout_s)) + self._write_timeout_s = max(0.001, float(write_timeout_s)) + self._flush_timeout_s = max(0.001, float(flush_timeout_s)) + self._max_write_attempts = max(1, int(max_write_attempts)) + self._retry_backoff_s = max(0.0, float(retry_backoff_s)) + self._task: asyncio.Task[None] | None = None + self._closed = False + self._published = 0 + self._direct_fallbacks = 0 + self._failures = 0 + self._write_error: BaseException | None = None + self._publish_latency = RollingLatency() + self._write_latency = RollingLatency() + + @property + def metrics(self) -> OutboxMetrics: + return OutboxMetrics( + queued=self._queue.qsize(), + published=self._published, + direct_fallbacks=self._direct_fallbacks, + failures=self._failures, + publish_latency=self._publish_latency.snapshot(), + write_latency=self._write_latency.snapshot(), + ) + + def start(self) -> None: + """Start the writer on the current event loop; idempotent.""" + if self._closed: + raise EvolutionOutboxClosed("evolution outbox is closed") + if self._task is None or self._task.done(): + self._task = asyncio.create_task(self._run(), name="evolution-event-outbox") + + async def publish(self, event: EvolutionEvent, *, critical: bool = False) -> None: + """Publish an event without silently losing it.""" + started_at = perf_counter() + try: + if self._closed: + raise EvolutionOutboxClosed("evolution outbox is closed") + if self._write_error is not None: + raise EvolutionOutboxWriteError( + "evolution outbox has an unpersisted event" + ) from self._write_error + if critical: + try: + inserted = await self._retry_write( + lambda: self._store.append(event), + timeout_s=self._critical_timeout_s, + ) + except EvolutionOutboxWriteError: + self._failures += 1 + raise + self._published += int(bool(inserted)) + return + self.start() + try: + self._queue.put_nowait(event) + except asyncio.QueueFull: + self._direct_fallbacks += 1 + try: + inserted = await self._retry_write(lambda: self._store.append(event)) + self._published += int(bool(inserted)) + except EvolutionOutboxWriteError: + self._failures += 1 + raise + finally: + self._publish_latency.observe((perf_counter() - started_at) * 1000.0) + + async def flush(self) -> None: + """Wait a bounded time for queued writes and surface any lost evidence.""" + if self._task is not None: + try: + await asyncio.wait_for(self._queue.join(), timeout=self._flush_timeout_s) + except asyncio.TimeoutError as exc: + raise EvolutionOutboxWriteError("evolution outbox flush timed out") from exc + if self._write_error is not None: + raise EvolutionOutboxWriteError("evolution outbox failed to persist evidence") from self._write_error + + async def close(self) -> None: + """Flush, stop the writer, and reject future publications.""" + if self._closed: + return + error: BaseException | None = None + try: + await self.flush() + except EvolutionOutboxWriteError as exc: + error = exc + finally: + self._closed = True + task = self._task + self._task = None + if task is not None and not task.done(): + task.cancel() + try: + await task + except asyncio.CancelledError: + pass + if error is not None: + raise error + + async def _run(self) -> None: + while True: + first = await self._queue.get() + batch = [first] + try: + deadline = asyncio.get_running_loop().time() + self._flush_interval_s + while len(batch) < self._max_batch: + remaining = deadline - asyncio.get_running_loop().time() + if remaining <= 0: + break + try: + batch.append(await asyncio.wait_for(self._queue.get(), remaining)) + except asyncio.TimeoutError: + break + try: + inserted = await self._retry_write( + lambda: self._store.append_many(batch) + ) + self._published += int(inserted) + except EvolutionOutboxWriteError as exc: + self._failures += len(batch) + if self._write_error is None: + self._write_error = exc.__cause__ or exc + logger.error("evolution outbox batch write exhausted retries", exc_info=True) + finally: + for _ in batch: + self._queue.task_done() + except asyncio.CancelledError: + # The owner calls flush before cancellation, so reaching this with a + # batch means an abnormal shutdown. Persist synchronously as a final + # best effort, then preserve cancellation semantics. + try: + await asyncio.to_thread(self._store.append_many, batch) + finally: + for _ in batch: + self._queue.task_done() + raise + + async def _retry_write( + self, + operation: Callable[[], bool | int], + *, + timeout_s: float | None = None, + ) -> bool | int: + delay = self._retry_backoff_s + timeout = self._write_timeout_s if timeout_s is None else timeout_s + last_error: BaseException | None = None + started_at = perf_counter() + try: + for attempt in range(self._max_write_attempts): + try: + pending: Awaitable[bool | int] = asyncio.to_thread(operation) + return await asyncio.wait_for(pending, timeout=timeout) + except (Exception, asyncio.TimeoutError) as exc: + last_error = exc + if attempt + 1 < self._max_write_attempts and delay > 0: + await asyncio.sleep(delay * (2**attempt)) + assert last_error is not None + if self._write_error is None: + self._write_error = last_error + raise EvolutionOutboxWriteError( + "evolution event persistence retries exhausted" + ) from last_error + finally: + self._write_latency.observe((perf_counter() - started_at) * 1000.0) + + +__all__ = [ + "EvolutionEventOutbox", + "EvolutionOutboxClosed", + "EvolutionOutboxWriteError", + "OutboxMetrics", +] diff --git a/src/leapflow/evolution/projection.py b/src/leapflow/evolution/projection.py new file mode 100644 index 00000000..f7d68054 --- /dev/null +++ b/src/leapflow/evolution/projection.py @@ -0,0 +1,526 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Checkpointed projections derived from the append-only evolution event log.""" +from __future__ import annotations + +import asyncio +import copy +from dataclasses import dataclass +from time import perf_counter +from typing import Any, Mapping, Protocol, runtime_checkable + +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionEventRecord +from leapflow.performance import LatencySummary, RollingLatency + +_PROJECTION_NAME = "evolution.board.v2" +_MAX_ROWS = 200 +_VERDICT_ACTIONS = ("absorb", "rebind", "acquire", "escalate") + + +@dataclass(frozen=True) +class ProjectionMetrics: + run_latency: LatencySummary + + +@runtime_checkable +class ProjectionStore(Protocol): + """Event and checkpoint operations needed by the projection runner.""" + + def read(self, **kwargs: Any) -> list[EvolutionEventRecord]: ... + + def load_projection(self, **kwargs: Any) -> tuple[int, dict[str, Any]] | None: ... + + def save_projection(self, **kwargs: Any) -> None: ... + + def delete_projection(self, **kwargs: Any) -> None: ... + + +class EvolutionProjectionRunner: + """Incrementally materialize the LeapBoard evolution view from facts.""" + + def __init__(self, store: ProjectionStore) -> None: + self._store = store + self._lock = asyncio.Lock() + self._run_latency = RollingLatency() + + @property + def metrics(self) -> ProjectionMetrics: + return ProjectionMetrics(run_latency=self._run_latency.snapshot()) + + async def project_session( + self, + *, + profile_id: str, + session_id: str, + rebuild: bool = False, + ) -> dict[str, Any]: + if not session_id: + raise ValueError("session_id is required for a session projection") + started_at = perf_counter() + try: + return await self._project( + profile_id=profile_id, + session_id=session_id, + scope_key=f"session:{session_id}", + rebuild=rebuild, + ) + finally: + self._run_latency.observe((perf_counter() - started_at) * 1000.0) + + async def project_aggregate( + self, + *, + profile_id: str, + rebuild: bool = False, + ) -> dict[str, Any]: + """Build the explicitly cross-session profile view.""" + started_at = perf_counter() + try: + return await self._project( + profile_id=profile_id, + session_id="", + scope_key="aggregate:any_session", + rebuild=rebuild, + ) + finally: + self._run_latency.observe((perf_counter() - started_at) * 1000.0) + + async def _project( + self, + *, + profile_id: str, + session_id: str, + scope_key: str, + rebuild: bool, + ) -> dict[str, Any]: + async with self._lock: + if rebuild: + await asyncio.to_thread( + self._store.delete_projection, + projection_name=_PROJECTION_NAME, + profile_id=profile_id, + scope_key=scope_key, + ) + checkpoint = 0 + state = self._empty_state(profile_id, session_id, scope_key) + else: + saved = await asyncio.to_thread( + self._store.load_projection, + projection_name=_PROJECTION_NAME, + profile_id=profile_id, + scope_key=scope_key, + ) + if saved is None: + checkpoint = 0 + state = self._empty_state(profile_id, session_id, scope_key) + else: + checkpoint, state = saved + + cursor = checkpoint + while True: + records = await asyncio.to_thread( + self._store.read, + profile_id=profile_id, + session_id=session_id, + after_sequence=cursor, + limit=5000, + ) + if not records: + break + for record in records: + self._apply(state, record) + cursor = records[-1].sequence + if len(records) < 5000: + break + + state["last_sequence"] = cursor + await asyncio.to_thread( + self._store.save_projection, + projection_name=_PROJECTION_NAME, + profile_id=profile_id, + scope_key=scope_key, + last_sequence=cursor, + state=state, + ) + return self._present(state) + + @staticmethod + def _empty_state(profile_id: str, session_id: str, scope_key: str) -> dict[str, Any]: + return { + "projection": _PROJECTION_NAME, + "profile_id": profile_id, + "scope": "session" if session_id else "aggregate", + "scope_key": scope_key, + "session_id": session_id, + "last_sequence": 0, + "event_count": 0, + "action_count": 0, + "failed_action_count": 0, + "environment_count": 0, + "teacher_failure_count": 0, + "no_op_count": 0, + "verdict_counts": {action: 0 for action in _VERDICT_ACTIONS}, + "episodes": {}, + "proposals": {}, + "verdicts": [], + "knowledge": [], + "provider_bindings": [], + "proposal_candidates": [], + "human_escalations": [], + "resolutions": [], + "environment": [], + "timeline": [], + } + + @staticmethod + def _apply(state: dict[str, Any], record: EvolutionEventRecord) -> None: + event = record.event + event_type = event.event_type + payload = event.to_dict()["payload"] + state["event_count"] = int(state.get("event_count") or 0) + 1 + state["last_sequence"] = record.sequence + + proposal_state = payload.get("proposal_state") + if isinstance(proposal_state, Mapping): + proposal = dict(proposal_state) + proposal_id = str(proposal.get("proposal_id") or event.context.proposal_id) + if proposal_id: + state["proposals"][proposal_id] = proposal + EvolutionProjectionRunner._append_bounded( + state["timeline"], + { + "sequence": record.sequence, + "title": f"proposal → {proposal.get('status', '').lower()}", + "summary": str(payload.get("reason") or proposal_id), + "severity": "notable" + if proposal.get("status") in {"FAILED", "QUARANTINED", "REJECTED"} + else "info", + }, + ) + + if event_type == EvolutionEventType.ACTION_STARTED: + state["action_count"] = int(state.get("action_count") or 0) + 1 + elif event_type == EvolutionEventType.ACTION_FAILED: + state["failed_action_count"] = int(state.get("failed_action_count") or 0) + 1 + elif event_type == EvolutionEventType.ENVIRONMENT_OBSERVED: + state["environment_count"] = int(state.get("environment_count") or 0) + 1 + EvolutionProjectionRunner._append_bounded( + state["environment"], + { + "observation_id": event.context.observation_id, + "kind": payload.get("kind", ""), + "app_id": payload.get("app_id", ""), + "summary": EvolutionProjectionRunner._environment_summary(payload), + "observed_at": event.occurred_at, + }, + ) + elif event_type == EvolutionEventType.SESSION_FINALIZED: + episode_id = str(payload.get("episode_id") or event.context.correlation_id) + state["episodes"][episode_id] = { + "episode_id": episode_id, + "opened_at": event.occurred_at, + "closed_at": 0.0, + "status": "teacher_queued", + "driver": "session", + "capability": "", + "policy_action": "", + "mutation_action": "none", + "gap_closure": "not_applicable", + "verification_tier": "teacher_pending", + "artifact_id": "", + } + EvolutionProjectionRunner._append_bounded( + state["timeline"], + { + "sequence": record.sequence, + "title": "session → teacher", + "summary": f"{event.context.session_id} finalized", + "severity": "info", + }, + ) + elif event_type == EvolutionEventType.TEACHER_GRADED: + episode = state["episodes"].setdefault( + event.context.correlation_id, + {"episode_id": event.context.correlation_id, "opened_at": event.occurred_at}, + ) + episode.update( + { + "closed_at": event.occurred_at, + "status": "graded", + "artifact_id": str(payload.get("artifact_id") or ""), + "verification_tier": "teacher_hindsight", + } + ) + elif event_type == EvolutionEventType.TEACHER_VERDICT_RECORDED: + action = str(payload.get("action") or "") + if action in _VERDICT_ACTIONS: + state["verdict_counts"][action] = int( + state["verdict_counts"].get(action) or 0 + ) + 1 + verdict = { + "verdict_id": str(payload.get("verdict_id") or event.context.decision_id), + "episode_id": event.context.correlation_id, + "action": action, + "capability": str(payload.get("capability") or ""), + "knowledge": str(payload.get("knowledge") or ""), + "rationale": str(payload.get("rationale") or ""), + "confidence": float(payload.get("confidence") or 0.0), + "target": str(payload.get("target") or ""), + "artifact_id": event.context.artifact_id, + "observed_at": event.occurred_at, + } + EvolutionProjectionRunner._append_bounded(state["verdicts"], verdict) + if action == "absorb": + EvolutionProjectionRunner._upsert_capability( + state["knowledge"], + { + "verdict_id": verdict["verdict_id"], + "capability": verdict["capability"], + "knowledge": verdict["knowledge"], + "confidence": verdict["confidence"], + "episode_id": verdict["episode_id"], + "created_at": verdict["observed_at"], + }, + ) + elif action == "rebind": + EvolutionProjectionRunner._upsert_capability( + state["provider_bindings"], + { + "verdict_id": verdict["verdict_id"], + "capability": verdict["capability"], + "plugin_id": verdict["target"], + "knowledge": verdict["knowledge"], + "confidence": verdict["confidence"], + "episode_id": verdict["episode_id"], + "created_at": verdict["observed_at"], + }, + ) + elif action == "acquire": + EvolutionProjectionRunner._append_bounded( + state["proposal_candidates"], + { + "capability": verdict["capability"], + "confidence": verdict["confidence"], + "episode_id": verdict["episode_id"], + }, + ) + elif action == "escalate": + EvolutionProjectionRunner._append_bounded( + state["human_escalations"], + { + "capability": verdict["capability"], + "rationale": verdict["rationale"], + "confidence": verdict["confidence"], + "episode_id": verdict["episode_id"], + }, + ) + episode = state["episodes"].setdefault( + event.context.correlation_id, + {"episode_id": event.context.correlation_id, "opened_at": event.occurred_at}, + ) + episode.update( + { + "closed_at": event.occurred_at, + "status": "committed" if action in {"absorb", "rebind"} else "open", + "driver": "world_model", + "capability": verdict["capability"], + "policy_action": action, + "mutation_action": "none", + "gap_closure": "not_applicable", + "verification_tier": "teacher_hindsight", + "artifact_id": event.context.artifact_id, + } + ) + EvolutionProjectionRunner._append_bounded( + state["timeline"], + { + "sequence": record.sequence, + "title": f"world_model → {action}", + "summary": verdict["capability"] or verdict["knowledge"], + "severity": "notable" if action in {"acquire", "escalate"} else "info", + }, + ) + elif event_type == EvolutionEventType.KNOWLEDGE_RETRACTED: + capability = str(payload.get("capability") or "") + state["knowledge"] = [ + item for item in state["knowledge"] if item.get("capability") != capability + ] + state["provider_bindings"] = [ + item + for item in state["provider_bindings"] + if item.get("capability") != capability + ] + EvolutionProjectionRunner._append_bounded( + state["timeline"], + { + "sequence": record.sequence, + "title": "knowledge → retracted", + "summary": capability, + "severity": "info", + }, + ) + elif event_type == EvolutionEventType.REQUIREMENT_RESOLVED: + resolution = { + "requirement_id": event.context.requirement_id, + "verdict_id": event.context.decision_id, + "proposal_id": event.context.proposal_id, + "capability": str( + dict(payload.get("requirement") or {}).get("capability") or "" + ), + "outcome": str(payload.get("outcome") or ""), + "reason": str(payload.get("reason") or ""), + "selected_plugin_id": str( + dict(payload.get("resolution") or {}).get("selected_plugin_id") or "" + ), + "selected_tool_name": str( + dict(payload.get("resolution") or {}).get("selected_tool_name") or "" + ), + "observed_at": event.occurred_at, + } + EvolutionProjectionRunner._append_bounded(state["resolutions"], resolution) + if resolution["outcome"] in {"no_op", "satisfied"}: + state["no_op_count"] = int(state.get("no_op_count") or 0) + 1 + EvolutionProjectionRunner._append_bounded( + state["timeline"], + { + "sequence": record.sequence, + "title": f"requirement → {resolution['outcome']}", + "summary": resolution["capability"] or resolution["reason"], + "severity": "info", + }, + ) + elif event_type == EvolutionEventType.TEACHER_JOB_FAILED: + state["teacher_failure_count"] = int(state.get("teacher_failure_count") or 0) + 1 + episode = state["episodes"].setdefault( + event.context.correlation_id, + {"episode_id": event.context.correlation_id, "opened_at": event.occurred_at}, + ) + episode.update( + { + "closed_at": event.occurred_at, + "status": "open" if payload.get("retryable") else "aborted", + "verification_tier": "teacher_failed", + } + ) + EvolutionProjectionRunner._append_bounded( + state["timeline"], + { + "sequence": record.sequence, + "title": "teacher → failed", + "summary": str(payload.get("error_type") or "teacher failure"), + "severity": "notable", + }, + ) + + @staticmethod + def _append_bounded(rows: list[dict[str, Any]], item: dict[str, Any]) -> None: + rows.append(item) + if len(rows) > _MAX_ROWS: + del rows[: len(rows) - _MAX_ROWS] + + @staticmethod + def _upsert_capability(rows: list[dict[str, Any]], item: dict[str, Any]) -> None: + capability = str(item.get("capability") or "") + rows[:] = [row for row in rows if str(row.get("capability") or "") != capability] + EvolutionProjectionRunner._append_bounded(rows, item) + + @staticmethod + def _environment_summary(payload: Mapping[str, Any]) -> str: + kind = str(payload.get("kind") or "environment") + app_id = str(payload.get("app_id") or "") + removed = list(payload.get("removed_affordances") or ()) + if removed: + return f"{app_id}: removed {', '.join(str(item) for item in removed)}" + outcome = str(payload.get("outcome") or "UNKNOWN") + if kind == "outcome": + return f"{app_id}: {outcome}" + return f"{app_id}: {kind}" + + @staticmethod + def _present(state: Mapping[str, Any]) -> dict[str, Any]: + snapshot = copy.deepcopy(dict(state)) + episodes = sorted( + (dict(item) for item in dict(snapshot.pop("episodes", {})).values()), + key=lambda item: float(item.get("opened_at") or 0.0), + reverse=True, + ) + verdict_counts = dict(snapshot.get("verdict_counts") or {}) + verdicts = list(snapshot.get("verdicts") or []) + proposals = sorted( + (dict(item) for item in dict(snapshot.pop("proposals", {})).values()), + key=lambda item: float(item.get("updated_at") or item.get("created_at") or 0.0), + reverse=True, + ) + summary = { + "episode_count": len(episodes), + "proposal_count": len(proposals), + "event_count": int(snapshot.get("event_count") or 0), + "action_count": int(snapshot.get("action_count") or 0), + "failed_action_count": int(snapshot.get("failed_action_count") or 0), + "environment_count": int(snapshot.get("environment_count") or 0), + "verdict_count": sum(int(value or 0) for value in verdict_counts.values()), + "teacher_failure_count": int(snapshot.get("teacher_failure_count") or 0), + "no_op_count": int(snapshot.get("no_op_count") or 0), + "by_action": verdict_counts, + } + summary["attention"] = bool( + summary["failed_action_count"] + or summary["teacher_failure_count"] + or verdict_counts.get("escalate") + ) + snapshot.update( + { + "summary": summary, + "episodes": episodes, + "proposals": proposals, + "verdicts": verdicts, + "mutation_matrix": [ + { + "driver": "world_model", + "capability": item.get("capability", ""), + "policy_action": item.get("action", ""), + "autonomy_level": "proposal_only", + "mutation_action": "none", + "registry_delta": "0", + "lifecycle_status": "not_started", + "gap_closure": "not_applicable", + "verification_tier": "teacher_hindsight", + } + for item in verdicts + ] + + [ + { + "driver": str(item.get("source") or "proposal"), + "capability": str( + (item.get("requirements") or [{}])[0].get("capability") or "" + ), + "policy_action": str( + dict(item.get("policy_decision") or {}).get("action") or "" + ), + "autonomy_level": str( + dict(item.get("policy_decision") or {}).get("autonomy_level") + or "" + ), + "mutation_action": "install" + if item.get("status") in {"INSTALLED", "PROBATION", "VERIFIED"} + else "none", + "registry_delta": "1" + if item.get("status") in {"INSTALLED", "PROBATION", "VERIFIED"} + else "0", + "lifecycle_status": str(item.get("status") or ""), + "gap_closure": "closed" + if item.get("status") == "VERIFIED" + else "open", + "verification_tier": str( + dict(item.get("trust_state") or {}).get("level") or "DRAFT" + ), + } + for item in proposals + ], + "degraded": not episodes, + } + ) + return snapshot + + +__all__ = ["EvolutionProjectionRunner", "ProjectionMetrics", "ProjectionStore"] diff --git a/src/leapflow/evolution/session_finalizer.py b/src/leapflow/evolution/session_finalizer.py new file mode 100644 index 00000000..2667326f --- /dev/null +++ b/src/leapflow/evolution/session_finalizer.py @@ -0,0 +1,194 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Durable session boundaries for cold-path evolution work.""" +from __future__ import annotations + +import asyncio +from dataclasses import asdict, dataclass +from typing import Any + +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionEventRecord, EvolutionEventStore + + +@dataclass(frozen=True) +class SessionFinalization: + """Result of sealing one session evidence window.""" + + session_id: str + from_sequence: int + through_sequence: int + episode_id: str = "" + job_id: str = "" + evidence_count: int = 0 + + @property + def queued(self) -> bool: + return bool(self.job_id) + + def to_dict(self) -> dict[str, Any]: + return {**asdict(self), "queued": self.queued} + + +class SessionFinalizer: + """Flush the hot path, seal a session slice, and enqueue one teacher job.""" + + def __init__(self, store: EvolutionEventStore, outbox: Any) -> None: + self._store = store + self._outbox = outbox + self._lock = asyncio.Lock() + + async def finalize( + self, + *, + profile_id: str, + workspace_id: str, + session_id: str, + session_generation: int = 0, + reason: str = "manual", + goal: str = "", + model: str = "", + ) -> SessionFinalization: + """Atomically queue exactly the evidence not finalized before this call.""" + if not session_id: + raise ValueError("session_id is required") + async with self._lock: + await self._outbox.flush() + from_sequence = await asyncio.to_thread( + self._store.last_finalized_sequence, + profile_id=profile_id, + session_id=session_id, + session_generation=session_generation, + ) + through_sequence = await asyncio.to_thread( + self._store.latest_evidence_sequence, + profile_id=profile_id, + session_id=session_id, + session_generation=session_generation, + ) + if through_sequence <= from_sequence: + return SessionFinalization( + session_id=session_id, + from_sequence=from_sequence, + through_sequence=through_sequence, + ) + evidence = await self._read_window( + profile_id=profile_id, + session_id=session_id, + session_generation=session_generation, + after_sequence=from_sequence, + through_sequence=through_sequence, + ) + source_types = { + EvolutionEventType.ACTION_STARTED, + EvolutionEventType.ACTION_COMPLETED, + EvolutionEventType.ACTION_FAILED, + EvolutionEventType.ENVIRONMENT_OBSERVED, + } + evidence = [record for record in evidence if record.event.event_type in source_types] + if not evidence: + return SessionFinalization( + session_id=session_id, + from_sequence=from_sequence, + through_sequence=through_sequence, + ) + observed_workspaces = { + record.event.context.workspace_id + for record in evidence + if record.event.context.workspace_id + } + if len(observed_workspaces) > 1: + raise ValueError(f"session {session_id!r} spans multiple workspaces") + if workspace_id and observed_workspaces - {workspace_id}: + raise ValueError( + f"session {session_id!r} contains evidence from another workspace" + ) + if not workspace_id and observed_workspaces: + workspace_id = next(iter(observed_workspaces)) + if not goal: + goal = self._goal_from_records(evidence) + episode_id, job_id = await asyncio.to_thread( + self._store.finalize_session, + profile_id=profile_id, + workspace_id=workspace_id, + session_id=session_id, + session_generation=session_generation, + from_sequence=from_sequence, + through_sequence=through_sequence, + reason=reason, + goal=goal, + model=model, + ) + return SessionFinalization( + session_id=session_id, + from_sequence=from_sequence, + through_sequence=through_sequence, + episode_id=episode_id, + job_id=job_id, + evidence_count=len(evidence), + ) + + async def finalize_pending_sessions( + self, + *, + profile_id: str = "", + reason: str = "shutdown", + model: str = "", + ) -> list[SessionFinalization]: + """Seal all sessions with new evidence, used only at daemon shutdown.""" + sessions = await asyncio.to_thread( + self._store.evidence_sessions, + profile_id=profile_id, + ) + results: list[SessionFinalization] = [] + for item in sessions: + result = await self.finalize( + profile_id=str(item.get("profile_id") or profile_id), + workspace_id=str(item.get("workspace_id") or ""), + session_id=str(item.get("session_id") or ""), + session_generation=int(item.get("session_generation") or 0), + reason=reason, + model=model, + ) + if result.queued: + results.append(result) + return results + + async def _read_window( + self, + *, + profile_id: str, + session_id: str, + session_generation: int, + after_sequence: int, + through_sequence: int, + ) -> list[EvolutionEventRecord]: + records: list[EvolutionEventRecord] = [] + cursor = after_sequence + while cursor < through_sequence: + page = await asyncio.to_thread( + self._store.read, + profile_id=profile_id, + session_id=session_id, + session_generation=session_generation, + after_sequence=cursor, + through_sequence=through_sequence, + limit=5000, + ) + if not page: + break + records.extend(page) + cursor = page[-1].sequence + return records + + @staticmethod + def _goal_from_records(records: list[EvolutionEventRecord]) -> str: + for record in reversed(records): + if record.event.event_type != EvolutionEventType.ACTION_STARTED: + continue + goal = str(record.event.payload.get("goal") or "").strip() + if goal: + return goal + return "" + + +__all__ = ["SessionFinalization", "SessionFinalizer"] diff --git a/src/leapflow/evolution/sink.py b/src/leapflow/evolution/sink.py index 196a5f03..9cc6a7c8 100644 --- a/src/leapflow/evolution/sink.py +++ b/src/leapflow/evolution/sink.py @@ -3,7 +3,7 @@ The probe's contract is "accept and return", so ``record`` only appends to a bounded deque. Persistence happens when someone calls :meth:`flush` -- the daemon's monitor -cycle, or process exit -- which keeps a file write out of the plugin registry's +cycle, or process exit -- which keeps an event-store write out of the plugin registry's version bump and the trust ledger's level transition. The buffer is bounded and drops *oldest* on overflow. That is the right direction @@ -91,6 +91,12 @@ def pending(self) -> tuple[EvolutionTrace, ...]: """Buffered traces not yet flushed, for a reader that wants live state.""" return tuple(self._buffer) + def list_traces(self, *, limit: int = 200) -> list[dict[str, Any]]: + """Read persisted traces through the configured event-store adapter.""" + if self._store is None or not hasattr(self._store, "list_traces"): + return [] + return [dict(item) for item in self._store.list_traces(limit=limit)] + @property def stats(self) -> dict[str, int]: return { diff --git a/src/leapflow/evolution/teacher_worker.py b/src/leapflow/evolution/teacher_worker.py new file mode 100644 index 00000000..35216ae8 --- /dev/null +++ b/src/leapflow/evolution/teacher_worker.py @@ -0,0 +1,698 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Durable daemon worker for one-call hindsight grading.""" +from __future__ import annotations + +import asyncio +import logging +import uuid +from dataclasses import asdict, dataclass, replace +from time import perf_counter +from typing import Any, Callable, Mapping, Protocol, Sequence, runtime_checkable + +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent, EvolutionEventRecord, content_hash +from leapflow.evolution.artifact_store import ArtifactRef +from leapflow.performance import LatencySummary, RollingLatency +from leapflow.security.redact import redact_sensitive_text + +logger = logging.getLogger(__name__) + +_INTERNAL_DEFECTS = ( + AttributeError, + TypeError, + NameError, + KeyError, + IndexError, + ImportError, + AssertionError, + NotImplementedError, +) + + +@runtime_checkable +class Teacher(Protocol): + """One-call hindsight evaluator used by the durable worker.""" + + async def grade_and_propose( + self, + trajectory: list[dict[str, Any]], + goal: str = "", + *, + degraded_capabilities: Sequence[Mapping[str, Any]] = (), + raise_on_error: bool = False, + ) -> Any: ... + + +@runtime_checkable +class TeacherWorkStore(Protocol): + """Persistence operations required by the durable teacher worker.""" + + def claim_teacher_job(self, **kwargs: Any) -> dict[str, Any] | None: ... + + def renew_teacher_job(self, job_id: str, **kwargs: Any) -> bool: ... + + def complete_teacher_job(self, job_id: str, **kwargs: Any) -> bool: ... + + def fail_teacher_job(self, job_id: str, error: str, **kwargs: Any) -> bool: ... + + def teacher_job(self, job_id: str) -> dict[str, Any] | None: ... + + def read(self, **kwargs: Any) -> list[EvolutionEventRecord]: ... + + +@runtime_checkable +class ArtifactWriter(Protocol): + """Minimal CAS interface used for teacher outputs.""" + + def put_json( + self, + value: Mapping[str, Any] | list[Any], + *, + privacy_class: str = "system", + ) -> ArtifactRef: ... + + +@dataclass(frozen=True) +class TeacherWorkerMetrics: + claim_latency: LatencySummary + job_latency: LatencySummary + + +@dataclass(frozen=True) +class TeacherJobOutcome: + """Observable result of one worker attempt.""" + + job_id: str + status: str + episode_id: str = "" + artifact_id: str = "" + verdict_count: int = 0 + grade_count: int = 0 + error: str = "" + + def to_dict(self) -> dict[str, Any]: + return asdict(self) + + +@dataclass(frozen=True) +class _AcquisitionPlan: + verdict_id: str + requirement: Any + outcome: str + reason: str + resolution: Mapping[str, Any] + proposal_id: str = "" + proposal_event: EvolutionEvent | None = None + + +class DurableTeacherWorker: + """Lease and grade finalized sessions without blocking daemon RPC handling.""" + + def __init__( + self, + *, + store: TeacherWorkStore, + artifact_store: ArtifactWriter, + teacher: Teacher, + profile_id: str = "", + producer_version: str = "", + poll_interval_s: float = 1.0, + lease_seconds: float = 120.0, + teacher_timeout_s: float = 180.0, + max_attempts: int = 3, + retry_backoff_s: float = 5.0, + proposal_queue: Any = None, + acquisition_resolver: Callable[[Any, Mapping[str, Any]], Mapping[str, Any]] | None = None, + authorising_origins: Sequence[str] = (), + degraded_capabilities: Callable[[], Sequence[Mapping[str, Any]]] | None = None, + knowledge_projection: Any = None, + ) -> None: + self._store = store + self._artifact_store = artifact_store + self._teacher = teacher + self._profile_id = str(profile_id) + self._producer_version = str(producer_version) + self._poll_interval_s = max(0.05, float(poll_interval_s)) + self._lease_seconds = max(3.0, float(lease_seconds)) + self._teacher_timeout_s = max(0.1, float(teacher_timeout_s)) + self._max_attempts = max(1, int(max_attempts)) + self._retry_backoff_s = max(0.0, float(retry_backoff_s)) + self._proposal_queue = proposal_queue + self._acquisition_resolver = acquisition_resolver + self._authorising_origins = tuple( + str(origin) for origin in authorising_origins if str(origin) + ) + self._degraded_capabilities = degraded_capabilities + self._knowledge_projection = knowledge_projection + self._lease_owner = f"teacher-{uuid.uuid4().hex}" + self._wake = asyncio.Event() + self._task: asyncio.Task[None] | None = None + self._closed = False + self._claim_latency = RollingLatency() + self._job_latency = RollingLatency() + + @property + def metrics(self) -> TeacherWorkerMetrics: + return TeacherWorkerMetrics( + claim_latency=self._claim_latency.snapshot(), + job_latency=self._job_latency.snapshot(), + ) + + def start(self) -> None: + if self._closed: + raise RuntimeError("teacher worker is closed") + if self._task is None or self._task.done(): + self._task = asyncio.create_task(self._run(), name="evolution-teacher-worker") + + def wake(self) -> None: + if not self._closed: + self._wake.set() + + async def close(self) -> None: + if self._closed: + return + self._closed = True + self._wake.set() + task = self._task + self._task = None + if task is not None and not task.done(): + task.cancel() + try: + await task + except asyncio.CancelledError: + pass + + async def wait_for_job(self, job_id: str, *, timeout_s: float = 180.0) -> dict[str, Any]: + """Wait for a job terminal state without holding a DuckDB connection.""" + deadline = asyncio.get_running_loop().time() + max(0.1, float(timeout_s)) + while True: + job = await asyncio.to_thread(self._store.teacher_job, job_id) + if job is None: + raise KeyError(f"teacher job not found: {job_id}") + if str(job.get("status")) in {"COMPLETED", "FAILED_FINAL"}: + return job + if asyncio.get_running_loop().time() >= deadline: + return job + self.wake() + await asyncio.sleep(min(0.1, self._poll_interval_s)) + + async def run_once(self) -> TeacherJobOutcome | None: + """Claim and process one due job, returning ``None`` when the queue is idle.""" + claim_started_at = perf_counter() + try: + job = await asyncio.to_thread( + self._store.claim_teacher_job, + lease_owner=self._lease_owner, + profile_id=self._profile_id, + lease_seconds=self._lease_seconds, + ) + finally: + self._claim_latency.observe((perf_counter() - claim_started_at) * 1000.0) + if job is None: + return None + + job_started_at = perf_counter() + heartbeat = asyncio.create_task( + self._heartbeat(str(job["job_id"])), + name=f"teacher-lease-{job['job_id']}", + ) + try: + return await self._process(job) + except Exception as exc: + attempts = int(job.get("attempts") or 1) + retryable = not isinstance(exc, _INTERNAL_DEFECTS) and attempts < self._max_attempts + retry_after = self._retry_backoff_s * (2 ** max(0, attempts - 1)) + error_text = redact_sensitive_text(str(exc), force=True)[:2000] + failure_event = EvolutionEvent.create( + EvolutionEventType.TEACHER_JOB_FAILED, + context=EvolutionContext( + profile_id=str(job.get("profile_id") or ""), + workspace_id=str(job.get("workspace_id") or ""), + session_id=str(job.get("session_id") or ""), + session_generation=int(job.get("session_generation") or 0), + correlation_id=str(job.get("episode_id") or ""), + ), + payload={ + "job_id": str(job["job_id"]), + "attempt": attempts, + "retryable": retryable, + "error_type": type(exc).__name__, + "error": error_text, + }, + producer="world_model.teacher_worker", + producer_version=self._producer_version, + privacy_class="session", + dedup_key=f"teacher.job_failed:{job['job_id']}:{attempts}", + ) + try: + await asyncio.to_thread( + self._store.fail_teacher_job, + str(job["job_id"]), + error_text, + lease_owner=self._lease_owner, + retryable=retryable, + retry_after_s=retry_after, + events=(failure_event,), + ) + except Exception: + logger.error( + "teacher job failure state could not be persisted job=%s", + job["job_id"], + exc_info=True, + ) + logger.warning( + "teacher job failed job=%s retryable=%s", + job["job_id"], + retryable, + exc_info=True, + ) + return TeacherJobOutcome( + job_id=str(job["job_id"]), + episode_id=str(job.get("episode_id") or ""), + status="FAILED_RETRYABLE" if retryable else "FAILED_FINAL", + error=str(exc), + ) + finally: + heartbeat.cancel() + try: + await heartbeat + except asyncio.CancelledError: + pass + self._job_latency.observe((perf_counter() - job_started_at) * 1000.0) + + async def _process(self, job: Mapping[str, Any]) -> TeacherJobOutcome: + records = await self._read_window(job) + trajectory = self._trajectory(records) + verdict = await asyncio.wait_for( + self._teacher.grade_and_propose( + trajectory, + str(job.get("goal") or ""), + degraded_capabilities=self._collect_degraded_capabilities(), + raise_on_error=True, + ), + timeout=self._teacher_timeout_s, + ) + grades = tuple(getattr(verdict, "grades", ()) or ()) + verdicts = tuple(getattr(verdict, "verdicts", ()) or ()) + acquisition_plans = self._plan_acquisitions(verdicts, job) + proposal_ids = [plan.proposal_id for plan in acquisition_plans if plan.proposal_id] + result_payload = { + "job_id": str(job["job_id"]), + "episode_id": str(job["episode_id"]), + "grades": [ + { + "experience_id": str(getattr(grade, "experience_id", "")), + "advantage": float(getattr(grade, "advantage", 0.0)), + "is_forking": bool(getattr(grade, "is_forking", False)), + "grade_label": str(getattr(grade, "grade_label", "")), + } + for grade in grades + ], + "verdicts": [item.to_dict() for item in verdicts], + "proposal_ids": proposal_ids, + "acquisition_resolutions": [ + { + "verdict_id": plan.verdict_id, + "requirement": plan.requirement.to_dict(), + "outcome": plan.outcome, + "reason": plan.reason, + "resolution": dict(plan.resolution), + "proposal_id": plan.proposal_id, + } + for plan in acquisition_plans + ], + "raw_payload": dict(getattr(verdict, "raw_payload", {}) or {}), + } + artifact = await asyncio.to_thread( + self._artifact_store.put_json, + result_payload, + privacy_class="session", + ) + prompt_hash = content_hash( + {"goal": str(job.get("goal") or ""), "trajectory": trajectory} + ) + context = EvolutionContext( + profile_id=str(job["profile_id"]), + workspace_id=str(job.get("workspace_id") or ""), + session_id=str(job["session_id"]), + session_generation=int(job.get("session_generation") or 0), + artifact_id=artifact.artifact_id, + correlation_id=str(job["episode_id"]), + ) + finalized = await asyncio.to_thread( + self._store.read, + profile_id=context.profile_id, + session_id=context.session_id, + correlation_id=context.correlation_id, + event_type=EvolutionEventType.SESSION_FINALIZED, + limit=1, + ) + causation_id = finalized[0].event.event_id if finalized else "" + graded_event = EvolutionEvent.create( + EvolutionEventType.TEACHER_GRADED, + context=context.with_ids(causation_id=causation_id), + payload={ + "job_id": str(job["job_id"]), + "episode_id": str(job["episode_id"]), + "grade_count": len(grades), + "verdict_count": len(verdicts), + "proposal_ids": proposal_ids, + "artifact_id": artifact.artifact_id, + "prompt_hash": prompt_hash, + }, + producer="world_model.teacher_worker", + producer_version=self._producer_version, + privacy_class="session", + dedup_key=f"teacher.graded:{job['job_id']}", + ) + events = [graded_event] + verdict_events: dict[str, EvolutionEvent] = {} + for item in verdicts: + verdict_event = EvolutionEvent.create( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + context=context.with_ids( + decision_id=str(item.verdict_id), + causation_id=graded_event.event_id, + ), + payload=item.to_dict(), + producer="world_model.teacher_worker", + producer_version=self._producer_version, + privacy_class="session", + dedup_key=f"teacher.verdict_recorded:{item.verdict_id}", + ) + verdict_events[str(item.verdict_id)] = verdict_event + events.append(verdict_event) + for plan in acquisition_plans: + verdict_event = verdict_events.get(plan.verdict_id) + causation_id = verdict_event.event_id if verdict_event is not None else graded_event.event_id + resolution_event = EvolutionEvent.create( + EvolutionEventType.REQUIREMENT_RESOLVED, + context=context.with_ids( + requirement_id=str(plan.requirement.requirement_id), + decision_id=plan.verdict_id, + proposal_id=plan.proposal_id, + causation_id=causation_id, + ), + payload={ + "requirement": plan.requirement.to_dict(), + "outcome": plan.outcome, + "reason": plan.reason, + "resolution": dict(plan.resolution), + "proposal_id": plan.proposal_id, + }, + producer="world_model.teacher_worker", + producer_version=self._producer_version, + privacy_class="session", + dedup_key=f"requirement.resolved:{job['job_id']}:{plan.verdict_id}", + ) + events.append(resolution_event) + if plan.proposal_event is not None: + events.append( + replace( + plan.proposal_event, + context=plan.proposal_event.context.with_ids( + causation_id=resolution_event.event_id + ), + ) + ) + completed = await asyncio.to_thread( + self._store.complete_teacher_job, + str(job["job_id"]), + lease_owner=self._lease_owner, + events=events, + prompt_hash=prompt_hash, + result_artifact_id=artifact.artifact_id, + ) + if not completed: + raise RuntimeError(f"teacher job lease lost: {job['job_id']}") + await self._after_commit() + return TeacherJobOutcome( + job_id=str(job["job_id"]), + episode_id=str(job["episode_id"]), + status="COMPLETED", + artifact_id=artifact.artifact_id, + verdict_count=len(verdicts), + grade_count=len(grades), + ) + + def _plan_acquisitions( + self, + verdicts: Sequence[Any], + job: Mapping[str, Any], + ) -> tuple[_AcquisitionPlan, ...]: + """Resolve each acquisition and prepare any proposal for atomic commit.""" + from leapflow.domain.evolution_intent import WORLD_MODEL_ORIGIN + from leapflow.learning.capability_gap_detector import CapabilityGapDetector + from leapflow.learning.outcome_governance_feed import origin_may_authorise + + detector = CapabilityGapDetector() + plans: list[_AcquisitionPlan] = [] + for verdict in verdicts: + intent = verdict.to_intent() + if intent is None: + continue + requirement = replace( + intent.to_requirement(), + requirement_id=f"req-wm-{intent.capability}", + ) + verdict_id = str(verdict.verdict_id) + if self._authorising_origins and not origin_may_authorise( + WORLD_MODEL_ORIGIN, self._authorising_origins + ): + plans.append( + _AcquisitionPlan( + verdict_id, + requirement, + "no_op", + "origin_not_authorised", + {}, + ) + ) + continue + if self._proposal_queue is None: + plans.append( + _AcquisitionPlan( + verdict_id, + requirement, + "no_op", + "self_evolution_disabled", + {}, + ) + ) + continue + if self._acquisition_resolver is None: + plans.append( + _AcquisitionPlan( + verdict_id, + requirement, + "no_op", + "live_resolution_unavailable", + {}, + ) + ) + continue + resolution = dict(self._acquisition_resolver(intent, job) or {}) + if not bool(resolution.get("resolved", False)): + plans.append( + _AcquisitionPlan( + verdict_id, + requirement, + "no_op", + str(resolution.get("reason") or "live_resolution_unavailable"), + resolution, + ) + ) + continue + if bool(resolution.get("satisfied", False)): + plans.append( + _AcquisitionPlan( + verdict_id, + requirement, + "satisfied", + "capability_already_available", + resolution, + ) + ) + continue + proposal = detector.proposal_from_evolution_intent(intent) + evidence = tuple(getattr(proposal, "evidence", ()) or ()) + metadata = dict(getattr(evidence[0], "metadata", {})) if evidence else {} + item, proposal_event = self._proposal_queue.prepare_enqueue( + requirements=(requirement,), + environment=dict(resolution.get("environment") or {}), + source="world_model", + observation_ids=tuple(intent.evidence_ids), + risk={"max_risk_level": requirement.max_risk_level}, + metadata={ + "plugin_id": str(getattr(proposal, "plugin_id", "")), + "capability_summary": str( + getattr(proposal, "capability_summary", "") + ), + "intent_id": str(metadata.get("intent_id", "")), + "confidence": str(metadata.get("confidence", "")), + "replaces": str(metadata.get("replaces", "")), + }, + occurred_at=float(getattr(verdict, "created_at", 0.0) or 0.0) or None, + ) + plans.append( + _AcquisitionPlan( + verdict_id, + requirement, + "unmet", + str(resolution.get("reason") or "no eligible capability provider"), + resolution, + proposal_id=item.proposal_id, + proposal_event=proposal_event, + ) + ) + return tuple(plans) + + def _collect_degraded_capabilities(self) -> tuple[Mapping[str, Any], ...]: + provider = self._degraded_capabilities + if provider is None: + return () + try: + facts = tuple(provider() or ()) + except Exception: # noqa: BLE001 - context may degrade; the job remains valid + logger.warning("teacher degradation context unavailable", exc_info=True) + return () + # Close the D1 feedback edge: show the teacher what it concluded last time for a + # still-failing capability, so the same evidence cannot only ever produce the same + # answer. Enriched from the durable knowledge projection rather than a second + # store, so the fact and its prior verdict share one source. + projection = self._knowledge_projection + if projection is None: + return facts + enriched: list[Mapping[str, Any]] = [] + for fact in facts: + capability = str(fact.get("capability") or "") + prior = projection.for_capability(capability) if capability else None + if prior is None: + enriched.append(fact) + continue + row = dict(fact) + row["prior_action"] = prior.action + row["prior_knowledge"] = prior.knowledge + enriched.append(row) + return tuple(enriched) + + async def _after_commit(self) -> None: + projection = self._knowledge_projection + if projection is not None: + try: + await asyncio.to_thread(projection.refresh) + except Exception: # noqa: BLE001 - committed facts remain replayable + logger.warning("knowledge projection refresh failed", exc_info=True) + async def _read_window( + self, + job: Mapping[str, Any], + ) -> list[EvolutionEventRecord]: + records: list[EvolutionEventRecord] = [] + cursor = int(job["from_sequence"]) + through_sequence = int(job["through_sequence"]) + while cursor < through_sequence: + page = await asyncio.to_thread( + self._store.read, + profile_id=str(job["profile_id"]), + session_id=str(job["session_id"]), + session_generation=int(job.get("session_generation") or 0), + after_sequence=cursor, + through_sequence=through_sequence, + limit=5000, + ) + if not page: + break + records.extend(page) + cursor = page[-1].sequence + return records + + async def _heartbeat(self, job_id: str) -> None: + interval = max(1.0, self._lease_seconds / 3.0) + while True: + await asyncio.sleep(interval) + renewed = await asyncio.to_thread( + self._store.renew_teacher_job, + job_id, + lease_owner=self._lease_owner, + lease_seconds=self._lease_seconds, + ) + if not renewed: + return + + async def _run(self) -> None: + while not self._closed: + self._wake.clear() + try: + outcome = await self.run_once() + except Exception: + logger.exception("teacher worker polling failed") + outcome = None + if outcome is not None: + continue + try: + await asyncio.wait_for(self._wake.wait(), timeout=self._poll_interval_s) + except asyncio.TimeoutError: + pass + + @staticmethod + def _trajectory(records: Sequence[EvolutionEventRecord]) -> list[dict[str, Any]]: + starts: dict[str, EvolutionEvent] = {} + trajectory: list[dict[str, Any]] = [] + for record in records: + event = record.event + action_id = event.context.action_id + if event.event_type == EvolutionEventType.ACTION_STARTED: + starts[action_id] = event + continue + if event.event_type not in { + EvolutionEventType.ACTION_COMPLETED, + EvolutionEventType.ACTION_FAILED, + }: + continue + started = starts.pop(action_id, None) + start_payload = started.payload if started is not None else {} + result = event.payload.get("result") + trajectory.append( + { + "experience_id": "", + "evidence_ids": [ + item + for item in ( + started.event_id if started is not None else "", + event.event_id, + ) + if item + ], + "action_description": ( + f"{start_payload.get('action_type', 'action')}:" + f"{start_payload.get('action_name', action_id or 'unknown')}" + ), + "predicted_effect": str(start_payload.get("goal") or "complete successfully"), + "actual_effect": str(result if result is not None else event.payload), + "delta": 0.0 if bool(event.payload.get("ok", False)) else 1.0, + } + ) + for action_id, started in starts.items(): + trajectory.append( + { + "experience_id": "", + "evidence_ids": [started.event_id], + "action_description": ( + f"{started.payload.get('action_type', 'action')}:" + f"{started.payload.get('action_name', action_id or 'unknown')}" + ), + "predicted_effect": str(started.payload.get("goal") or "complete successfully"), + "actual_effect": "action did not record a terminal outcome", + "delta": 1.0, + } + ) + return trajectory + + +__all__ = [ + "DurableTeacherWorker", + "Teacher", + "TeacherJobOutcome", + "TeacherWorkerMetrics", + "TeacherWorkStore", +] diff --git a/src/leapflow/hardware/transports/__init__.py b/src/leapflow/hardware/transports/__init__.py index 6397b648..c9cbfd9c 100644 --- a/src/leapflow/hardware/transports/__init__.py +++ b/src/leapflow/hardware/transports/__init__.py @@ -25,7 +25,7 @@ TransportFactory = Callable[[Mapping[str, Any]], HardwareTransport] -_TRANSPORTS: dict[str, str] = { +_BUILTIN_TRANSPORTS: dict[str, str] = { # kind -> "module:factory", imported lazily so that an optional dependency in # one transport cannot break registry loading for the others. "mock": "leapflow.hardware.transports.mock:build_transport", @@ -35,6 +35,7 @@ "host": "leapflow.hardware.transports.host:build_transport", "media": "leapflow.hardware.transports.media:build_transport", } +_TRANSPORTS: dict[str, str] = dict(_BUILTIN_TRANSPORTS) _EP_GROUP = "leapflow.hardware.transports" _ep_scanned: bool = False @@ -83,11 +84,16 @@ def _discover_entry_points() -> None: def available_transports() -> tuple[str, ...]: - """Return the registered transport kinds, sorted for stable reporting.""" + """Return all registered transport kinds, including discovered extensions.""" _discover_entry_points() return tuple(sorted(_TRANSPORTS)) +def builtin_transports() -> tuple[str, ...]: + """Return core kinds whose conformance is owned by this repository.""" + return tuple(sorted(_BUILTIN_TRANSPORTS)) + + def register_transport(kind: str, target: str) -> Callable[[], None]: """Register a transport factory as ``"module:factory"``. @@ -146,4 +152,9 @@ def build_transport(kind: str, config: Mapping[str, Any] | None = None) -> Hardw return factory(config or {}) -__all__ = ["available_transports", "build_transport", "register_transport"] +__all__ = [ + "available_transports", + "build_transport", + "builtin_transports", + "register_transport", +] diff --git a/src/leapflow/layout.py b/src/leapflow/layout.py index 8315d589..d9560639 100644 --- a/src/leapflow/layout.py +++ b/src/leapflow/layout.py @@ -411,26 +411,15 @@ def dsh_plugins_dir(self) -> Path: return self.plugins_dir / "dsh" @property - def plugin_proposals_path(self) -> Path: - # Profile-scoped review queue for capability-gap → plugin proposals. - # It is durable user/profile state, not runtime scratch. - return self.root / "plugins" / "proposals.json" + def plugin_staging_dir(self) -> Path: + """Profile-owned quarantine area for plugin candidates under validation.""" + return self.plugins_dir / ".staging" @property def capability_observations_path(self) -> Path: # Profile-scoped durable observation backlog for structured capability gaps. return self.root / "plugins" / "capability_observations.json" - @property - def capability_proposal_queue_path(self) -> Path: - # Profile-scoped adaptive proposal queue derived from capability observations. - return self.root / "plugins" / "proposal_queue.json" - - @property - def plugin_outcomes_path(self) -> Path: - # Profile-scoped execution outcome audit for adaptive plugin lifecycle governance. - return self.root / "plugins" / "outcomes.json" - @property def distilled_knowledge_path(self) -> Path: # Profile-scoped store for what the teacher distilled about the environment. @@ -446,12 +435,14 @@ def capability_plans_path(self) -> Path: return self.root / "plugins" / "capability_plans.json" @property - def evolution_traces_path(self) -> Path: - # Profile-scoped framework self-evolution traces: registry mutations, trust - # transitions, world-model proposals, and lifecycle openings. Beside the - # capability stores because the causal ledger reads them together; distinct - # from them because these are facts no other store retains. - return self.root / "plugins" / "evolution_traces.json" + def evolution_artifacts_dir(self) -> Path: + """Content-addressed artifacts referenced by the evolution event log. + + Large or sensitive payloads never belong in DuckDB event JSON. Generated + source, teacher responses, validation reports and replay media are stored by + digest here; the event stream carries only bounded metadata and the digest. + """ + return self.root / "artifacts" / "sha256" @property def plugin_versions_dir(self) -> Path: @@ -534,6 +525,7 @@ def ensure(self) -> None: self.skills_dir, self.plugins_dir, self.dsh_plugins_dir, + self.plugin_staging_dir, self.audit_dir, self.history_dir, self.runtime_dir, diff --git a/src/leapflow/learning/degradation_sink.py b/src/leapflow/learning/degradation_sink.py index df609e2c..01984263 100644 --- a/src/leapflow/learning/degradation_sink.py +++ b/src/leapflow/learning/degradation_sink.py @@ -17,7 +17,7 @@ from __future__ import annotations import logging -from typing import Any, Callable, Mapping, Sequence +from typing import Any, Callable, Mapping logger = logging.getLogger(__name__) @@ -120,175 +120,82 @@ def sink( return sink -def build_proposal_sink(*, queue: Any) -> Callable[..., str]: - """Return the sink that turns an accepted acquisition into a queued proposal. - - The last hop of the acquisition chain, and it was missing: the driver derived an - ``EvolutionIntent`` from an ``acquire`` verdict, turned it into a requirement, and - stopped. Nothing enqueued it, so resolution reported the capability unmet forever and - the teacher's most expensive verdict -- the only one that leads to code -- had no - effect at all. - - Queueing is not acting. The queue is read by the evolution dashboard and by the - ``self_management`` tools, both of which pass through approval before anything is - generated, so this hop makes the proposal *visible and actionable* rather than - executed. That separation is why the sink can be wired by default while generation - stays governed. - - ``observation_ids`` and ``environment`` are threaded from the driver so the queue - item carries the evidence and the task environment it was born from. The causal - ledger joins a proposal back to its motivating observations by exactly these ids; - without them a queued acquisition is an orphan the ledger cannot reconstruct. - """ - - def sink( - proposal: Any, - *, - observation_ids: Sequence[str] = (), - environment: Any = None, - ) -> str: - requirement = _requirement_from(proposal) - if requirement is None: - # Without a capability the queue has nothing to deduplicate on and resolution - # has nothing to satisfy, so the item could never be closed. - logger.debug( - "proposal_sink: refused proposal without a capability (%r)", - getattr(proposal, "proposal_id", ""), - ) - return "" - evidence = tuple(getattr(proposal, "evidence", ()) or ()) - metadata = dict(getattr(evidence[0], "metadata", {})) if evidence else {} - env_payload = _environment_dict(environment) - try: - item = queue.enqueue( - requirements=(requirement,), - environment=env_payload, - source="world_model", - observation_ids=tuple(str(o) for o in observation_ids if str(o)), - risk={"max_risk_level": requirement.max_risk_level}, - metadata={ - "plugin_id": str(getattr(proposal, "plugin_id", "")), - "capability_summary": str(getattr(proposal, "capability_summary", "")), - # The world model's own words and identity, carried so the ledger can - # render "why this evolved" and so a reviewer sees the hypothesis. - "intent_id": str(metadata.get("intent_id", "")), - "confidence": str(metadata.get("confidence", "")), - # Carried so a reviewer can see what a challenger is challenging, and - # so a rival stays distinguishable from a gap fill for the same - # capability. - "replaces": str(metadata.get("replaces", "")), - }, - ) - except Exception: # noqa: BLE001 - queueing must not fail the session - logger.debug("proposal_sink: could not enqueue", exc_info=True) - return "" - return str(getattr(item, "proposal_id", "")) - - return sink - - -def _environment_dict(environment: Any) -> dict[str, Any]: - """Coerce a fingerprint or mapping into the queue's plain-dict environment.""" - if environment is None: - return {} - to_dict = getattr(environment, "to_dict", None) - if callable(to_dict): - try: - return dict(to_dict()) - except Exception: # noqa: BLE001 - a fingerprint is context, not a gate - return {} - if isinstance(environment, Mapping): - return dict(environment) - return {} - - -def _requirement_from(proposal: Any) -> Any: - """Rebuild the requirement the queue keys on, from the proposal's own evidence. - - ``max_risk_level`` is passed explicitly because the domain default is ``external`` -- - the most permissive value there is. Omitting it would let a proposal that was clamped - to ``read_only`` enter the queue asking for everything, which is the opposite of what - the clamp exists for. +def build_live_capability_resolver( + *, + registry_provider: Callable[[], Any], + environment_provider: Callable[[], Any], +) -> Callable[[Any, Mapping[str, Any]], dict[str, Any]]: + """Build the mandatory resolution-before-acquisition gate. - ``requirement_id`` is derived from the capability rather than minted fresh, because the - queue deduplicates on a hash of the requirement payload. A new uuid on every rebuild - defeated that silently: the same capability enqueued a new proposal every session, so a - reviewer would face a growing pile of identical items and the health of the queue would - measure how long the process had been running. + The result is evidence, not authority. A resolved capability becomes a + durable no-op; only an unmet requirement may be turned into a proposal. + Resolution failure is reported explicitly so callers can fail closed. """ - from leapflow.domain.capability_requirement import CapabilityRequirement - - evidence = tuple(getattr(proposal, "evidence", ()) or ()) - metadata = dict(getattr(evidence[0], "metadata", {})) if evidence else {} - capability = str(metadata.get("capability") or "").strip() - if not capability: - return None - return CapabilityRequirement.create( - capability, - "world_model", - evidence=str(getattr(proposal, "capability_summary", "") or capability), - max_risk_level=str(getattr(proposal, "risk_level", "read_only")), - requirement_id=f"req-wm-{capability}", + from leapflow.plugins.capability_resolver import ( + CapabilityResolver, + DeclaredMatchScorer, + EnvironmentAffordanceScorer, + EnvironmentFitScorer, + ResolverContext, + RiskCostScorer, + candidates_from_registry, ) + resolver = CapabilityResolver( + scorers=( + DeclaredMatchScorer(), + EnvironmentFitScorer(), + EnvironmentAffordanceScorer(), + RiskCostScorer(), + ) + ) -def build_alternatives_provider( - *, registry_provider: Callable[[], Any], affordances_provider: Callable[[], Any] | None = None -) -> Callable[[str, str], tuple[dict[str, Any], ...]]: - """Return a reader for the *other* providers of a capability, and whether each fits. - - Without this the teacher is asked to choose between two actions whose definitions are - exactly the fact it was never given: - - rebind -- "another installed capability already covers the new environment" - acquire -- "nothing installed covers this" - - It was shown a flat list of global capability *names* and nothing about how many - providers a capability has or whether any of them can run here. Measured on a real - model: ``rebind`` on 3 of 3 trials of a unit whose candidate set had one entry, then - three different answers in three trials once the catalogue stopped implying that - everything listed fits. That is what choosing without the deciding fact looks like. - - Admissibility comes from the same declaration the resolver scores on - (``requires_environment_affordances``), so the teacher and the selection layer cannot - disagree about what is available. Reported, never enforced: the teacher may still - answer ``acquire`` when an alternative exists but is a poor fit, which is a judgement - only it can make. - """ - - def alternatives(capability: str, incumbent: str = "") -> tuple[dict[str, Any], ...]: - from leapflow.plugins.capability_resolver import candidates_from_registry - + def resolve(intent: Any, job: Mapping[str, Any]) -> dict[str, Any]: try: - present = frozenset(str(a) for a in (affordances_provider() or ())) if affordances_provider else frozenset() - except Exception: # noqa: BLE001 - unknown affordances must not hide alternatives - present = frozenset() - try: - candidates = candidates_from_registry(registry_provider()) - except Exception: # noqa: BLE001 - context, never a gate - logger.debug("alternatives: registry unavailable", exc_info=True) - return () - rows: list[dict[str, Any]] = [] - for candidate in candidates: - if capability not in candidate.provides_capabilities: - continue - if incumbent and candidate.plugin_id == incumbent: - continue - required = frozenset(candidate.requires_environment_affordances) - rows.append( - { - "plugin_id": candidate.plugin_id, - "tool_name": candidate.tool_name, - # Unknown affordances read as "fits": claiming a candidate does not fit - # because the environment could not be described would push every - # verdict toward acquire, which is the expensive direction. - "fits_here": (not required) or (not present) or required <= present, - "requires": tuple(sorted(required)), + registry = registry_provider() + registry.assemble() + environment = environment_provider() + if environment is None: + return { + "resolved": False, + "satisfied": False, + "reason": "environment_unavailable", + "environment": {}, } + requirement = intent.to_requirement() + decision = resolver.resolve_one( + requirement, + candidates_from_registry(registry), + ResolverContext(environment=environment), ) - return tuple(rows) - - return alternatives + except (AttributeError, RuntimeError, TypeError, ValueError): + logger.warning("live capability resolution failed", exc_info=True) + return { + "resolved": False, + "satisfied": False, + "reason": "live_resolution_failed", + "environment": {}, + } + selected = decision.selected + return { + "resolved": True, + "satisfied": selected is not None, + "reason": decision.reason, + "selected_plugin_id": ( + selected.candidate.plugin_id if selected is not None else "" + ), + "selected_tool_name": ( + selected.candidate.tool_name if selected is not None else "" + ), + "candidate_count": len(decision.candidates), + "environment": { + **environment.to_dict(), + "workspace_id": str(job.get("workspace_id") or ""), + "session_id": str(job.get("session_id") or ""), + }, + } + + return resolve def _retire(knowledge_store: Any, capabilities: tuple[str, ...], plugin_id: str) -> None: @@ -307,8 +214,7 @@ def _retire(knowledge_store: Any, capabilities: tuple[str, ...], plugin_id: str) __all__ = [ - "build_alternatives_provider", "build_degradation_sink", - "build_proposal_sink", + "build_live_capability_resolver", "declared_capabilities_by_plugin", ] diff --git a/src/leapflow/learning/world_model_driver.py b/src/leapflow/learning/world_model_driver.py deleted file mode 100644 index d771a409..00000000 --- a/src/leapflow/learning/world_model_driver.py +++ /dev/null @@ -1,716 +0,0 @@ -# Copyright (c) Alibaba, Inc. and its affiliates. -"""The world model as the first driver of capability self-evolution. - -``TrajectoryGrader.grade_and_propose`` can emit an :class:`EvolutionIntent`, and -the observation pipeline can turn a declared intent into a governed -``CapabilityRequirement``. Nothing joined the two, so the world model could form a -capability hypothesis that no part of the system ever received. This driver is -that join, and it is deliberately the *only* one. - -Where it runs, and why that is safe: - -* **Cold path, once per episode.** It is invoked at the session-end learning - boundary, after a trajectory is flushed -- never inside a turn. The teacher's own - ``grading`` budget pool bounds how often it can spend an LLM call, so making the - world model the first driver adds no per-turn cost. -* **Privileged context, not privileged authority.** The teacher sees the whole - trajectory with actual outcomes (hindsight the acting policy never had), which is - what lets it notice a capability was *missing* rather than merely used badly. It - still only proposes: each intent is written as ordinary structured evidence and - must pass the classifier, the detector, resolution, risk classification, - approval, validation and trust exactly like an ``unknown_tool`` signal. -* **Opt-in.** Admission is decided by ``CapabilityEvidenceClassifier``. Until an - operator adds ``world_model_intent`` to ``accepted_evidence_kinds``, intents are - reported as *proposed but not admitted* and change nothing. The driver never - writes around that gate. -* **Clamped.** Every intent is rendered with an explicit ``risk_ceiling``, so a - model cannot widen the risk cap of the capability it is asking for. -""" - -from __future__ import annotations - -import inspect -import logging -from dataclasses import dataclass, field -from typing import Any, Mapping, Protocol, Sequence, runtime_checkable - -from leapflow.domain.capability_requirement import CapabilityRequirement -from leapflow.domain.evolution_intent import ( - MODEL_AUTHORED_RISK_CEILING, - WORLD_MODEL_ORIGIN, - EvolutionIntent, -) -from leapflow.domain.plugin_proposal import RiskLevel - -logger = logging.getLogger(__name__) - -#: Exception types that mean "this call was wired wrongly", not "this datum was bad". -#: They are separated from the resilient catch-all so a contract break is reported -#: instead of being absorbed as one more skipped intent. -_INTERNAL_DEFECTS = (TypeError, AttributeError, NameError) - - -def _accepted_kwargs(target: Any, candidates: Sequence[str]) -> frozenset[str]: - """Which of ``candidates`` this callable can actually receive by keyword. - - Optional context must stay optional. A collaborator supplied by a caller keeps - whatever signature it was written against, so newer keywords are offered only to - the ones that declare them (or accept ``**kwargs``). When the signature cannot be - read -- a builtin, a C callable -- nothing extra is passed, which is the safe - direction: the original positional contract always works. - """ - if target is None: - return frozenset() - try: - parameters = inspect.signature(target).parameters - except (TypeError, ValueError): - return frozenset() - if any(p.kind is inspect.Parameter.VAR_KEYWORD for p in parameters.values()): - return frozenset(candidates) - return frozenset(name for name in candidates if name in parameters) - - -@runtime_checkable -class CapabilityGapTeacher(Protocol): - """A hindsight evaluator that can also propose capability gaps. - - Structural rather than a concrete import so the driver does not bind the - learning layer to ``world_model``, and so a recorded or stub teacher can be - substituted in tests and experiments. - """ - - async def grade_and_propose( - self, trajectory: list[dict], goal: str = "", **kwargs: Any - ) -> Any: - """Return an object exposing ``grades`` and ``intents``. - - ``**kwargs`` keeps this structural contract open: the driver passes - ``degraded_capabilities`` when it has any, and a teacher that predates that - context stays conformant by ignoring it. - """ - ... - - -@runtime_checkable -class EvidenceIntake(Protocol): - """The governed intake an intent must pass through.""" - - def observe_result( - self, result: Mapping[str, Any] | None, **kwargs: Any - ) -> dict[str, Any] | None: - """Persist admitted evidence; return ``None`` when the gate rejects it.""" - ... - - def requirements( - self, *, min_count: int = 1, limit: int = 50 - ) -> tuple[CapabilityRequirement, ...]: - """Derive requirements from admitted evidence.""" - ... - - -@dataclass(frozen=True) -class WorldModelDriveResult: - """What one world-model-driven evolution pass produced. - - ``proposed`` counts every intent the teacher formed; ``admitted`` counts those - the evidence gate accepted. The two differ whenever the operator has not opted - in, which is the normal default -- so a non-zero ``proposed`` with an empty - ``admitted`` is a correct, quiet outcome, not a failure. - - Admission is only the first gate. An admitted requirement then passes the - authority filter: a hypothesis whose requirement origin the operator has not - authorised to drive acquisition is recorded in ``unauthorised`` -- a durable no-op, - the record of *why the framework did not change*, not dropped telemetry. Whether an - installed provider already covers the capability (rebind vs acquire) is decided - upstream by the teacher, which sees the failed-outcome hindsight the resolver never - does; re-checking it here by declared fitness would re-introduce the blind spot the - world model exists to bypass, so the driver does not. - """ - - grades: tuple[Any, ...] = () - #: Everything the teacher concluded, across all four actions. ``intents`` below is - #: the ``acquire`` subset, so the cheap verdicts stay visible instead of being - #: dropped for not writing code -- three of the four change nothing except what the - #: acting agent knows, which is the point of asking. - verdicts: tuple[Any, ...] = () - #: Capabilities whose knowledge was written to the distilled store this session. - #: The C1 channel's receipt: a session that adapted purely by teaching the next one - #: something has this non-empty and everything else empty. - distilled: tuple[str, ...] = () - intents: tuple[EvolutionIntent, ...] = () - admitted_observation_ids: tuple[str, ...] = () - requirements: tuple[CapabilityRequirement, ...] = field(default_factory=tuple) - #: Proposals queued for governed acquisition. Empty when no sink is installed, - #: which is the default: an intent then reaches a requirement and stops there. - queued_proposal_ids: tuple[str, ...] = () - #: Capabilities whose requirement origin may not authorise an acquisition. A - #: durable no-op, retired with its reason, so a rejected authority branch is - #: reconstructable rather than invisible. - unauthorised: tuple[str, ...] = () - - @property - def proposed(self) -> int: - return len(self.intents) - - @property - def admitted(self) -> int: - return len(self.admitted_observation_ids) - - def to_dict(self) -> dict[str, Any]: - return { - "graded_actions": len(self.grades), - "proposed": self.proposed, - "admitted": self.admitted, - "queued": len(self.queued_proposal_ids), - "unauthorised": list(self.unauthorised), - "capabilities": sorted({r.capability for r in self.requirements}), - # Counted per action so a session that adapted purely by distilling - # knowledge is distinguishable from one that did nothing. - "distilled": list(self.distilled), - "by_action": { - action: sum(1 for v in self.verdicts if getattr(v, "action", "") == action) - for action in ("absorb", "rebind", "acquire", "escalate") - }, - } - -class WorldModelEvolutionDriver: - """Turn hindsight capability hypotheses into governed requirements.""" - - def __init__( - self, - *, - teacher: CapabilityGapTeacher, - intake: EvidenceIntake, - risk_ceiling: RiskLevel = MODEL_AUTHORED_RISK_CEILING, - source: str = "world_model", - degraded_capabilities: Any = None, - proposal_sink: Any = None, - knowledge_store: Any = None, - alternatives_for: Any = None, - authorising_origins: Sequence[str] = (), - ) -> None: - self._teacher = teacher - self._intake = intake - self._risk_ceiling = risk_ceiling - self._source = source - # Facts the teacher needs in order to adjudicate a *replacement*: which - # capabilities have a provider that keeps failing while still in service. - # Injected as a callable so the driver does not bind to a store, and so a - # deployment without governance wiring simply grades without them. - self._degraded_capabilities = degraded_capabilities - # Where an intent becomes a queued ``PluginProposal``. Without it an intent - # reaches a requirement and stops: resolution reports the capability unmet and - # nothing turns that into an acquisition. This is the last hop of the chain, - # and it stays optional because queueing proposals is a governed, opt-in - # capability rather than something grading should do by default. - self._proposal_sink = proposal_sink - # Which optional context this particular sink accepts. The sink is caller-supplied - # and its original contract was ``sink(proposal)``; passing newer keywords - # unconditionally raised ``TypeError`` inside the per-intent guard below, which - # swallowed it at debug level and silently stopped queueing *every* acquisition - # for any sink that had not adopted them. Resolving the signature once keeps the - # extra causal context additive instead of breaking the contract. - self._sink_kwargs = _accepted_kwargs( - proposal_sink, ("observation_ids", "environment") - ) - # Where the cheap verdicts land. Three of the four actions change nothing except - # what the acting agent knows, so without this they would be graded, traced, and - # then thrown away -- the teacher would have judged correctly and the next - # session would repeat the same mistake. Optional so a deployment without the - # store still grades and still acquires. - self._knowledge_store = knowledge_store - # The other providers of a degraded capability, and whether each can run here. - # Without it the teacher must choose between ``rebind`` ("another installed - # capability covers this") and ``acquire`` ("nothing does") without being told - # which is true -- the deciding fact for both. - self._alternatives_for = alternatives_for - # Requirement origins permitted to drive an acquisition. Empty means - # unrestricted (shipped default). Setting it to ``("world_model",)`` is the - # executable form of "self-evolution's first driver is the world model": a - # requirement of any other origin is retired as a no-op rather than queued. - self._authorising_origins = tuple( - str(origin) for origin in (authorising_origins or ()) if str(origin) - ) - - async def drive( - self, - trajectory: Sequence[Mapping[str, Any]], - goal: str = "", - *, - environment: Any = None, - session_id: str = "", - turn_id: str = "", - workspace_root: str = "", - ) -> WorldModelDriveResult: - """Grade the episode, then submit any capability gap it revealed. - - Returns an empty result rather than raising: this runs on a learning - boundary, and a failure to learn must never fail the session that produced - the trajectory. - """ - if not trajectory: - return WorldModelDriveResult() - degraded = self._collect_degraded() - try: - verdict = await self._teacher.grade_and_propose( - list(trajectory), goal, degraded_capabilities=degraded - ) - except TypeError: - # A teacher that does not accept the newer context: grade without it - # rather than lose the episode's grading entirely. - try: - verdict = await self._teacher.grade_and_propose(list(trajectory), goal) - except Exception: # noqa: BLE001 - teacher is advisory - logger.debug("world_model_driver: teacher failed", exc_info=True) - return WorldModelDriveResult() - except Exception: # noqa: BLE001 - teacher is advisory; never fail the session - logger.debug("world_model_driver: teacher failed", exc_info=True) - return WorldModelDriveResult() - - grades = tuple(getattr(verdict, "grades", ()) or ()) - verdicts = tuple(getattr(verdict, "verdicts", ()) or ()) - # Only ``acquire`` becomes an intent. The other three are conclusions about the - # environment, and forwarding them into the acquisition path would turn a - # recommendation to rebind into a request to write code. - intents = tuple(getattr(verdict, "intents", ()) or ()) - # Distil before branching on ``intents``: a session whose every verdict was - # ``absorb`` adapted the system, and it is the *only* thing that happened. - distilled = self._distil(verdicts, environment) - if not intents: - # Still a real outcome: the teacher may have concluded the change is - # absorbable, which is the cheapest and most common correct answer. - return WorldModelDriveResult( - grades=grades, verdicts=verdicts, distilled=distilled - ) - - admitted: list[str] = [] - # The intents the gate actually accepted, kept alongside their observation ids. - # Collecting only the ids was enough to *count* admissions and not enough to - # act on them: queueing then received every intent whenever any one of them was - # admitted, so a rejected hypothesis reached the proposal queue through a side - # door -- the exact bypass the opt-in gate exists to prevent. - admitted_intents: list[EvolutionIntent] = [] - # capability -> the observation ids that motivated it, so a queued proposal can - # carry the evidence back to the causal ledger instead of minting a fresh id - # the ledger cannot join. - obs_by_capability: dict[str, list[str]] = {} - for intent in intents: - try: - record = self._intake.observe_result( - intent.to_observation_result(risk_ceiling=self._risk_ceiling), - environment=environment, - source=self._source, - session_id=session_id, - turn_id=turn_id, - workspace_root=workspace_root, - ) - except (OSError, RuntimeError, TypeError, ValueError, AttributeError): - logger.debug("world_model_driver: intake rejected an intent", exc_info=True) - continue - if record is not None: - observation_id = str(record.get("observation_id") or "") - if observation_id: - admitted.append(observation_id) - admitted_intents.append(intent) - obs_by_capability.setdefault(intent.capability, []).append( - observation_id - ) - - requirements: tuple[CapabilityRequirement, ...] = () - if admitted: - try: - requirements = self._intake.requirements(min_count=1) - except (OSError, RuntimeError, TypeError, ValueError, AttributeError): - logger.debug("world_model_driver: requirement derivation failed", exc_info=True) - if intents and not admitted: - logger.debug( - "world_model_driver: %d intent(s) proposed but not admitted; add " - "'world_model_intent' to accepted_evidence_kinds to enable", - len(intents), - ) - queued, unauthorised = self._govern( - admitted_intents, requirements, environment, obs_by_capability, degraded - ) - result = WorldModelDriveResult( - grades=grades, - verdicts=verdicts, - distilled=distilled, - intents=intents, - admitted_observation_ids=tuple(admitted), - requirements=requirements, - queued_proposal_ids=queued, - unauthorised=unauthorised, - ) - self._trace_drive(result) - return result - - def _govern( - self, - admitted_intents: Sequence[EvolutionIntent], - requirements: Sequence[CapabilityRequirement], - environment: Any, - obs_by_capability: Mapping[str, Sequence[str]], - degraded: Sequence[Mapping[str, Any]], - ) -> tuple[tuple[str, ...], tuple[str, ...]]: - """Turn admitted hypotheses into queued proposals, gated by authority. - - One gate stands between an admitted hypothesis and a queued proposal, and it - records its rejections rather than dropping them: a requirement whose origin - ``authorising_origins`` does not permit is retired with ``origin_not_authorised`` - -- the executable form of "only the world model may drive acquisition". - - There is deliberately no second, declared-fitness resolution-first gate here. - Rebind-vs-acquire -- whether an installed provider already covers the capability - in this environment -- is decided upstream by the teacher, which reasons from - failed-outcome hindsight and the alternatives it was shown. A declared-fitness - re-check would count a behaviourally broken but structurally present incumbent as - "satisfied" and suppress exactly the semantic-regression acquire the world model - exists to catch, so the acquire verdict is trusted as the resolution result. - - Only what survives authority is queued, and the scope is this session's admitted - intents -- they are by construction what this episode produced, so a stale - requirement from an earlier episode cannot be re-queued here. The proposal is - built from the intent itself (``proposal_from_evolution_intent``), so queueing - deliberately does not wait on the store having derived a requirement row: an - intersection with the requirement backlog silently made acquisition depend on - store thresholds and dropped every proposal when the backlog was empty. - """ - if not admitted_intents: - return (), () - capabilities = tuple( - sorted({str(getattr(i, "capability", "")) for i in admitted_intents} - {""}) - ) - # Everything this driver admits is world-model-authored, so authority is a - # single question about that origin rather than a per-requirement lookup. - if not self._origin_authorised(WORLD_MODEL_ORIGIN): - for capability in capabilities: - self._record_no_op(capability, "origin_not_authorised") - return (), capabilities - - queued = self._queue_proposals( - list(admitted_intents), - degraded, - obs_by_capability, - environment, - ) - return queued, () - - def _origin_authorised(self, origin: str) -> bool: - """Whether ``authorising_origins`` permits this origin to drive acquisition. - - Empty ``authorising_origins`` is unrestricted, so everything is authorised -- - the shipped default. The check is the same ``origin_may_authorise`` the - resolution-first gap gate uses on the observation path, so the driver and the - loop cannot disagree about who may authorise an acquisition. - """ - if not self._authorising_origins: - return True - from leapflow.learning.outcome_governance_feed import origin_may_authorise - - return bool(origin_may_authorise(origin, self._authorising_origins)) - - def _record_no_op(self, capability: str, reason: str) -> None: - """Retire a capability's evidence as a durable no-op, and trace why. - - A no-op branch is a first-class result: it is *why the framework did not - change*. Retiring the observation with a reason makes it reconstructable from - the store (the ledger reads observation status), and the trace makes it visible - on the board. Contained: bookkeeping a no-op must never fail the session. - """ - resolver = getattr(self._intake, "resolve_capability", None) - if callable(resolver): - try: - resolver(capability, reason=reason) - except Exception: # noqa: BLE001 - retirement is advisory - logger.debug( - "world_model_driver: could not retire %s (%s)", - capability, reason, exc_info=True, - ) - self._trace_no_op(capability, reason) - - def _distil(self, verdicts: Any, environment: Any) -> tuple[str, ...]: - """Persist what each verdict concluded, returning the capabilities recorded. - - Contained: distillation improves the *next* session's context, so failing to - write it must not fail this one. Returns capability names rather than entries - because the caller reports counts and the entries live in the store. - """ - if self._knowledge_store is None or not verdicts: - return () - env = {} - if environment is not None and hasattr(environment, "to_dict"): - try: - env = dict(environment.to_dict()) - except Exception: # noqa: BLE001 - a fingerprint is context, not a gate - env = {} - try: - stored = self._knowledge_store.record_all(verdicts, environment=env) - return tuple(entry.capability for entry in stored) - except Exception: # noqa: BLE001 - distillation must never fail a session - logger.debug("world_model_driver: distillation failed", exc_info=True) - return () - - def _collect_degraded(self) -> tuple[Mapping[str, Any], ...]: - """Degradation facts for the teacher, filtered and environment-tagged. - - Prefers the intake's own reader when it has one, so the two rules that make - this evidence usable -- retry-owned classes excluded, environment fingerprint - attached -- are applied in one place rather than re-derived here. An explicit - provider still wins, which is what lets an experiment substitute its own view. - """ - provider = self._degraded_capabilities - if provider is None: - provider = getattr(self._intake, "degraded_capabilities", None) - if provider is None: - return () - try: - facts = tuple(provider() or ()) - except Exception: # noqa: BLE001 - missing context degrades grading, not the session - logger.debug("world_model_driver: degradation facts unavailable", exc_info=True) - return () - return self._with_alternatives(self._with_prior_verdicts(facts)) - - def _with_prior_verdicts( - self, facts: tuple[Mapping[str, Any], ...] - ) -> tuple[Mapping[str, Any], ...]: - """Attach what was concluded last time about each still-failing capability. - - This is the feedback edge, and without it the loop is open: the teacher would be - shown the same degradation every session and could only ever reach the same - conclusion, having no way to learn that its previous answer did not work. - - Deliberately stated as *fact*, not as a verdict on the verdict. Knowledge existing - while the capability still fails is evidence that the previous adaptation did not - resolve it -- not proof the judgement was wrong. The student may never have used - the knowledge, or the environment may have moved again, or this may be a different - failure. Which of those it is, is exactly what the teacher is for. - """ - if self._knowledge_store is None or not facts: - return facts - enriched: list[Mapping[str, Any]] = [] - for fact in facts: - capability = str(fact.get("capability") or "") - try: - prior = self._knowledge_store.for_capability(capability) - except Exception: # noqa: BLE001 - context, never a gate - prior = None - if prior is None: - enriched.append(fact) - continue - merged = dict(fact) - merged["prior_action"] = prior.action - merged["prior_knowledge"] = prior.knowledge - enriched.append(merged) - return tuple(enriched) - - def _with_alternatives( - self, facts: tuple[Mapping[str, Any], ...] - ) -> tuple[Mapping[str, Any], ...]: - """Attach the other providers of each degraded capability. - - Answers the question the action space is defined by. A teacher that cannot see - whether an alternative exists is guessing between rebind and acquire, and the - measured behaviour was exactly that. - """ - if self._alternatives_for is None or not facts: - return facts - enriched: list[Mapping[str, Any]] = [] - for fact in facts: - try: - rows = tuple( - self._alternatives_for( - str(fact.get("capability") or ""), str(fact.get("plugin_id") or "") - ) - or () - ) - except Exception: # noqa: BLE001 - context, never a gate - logger.debug("world_model_driver: alternatives unavailable", exc_info=True) - enriched.append(fact) - continue - merged = dict(fact) - merged["alternatives"] = rows - enriched.append(merged) - return tuple(enriched) - - def _queue_proposals( - self, - admitted_intents: Sequence[EvolutionIntent], - degraded: Sequence[Mapping[str, Any]] = (), - obs_by_capability: Mapping[str, Sequence[str]] | None = None, - environment: Any = None, - ) -> tuple[str, ...]: - """Turn *unmet* intents into queued proposals, if a sink is installed. - - Takes only the intents that survived the authority and resolution-first gates, - never the full admitted set: an intent the operator has not opted into, or one - the catalog already satisfies, must not become a queued acquisition by a side - door. The proposal itself mutates nothing -- generation and installation remain - separately approval-gated -- so queueing is the last *observation-only* step. - - The motivating ``observation_ids`` and the task ``environment`` travel with the - proposal so the causal ledger can join a queued acquisition back to the evidence - that produced it, rather than facing a proposal minted from nowhere. - - An intent whose capability appears in ``degraded`` is queued as a *rival* to the - named incumbent rather than as a gap fill. That is a factual lookup against the - degradation record, not a reading of the hypothesis: the record exists precisely - because a provider is installed and failing. Without the distinction the rival - would be named after the capability alone, collide with the incumbent's own - generated name, and never be able to coexist with the thing it competes against. - - Each proposal is built with the clamped risk ceiling, so a model cannot widen - the risk cap of what it is asking to have built. - """ - if self._proposal_sink is None or not admitted_intents: - return () - obs_map = {k: tuple(v) for k, v in dict(obs_by_capability or {}).items()} - incumbents = { - str(item.get("capability") or ""): str(item.get("plugin_id") or "") - for item in degraded or () - if item.get("capability") - } - queued: list[str] = [] - try: - from leapflow.learning.capability_gap_detector import CapabilityGapDetector - - detector = CapabilityGapDetector() - except Exception: # noqa: BLE001 - logger.debug("world_model_driver: detector unavailable", exc_info=True) - return () - for intent in admitted_intents: - try: - proposal = detector.proposal_from_evolution_intent( - intent, - risk_ceiling=self._risk_ceiling, - incumbent=incumbents.get(str(getattr(intent, "capability", "")), ""), - ) - extra: dict[str, Any] = {} - if "observation_ids" in self._sink_kwargs: - extra["observation_ids"] = obs_map.get( - str(getattr(intent, "capability", "")), () - ) - if "environment" in self._sink_kwargs: - extra["environment"] = environment - identifier = self._proposal_sink(proposal, **extra) - except _INTERNAL_DEFECTS: - # A wiring fault, not a bad intent: the sink or the detector was called - # wrongly. Logged loudly because the loop continues -- at debug level - # this exact case hid a regression that silently disabled queueing. - logger.warning( - "world_model_driver: proposal sink rejected the call for %r; " - "acquisition not queued", - getattr(intent, "capability", ""), - exc_info=True, - ) - continue - except Exception: # noqa: BLE001 - one bad intent must not stop the rest - logger.debug("world_model_driver: proposal not queued", exc_info=True) - continue - queued.append(str(identifier or getattr(proposal, "proposal_id", ""))) - return tuple(q for q in queued if q) - - def _trace_no_op(self, capability: str, reason: str) -> None: - """Emit the no-op branch as a first-class evolution fact. - - An unauthorised requirement is *why the framework did not change*, which the - co-evolution contract requires to be as visible as why it did. Emitting it here - means the board can distinguish "the world model saw a gap it was not permitted - to act on" from "the world model saw nothing". - """ - try: - from leapflow.domain.evolution_trace import EvolutionStage - from leapflow.telemetry.evolution_tap import emit_trace, is_enabled - - if not is_enabled(): - return - emit_trace( - EvolutionStage.DECIDE, - "world_model_no_op", - correlation={"capability": str(capability)}, - summary=f"{capability}: {reason}", - detail={"capability": str(capability), "reason": str(reason)}, - ) - except Exception: # noqa: BLE001 - the teacher is advisory; telemetry more so - logger.debug("world_model_driver: no-op trace failed", exc_info=True) - - def _trace_drive(self, result: WorldModelDriveResult) -> None: - """Emit what the teacher concluded, admitted or not. - - The highest-value probe in the system, because of the case it is the only - record of: an intent that was *proposed and not admitted* writes no - observation, so it exists nowhere durable and vanishes with the process. The - board would otherwise show a silent, idle pipeline while the world model was - in fact proposing on every session -- indistinguishable from a model that had - nothing to say. - - Not admitting is a legitimate quiet outcome, not a failure: the evidence kind - simply is not in ``accepted_evidence_kinds``. The trace says which it was so - a reader can tell "switched off" from "nothing happening". - """ - try: - from leapflow.domain.evolution_trace import EvolutionStage - from leapflow.telemetry.evolution_tap import emit_trace, is_enabled - - if not is_enabled(): - return - intents = result.intents - admitted = result.admitted_observation_ids - emit_trace( - EvolutionStage.OBSERVE, - "world_model_drive", - correlation={ - "intent_ids": ",".join( - str(getattr(i, "intent_id", "")) for i in intents - ), - }, - summary=( - f"teacher returned {len(result.verdicts)} verdict(s); " - f"{len(intents)} acquire, admitted {len(admitted)}" - if result.verdicts - else "teacher proposed nothing" - ), - detail={ - # The model's own hypothesis, rationale, expected effect and - # confidence -- the only structured answer to "why should this - # evolve" that exists anywhere. - "verdicts": [ - dict(v.to_dict()) if hasattr(v, "to_dict") else {} - for v in result.verdicts - ], - "intents": [self._intent_detail(i) for i in intents], - "admitted_observation_ids": list(admitted), - "queued_proposal_ids": list(result.queued_proposal_ids), - "unauthorised": list(result.unauthorised), - "graded": len(result.grades), - "requirements": len(result.requirements), - "not_admitted_reason": ( - "world_model_intent is not in accepted_evidence_kinds" - if intents and not admitted - else "" - ), - }, - ) - except Exception: # noqa: BLE001 - the teacher is advisory; telemetry more so - logger.debug("world_model_driver: evolution trace failed", exc_info=True) - - @staticmethod - def _intent_detail(intent: Any) -> dict[str, Any]: - """Serialise an intent defensively -- a teacher-authored object may be partial.""" - to_dict = getattr(intent, "to_dict", None) - if callable(to_dict): - try: - return dict(to_dict()) - except Exception: # noqa: BLE001 - pass - return { - key: getattr(intent, key, "") - for key in ("intent_id", "capability", "hypothesis", "confidence") - } - - -__all__ = [ - "CapabilityGapTeacher", - "EvidenceIntake", - "WorldModelDriveResult", - "WorldModelEvolutionDriver", -] diff --git a/src/leapflow/monitor/evolution_producer.py b/src/leapflow/monitor/evolution_producer.py index 541bfaad..dc512eb7 100644 --- a/src/leapflow/monitor/evolution_producer.py +++ b/src/leapflow/monitor/evolution_producer.py @@ -141,7 +141,8 @@ async def observe(self, ctx: ProducerContext) -> Sequence[Finding]: with it, and the failure it would report is its own. """ try: - payload = self._build_payload(ctx) + projection = await self._event_projection(ctx) + payload = self._build_payload(ctx, event_projection=projection) except Exception: # noqa: BLE001 - observability must not break the cycle # Logged at warning, not debug: every read inside is individually # guarded and degrades to an ``unverifiable`` row, so reaching this @@ -225,19 +226,19 @@ def _fiber_transitions( ) return rows - def _build_payload(self, ctx: ProducerContext) -> dict[str, Any]: + def _build_payload( + self, + ctx: ProducerContext, + *, + event_projection: Mapping[str, Any] | None = None, + ) -> dict[str, Any]: snapshot = self._live_registry_snapshot() - rebuilt = self._episodes(ctx) - # ``None`` means the history could not be rebuilt; ``()`` means there is - # genuinely none. Collapsing the two would report a local defect as an - # absence of data -- the same conflation the reachability rows exist to - # prevent, and it would be inconsistent for this panel to commit it. - episodes: tuple[Any, ...] = rebuilt or () + episodes: tuple[Any, ...] = () # Traces are read before reachability because three of its rows are decided # by whether the cold-path sweep left a trace. Deriving them from anything # else is how they came to be hardcoded. traces = self._recent_traces() - reachability = self._reachability(snapshot, traces) + reachability = self._reachability(snapshot, traces, event_projection) payload: dict[str, Any] = { "observed_at": float(getattr(ctx, "now", 0.0) or 0.0), "roster": snapshot["roster"], @@ -279,22 +280,28 @@ def _build_payload(self, ctx: ProducerContext) -> dict[str, Any]: payload["trace_feed"] = self._trace_feed(traces) payload["unadmitted"] = self._unadmitted(traces) payload["reward_bandwidth"] = self._reward_bandwidth(traces, episodes) - if rebuilt is None: + payload["summary"] = self._summary(snapshot, reachability, episodes, traces) + if event_projection is None: + payload["degraded"] = True payload["degraded_kind"] = UNVERIFIABLE payload["degraded_reason"] = ( - "The causal history could not be rebuilt: the decision or observation " - "records could not be read. This is a fault to investigate, not an " - "absence of activity. The live snapshot and pipeline reachability below " - "are unaffected." + "The append-only evolution projection could not be read. This is a " + "runtime fault, not an absence of activity." ) - elif not episodes: + return payload + + projected = dict(event_projection) + projected_summary = dict(projected.pop("summary", {}) or {}) + payload.update(projected) + payload["summary"] = {**payload["summary"], **projected_summary} + if payload.get("degraded"): payload["degraded_kind"] = NO_EVIDENCE payload["degraded_reason"] = ( - "No capability decision has been recorded yet, so there is no causal " - "history to rebuild. The live snapshot and pipeline reachability below " - "are unaffected." + "No evolution event has been recorded in this scope yet." ) - payload["summary"] = self._summary(snapshot, reachability, episodes, traces) + else: + payload.pop("degraded_kind", None) + payload.pop("degraded_reason", None) return payload # ── live traces (facts no store retains) ───────────────────────────── @@ -302,37 +309,24 @@ def _build_payload(self, ctx: ProducerContext) -> dict[str, Any]: def _recent_traces(self) -> list[dict[str, Any]]: """Flush the probe buffer, then read the newest traces back. - Flushing here rather than on a separate schedule is what keeps the panel and - the file consistent: this producer is the only consumer, and it runs on the - monitor tick, which is the cold path the tap's contract requires. Probe sites - therefore only ever buffer. - - Empty is the normal state -- no sink is installed outside the daemon, and a - framework that has not mutated has nothing to report. Distinguished from a - read failure only in the log, because unlike the episode history there is no - "records exist but are unreadable" case to mistake it for: the store treats a - corrupt file as empty by design. + Flushing here rather than on a separate schedule keeps the panel aligned + with the append-only event stream. Probe sites only buffer; the monitor tick + performs the durable write through the daemon-owned event store adapter. """ try: from leapflow.telemetry.evolution_tap import current_sink sink = current_sink() - if sink is not None and hasattr(sink, "flush"): + if sink is None: + return [] + if hasattr(sink, "flush"): sink.flush() - except Exception: # noqa: BLE001 - a failed flush costs freshness, not the cycle - logger.debug("evolution producer: trace flush failed", exc_info=True) - store = self._json_store( - "evolution_traces_path", "evolution_trace_store", "JsonEvolutionTraceStore" - ) - if store is None: - return [] - try: return [ dict(row) - for row in store.list_traces(limit=_MAX_TRACES) + for row in sink.list_traces(limit=_MAX_TRACES) if isinstance(row, Mapping) ] - except Exception: # noqa: BLE001 + except Exception: # noqa: BLE001 - trace visibility must not break the cycle logger.debug("evolution producer: traces unreadable", exc_info=True) return [] @@ -467,43 +461,20 @@ def _reachability_mix(reachability: Sequence[Mapping[str, Any]]) -> list[dict[st order = (WIRED, NO_EVIDENCE, NOT_ADMITTED, UNVERIFIABLE) return [{"label": name, "value": counts[name]} for name in order if counts.get(name)] - def _episodes(self, ctx: ProducerContext) -> tuple[Any, ...] | None: - """Rebuild recent episodes from existing records. - - Returns ``None`` when the history could not be rebuilt at all, and ``()`` - when it was rebuilt and is genuinely empty. The caller depends on that - difference: "could not look" and "nothing to see" are different answers, - and only one of them is a fault. - - The ledger reads the plan and observation stores, so it is resolved per - cycle for the same reason the stores are: the profile layout is bound - during deferred daemon initialisation. - """ - plans = self._json_store( - "capability_plans_path", "capability_plan_store", "JsonCapabilityPlanStore" - ) - if plans is None: + @staticmethod + async def _event_projection(ctx: ProducerContext) -> dict[str, Any] | None: + """Read the aggregate projection exposed by the daemon service facade.""" + services = getattr(ctx, "services", None) + reader = getattr(services, "evolution_projection_aggregate", None) + if not callable(reader): return None - observations = self._json_store( - "capability_observations_path", - "capability_observation_store", - "JsonCapabilityObservationStore", - ) - trust, _usage = self._trust_and_usage() try: - from leapflow.evolution import EvolutionLedger - - ledger = EvolutionLedger( - plan_store=plans, observation_store=observations, trust_ledger=trust - ) - return tuple( - ledger.recent_episodes( - limit=_MAX_EPISODES, now=float(getattr(ctx, "now", 0.0) or 0.0) - ) - ) - except Exception: # noqa: BLE001 - a missing timeline degrades the panel, not the cycle - logger.debug("evolution producer: ledger unavailable", exc_info=True) + result = await reader() + except Exception: # noqa: BLE001 - observability degrades instead of failing + logger.debug("evolution producer: event projection unavailable", exc_info=True) return None + projection = result.get("projection") if isinstance(result, Mapping) else None + return dict(projection) if isinstance(projection, Mapping) else None @staticmethod def _timeline(episodes: Sequence[Any]) -> list[dict[str, Any]]: @@ -843,7 +814,10 @@ def _trust_and_usage() -> tuple[Any, Any]: # ── pipeline reachability ───────────────────────────────────────────── def _reachability( - self, snapshot: Mapping[str, Any], traces: Sequence[Mapping[str, Any]] + self, + snapshot: Mapping[str, Any], + traces: Sequence[Mapping[str, Any]], + event_projection: Mapping[str, Any] | None, ) -> list[dict[str, Any]]: """Report the runtime evidence for each pipeline segment. @@ -863,7 +837,7 @@ def _reachability( self._segment_evidence_gate(settings), self._segment_authorising_origins(settings), self._segment_observations(observations), - self._segment_lifecycle(), + self._segment_lifecycle(event_projection), self._segment_plan_records(), self._segment_trust(snapshot), ] @@ -999,51 +973,40 @@ def _segment_observations(self, store: Any) -> dict[str, Any]: next_step="Nothing to act on: no capability gap has been recorded yet.", ) - def _segment_lifecycle(self) -> dict[str, Any]: - """Whether the trust/probation/quarantine tier is actually governing. - - A non-empty queue used to be reported ``wired``, which read as the healthy - class beside a genuinely healthy ``Trust accrual``. On a real profile that - was 212 records, every one of them ``PENDING``, none carrying a policy - decision or install result, all of them written by ``plugin_propose`` and - nothing draining them: a monotonically growing dead end presented as a - working segment. - - So the evidence is a *transition*, not a row count. Records existing prove - the queue is writable; a record past ``PENDING`` proves something reads it - back and advances it, which is the only thing this segment claims to check. - """ - store = self._json_store("capability_proposal_queue_path", "capability_proposal_queue", "JsonCapabilityProposalQueue") - if store is None: - return self._row("lifecycle", "Lifecycle records", UNVERIFIABLE, "queue unreadable") - try: - items = store.list_items(limit=0) - except Exception: # noqa: BLE001 - logger.debug("evolution producer: lifecycle read failed", exc_info=True) - return self._row("lifecycle", "Lifecycle records", UNVERIFIABLE, "queue unreadable") - if items: + def _segment_lifecycle( + self, event_projection: Mapping[str, Any] | None + ) -> dict[str, Any]: + """Report proposal lifecycle evidence from the append-only projection.""" + if event_projection is None: + return self._row( + "lifecycle", "Lifecycle records", UNVERIFIABLE, "projection unreadable" + ) + proposals = [ + dict(item) + for item in event_projection.get("proposals", ()) + if isinstance(item, Mapping) + ] + if proposals: counts: dict[str, int] = {} - for item in items: - status = str(getattr(item, "status", "") or "unknown") + for item in proposals: + status = str(item.get("status") or "unknown") counts[status] = counts.get(status, 0) + 1 - spread = ", ".join(f"{k}={v}" for k, v in sorted(counts.items())) + spread = ", ".join(f"{key}={value}" for key, value in sorted(counts.items())) advanced = sum( - count for status, count in counts.items() + count + for status, count in counts.items() if status.upper() not in _LIFECYCLE_ENTRY_STATES ) if advanced: return self._row("lifecycle", "Lifecycle records", WIRED, spread) - # Entry state only. The queue is written but never read back, so the - # governor is not running -- and the row says which way the count grows. return self._row( "lifecycle", "Lifecycle records", NO_EVIDENCE, spread, next_step=( - f"{len(items)} record(s) have never left their entry state, so nothing " - "reads the queue back. The governor advances a record only when the " - "co-evolution sweep runs; until then the queue only grows." + f"{len(proposals)} record(s) have never left their entry state; " + "without the proposal orchestrator the queue only grows." ), ) return self._row( @@ -1051,10 +1014,7 @@ class beside a genuinely healthy ``Trust accrual``. On a real profile that "Lifecycle records", NO_EVIDENCE, "queue is empty", - next_step=( - "The governor has nothing to govern. A lifecycle record opens when " - "plugin_propose runs." - ), + next_step="A lifecycle record opens when plugin_propose runs.", ) def _segment_plan_records(self) -> dict[str, Any]: diff --git a/src/leapflow/perception/__init__.py b/src/leapflow/perception/__init__.py index 70ad4767..fafc2edc 100644 --- a/src/leapflow/perception/__init__.py +++ b/src/leapflow/perception/__init__.py @@ -15,6 +15,7 @@ EmitCallback, ) from leapflow.perception.config import PerceptionConfig, SamplingConfig, ScorerConfig +from leapflow.perception.environment_source import EnvironmentSource, EnvironmentSourceManager from leapflow.perception.session import PerceptionSession from leapflow.perception.signal_source import ( SignalSource, @@ -38,6 +39,8 @@ "ActiveSourceManager", "DiscordBotSignalSource", "EmitCallback", + "EnvironmentSource", + "EnvironmentSourceManager", "FeishuIMSignalSource", "FileWatchSignalSource", "SlackBotSignalSource", diff --git a/src/leapflow/perception/environment_source.py b/src/leapflow/perception/environment_source.py new file mode 100644 index 00000000..5bed3874 --- /dev/null +++ b/src/leapflow/perception/environment_source.py @@ -0,0 +1,156 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Daemon-owned lifecycle for structured task-environment sources.""" +from __future__ import annotations + +import asyncio +import logging +from typing import Awaitable, Callable, Protocol, runtime_checkable + +from leapflow.domain.environment_signal import EnvironmentObservation + +logger = logging.getLogger(__name__) + +EnvironmentEmit = Callable[[EnvironmentObservation], Awaitable[None]] +EnvironmentSink = Callable[[EnvironmentObservation], Awaitable[None]] + + +@runtime_checkable +class EnvironmentSource(Protocol): + """Long-lived producer of typed task-environment observations.""" + + @property + def source_id(self) -> str: ... + + async def start(self, emit: EnvironmentEmit) -> None: ... + + async def stop(self) -> None: ... + + +class EnvironmentSourceManager: + """Own environment source tasks and serialize their downstream writes.""" + + def __init__( + self, + sink: EnvironmentSink, + *, + queue_capacity: int = 256, + shutdown_timeout_s: float = 5.0, + ) -> None: + self._sink = sink + self._queue: asyncio.Queue[EnvironmentObservation] = asyncio.Queue( + maxsize=max(1, int(queue_capacity)) + ) + self._shutdown_timeout_s = max(0.1, float(shutdown_timeout_s)) + self._sources: dict[str, EnvironmentSource] = {} + self._source_tasks: dict[str, asyncio.Task[None]] = {} + self._consumer_task: asyncio.Task[None] | None = None + self._started = False + self._closed = False + self._dropped = 0 + + def register(self, source: EnvironmentSource) -> None: + if self._started: + raise RuntimeError("cannot register an environment source after start") + if not isinstance(source, EnvironmentSource): + raise TypeError(f"not an EnvironmentSource: {type(source).__name__}") + if source.source_id in self._sources: + raise ValueError(f"duplicate environment source: {source.source_id}") + self._sources[source.source_id] = source + + async def start(self) -> None: + if self._started: + return + if self._closed: + raise RuntimeError("environment source manager is closed") + self._started = True + self._consumer_task = asyncio.create_task( + self._consume(), + name="environment-source-consumer", + ) + for source_id, source in self._sources.items(): + self._source_tasks[source_id] = asyncio.create_task( + self._run_source(source), + name=f"environment-source:{source_id}", + ) + + async def publish(self, observation: EnvironmentObservation) -> None: + """Apply bounded backpressure instead of silently dropping causal evidence.""" + if self._closed: + return + try: + await asyncio.wait_for( + self._queue.put(observation), + timeout=self._shutdown_timeout_s, + ) + except asyncio.TimeoutError: + self._dropped += 1 + logger.error( + "environment source queue saturated; dropped observation=%s", + observation.observation_id, + ) + + async def close(self) -> None: + if self._closed: + return + self._closed = True + for source in self._sources.values(): + try: + await asyncio.wait_for(source.stop(), timeout=self._shutdown_timeout_s) + except (asyncio.TimeoutError, Exception): + logger.warning( + "environment source stop failed source=%s", + source.source_id, + exc_info=True, + ) + for task in self._source_tasks.values(): + task.cancel() + for task in self._source_tasks.values(): + try: + await task + except (asyncio.CancelledError, Exception): + pass + self._source_tasks.clear() + try: + await asyncio.wait_for(self._queue.join(), timeout=self._shutdown_timeout_s) + except asyncio.TimeoutError: + logger.error("environment observation queue did not drain before shutdown") + consumer = self._consumer_task + self._consumer_task = None + if consumer is not None and not consumer.done(): + consumer.cancel() + try: + await consumer + except asyncio.CancelledError: + pass + + @property + def source_ids(self) -> tuple[str, ...]: + return tuple(sorted(self._sources)) + + @property + def dropped_count(self) -> int: + return self._dropped + + async def _run_source(self, source: EnvironmentSource) -> None: + try: + await source.start(self.publish) + except asyncio.CancelledError: + raise + except Exception: + logger.exception("environment source failed source=%s", source.source_id) + + async def _consume(self) -> None: + while True: + observation = await self._queue.get() + try: + await self._sink(observation) + except Exception: + logger.exception( + "environment observation sink failed observation=%s", + observation.observation_id, + ) + finally: + self._queue.task_done() + + +__all__ = ["EnvironmentEmit", "EnvironmentSource", "EnvironmentSourceManager"] diff --git a/src/leapflow/perception/leapspace_source.py b/src/leapflow/perception/leapspace_source.py new file mode 100644 index 00000000..af05c4af --- /dev/null +++ b/src/leapflow/perception/leapspace_source.py @@ -0,0 +1,120 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""LeapSpace adapter for daemon-native task-environment observations.""" +from __future__ import annotations + +import asyncio +import json +import logging +from pathlib import Path +from typing import Any + +from leapflow.domain.environment_signal import EnvironmentObservation, InterfaceSnapshot +from leapflow.perception.environment_source import EnvironmentEmit + +logger = logging.getLogger(__name__) + + +class LeapSpaceEnvironmentSource: + """Poll LeapSpace's atomic state envelopes without importing its UI runtime.""" + + def __init__( + self, + state_root: Path | str, + *, + workspace_id: str = "", + session_id: str = "", + poll_interval_s: float = 0.5, + ) -> None: + self._root = Path(state_root).expanduser().resolve() + self._workspace_id = str(workspace_id) + self._session_id = str(session_id) + self._poll_interval_s = max(0.05, float(poll_interval_s)) + self._snapshots: dict[str, InterfaceSnapshot] = {} + self._result_hashes: dict[str, str] = {} + self._stopped = asyncio.Event() + + @property + def source_id(self) -> str: + return "leapspace" + + async def start(self, emit: EnvironmentEmit) -> None: + self._stopped.clear() + while not self._stopped.is_set(): + for observation in await asyncio.to_thread(self._scan): + await emit(observation) + try: + await asyncio.wait_for(self._stopped.wait(), timeout=self._poll_interval_s) + except asyncio.TimeoutError: + pass + + async def stop(self) -> None: + self._stopped.set() + + def _scan(self) -> tuple[EnvironmentObservation, ...]: + if not self._root.exists(): + return () + observations: list[EnvironmentObservation] = [] + for state_path in sorted(self._root.glob("*/state.json")): + envelope = self._read_json(state_path) + if not envelope: + continue + app_id = str(envelope.get("app_id") or state_path.parent.name) + snapshot = InterfaceSnapshot.create( + source_id=self.source_id, + app_id=app_id, + workspace_id=self._workspace_id, + session_id=self._session_id, + version=str(envelope.get("version") or ""), + affordances=envelope.get("affordances") or (), + elements=envelope.get("elements") or (), + data=envelope.get("data") or {}, + observed_at=state_path.stat().st_mtime, + provenance={"kind": "leapspace_state", "path": f"{app_id}/state.json"}, + ) + previous = self._snapshots.get(app_id) + self._snapshots[app_id] = snapshot + observation = ( + EnvironmentObservation.snapshot(snapshot) + if previous is None + else EnvironmentObservation.between(previous, snapshot) + ) + if observation is not None: + observations.append(observation) + + for result_path in sorted(self._root.glob("*/result.json")): + payload = self._read_json(result_path) + if not payload: + continue + task_id = str(payload.get("task_id") or result_path.parent.name) + digest = json.dumps(payload, ensure_ascii=False, sort_keys=True, default=str) + if self._result_hashes.get(task_id) == digest: + continue + self._result_hashes[task_id] = digest + observations.append( + EnvironmentObservation.task_outcome( + source_id=self.source_id, + task_id=task_id, + outcome=str(payload.get("outcome") or "UNKNOWN"), + capability=str(payload.get("capability") or ""), + workspace_id=self._workspace_id, + session_id=self._session_id, + observed_at=result_path.stat().st_mtime, + provenance={ + "kind": "leapspace_verdict", + "path": f"{task_id}/result.json", + "exit_code": payload.get("exit_code", ""), + }, + ) + ) + return tuple(observations) + + @staticmethod + def _read_json(path: Path) -> dict[str, Any]: + try: + value = json.loads(path.read_text(encoding="utf-8")) + except (OSError, json.JSONDecodeError, TypeError, ValueError): + return {} + return value if isinstance(value, dict) else {} + + +__all__ = ["LeapSpaceEnvironmentSource"] diff --git a/src/leapflow/perception/signal_source.py b/src/leapflow/perception/signal_source.py index a8804425..66292c51 100644 --- a/src/leapflow/perception/signal_source.py +++ b/src/leapflow/perception/signal_source.py @@ -14,7 +14,7 @@ from __future__ import annotations from dataclasses import dataclass -from typing import Any, Dict, FrozenSet, List, Optional, Protocol, runtime_checkable +from typing import Any, Dict, FrozenSet, Optional, Protocol, runtime_checkable from leapflow.perception.types import InteractionSignal diff --git a/src/leapflow/perception/signal_sources_builtin.py b/src/leapflow/perception/signal_sources_builtin.py index 53930c8c..cbaf49d8 100644 --- a/src/leapflow/perception/signal_sources_builtin.py +++ b/src/leapflow/perception/signal_sources_builtin.py @@ -13,7 +13,6 @@ from typing import Any, Dict, FrozenSet, Optional from leapflow.perception.signal_source import ( - SignalSource, SignalSourceRegistry, SignalTransformContext, ) diff --git a/src/leapflow/performance.py b/src/leapflow/performance.py new file mode 100644 index 00000000..f072e92b --- /dev/null +++ b/src/leapflow/performance.py @@ -0,0 +1,67 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Bounded latency measurements for runtime and evolution components.""" +from __future__ import annotations + +import math +import threading +from collections import deque +from dataclasses import asdict, dataclass + + +@dataclass(frozen=True) +class LatencySummary: + """Immutable percentile snapshot in milliseconds.""" + + count: int = 0 + minimum_ms: float = 0.0 + mean_ms: float = 0.0 + p50_ms: float = 0.0 + p95_ms: float = 0.0 + p99_ms: float = 0.0 + maximum_ms: float = 0.0 + + def to_dict(self) -> dict[str, int | float]: + return asdict(self) + + +class RollingLatency: + """Thread-safe bounded sampler with O(1) writes and cold-path sorting.""" + + def __init__(self, *, capacity: int = 2048) -> None: + self._samples: deque[float] = deque(maxlen=max(1, int(capacity))) + self._lock = threading.Lock() + + def observe(self, duration_ms: float) -> None: + with self._lock: + self._samples.append(max(0.0, float(duration_ms))) + + def snapshot(self) -> LatencySummary: + with self._lock: + samples = sorted(self._samples) + if not samples: + return LatencySummary() + count = len(samples) + return LatencySummary( + count=count, + minimum_ms=round(samples[0], 4), + mean_ms=round(sum(samples) / count, 4), + p50_ms=round(_percentile(samples, 0.50), 4), + p95_ms=round(_percentile(samples, 0.95), 4), + p99_ms=round(_percentile(samples, 0.99), 4), + maximum_ms=round(samples[-1], 4), + ) + + +def _percentile(sorted_samples: list[float], quantile: float) -> float: + if len(sorted_samples) == 1: + return sorted_samples[0] + position = (len(sorted_samples) - 1) * min(1.0, max(0.0, quantile)) + lower = math.floor(position) + upper = math.ceil(position) + if lower == upper: + return sorted_samples[lower] + weight = position - lower + return sorted_samples[lower] * (1.0 - weight) + sorted_samples[upper] * weight + + +__all__ = ["LatencySummary", "RollingLatency"] diff --git a/src/leapflow/platform/event_bus.py b/src/leapflow/platform/event_bus.py index 2545559f..363c661f 100644 --- a/src/leapflow/platform/event_bus.py +++ b/src/leapflow/platform/event_bus.py @@ -9,7 +9,7 @@ import asyncio import logging import time -from typing import Any, Callable, Dict, List, Optional, TYPE_CHECKING +from typing import Any, Callable, Dict, Optional, TYPE_CHECKING from leapflow.domain.events import PRE_NORMALIZED_EVENT_PREFIXES, SystemEvent from leapflow.memory.providers.episodic import EpisodicMemoryProvider @@ -19,7 +19,6 @@ from leapflow.platform.reorder_buffer import EventReorderBuffer if TYPE_CHECKING: - from leapflow.domain.effect_scope import EffectScope from leapflow.learning.event_consumer import EventConsumer from leapflow.privacy.policy import EventPrivacyFilter diff --git a/src/leapflow/plugins/adaptive_loop.py b/src/leapflow/plugins/adaptive_loop.py index 16a07ab4..7fdec4e5 100644 --- a/src/leapflow/plugins/adaptive_loop.py +++ b/src/leapflow/plugins/adaptive_loop.py @@ -324,68 +324,6 @@ def plan_next_action( rollback_available=rollback_available, ) - async def apply_policy_decision( - self, - proposal: Any, - decision: Any, - *, - proposal_queue: Any = None, - generated_code: str = "", - version_label: str = "", - ) -> Mapping[str, Any]: - """Apply a policy decision through existing lifecycle boundaries. - - This method only mutates the registry for explicit lifecycle decisions; - queue/status-only decisions update durable proposal state and return. - """ - action = str(getattr(decision, "action", "") or "") - proposal_id = str(getattr(proposal, "proposal_id", "") or "") - plugin_id = _proposal_plugin_id(proposal) - decision_payload = ( - decision.to_dict() if hasattr(decision, "to_dict") else {"action": action} - ) - - if action in {"observe_only", "propose", "request_approval", "none"}: - if proposal_queue is not None: - proposal_queue.update(proposal_id, policy_decision=decision_payload) - return {"ok": True, "action": action, "proposal_id": proposal_id} - if action == "generate": - if proposal_queue is not None: - proposal_queue.update( - proposal_id, status="GENERATED", policy_decision=decision_payload - ) - return {"ok": True, "action": "generate", "proposal_id": proposal_id} - if action == "install": - if self._lifecycle_actor is None: - return {"ok": False, "error": "lifecycle_actor is required for install"} - result = await self._lifecycle_actor.install( - plugin_id=plugin_id, - code=generated_code, - proposal_id=proposal_id, - version_label=version_label, - ) - if proposal_queue is not None: - proposal_queue.update( - proposal_id, - status="INSTALLED" if result.get("ok") else "FAILED", - policy_decision=decision_payload, - install_result=result, - ) - return result - if action in {"disable", "quarantine"}: - if self._lifecycle_actor is None: - return {"ok": False, "error": "lifecycle_actor is required for disable"} - result = await self._lifecycle_actor.disable(plugin_id=plugin_id) - if proposal_queue is not None: - proposal_queue.update( - proposal_id, - status="QUARANTINED" if result.get("ok") else "FAILED", - policy_decision=decision_payload, - install_result=result, - ) - return result - return {"ok": False, "error": f"Unsupported policy action: {action}"} - def _read_preferences(self) -> tuple[tuple[str, str], ...]: """The teacher's rebind recommendations, or nothing. @@ -614,22 +552,6 @@ def _selected_delta( } -def _proposal_plugin_id(proposal: Any) -> str: - metadata = dict(getattr(proposal, "metadata", {}) or {}) - if metadata.get("plugin_id"): - return str(metadata["plugin_id"]) - if getattr(proposal, "install_result", None): - result = dict(getattr(proposal, "install_result") or {}) - if result.get("plugin_id"): - return str(result["plugin_id"]) - if getattr(proposal, "requirements", None): - for requirement in getattr(proposal, "requirements") or (): - if isinstance(requirement, Mapping): - cap = str(requirement.get("capability") or "generated") - return cap.replace(".", "_").replace("-", "_") + "_plugin" - return str(getattr(proposal, "proposal_id", "adaptive_plugin") or "adaptive_plugin") - - __all__ = [ "AdaptiveDecision", "AdaptiveLoopMutation", diff --git a/src/leapflow/plugins/dsh/plugin.py b/src/leapflow/plugins/dsh/plugin.py index a567cacb..c2abac60 100644 --- a/src/leapflow/plugins/dsh/plugin.py +++ b/src/leapflow/plugins/dsh/plugin.py @@ -66,13 +66,20 @@ async def _handler(**kwargs: Any) -> Any: "category": "bridge", "runtime": "node", "bridge": "dsh_ndjson_v1", - "risk_level": "external" if self._descriptor.permissions else "medium", - "requires_approval": False, - "execution_policy": "parallel_safe", + "risk_level": "external" if self._descriptor.permissions else "read_only", + "requires_approval": bool(self._descriptor.permissions), + "effect_scope": "external" if self._descriptor.permissions else "none", + "idempotency_scope": "session" if self._descriptor.permissions else "turn", + "execution_policy": ( + "external_side_effect" if self._descriptor.permissions else "read_only" + ), "source_bundle_sha256": self._descriptor.bundle_sha256, "limitations": list(self._descriptor.limitations), }, - mutates_state=False, + mutates_state=bool(self._descriptor.permissions), + execution_policy=( + "external_side_effect" if self._descriptor.permissions else "read_only" + ), ) async def _invoke(self, tool_name: str, arguments: dict[str, Any]) -> Any: diff --git a/src/leapflow/plugins/evolution_contracts.py b/src/leapflow/plugins/evolution_contracts.py index 803e2f2a..d434d08f 100644 --- a/src/leapflow/plugins/evolution_contracts.py +++ b/src/leapflow/plugins/evolution_contracts.py @@ -10,16 +10,13 @@ Two distinct vocabularies meet here, and conflating them is the mistake to avoid: -* ``domain.plugin_proposal.ProposalStatus`` -- ``draft | review | approved | - rejected`` -- is a **review** state: should a human accept this proposal? -* ``storage.capability_proposal_queue.ProposalStatus`` -- ``PENDING | GENERATED | - APPROVED | INSTALLED | PROBATION | VERIFIED | REJECTED | FAILED | QUARANTINED`` - -- is an **acquisition lifecycle** state: where is this capability in its - journey from hypothesis to trusted? - -They are not duplicates and must not be merged into one field. A proposal that a -human has ``approved`` may still be anywhere in its lifecycle. The lifecycle store -below owns the second vocabulary. +* ``domain.plugin_proposal.ProposalStatus`` describes the immutable review content + embedded in the lifecycle event. +* ``storage.capability_proposal_queue.ProposalStatus`` describes the governed + acquisition state from hypothesis through probation and verification. + +Both now travel in one append-only proposal record, but remain separate fields: a +review decision is evidence for a lifecycle transition, not the lifecycle itself. """ from __future__ import annotations diff --git a/src/leapflow/plugins/lifecycle_governor.py b/src/leapflow/plugins/lifecycle_governor.py index e870d30d..7af46924 100644 --- a/src/leapflow/plugins/lifecycle_governor.py +++ b/src/leapflow/plugins/lifecycle_governor.py @@ -144,40 +144,51 @@ async def record_outcome( side_effect_state=side_effect_state, metadata=metadata, ) + internal_defect = hard_failure or str(failure_class) == "internal_defect" if ok: self._trust_ledger.record_success(plugin_id) else: - self._trust_ledger.record_failure(plugin_id, hard=hard_failure) + self._trust_ledger.record_failure(plugin_id, hard=internal_defect) trust = self._trust_ledger.level(plugin_id) failure_streak = self._outcome_store.failure_streak(plugin_id) + trust_state = { + "level": trust.name, + "failure_streak": failure_streak, + "frozen": self._trust_ledger.is_frozen(plugin_id), + } lifecycle_result: Mapping[str, Any] = {"ok": True} action = "probation_execute" - if hard_failure or failure_streak >= self._quarantine_after: + if internal_defect or failure_streak >= self._quarantine_after: action = "quarantine" if self._lifecycle_actor is not None: lifecycle_result = await self._lifecycle_actor.disable(plugin_id=plugin_id) - self._proposal_queue.update( + self._transition( proposal_id, - status="QUARANTINED" if lifecycle_result.get("ok", True) else "FAILED", - trust_state={"level": trust.name, "failure_streak": failure_streak}, + "QUARANTINED" if lifecycle_result.get("ok", True) else "FAILED", + trust_state=trust_state, test_results=[outcome], install_result=lifecycle_result, + metadata={ + "terminal_reason": "internal_defect" + if internal_defect + else "failure_streak_exceeded" + }, ) elif trust >= self._verified_at: action = "verify" - self._proposal_queue.update( + self._transition( proposal_id, - status="VERIFIED", - trust_state={"level": trust.name, "failure_streak": failure_streak}, + "VERIFIED", + trust_state=trust_state, test_results=[outcome], ) else: - self._proposal_queue.update( + self._transition( proposal_id, - status="PROBATION", - trust_state={"level": trust.name, "failure_streak": failure_streak}, + "PROBATION", + trust_state=trust_state, test_results=[outcome], ) if action != "quarantine": @@ -201,5 +212,21 @@ async def record_outcome( outcome=outcome, ) + def _transition(self, proposal_id: str, status: str, **changes: Any) -> None: + """Use the lifecycle state machine when the backing store exposes it.""" + if not proposal_id: + return + transition = getattr(self._proposal_queue, "transition", None) + if callable(transition): + current = self._proposal_queue.get(proposal_id) + if current is None: + return + if current.status == status: + self._proposal_queue.update(proposal_id, **changes) + else: + transition(proposal_id, status, **changes) + return + self._proposal_queue.update(proposal_id, status=status, **changes) + __all__ = ["LifecycleGovernanceResult", "LifecycleGovernor"] diff --git a/src/leapflow/plugins/proposal_orchestrator.py b/src/leapflow/plugins/proposal_orchestrator.py new file mode 100644 index 00000000..a8e893c2 --- /dev/null +++ b/src/leapflow/plugins/proposal_orchestrator.py @@ -0,0 +1,306 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Durable orchestration for governed capability acquisition proposals.""" +from __future__ import annotations + +from dataclasses import dataclass +from typing import Any, Mapping, Protocol, runtime_checkable + +from leapflow.evolution.artifact_store import ContentAddressedArtifactStore +from leapflow.learning.plugin_trust import PluginTrustLevel +from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy +from leapflow.security.actions import ActionDescriptor +from leapflow.storage.capability_proposal_queue import CapabilityProposalItem + + +@runtime_checkable +class ProposalApprovalGate(Protocol): + async def evaluate(self, action: ActionDescriptor) -> Any: ... + + +@dataclass(frozen=True) +class ProposalApproval: + """One explicit approval result tied to a durable proposal transition.""" + + approved: bool + proposal_id: str + stage: str + approval_id: str = "" + denial_message: str = "" + + +class ProposalOrchestrator: + """Apply policy and two explicit approvals to one acquisition lifecycle.""" + + def __init__( + self, + *, + queue: Any, + artifact_store: ContentAddressedArtifactStore, + approval_gate: ProposalApprovalGate | None, + policy: AdaptiveEvolutionPolicy, + ) -> None: + self._queue = queue + self._artifacts = artifact_store + self._approval_gate = approval_gate + self._policy = policy + + def register_generated( + self, + proposal_id: str, + code: str, + *, + validation: Mapping[str, Any], + ) -> CapabilityProposalItem: + """Persist validated source in CAS and advance PENDING to GENERATED.""" + proposal = self._required(proposal_id) + if proposal.status in {"GENERATED", "APPROVED"} and proposal.generated_code_ref: + if self._artifacts.get_text(proposal.generated_code_ref) == code: + return proposal + raise ValueError(f"proposal {proposal_id} already references a different artifact") + if proposal.status != "PENDING": + raise ValueError(f"proposal {proposal_id} is not pending") + decision = self._policy.decide(proposal, trust_level=PluginTrustLevel.DRAFT) + if not decision.allowed or decision.action != "generate": + raise PermissionError(decision.reason) + validation_payload = dict(validation) + if not bool(validation_payload.get("ok", False)) or validation_payload.get( + "compatibility_ok" + ) is not True: + return self._queue.transition( + proposal_id, + "FAILED", + policy_decision=decision.to_dict(), + metadata={ + "validation": validation_payload, + "terminal_reason": "static or compatibility validation failed", + }, + ) + artifact = self._artifacts.put_text( + code, + media_type="text/x-python; charset=utf-8", + privacy_class="profile", + ) + return self._queue.transition( + proposal_id, + "GENERATED", + generated_code_ref=artifact.artifact_id, + policy_decision=decision.to_dict(), + metadata={"validation": validation_payload, "artifact": artifact.to_dict()}, + ) + + async def approve_content(self, proposal_id: str) -> ProposalApproval: + """Ask whether the generated implementation is acceptable in principle.""" + proposal = self._required(proposal_id) + if proposal.status == "APPROVED" and proposal.proposal_approval_id: + return ProposalApproval( + True, proposal_id, "content", approval_id=proposal.proposal_approval_id + ) + if proposal.status != "GENERATED": + raise ValueError(f"proposal {proposal_id} has no generated artifact to approve") + descriptor = ActionDescriptor.platform_action( + "plugin_management", + "approve_proposal_content", + { + "proposal_id": proposal_id, + "artifact_id": proposal.generated_code_ref, + "requirements": [dict(item) for item in proposal.requirements], + }, + metadata={ + "effect": "write", + "risk_level": "high", + "category": "self_modification", + "approval_stage": "proposal_content", + "proposal_id": proposal_id, + }, + ) + gate = self._approval_gate + if gate is None: + return self._reject( + proposal_id, + stage="content", + approval_id=descriptor.action_id, + reason="approval_gate_missing", + denial_message="proposal approval blocked: no approval gate configured", + ) + try: + result = await gate.evaluate(descriptor) + except Exception as exc: # noqa: BLE001 - an unavailable gate must fail closed + return self._reject( + proposal_id, + stage="content", + approval_id=descriptor.action_id, + reason=f"approval_gate_error:{type(exc).__name__}", + denial_message="proposal approval failed closed", + ) + approval_id = str( + getattr(getattr(result, "action", None), "action_id", "") + or descriptor.action_id + ) + if not bool(getattr(result, "approved", False)): + return self._reject( + proposal_id, + stage="content", + approval_id=approval_id, + reason=str(getattr(result, "reason", "") or "user_denied"), + denial_message=str(getattr(result, "denial_message", "") or "approval denied"), + ) + self._queue.transition( + proposal_id, + "APPROVED", + proposal_approval_id=approval_id, + policy_decision={ + "action": "request_approval", + "reason": "generated proposal content approved", + "approval_stage": "proposal_content", + }, + ) + return ProposalApproval(True, proposal_id, "content", approval_id=approval_id) + + async def authorize_mutation(self, proposal_id: str) -> ProposalApproval: + """Ask separately for the process-global install mutation.""" + proposal = self._required(proposal_id) + if proposal.status == "APPROVED" and proposal.mutation_approval_id: + return ProposalApproval( + True, proposal_id, "mutation", approval_id=proposal.mutation_approval_id + ) + if proposal.status != "APPROVED" or not proposal.proposal_approval_id: + raise PermissionError("proposal content must be approved before installation") + plugin_id = str(dict(proposal.metadata).get("plugin_id") or proposal_id) + descriptor = ActionDescriptor.platform_action( + "plugin_management", + "install", + {"proposal_id": proposal_id, "plugin_id": plugin_id}, + metadata={ + "effect": "write", + "risk_level": "high", + "category": "self_modification", + "approval_stage": "plugin_mutation", + "proposal_id": proposal_id, + }, + ) + gate = self._approval_gate + if gate is None: + return self._reject( + proposal_id, + stage="mutation", + approval_id=descriptor.action_id, + reason="approval_gate_missing", + denial_message="plugin mutation blocked: no approval gate configured", + ) + try: + result = await gate.evaluate(descriptor) + except Exception as exc: # noqa: BLE001 - an unavailable gate must fail closed + return self._reject( + proposal_id, + stage="mutation", + approval_id=descriptor.action_id, + reason=f"approval_gate_error:{type(exc).__name__}", + denial_message="plugin mutation approval failed closed", + ) + approval_id = str( + getattr(getattr(result, "action", None), "action_id", "") + or descriptor.action_id + ) + if not bool(getattr(result, "approved", False)): + return self._reject( + proposal_id, + stage="mutation", + approval_id=approval_id, + reason=str(getattr(result, "reason", "") or "user_denied"), + denial_message=str(getattr(result, "denial_message", "") or "approval denied"), + ) + self._queue.update(proposal_id, mutation_approval_id=approval_id) + return ProposalApproval(True, proposal_id, "mutation", approval_id=approval_id) + + def generated_code(self, proposal_id: str) -> str: + proposal = self._required(proposal_id) + if not proposal.generated_code_ref: + raise ValueError(f"proposal {proposal_id} has no generated artifact") + return self._artifacts.get_text(proposal.generated_code_ref) + + def record_installed( + self, + proposal_id: str, + install_result: Mapping[str, Any], + ) -> CapabilityProposalItem: + proposal = self._required(proposal_id) + if proposal.status == "INSTALLED": + return proposal + if proposal.status != "APPROVED" or not proposal.mutation_approval_id: + raise PermissionError("plugin mutation approval is required before installation") + target = "INSTALLED" if bool(install_result.get("ok")) else "FAILED" + reason = "plugin installed" if target == "INSTALLED" else str( + install_result.get("error") or "plugin installation failed" + ) + return self._queue.transition( + proposal_id, + target, # type: ignore[arg-type] + install_result=dict(install_result), + metadata={"terminal_reason": reason} if target == "FAILED" else {}, + ) + + def supersede(self, proposal_id: str, *, replacement_id: str, reason: str) -> CapabilityProposalItem: + """Close an uninstalled proposal in favor of a newer durable proposal.""" + return self._queue.transition( + proposal_id, + "SUPERSEDED", + metadata={"terminal_reason": reason, "replacement_proposal_id": replacement_id}, + ) + + def expire(self, proposal_id: str, *, reason: str) -> CapabilityProposalItem: + """Close an uninstalled proposal whose review window has elapsed.""" + return self._queue.transition( + proposal_id, + "EXPIRED", + metadata={"terminal_reason": reason}, + ) + + def record_noop(self, proposal_id: str, *, reason: str) -> CapabilityProposalItem: + """Close a proposal resolved without acquiring a new capability.""" + return self._queue.transition( + proposal_id, + "NO_OP", + metadata={"terminal_reason": reason}, + ) + + def _reject( + self, + proposal_id: str, + *, + stage: str, + approval_id: str, + reason: str, + denial_message: str, + ) -> ProposalApproval: + approval_field = ( + {"proposal_approval_id": approval_id} + if stage == "content" + else {"mutation_approval_id": approval_id} + ) + self._queue.transition( + proposal_id, + "REJECTED", + **approval_field, + policy_decision={ + "action": "reject", + "reason": reason, + "approval_stage": "proposal_content" if stage == "content" else "plugin_mutation", + }, + metadata={"terminal_reason": reason}, + ) + return ProposalApproval( + False, + proposal_id, + stage, + approval_id=approval_id, + denial_message=denial_message, + ) + + def _required(self, proposal_id: str) -> CapabilityProposalItem: + proposal = self._queue.get(proposal_id) + if proposal is None: + raise KeyError(f"unknown capability proposal: {proposal_id}") + return proposal + + +__all__ = ["ProposalApproval", "ProposalApprovalGate", "ProposalOrchestrator"] diff --git a/src/leapflow/plugins/protocol.py b/src/leapflow/plugins/protocol.py index f20289c0..e43fa574 100644 --- a/src/leapflow/plugins/protocol.py +++ b/src/leapflow/plugins/protocol.py @@ -76,6 +76,7 @@ class ToolMetadata: # which supports both generated-plugin **kwargs handlers and older params-dict handlers. x_leapflow: dict[str, Any] = field(default_factory=dict) mutates_state: bool = False + execution_policy: str = "" # Declarative capability metadata consumed by the capability resolver and # environment-fit scoring. ``provides_capabilities`` are abstract capability # tags this tool offers (matched against a requirement). ``requires_capabilities`` @@ -108,6 +109,8 @@ def to_openai_schema(self) -> dict[str, Any]: x_leapflow = dict(self.x_leapflow) if self.mutates_state: x_leapflow.setdefault("mutates_state", True) + if self.execution_policy: + x_leapflow.setdefault("execution_policy", self.execution_policy) if self.provides_capabilities: x_leapflow.setdefault("provides_capabilities", list(self.provides_capabilities)) if self.requires_capabilities: diff --git a/src/leapflow/plugins/registry.py b/src/leapflow/plugins/registry.py index 92249ab8..f653ff0b 100644 --- a/src/leapflow/plugins/registry.py +++ b/src/leapflow/plugins/registry.py @@ -5,9 +5,11 @@ import logging from dataclasses import dataclass +from time import perf_counter from typing import Any, Callable, Dict, Iterable, List, Optional from leapflow.domain.tool_pipeline import ToolExecutionPipeline +from leapflow.performance import LatencySummary, RollingLatency from leapflow.plugins.protocol import ToolMetadata, ToolPlugin logger = logging.getLogger(__name__) @@ -66,6 +68,7 @@ def __init__(self) -> None: self._version: int = 0 self._last_bound_deps: dict[str, Any] = {} # Track last-injected deps for re-injection on reload self._tool_pipeline = ToolExecutionPipeline() + self._snapshot_latency = RollingLatency() # ── Cross-cutting runtime gates ── self._file_read_gate: Any = None @@ -257,22 +260,47 @@ def assemble(self) -> None: ) def publish_plugin_tools(self, plugin: ToolPlugin) -> list[str]: - """Publish an already-registered plugin's tools into the live catalog. + """Publish an already-registered plugin's tools into the live catalog.""" + return self._publish_plugin_tools(plugin, strict=False) - assemble() runs once at boot; a plugin that arrives later (install, - hot-reload) makes its tools dispatchable through this method, keeping - the definitions, metadata, and handler table in one place instead of - letting callers write to the registry's internals. + def publish_plugin_tools_atomic(self, plugin: ToolPlugin) -> list[str]: + """Publish all tools or none, rejecting live-name collisions up front.""" + return self._publish_plugin_tools(plugin, strict=True) - Returns the published tool names and bumps the version counter so - downstream caches (engine tool registry, PCD catalog) invalidate. - """ + def _publish_plugin_tools(self, plugin: ToolPlugin, *, strict: bool) -> list[str]: tool_names = [tool.name for tool in plugin.tools] + if strict: + duplicates = sorted({name for name in tool_names if tool_names.count(name) > 1}) + conflicts = sorted( + name + for name in tool_names + if name in self._tool_owner and self._tool_owner[name] != plugin.plugin_id + ) + if duplicates or conflicts: + details = [] + if duplicates: + details.append(f"duplicate declarations: {duplicates}") + if conflicts: + details.append(f"live conflicts: {conflicts}") + raise ValueError("plugin tool publication rejected: " + "; ".join(details)) # Before the first assemble() the pending pass will pick these tools up # from the plugin itself; publishing now would duplicate every schema. if self._assembled: - for tool in plugin.tools: - self._index_tool(tool, plugin.plugin_id) + handlers_before = dict(self._tool_handlers) + owners_before = dict(self._tool_owner) + definitions_before = list(self._tool_definitions) + metadata_before = list(self._all_metadata) + conflicts_before = list(self._conflicts) + try: + for tool in plugin.tools: + self._index_tool(tool, plugin.plugin_id) + except Exception: + self._tool_handlers = handlers_before + self._tool_owner = owners_before + self._tool_definitions = definitions_before + self._all_metadata = metadata_before + self._conflicts = conflicts_before + raise self._bump_version( "tools_published", plugin_id=plugin.plugin_id, tool_names=list(tool_names) ) @@ -418,6 +446,18 @@ def tool_handlers(self) -> dict[str, Any]: self.assemble() return self._tool_handlers + def snapshot_handlers(self) -> dict[str, Any]: + """Return an immutable-by-convention turn snapshot and record copy latency.""" + started_at = perf_counter() + try: + return dict(self.tool_handlers) + finally: + self._snapshot_latency.observe((perf_counter() - started_at) * 1000.0) + + @property + def snapshot_latency(self) -> LatencySummary: + return self._snapshot_latency.snapshot() + @property def all_metadata(self) -> list[ToolMetadata]: """All ToolMetadata entries (for PCD, capability manifests, etc.).""" diff --git a/src/leapflow/plugins/sandbox/sandbox_host.py b/src/leapflow/plugins/sandbox/sandbox_host.py index 87c6169e..fa6a6bb1 100644 --- a/src/leapflow/plugins/sandbox/sandbox_host.py +++ b/src/leapflow/plugins/sandbox/sandbox_host.py @@ -11,9 +11,11 @@ import asyncio import logging +import os import sys import uuid -from typing import Any, Dict, List, Optional +from dataclasses import dataclass +from typing import Any, Dict, List, Optional, Sequence from leapflow.plugins.protocol import ToolMetadata from leapflow.plugins.sandbox.protocol import SandboxRequest, SandboxResponse @@ -21,19 +23,56 @@ logger = logging.getLogger(__name__) +@dataclass(frozen=True) +class SandboxLimits: + """Cold-path process and RPC limits for one sandbox worker.""" + + invoke_timeout_s: float = 30.0 + shutdown_timeout_s: float = 3.0 + cpu_time_s: int = 0 + max_memory_bytes: int = 0 + + def __post_init__(self) -> None: + if self.invoke_timeout_s <= 0 or self.shutdown_timeout_s <= 0: + raise ValueError("sandbox timeouts must be positive") + if self.cpu_time_s < 0 or self.max_memory_bytes < 0: + raise ValueError("sandbox resource limits cannot be negative") + + class SandboxHost: """Manages a worker subprocess for one sandboxed plugin.""" def __init__( - self, plugin_module_path: str, *, invoke_timeout_s: float = 30.0 + self, + plugin_module_path: str, + *, + invoke_timeout_s: float = 30.0, + shutdown_timeout_s: float = 3.0, + cpu_time_s: int = 0, + max_memory_bytes: int = 0, + python_paths: Sequence[str] = (), ) -> None: self._module_path = plugin_module_path - self._invoke_timeout_s = invoke_timeout_s + self._python_paths = tuple(str(path) for path in python_paths if str(path)) + self._limits = SandboxLimits( + invoke_timeout_s=float(invoke_timeout_s), + shutdown_timeout_s=float(shutdown_timeout_s), + cpu_time_s=int(cpu_time_s), + max_memory_bytes=int(max_memory_bytes), + ) self._proc: Optional[asyncio.subprocess.Process] = None self._lock = asyncio.Lock() # serialize stdin/stdout access async def start(self) -> None: """Launch the worker subprocess.""" + env = dict(os.environ) + env["LEAPFLOW_SANDBOX_CPU_TIME_S"] = str(self._limits.cpu_time_s) + env["LEAPFLOW_SANDBOX_MAX_MEMORY_BYTES"] = str(self._limits.max_memory_bytes) + if self._python_paths: + current = env.get("PYTHONPATH", "") + env["PYTHONPATH"] = os.pathsep.join( + [*self._python_paths, *([current] if current else [])] + ) self._proc = await asyncio.create_subprocess_exec( sys.executable, "-m", @@ -42,6 +81,7 @@ async def start(self) -> None: stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, + env=env, ) logger.info( "Sandbox worker started for %s (pid %s)", @@ -91,7 +131,7 @@ async def _send_request( self._proc.stdin.write((req.to_json() + "\n").encode()) await self._proc.stdin.drain() line = await asyncio.wait_for( - self._proc.stdout.readline(), timeout=self._invoke_timeout_s + self._proc.stdout.readline(), timeout=self._limits.invoke_timeout_s ) if not line: return SandboxResponse( @@ -101,10 +141,11 @@ async def _send_request( ) return SandboxResponse.from_json(line.decode().strip()) except asyncio.TimeoutError: + await self._kill_worker() return SandboxResponse( request_id=req.request_id, ok=False, - error=f"Sandbox invoke timed out after {self._invoke_timeout_s}s", + error=f"Sandbox invoke timed out after {self._limits.invoke_timeout_s}s", ) except (ConnectionResetError, OSError, ValueError) as exc: return SandboxResponse( @@ -122,7 +163,9 @@ async def stop(self) -> None: req = SandboxRequest(request_id="shutdown", method="shutdown") self._proc.stdin.write((req.to_json() + "\n").encode()) await self._proc.stdin.drain() - await asyncio.wait_for(self._proc.wait(), timeout=3.0) + await asyncio.wait_for( + self._proc.wait(), timeout=self._limits.shutdown_timeout_s + ) except (asyncio.TimeoutError, ConnectionResetError, OSError): try: self._proc.kill() @@ -133,6 +176,18 @@ async def stop(self) -> None: self._proc = None logger.info("Sandbox worker stopped for %s", self._module_path) + async def _kill_worker(self) -> None: + proc = self._proc + if proc is None: + return + try: + proc.kill() + await proc.wait() + except (ProcessLookupError, OSError): + pass + finally: + self._proc = None + class SandboxedToolPlugin: """A ToolPlugin whose handlers execute in a sandbox subprocess. diff --git a/src/leapflow/plugins/sandbox/worker.py b/src/leapflow/plugins/sandbox/worker.py index 2fdaccba..6997d615 100644 --- a/src/leapflow/plugins/sandbox/worker.py +++ b/src/leapflow/plugins/sandbox/worker.py @@ -20,6 +20,7 @@ import importlib import json import logging +import os import sys from typing import Any, Callable, Dict @@ -28,6 +29,22 @@ logger = logging.getLogger(__name__) +def _apply_resource_limits() -> None: + """Apply host-declared OS limits before importing untrusted plugin code.""" + cpu_time_s = max(0, int(os.getenv("LEAPFLOW_SANDBOX_CPU_TIME_S", "0"))) + max_memory_bytes = max(0, int(os.getenv("LEAPFLOW_SANDBOX_MAX_MEMORY_BYTES", "0"))) + if not cpu_time_s and not max_memory_bytes: + return + try: + import resource + except ImportError as exc: # pragma: no cover - non-POSIX safety path + raise RuntimeError("sandbox resource limits are unavailable on this platform") from exc + if cpu_time_s: + resource.setrlimit(resource.RLIMIT_CPU, (cpu_time_s, cpu_time_s)) + if max_memory_bytes: + resource.setrlimit(resource.RLIMIT_AS, (max_memory_bytes, max_memory_bytes)) + + async def _serve(plugin_module_path: str) -> None: """Load the plugin and serve requests from stdin.""" handlers: Dict[str, Callable[..., Any]] = {} @@ -107,4 +124,5 @@ async def _invoke( if __name__ == "__main__": module_path = sys.argv[1] if len(sys.argv) > 1 else "" + _apply_resource_limits() asyncio.run(_serve(module_path)) diff --git a/src/leapflow/plugins/scoped_registry.py b/src/leapflow/plugins/scoped_registry.py index 51873879..75b060b3 100644 --- a/src/leapflow/plugins/scoped_registry.py +++ b/src/leapflow/plugins/scoped_registry.py @@ -44,6 +44,7 @@ def __init__(self, registry: Any) -> None: """Wrap an existing ToolPluginRegistry instance.""" self._registry = registry self._fibers: dict[str, PluginFiber] = {} + self._draft_plugins: dict[str, ToolPlugin] = {} self._plugin_modules: dict[str, str] = {} # plugin_id → module path self._plugin_files: dict[str, Path] = {} # plugin_id → installed source file @@ -54,10 +55,64 @@ def create_fiber(self, plugin_id: str) -> PluginFiber: self._fibers[plugin_id] = fiber return fiber + def create_draft_fiber(self, plugin_id: str) -> PluginFiber: + """Create an isolated DRAFT fiber that cannot dispatch live tools.""" + if plugin_id in self._fibers and not self._fibers[plugin_id].is_disposed: + raise ValueError(f"Plugin '{plugin_id}' already has a live fiber") + fiber = self.create_fiber(plugin_id) + fiber.mark_draft() + return fiber + def get_fiber(self, plugin_id: str) -> Optional[PluginFiber]: """Get an existing fiber by plugin ID.""" return self._fibers.get(plugin_id) + def stage_plugin(self, plugin: ToolPlugin, fiber: PluginFiber) -> None: + """Attach a plugin to a DRAFT fiber without publishing any handler.""" + plugin_id = plugin.plugin_id + if fiber.plugin_id != plugin_id or fiber.state != FiberState.DRAFT: + raise ValueError("draft plugin and fiber identity/state do not match") + if self._registry.get_plugin(plugin_id) is not None: + raise ValueError(f"Duplicate plugin_id: {plugin_id!r}") + self._draft_plugins[plugin_id] = plugin + fiber.scope.effect(lambda pid=plugin_id: self._draft_plugins.pop(pid, None)) + module_name = str(getattr(plugin, "__leapflow_plugin_module__", "") or "") + module = sys.modules.get(module_name) if module_name else None + if module is not None: + fiber.scope.effect( + lambda name=module_name, loaded=module: ( + sys.modules.pop(name, None) + if sys.modules.get(name) is loaded + else None + ) + ) + + def promote_draft(self, plugin_id: str) -> PluginFiber: + """Atomically publish a tested DRAFT plugin into the live registry.""" + fiber = self._fibers.get(plugin_id) + plugin = self._draft_plugins.get(plugin_id) + if fiber is None or plugin is None or fiber.state != FiberState.DRAFT: + raise ValueError(f"Plugin '{plugin_id}' has no staged DRAFT") + self.scoped_register(plugin, fiber) + try: + published = self._registry.publish_plugin_tools_atomic(plugin) + fiber.activate() + except Exception: + if fiber.state != FiberState.DISPOSED: + fiber.dispose() + self._fibers.pop(plugin_id, None) + raise + self._draft_plugins.pop(plugin_id, None) + logger.info("Promoted DRAFT plugin '%s' with %d tools", plugin_id, len(published)) + return fiber + + def discard_draft(self, plugin_id: str) -> None: + """Dispose an unpublished DRAFT and remove all staging metadata.""" + fiber = self._fibers.pop(plugin_id, None) + self._draft_plugins.pop(plugin_id, None) + if fiber is not None and not fiber.is_disposed: + fiber.dispose() + def scoped_register(self, plugin: ToolPlugin, fiber: PluginFiber) -> None: """Register a plugin with lifecycle tracking. diff --git a/src/leapflow/plugins/tool_plugins/file_ops.py b/src/leapflow/plugins/tool_plugins/file_ops.py index c89ac621..397c3441 100644 --- a/src/leapflow/plugins/tool_plugins/file_ops.py +++ b/src/leapflow/plugins/tool_plugins/file_ops.py @@ -135,6 +135,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="mutating_once", provides_capabilities=("file.write",), requires_platform_capabilities=("file.ops",), ), @@ -287,6 +288,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="mutating_idempotent", provides_capabilities=("file.edit",), requires_platform_capabilities=("file.ops",), ), diff --git a/src/leapflow/plugins/tool_plugins/gateway.py b/src/leapflow/plugins/tool_plugins/gateway.py index a1914f18..e0633856 100644 --- a/src/leapflow/plugins/tool_plugins/gateway.py +++ b/src/leapflow/plugins/tool_plugins/gateway.py @@ -71,6 +71,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("platform.action",), requires_capabilities=("platform.connect",), requires_platform_capabilities=("file.ops",), @@ -110,7 +111,10 @@ def tools(self) -> list[ToolMetadata]: "schema_cost": "high", "requires_approval": True, }, + mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("platform.connect",), + requires_platform_capabilities=("file.ops",), ), ToolMetadata( name="gateway_send", @@ -148,6 +152,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("platform.send_message",), requires_capabilities=("platform.configure",), requires_platform_capabilities=("file.ops",), @@ -197,7 +202,10 @@ def tools(self) -> list[ToolMetadata]: "schema_cost": "high", "requires_approval": True, }, + mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("platform.configure",), + requires_platform_capabilities=("file.ops",), ), ] diff --git a/src/leapflow/plugins/tool_plugins/hub.py b/src/leapflow/plugins/tool_plugins/hub.py index aec8da53..a16bec8f 100644 --- a/src/leapflow/plugins/tool_plugins/hub.py +++ b/src/leapflow/plugins/tool_plugins/hub.py @@ -59,6 +59,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("hub.push",), requires_platform_capabilities=("file.ops",), ), @@ -87,6 +88,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("hub.pull",), requires_platform_capabilities=("file.ops",), ), @@ -137,6 +139,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": True, }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("hub.sync",), requires_platform_capabilities=("file.ops",), ), diff --git a/src/leapflow/plugins/tool_plugins/self_management.py b/src/leapflow/plugins/tool_plugins/self_management.py index 2a519ce8..005a35bf 100644 --- a/src/leapflow/plugins/tool_plugins/self_management.py +++ b/src/leapflow/plugins/tool_plugins/self_management.py @@ -10,10 +10,10 @@ - plugin_propose : create a side-effect-free proposal from capability-gap evidence - assess_compatibility : assess foreign plugin manifest compatibility with LeapFlow -Generation (no approval needed — produces validated code without installing): +Governed generation (proposal content approval, no installation yet): - plugin_generate : describe a capability need; the LLM produces conformant - plugin code and it is rigorously validated. The validated - code is returned; installation is a separate, gated step. + plugin code, stores it in CAS, validates it, and requests + content approval. Installation is a second gated step. State-mutating (REQUIRES approval — routed through the plugin_approval_gate): - plugin_install : write validated code (from plugin_generate) or a @@ -50,7 +50,7 @@ import logging from pathlib import Path -from typing import Any, Dict, Optional +from typing import Any, Dict, Mapping, Optional from leapflow.plugins.protocol import ToolMetadata @@ -102,6 +102,7 @@ def __init__(self) -> None: # lazily from the active profile layout so in-process CLI mode still # installs into a profile-scoped path rather than the package dir. self._plugin_install_dir: Optional[str] = None + self._plugin_staging_dir: Optional[str] = None # Optional MarketplaceClient used by the marketplace_name install branch. # None when no marketplace is configured; the branch then returns a # structured error. @@ -109,15 +110,14 @@ def __init__(self) -> None: # Hex-encoded Ed25519 public keys trusted to sign marketplace plugins. # When non-empty, marketplace installs require a valid signature. self._trusted_pubkeys: set[str] = set() - # Optional persistent store for PluginProposal review queue. When not - # injected, it is resolved lazily from ProfileLayout.plugin_proposals_path. - self._plugin_proposal_store: Any = None - # Acquisition-lifecycle ledger (PENDING -> GENERATED -> INSTALLED -> - # PROBATION -> VERIFIED/QUARANTINED). Distinct from the review store above: - # that one answers "should a human accept this proposal", this one tracks - # where the capability is in its journey, and is what AdaptiveEvolutionPolicy - # and LifecycleGovernor operate on. + # Sole acquisition-lifecycle ledger (PENDING -> GENERATED -> APPROVED -> + # INSTALLED -> PROBATION -> VERIFIED/QUARANTINED). Rich review content is + # embedded in the same record; AdaptiveEvolutionPolicy and LifecycleGovernor + # both operate on this store. self._capability_lifecycle_store: Any = None + self._proposal_orchestrator: Any = None + self._evolution_outbox: Any = None + self._evolution_profile_id: str = "" # Optional version store; lazily resolved from ProfileLayout.plugin_versions_dir. self._plugin_version_store: Any = None # Optional adaptive capability decision store; lazily resolved from @@ -139,12 +139,15 @@ def dependencies(self) -> list[str]: "llm_provider", "plugin_generation_enabled", "plugin_install_dir", + "plugin_staging_dir", "marketplace_client", "marketplace_trusted_pubkeys", - "plugin_proposal_store", "plugin_version_store", "capability_plan_store", "capability_lifecycle_store", + "proposal_orchestrator", + "evolution_outbox", + "evolution_profile_id", ] def bind_runtime(self, **deps: Any) -> None: @@ -157,19 +160,26 @@ def bind_runtime(self, **deps: Any) -> None: if "plugin_install_dir" in deps: value = deps["plugin_install_dir"] self._plugin_install_dir = str(value) if value else None + if "plugin_staging_dir" in deps: + value = deps["plugin_staging_dir"] + self._plugin_staging_dir = str(value) if value else None if "marketplace_client" in deps: self._marketplace_client = deps["marketplace_client"] if "marketplace_trusted_pubkeys" in deps: raw = deps["marketplace_trusted_pubkeys"] or () self._trusted_pubkeys = {str(k).strip() for k in raw if str(k).strip()} - if "plugin_proposal_store" in deps: - self._plugin_proposal_store = deps["plugin_proposal_store"] if "plugin_version_store" in deps: self._plugin_version_store = deps["plugin_version_store"] if "capability_plan_store" in deps: self._capability_plan_store = deps["capability_plan_store"] if "capability_lifecycle_store" in deps: self._capability_lifecycle_store = deps["capability_lifecycle_store"] + if "proposal_orchestrator" in deps: + self._proposal_orchestrator = deps["proposal_orchestrator"] + if "evolution_outbox" in deps: + self._evolution_outbox = deps["evolution_outbox"] + if "evolution_profile_id" in deps: + self._evolution_profile_id = str(deps["evolution_profile_id"] or "") # ── Read-only introspection ──────────────────────────── @@ -303,9 +313,7 @@ def _build_capability_report( "plugin_install_dir": install_dir, "marketplace_configured": self._marketplace_client is not None, "trusted_marketplace_pubkeys": len(self._trusted_pubkeys), - "proposal_store_available": ( - self._plugin_proposal_store is not None or profile_layout is not None - ), + "proposal_store_available": self._capability_lifecycle_store is not None, "version_store_available": ( self._plugin_version_store is not None or profile_layout is not None ), @@ -395,7 +403,7 @@ def _capability_limitations(dependency_state: dict[str, Any]) -> list[str]: limitations.append("Marketplace installs require a configured marketplace client.") if not dependency_state["proposal_store_available"]: limitations.append( - "Plugin proposals require a profile layout or injected proposal store." + "Plugin proposals require the daemon-injected evolution lifecycle store." ) if not dependency_state["version_store_available"]: limitations.append( @@ -562,17 +570,17 @@ async def _plugin_propose_handler( except (TypeError, ValueError) as exc: return {"ok": False, "error": f"Proposal test case parsing failed: {exc}"} - try: - stored = self._proposal_store().save(proposal) - except (RuntimeError, OSError, ValueError, AttributeError) as exc: - return {"ok": False, "error": f"Proposal persistence failed: {exc}"} - - lifecycle_id = self._open_lifecycle_record(stored, requested_capability) + lifecycle_id = self._open_lifecycle_record(proposal, requested_capability) + if not lifecycle_id: + return { + "ok": False, + "error": "Proposal persistence failed: lifecycle store unavailable", + } return { "ok": True, "action": "propose", - "proposal": stored.to_dict(), + "proposal": proposal.to_dict(), "lifecycle_proposal_id": lifecycle_id, "next_actions": [ "Review proposal fields and risk level.", @@ -639,78 +647,102 @@ async def _plugin_generate_handler( ) result = await generator.generate_and_validate(request) if proposal_id: + lifecycle_id = self._lifecycle_proposal_id(source, proposal_id) result["proposal_id"] = proposal_id - if result.get("ok"): - self._mark_generation_started(source, proposal_id) + result["lifecycle_proposal_id"] = lifecycle_id + if result.get("ok") and lifecycle_id and self._proposal_orchestrator is not None: + item = self._proposal_orchestrator.register_generated( + lifecycle_id, + str(result.get("code") or ""), + validation={ + "ok": True, + "stage": "passed", + "compatibility_ok": True, + "target_protocol": "ToolPlugin", + "exposed_tools": list(result.get("exposed_tools") or ()), + }, + ) + content_approval = await self._proposal_orchestrator.approve_content( + lifecycle_id + ) + result.update( + { + "generated_code_ref": item.generated_code_ref, + "content_approved": content_approval.approved, + "content_approval_id": content_approval.approval_id, + } + ) + if not content_approval.approved: + result.update( + { + "ok": False, + "error": content_approval.denial_message, + "requires_approval": True, + } + ) + elif result.get("ok"): + result.update( + { + "ok": False, + "error": "proposal orchestration unavailable; content approval cannot be recorded", + "requires_approval": True, + } + ) return result - except (AttributeError, RuntimeError) as exc: + except (AttributeError, KeyError, PermissionError, RuntimeError, ValueError) as exc: return {"ok": False, "error": f"Generation failed: {exc}"} def _resolve_generation_source( self, proposal_id: str ) -> tuple[str, str, str, tuple[str, ...]]: - """Resolve a generation request from *either* proposal store. - - Two stores can name a proposal, and both must reach generation: - - * the **review store** (``JsonPluginProposalStore``) holds a rich - ``PluginProposal`` created by the manual ``plugin_propose`` UX flow; - * the **lifecycle queue** (``JsonCapabilityProposalQueue``) holds the - acquisition record the world-model driver enqueues -- a - ``prop-`` id keyed on the requirement, carrying the capability, - the ``plugin_id`` the sink stamped, and the hypothesis as its summary. - - Before this, ``plugin_generate`` looked only in the review store, so a - world-model proposal could never be generated from its own id: Scene C could - not proceed from a real teacher verdict to a validated artifact. Returning a - normalised ``(source, plugin_id, description, provides_capabilities)`` unifies - the two consumption points without collapsing their distinct lifecycle - vocabularies. ``source`` is ``""`` when neither store knows the id. - """ - review = self._proposal_store().get(proposal_id) - if review is not None: + """Resolve either canonical lifecycle id or review alias from one store.""" + try: + store = self._lifecycle_store() + item = store.get(proposal_id) + source = "lifecycle" + if item is None: + item = store.find_by_metadata("review_proposal_id", proposal_id) + source = "review" + except (RuntimeError, OSError, ValueError, AttributeError): + item = None + source = "" + if item is None: + return ("", "", "", ()) + metadata = dict(item.metadata or {}) + review_payload = metadata.get("review_proposal") + if isinstance(review_payload, Mapping): + from leapflow.domain.plugin_proposal import PluginProposal + + review = PluginProposal.from_dict(review_payload) return ( - "review", + source, str(review.plugin_id), str(review.capability_summary), _declared_capabilities(review), ) - try: - item = self._lifecycle_store().get(proposal_id) - except (RuntimeError, OSError, ValueError, AttributeError): - item = None - if item is not None: - requirements = [dict(r) for r in (item.requirements or ())] - capability = str((requirements[0].get("capability") if requirements else "") or "") - metadata = dict(item.metadata or {}) - plugin_id = str(metadata.get("plugin_id") or "") - description = str( - metadata.get("capability_summary") - or (requirements[0].get("evidence") if requirements else "") - or capability - ) - provides = (capability,) if capability else () - return ("lifecycle", plugin_id, description, provides) - return ("", "", "", ()) - - def _mark_generation_started(self, source: str, proposal_id: str) -> None: - """Advance the proposal's status in whichever store owns it. - - The two stores speak different vocabularies on purpose (see - ``evolution_contracts``): the review store moves to ``review`` (a human-accept - state), the lifecycle queue to ``GENERATED`` (an acquisition-lifecycle state - ``AdaptiveEvolutionPolicy`` reads next). Contained: a status write must not fail - a generation that already succeeded. - """ - try: - if source == "review": - self._proposal_store().update_status(proposal_id, "review") - elif source == "lifecycle": - self._lifecycle_store().update(proposal_id, status="GENERATED") - except (RuntimeError, OSError, ValueError, AttributeError): - logger.debug( - "plugin_generate: could not advance %s status", proposal_id, exc_info=True - ) + requirements = [dict(requirement) for requirement in (item.requirements or ())] + capability = str((requirements[0].get("capability") if requirements else "") or "") + plugin_id = str(metadata.get("plugin_id") or "") + description = str( + metadata.get("capability_summary") + or (requirements[0].get("evidence") if requirements else "") + or capability + ) + provides = (capability,) if capability else () + return (source, plugin_id, description, provides) + + def _lifecycle_proposal_id(self, source: str, proposal_id: str) -> str: + if source == "lifecycle": + return proposal_id + if source == "review": + try: + item = self._lifecycle_store().find_by_metadata( + "review_proposal_id", proposal_id + ) + except (RuntimeError, OSError, ValueError, AttributeError): + item = None + return str(getattr(item, "proposal_id", "") or "") + return "" # ── Compatibility assessment (read-only) ───────────────── @@ -826,12 +858,39 @@ async def _plugin_install_handler( ) -> Dict[str, Any]: """Install Python code/marketplace content or a real DSH source bundle.""" proposal = None + lifecycle_id = "" if proposal_id: - proposal = self._proposal_store().get(proposal_id) - if proposal is None: + try: + store = self._lifecycle_store() + lifecycle = store.get(proposal_id) + if lifecycle is None: + lifecycle = store.find_by_metadata("review_proposal_id", proposal_id) + except (RuntimeError, OSError, ValueError, AttributeError): + lifecycle = None + if lifecycle is None: return {"ok": False, "error": f"Plugin proposal '{proposal_id}' not found"} - plugin_id = plugin_id or proposal.plugin_id + lifecycle_id = str(lifecycle.proposal_id) + metadata = dict(lifecycle.metadata or {}) + review_payload = metadata.get("review_proposal") + if isinstance(review_payload, Mapping): + from leapflow.domain.plugin_proposal import PluginProposal + + proposal = PluginProposal.from_dict(review_payload) + plugin_id = plugin_id or proposal.plugin_id + else: + plugin_id = plugin_id or str(metadata.get("plugin_id") or "") source_path = str(source_path or kwargs.get("source_path") or "") + if ( + lifecycle_id + and not code + and not marketplace_name + and not source_path + and self._proposal_orchestrator is not None + ): + try: + code = self._proposal_orchestrator.generated_code(lifecycle_id) + except (KeyError, OSError, RuntimeError, ValueError) as exc: + return {"ok": False, "error": str(exc)} modes = sum(bool(value) for value in (code, marketplace_name, source_path)) if modes != 1: return { @@ -888,11 +947,31 @@ async def _plugin_install_handler( if not plugin_id: return {"ok": False, "error": "plugin_id is required unless source_path or proposal_id is provided"} - approved, denial = await self._check_approval( - "install", plugin_id, proposal_id=proposal_id, metadata=source_metadata, - ) - if not approved: - return {"ok": False, "error": denial, "requires_approval": True} + if lifecycle_id: + if self._proposal_orchestrator is None: + return { + "ok": False, + "error": "proposal orchestration unavailable; mutation approval cannot be recorded", + "requires_approval": True, + } + try: + mutation_approval = await self._proposal_orchestrator.authorize_mutation( + lifecycle_id + ) + except (KeyError, PermissionError, ValueError) as exc: + return {"ok": False, "error": str(exc), "requires_approval": True} + if not mutation_approval.approved: + return { + "ok": False, + "error": mutation_approval.denial_message, + "requires_approval": True, + } + else: + approved, denial = await self._check_approval( + "install", plugin_id, proposal_id=proposal_id, metadata=source_metadata, + ) + if not approved: + return {"ok": False, "error": denial, "requires_approval": True} from leapflow.plugins import get_registry @@ -929,20 +1008,35 @@ async def _plugin_install_handler( return {"ok": False, "error": "Must provide code, marketplace_name, or source_path"} if proposal_id: result["proposal_id"] = proposal_id - if result.get("ok"): - self._proposal_store().update_status(proposal_id, "approved") + if lifecycle_id and self._proposal_orchestrator is not None: + self._proposal_orchestrator.record_installed(lifecycle_id, result) + result["lifecycle_proposal_id"] = lifecycle_id + elif result.get("ok"): + from leapflow.domain.event_types import EvolutionEventType + + persisted = await self._emit_plugin_event( + EvolutionEventType.PLUGIN_INSTALLED, + plugin_id=plugin_id, + version_id=str(result.get("version") or version_label), + payload={ + "action": "install", + "installed_tools": list(result.get("installed_tools") or ()), + }, + dedup_suffix=str( + result.get("version") + or source_metadata.get("bundle_sha256") + or "installed" + ), + ) + if not persisted: + result["audit_incomplete"] = True return result except (ImportError, AttributeError, OSError, RuntimeError, ValueError) as exc: logger.warning("plugin_install failed for %s: %s", plugin_id, exc, exc_info=True) return {"ok": False, "error": f"Install failed: {exc}"} def _resolve_install_dir(self) -> "Path": - """Resolve the profile-scoped directory for installed plugin code. - - Precedence: the injected ``plugin_install_dir`` (from bind_runtime) -> - the active ``ProfileLayout.plugins_dir`` -> a plugins dir under the data - root. Always profile-scoped; never the Python package directory. - """ + """Resolve the profile-scoped directory for installed plugin code.""" from pathlib import Path if self._plugin_install_dir: @@ -955,35 +1049,49 @@ def _resolve_install_dir(self) -> "Path": return profile_layout.plugins_dir return Path(settings.layout.root) / "plugins" - def _proposal_store(self) -> Any: - """Resolve the profile-scoped proposal store.""" - if self._plugin_proposal_store is not None: - return self._plugin_proposal_store + def _resolve_staging_dir(self) -> "Path": + """Resolve the profile-owned quarantine directory for candidate code.""" + from pathlib import Path + + if self._plugin_staging_dir: + return Path(self._plugin_staging_dir) + if self._plugin_install_dir: + return Path(self._plugin_install_dir) / ".staging" + from leapflow.config import get_settings + + profile_layout = getattr(get_settings(), "profile_layout", None) + if profile_layout is not None: + return profile_layout.plugin_staging_dir + return self._resolve_install_dir() / ".staging" + + @staticmethod + def _sandbox_settings() -> dict[str, int | float]: + """Return bounded sandbox configuration from the effective settings.""" from leapflow.config import get_settings - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore settings = get_settings() - profile_layout = getattr(settings, "profile_layout", None) - if profile_layout is None: - raise RuntimeError("profile_layout is required for plugin proposal storage") - self._plugin_proposal_store = JsonPluginProposalStore(profile_layout.plugin_proposals_path) - return self._plugin_proposal_store + return { + "invoke_timeout_s": max( + 0.1, float(getattr(settings, "plugin_sandbox_invoke_timeout_s", 15.0)) + ), + "shutdown_timeout_s": max( + 0.1, float(getattr(settings, "plugin_sandbox_shutdown_timeout_s", 3.0)) + ), + "cpu_time_s": max( + 0, int(getattr(settings, "plugin_sandbox_cpu_time_s", 30)) + ), + "max_memory_bytes": max( + 0, int(getattr(settings, "plugin_sandbox_max_memory_mb", 0)) + ) + * 1024 + * 1024, + } def _lifecycle_store(self) -> Any: """Resolve the profile-scoped acquisition-lifecycle ledger.""" if self._capability_lifecycle_store is not None: return self._capability_lifecycle_store - from leapflow.config import get_settings - from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue - - settings = get_settings() - profile_layout = getattr(settings, "profile_layout", None) - if profile_layout is None: - raise RuntimeError("profile_layout is required for capability lifecycle storage") - self._capability_lifecycle_store = JsonCapabilityProposalQueue( - profile_layout.capability_proposal_queue_path - ) - return self._capability_lifecycle_store + raise RuntimeError("capability lifecycle store was not injected by the runtime") def _open_lifecycle_record(self, proposal: Any, capability: str) -> str: """Open a PENDING lifecycle record correlated with a review proposal. @@ -1013,6 +1121,7 @@ def _open_lifecycle_record(self, proposal: Any, capability: str) -> str: metadata={ "plugin_id": proposal.plugin_id, "review_proposal_id": proposal.proposal_id, + "review_proposal": proposal.to_dict(), }, ) self._trace_lifecycle_opened(item, proposal, requirement) @@ -1091,8 +1200,14 @@ def _capability_plan_store_resolved(self) -> Any: async def _install_from_code( self, plugin_id: str, code: str, *, proposal: Any = None, version_label: str = "" ) -> Dict[str, Any]: - """Re-validate, write to the profile dir, smoke test, then load in-process.""" + """Validate in quarantine, then atomically publish one DRAFT fiber.""" + import os + import shutil + import sys + import tempfile + from leapflow.learning.plugin_generator import PluginValidator + from leapflow.plugins import get_scoped_registry validator = PluginValidator() vresult = await validator.validate(plugin_id, code) @@ -1103,35 +1218,37 @@ async def _install_from_code( } install_dir = self._resolve_install_dir() + staging_root = self._resolve_staging_dir() install_dir.mkdir(parents=True, exist_ok=True) + staging_root.mkdir(parents=True, exist_ok=True) + staging_dir = Path(tempfile.mkdtemp(prefix=f"{plugin_id}-", dir=staging_root)) + staged_target = staging_dir / f"{plugin_id}.py" target = install_dir / f"{plugin_id}.py" - target.write_text(code) - - # D3: real subprocess smoke test before the plugin is made live. - smoke_ok, smoke_err = await self._sandbox_smoke_test(plugin_id, install_dir) - if not smoke_ok: - self._safe_unlink(target) - return {"ok": False, "error": smoke_err} - - result = self._register_inprocess(plugin_id, plugin_id, target) - if not result.get("ok"): - return result - if proposal is not None and getattr(proposal, "test_cases", ()): - ok, error, observations = await self._run_behavior_tests_for_plugin( - plugin_id, tuple(getattr(proposal, "test_cases", ()) or ()) + previous_source = target.read_bytes() if target.exists() else None + previous_module = sys.modules.get(plugin_id) + scoped = get_scoped_registry() + promoted = False + try: + staged_target.write_text(code, encoding="utf-8") + test_cases = tuple(getattr(proposal, "test_cases", ()) or ()) + ok, error, observations = await self._sandbox_validate_candidate( + plugin_id, + staging_dir, + test_cases=test_cases, ) - result["behavior_tests"] = observations if not ok: - from leapflow.plugins import get_scoped_registry + return {"ok": False, "error": error, "behavior_tests": observations} + + new_plugin, load_err = self._load_from_path(plugin_id, staged_target) + if new_plugin is None: + return {"ok": False, "error": load_err} + fiber = scoped.create_draft_fiber(plugin_id) + scoped.stage_plugin(new_plugin, fiber) + setattr(new_plugin, "__leapflow_plugin_path__", str(target)) + os.replace(staged_target, target) + fiber = scoped.promote_draft(plugin_id) + promoted = True - scoped = get_scoped_registry() - try: - scoped.dispose_plugin(plugin_id, prune_metadata=True) - except KeyError: - pass - self._safe_unlink(target) - return {"ok": False, "error": f"Behavior tests failed: {error}"} - try: version_info = self._version_store().record_source( plugin_id, target, @@ -1141,18 +1258,75 @@ async def _install_from_code( "proposal_id": getattr(proposal, "proposal_id", ""), }, ) - result["version"] = version_info.get("version", "") - except (RuntimeError, OSError, ValueError, AttributeError) as exc: - logger.debug( - "plugin version recording skipped for %s: %s", plugin_id, exc, exc_info=True - ) - version_info = {} - # An artifact this path installed is one self-evolution acquired, so later - # sweeps may verify its effect and reclaim it if nothing can ever select it. - # A hand-installed plugin is deliberately never recorded here. - self._record_acquisition(plugin_id) - self._trace_artifact_installed(plugin_id, proposal, version_info, result) - return result + result: Dict[str, Any] = { + "ok": True, + "action": "install", + "plugin_id": plugin_id, + "installed_tools": [tool.name for tool in new_plugin.tools], + "state": fiber.state.value, + "shadow_validated": True, + "behavior_tests": observations, + "version": version_info.get("version", ""), + } + self._record_acquisition(plugin_id) + self._trace_artifact_installed(plugin_id, proposal, version_info, result) + return result + except (AttributeError, OSError, RuntimeError, TypeError, ValueError) as exc: + if promoted: + try: + scoped.dispose_plugin(plugin_id, prune_metadata=True) + except (KeyError, RuntimeError, ValueError): + pass + else: + scoped.discard_draft(plugin_id) + if previous_source is None: + self._safe_unlink(target) + else: + target.write_bytes(previous_source) + if previous_module is None: + sys.modules.pop(plugin_id, None) + else: + sys.modules[plugin_id] = previous_module + return {"ok": False, "error": f"Install transaction failed: {exc}"} + finally: + shutil.rmtree(staging_dir, ignore_errors=True) + + async def _emit_plugin_event( + self, + event_type: str, + *, + plugin_id: str, + proposal_id: str = "", + version_id: str = "", + payload: Mapping[str, Any] | None = None, + dedup_suffix: str, + ) -> bool: + """Persist a plugin mutation fact through the daemon-owned outbox.""" + outbox = self._evolution_outbox + if outbox is None or not self._evolution_profile_id: + return False + from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent + + event = EvolutionEvent.create( + event_type, + context=EvolutionContext( + profile_id=self._evolution_profile_id, + proposal_id=proposal_id, + plugin_id=plugin_id, + version_id=version_id, + correlation_id=proposal_id or plugin_id, + ), + payload=dict(payload or {}), + producer="plugin.self_management", + privacy_class="profile", + dedup_key=f"{event_type}:{plugin_id}:{dedup_suffix}", + ) + try: + await outbox.publish(event, critical=True) + return True + except Exception: # noqa: BLE001 - mutation already happened; report audit gap + logger.error("plugin mutation event could not be persisted", exc_info=True) + return False @staticmethod def _record_acquisition(plugin_id: str) -> None: @@ -1504,54 +1678,98 @@ async def _install_from_marketplace( return self._register_inprocess(plugin_id, module_name, installed_path) async def _sandbox_smoke_test( - self, module_name: str, install_dir: "Path", *, timeout_s: float = 15.0 + self, module_name: str, install_dir: "Path", *, timeout_s: float | None = None ) -> tuple[bool, str]: - """Load the module in a sandbox worker and invoke its first tool once. - - Returns (ok, error). A host-level failure (worker crash/timeout/comm - error, signalled by an empty ``error_type``) fails the test. A tool - that raises but is caught at the isolation boundary (non-empty - ``error_type``) still counts as success: the module loaded and the - handler is invocable, which is all the smoke test asserts. - """ - import os + """Load a module in the bounded subprocess and invoke its first tool.""" + limits = self._sandbox_settings() + if timeout_s is not None: + limits["invoke_timeout_s"] = max(0.1, float(timeout_s)) + ok, error, _ = await self._sandbox_validate_candidate( + module_name, + install_dir, + test_cases=(), + limits=limits, + ) + return ok, error + async def _sandbox_validate_candidate( + self, + module_name: str, + install_dir: "Path", + *, + test_cases: tuple[Any, ...], + limits: dict[str, int | float] | None = None, + ) -> tuple[bool, str, list[dict[str, Any]]]: + """Run smoke and proposal behavior tests without publishing host handlers.""" from leapflow.plugins.sandbox.sandbox_host import SandboxHost - host = SandboxHost(module_name, invoke_timeout_s=timeout_s) - # The worker imports the plugin by module name; make the install dir - # importable for the child process during startup only. - started = False - original_pp = os.environ.get("PYTHONPATH") - os.environ["PYTHONPATH"] = os.pathsep.join( - [str(install_dir)] + ([original_pp] if original_pp else []) + sandbox_limits = dict(limits or self._sandbox_settings()) + host = SandboxHost( + module_name, + python_paths=(str(install_dir),), + **sandbox_limits, ) + started = False + observations: list[dict[str, Any]] = [] try: await host.start() started = True except (OSError, RuntimeError, ValueError) as exc: - return False, f"Sandbox smoke test error: {exc}" - finally: - if original_pp is None: - os.environ.pop("PYTHONPATH", None) - else: - os.environ["PYTHONPATH"] = original_pp + return False, f"Sandbox smoke test error: {exc}", observations if not started: - return False, "Sandbox smoke test failed: worker did not start" + return False, "Sandbox smoke test failed: worker did not start", observations try: if not await host.ping(): - return False, "Sandbox smoke test failed: worker did not respond" + return False, "Sandbox smoke test failed: worker did not respond", observations tool_names = await host.list_tools() if not tool_names: - return False, ( + return ( + False, "Sandbox smoke test failed: plugin exposed no tools " - "(likely failed to import in isolation)" + "(likely failed to import in isolation)", + observations, + ) + smoke = await host.invoke(tool_names[0], {}) + if not smoke.ok and not smoke.error_type: + return False, f"Sandbox smoke test failed: {smoke.error}", observations + for index, case in enumerate(test_cases): + tool_name = str(getattr(case, "tool_name", "") or "") + if tool_name not in tool_names: + return ( + False, + f"Behavior tests failed: behavior test {index}: " + f"tool {tool_name!r} not exposed", + observations, + ) + arguments = dict(getattr(case, "arguments", {}) or {}) + expected = dict(getattr(case, "expected_subset", {}) or {}) + response = await host.invoke(tool_name, arguments) + if not response.ok: + return ( + False, + f"Behavior tests failed: behavior test {index}: " + f"handler raised {response.error_type or 'SandboxError'}: {response.error}", + observations, + ) + observations.append( + {"tool_name": tool_name, "arguments": arguments, "result": response.result} ) - resp = await host.invoke(tool_names[0], {}) - if not resp.ok and not resp.error_type: - return False, f"Sandbox smoke test failed: {resp.error}" - return True, "" + if not isinstance(response.result, dict): + return ( + False, + f"Behavior tests failed: behavior test {index}: result is not a dict", + observations, + ) + for key, expected_value in expected.items(): + if response.result.get(key) != expected_value: + return ( + False, + f"Behavior tests failed: behavior test {index}: expected " + f"{key}={expected_value!r}, got {response.result.get(key)!r}", + observations, + ) + return True, "", observations finally: try: await host.stop() @@ -1568,22 +1786,21 @@ def _register_inprocess( """ import sys - from leapflow.plugins import get_registry, get_scoped_registry + from leapflow.plugins import get_scoped_registry new_plugin, load_err = self._load_from_path(module_name, target) if new_plugin is None: self._safe_unlink(target) return {"ok": False, "error": load_err} - reg = get_registry() scoped = get_scoped_registry() - fiber = scoped.create_fiber(plugin_id) + fiber = scoped.create_draft_fiber(plugin_id) try: - scoped.scoped_register(new_plugin, fiber) - fiber.activate() - installed_tools = reg.publish_plugin_tools(new_plugin) + scoped.stage_plugin(new_plugin, fiber) + fiber = scoped.promote_draft(plugin_id) + installed_tools = [tool.name for tool in new_plugin.tools] except (RuntimeError, ValueError, AttributeError, TypeError) as exc: - self._rollback_fiber(scoped, plugin_id, fiber) + scoped.discard_draft(plugin_id) sys.modules.pop(module_name, None) self._safe_unlink(target) return {"ok": False, "error": f"Registration failed: {exc}"} @@ -1605,29 +1822,22 @@ async def _register_sandboxed( the sandbox worker and every handler proxies to it via SandboxedToolPlugin. The worker is stopped when the fiber is disposed. """ - import os - - from leapflow.plugins import get_registry, get_scoped_registry + from leapflow.plugins import get_scoped_registry from leapflow.plugins.protocol import ToolMetadata from leapflow.plugins.sandbox.sandbox_host import SandboxHost, SandboxedToolPlugin install_dir = installed_path.parent - host = SandboxHost(module_name) - started = False - original_pp = os.environ.get("PYTHONPATH") - os.environ["PYTHONPATH"] = os.pathsep.join( - [str(install_dir)] + ([original_pp] if original_pp else []) + host = SandboxHost( + module_name, + python_paths=(str(install_dir),), + **self._sandbox_settings(), ) + started = False try: await host.start() started = True except (OSError, RuntimeError, ValueError) as exc: return {"ok": False, "error": f"Sandbox start failed: {exc}"} - finally: - if original_pp is None: - os.environ.pop("PYTHONPATH", None) - else: - os.environ["PYTHONPATH"] = original_pp if not started: return {"ok": False, "error": "Sandbox start failed"} @@ -1654,17 +1864,15 @@ async def _register_sandboxed( ] sandboxed = SandboxedToolPlugin(plugin_id, "marketplace", metadatas, host) - reg = get_registry() scoped = get_scoped_registry() - fiber = scoped.create_fiber(plugin_id) + fiber = scoped.create_draft_fiber(plugin_id) try: - scoped.scoped_register(sandboxed, fiber) - fiber.activate() - installed_tools = reg.publish_plugin_tools(sandboxed) - # Stop the worker subprocess when the fiber is disposed. - fiber.scope.effect(lambda h=host: self._schedule_host_stop(h)) + scoped.stage_plugin(sandboxed, fiber) + fiber.scope.async_effect(host.stop) + fiber = scoped.promote_draft(plugin_id) + installed_tools = [tool.name for tool in sandboxed.tools] except (RuntimeError, ValueError, AttributeError, TypeError) as exc: - self._rollback_fiber(scoped, plugin_id, fiber) + scoped.discard_draft(plugin_id) await host.stop() self._safe_unlink(installed_path) return {"ok": False, "error": f"Sandboxed registration failed: {exc}"} @@ -1720,31 +1928,6 @@ def _load_from_path(self, module_name: str, path: "Path") -> "tuple[Any, str]": ) return plugin_obj, "" - @staticmethod - def _rollback_fiber(scoped: Any, plugin_id: str, fiber: Any) -> None: - """Dispose a fiber and drop it from the scoped registry (rollback path).""" - from leapflow.domain.plugin_fiber import FiberState - - try: - if fiber.state == FiberState.ACTIVE: - fiber.begin_unload() - if fiber.state != FiberState.DISPOSED: - fiber.dispose() - except (RuntimeError, ValueError, AttributeError): - pass - scoped._fibers.pop(plugin_id, None) - - @staticmethod - def _schedule_host_stop(host: Any) -> None: - """Best-effort async shutdown of a sandbox worker on fiber disposal.""" - import asyncio - - try: - loop = asyncio.get_running_loop() - except RuntimeError: - return - loop.create_task(host.stop()) - @staticmethod def _safe_unlink(path: "Path") -> None: """Remove a written plugin file, ignoring absence/IO errors.""" @@ -1785,16 +1968,25 @@ def _active_proposal_tests(self, plugin_id: str) -> tuple[str, tuple[Any, ...], if not proposal_id: return "", (), "" try: - proposal = self._proposal_store().get(proposal_id) + store = self._lifecycle_store() + lifecycle = store.get(proposal_id) + if lifecycle is None: + lifecycle = store.find_by_metadata("review_proposal_id", proposal_id) except (RuntimeError, OSError, ValueError, AttributeError) as exc: return ( proposal_id, (), f"Plugin proposal '{proposal_id}' unavailable for behavior tests: {exc}", ) - if proposal is None: + if lifecycle is None: return proposal_id, (), f"Plugin proposal '{proposal_id}' not found for behavior tests" - return proposal_id, tuple(getattr(proposal, "test_cases", ()) or ()), "" + review_payload = dict(lifecycle.metadata or {}).get("review_proposal") + if not isinstance(review_payload, Mapping): + return proposal_id, (), "" + from leapflow.domain.plugin_proposal import PluginProposal + + proposal = PluginProposal.from_dict(review_payload) + return proposal_id, tuple(proposal.test_cases), "" async def _run_behavior_tests_for_plugin( self, plugin_id: str, test_cases: tuple[Any, ...] @@ -1870,13 +2062,16 @@ async def _plugin_rollback_handler( approved, denial = await self._check_approval("rollback", plugin_id) if not approved: return {"ok": False, "error": denial, "requires_approval": True} - try: - from leapflow.plugins import reload_plugin + from leapflow.plugins import reload_plugin - target = self._resolve_install_dir() / f"{plugin_id}.py" - entry = self._version_store().rollback(plugin_id, version, target) + target = self._resolve_install_dir() / f"{plugin_id}.py" + version_store = self._version_store() + metadata_snapshot = version_store.snapshot_state(plugin_id) + source_snapshot = target.read_bytes() if target.exists() else None + try: + entry = version_store.rollback(plugin_id, version, target) fiber = reload_plugin(plugin_id) - return { + response = { "ok": True, "action": "rollback", "plugin_id": plugin_id, @@ -1884,11 +2079,40 @@ async def _plugin_rollback_handler( "state": fiber.state.value, "new_generation": fiber.generation, } - except KeyError as exc: - return {"ok": False, "error": str(exc)} - except (RuntimeError, OSError, AttributeError) as exc: + from leapflow.domain.event_types import EvolutionEventType + + persisted = await self._emit_plugin_event( + EvolutionEventType.PLUGIN_ROLLED_BACK, + plugin_id=plugin_id, + version_id=str(entry.get("version") or version), + payload=response, + dedup_suffix=f"{entry.get('version', version)}:{fiber.generation}", + ) + if not persisted: + response["audit_incomplete"] = True + return response + except (KeyError, RuntimeError, OSError, AttributeError) as exc: + restoration_error = "" + try: + version_store.restore_source(target, source_snapshot) + version_store.restore_state(plugin_id, metadata_snapshot) + reload_plugin(plugin_id) + except (KeyError, RuntimeError, OSError, AttributeError) as restore_exc: + restoration_error = str(restore_exc) + logger.error( + "plugin_rollback could not restore the previous runtime: %s", + restore_exc, + exc_info=True, + ) logger.warning("plugin_rollback failed: %s", exc, exc_info=True) - return {"ok": False, "error": f"Rollback failed: {exc}"} + response = { + "ok": False, + "error": f"Rollback failed: {exc}", + "rolled_back": restoration_error == "", + } + if restoration_error: + response["rollback_error"] = restoration_error + return response async def _plugin_enable_handler(self, plugin_id: str, **kwargs: Any) -> Dict[str, Any]: """Re-enable a previously disabled plugin. REQUIRES approval. @@ -2329,9 +2553,9 @@ def tools(self) -> list[ToolMetadata]: "description. The LLM produces code that conforms to the " "ToolPlugin Protocol; it is then rigorously validated " "(syntax, structure, import, protocol conformance). The " - "isolated sandbox smoke test runs later, at install-time. " - "Returns the validated code but DOES NOT install it — " - "installation is a separate approval-gated step via plugin_install." + "generated source is stored in CAS and receives explicit content " + "approval. It DOES NOT install the plugin — installation requires " + "a second, mutation-specific approval via plugin_install." ), parameters_schema={ "type": "object", @@ -2346,7 +2570,7 @@ def tools(self) -> list[ToolMetadata]: }, "proposal_id": { "type": "string", - "description": "Optional PluginProposal id to generate from; fills plugin_id/description when omitted.", + "description": "Optional lifecycle proposal id or review alias; fills plugin_id/description when omitted.", }, }, "required": [], @@ -2359,7 +2583,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": False, "effect_scope": "none", "idempotency_scope": "turn", - "summary": "generate a new plugin (produces code only, no install)", + "summary": "generate, validate, persist, and approve proposal content", }, provides_capabilities=("plugin.generate",), ), @@ -2394,7 +2618,7 @@ def tools(self) -> list[ToolMetadata]: }, "proposal_id": { "type": "string", - "description": "Optional PluginProposal id to link into approval metadata and mark approved on success.", + "description": "Optional lifecycle proposal id or review alias; requires prior content approval.", }, "version_label": { "type": "string", diff --git a/src/leapflow/plugins/tool_plugins/shell_terminal.py b/src/leapflow/plugins/tool_plugins/shell_terminal.py index 394640eb..856e5e6f 100644 --- a/src/leapflow/plugins/tool_plugins/shell_terminal.py +++ b/src/leapflow/plugins/tool_plugins/shell_terminal.py @@ -70,6 +70,7 @@ def tools(self) -> list[ToolMetadata]: "idempotency_scope": "session", }, mutates_state=True, + execution_policy="external_side_effect", # Grounded in leapflow.domain.platform.Capability.SHELL_EXEC: # a host without shell execution cannot run this tool, which # environment-fit scoring uses to exclude it rather than fail @@ -110,6 +111,7 @@ def tools(self) -> list[ToolMetadata]: "effect_scope": "external", }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("shell.session_create",), requires_platform_capabilities=("shell.exec",), ), @@ -140,6 +142,7 @@ def tools(self) -> list[ToolMetadata]: "effect_scope": "external", }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("shell.session_input",), requires_platform_capabilities=("shell.exec",), ), @@ -191,6 +194,7 @@ def tools(self) -> list[ToolMetadata]: "requires_approval": False, }, mutates_state=True, + execution_policy="external_side_effect", provides_capabilities=("shell.session_destroy",), requires_platform_capabilities=("shell.exec",), ), diff --git a/src/leapflow/skills/registry.py b/src/leapflow/skills/registry.py index 05117e62..3bee7f10 100644 --- a/src/leapflow/skills/registry.py +++ b/src/leapflow/skills/registry.py @@ -191,7 +191,8 @@ async def invoke( if not pre.passed: return SkillResult(ok=False, error=f"precondition_failed: {pre.reason}") - # Core execution closure for prediction loop wrapping + # The registry validates and invokes only. Cross-cutting evidence belongs to + # the runtime ActionExecutor so every entry point follows the same boundary. async def _execute_core() -> Any: from leapflow.utils.resilience import ResiliencePolicy, execute_with_resilience policy = ResiliencePolicy(timeout_s=self._timeout_for(skill)) @@ -199,20 +200,9 @@ async def _execute_core() -> Any: lambda: skill.run(**validated), policy ) - # Execute with optional prediction loop t0 = time.perf_counter() - prediction_outcome = None try: - if self._prediction_loop is not None: - user_goal = str(kwargs.get("user_goal", "") or "") - if user_goal and hasattr(self._prediction_loop, "set_goal"): - self._prediction_loop.set_goal(user_goal) - action_desc = f"skill:{name}" - output, prediction_outcome = await self._prediction_loop.wrap_execution( - action_desc, _execute_core, - ) - else: - output = await _execute_core() + output = await _execute_core() elapsed = time.perf_counter() - t0 except asyncio.TimeoutError: elapsed = time.perf_counter() - t0 diff --git a/src/leapflow/storage/__init__.py b/src/leapflow/storage/__init__.py index e43e173a..a2c6d80f 100644 --- a/src/leapflow/storage/__init__.py +++ b/src/leapflow/storage/__init__.py @@ -11,6 +11,13 @@ from leapflow.storage.connection import ConnectionHolder, LocalConnectionHolder from leapflow.storage.conversation_store import DuckDBConversationStore from leapflow.storage.duckdb_connect import DatabaseLockedError, connect, is_lock_error +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.distilled_knowledge_store import EvolutionDistilledKnowledgeStore +from leapflow.storage.evolution_event_store import ( + DuckDBEvolutionEventStore, + EvolutionTraceEventStore, +) +from leapflow.storage.plugin_outcome_store import EvolutionPluginOutcomeStore from leapflow.storage.session_store import LearningSessionStore from leapflow.storage.skill_docs import SkillDocStore from leapflow.storage.skill_library import SkillLibraryStore @@ -21,6 +28,11 @@ "ConnectionHolder", "DatabaseLockedError", "DuckDBConversationStore", + "DuckDBEvolutionEventStore", + "EvolutionCapabilityProposalStore", + "EvolutionDistilledKnowledgeStore", + "EvolutionPluginOutcomeStore", + "EvolutionTraceEventStore", "LocalConnectionHolder", "LearningSessionStore", "SkillDocStore", diff --git a/src/leapflow/storage/capability_proposal_queue.py b/src/leapflow/storage/capability_proposal_queue.py index 84648857..b4947d7b 100644 --- a/src/leapflow/storage/capability_proposal_queue.py +++ b/src/leapflow/storage/capability_proposal_queue.py @@ -3,13 +3,14 @@ from __future__ import annotations -import json +import threading import time from dataclasses import dataclass, field -from pathlib import Path from typing import Any, Literal, Mapping, Sequence from leapflow.domain.capability_requirement import CapabilityRequirement +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent, content_hash ProposalStatus = Literal[ "PENDING", @@ -21,9 +22,34 @@ "REJECTED", "FAILED", "QUARANTINED", + "SUPERSEDED", + "EXPIRED", + "NO_OP", ] -_ACTIVE_STATUSES = {"PENDING", "GENERATED", "APPROVED", "INSTALLED", "PROBATION"} +_ACTIVE_STATUSES = { + "PENDING", + "GENERATED", + "APPROVED", + "INSTALLED", + "PROBATION", + "VERIFIED", +} +_CANCELLATION_STATUSES = frozenset({"REJECTED", "FAILED", "SUPERSEDED", "EXPIRED", "NO_OP"}) +_ALLOWED_TRANSITIONS: dict[str, frozenset[str]] = { + "PENDING": frozenset({"GENERATED", *_CANCELLATION_STATUSES}), + "GENERATED": frozenset({"APPROVED", *_CANCELLATION_STATUSES}), + "APPROVED": frozenset({"INSTALLED", *_CANCELLATION_STATUSES}), + "INSTALLED": frozenset({"PROBATION", "QUARANTINED", "FAILED"}), + "PROBATION": frozenset({"VERIFIED", "QUARANTINED", "FAILED"}), + "VERIFIED": frozenset({"PROBATION", "QUARANTINED", "FAILED"}), + "QUARANTINED": frozenset({"FAILED"}), + "REJECTED": frozenset(), + "FAILED": frozenset(), + "SUPERSEDED": frozenset(), + "EXPIRED": frozenset(), + "NO_OP": frozenset(), +} @dataclass(frozen=True) @@ -39,7 +65,8 @@ class CapabilityProposalItem: observation_ids: tuple[str, ...] = () policy_decision: Mapping[str, Any] = field(default_factory=dict) generated_code_ref: str = "" - approval_id: str = "" + proposal_approval_id: str = "" + mutation_approval_id: str = "" install_result: Mapping[str, Any] = field(default_factory=dict) test_results: tuple[Mapping[str, Any], ...] = () trust_state: Mapping[str, Any] = field(default_factory=dict) @@ -58,7 +85,8 @@ def to_dict(self) -> dict[str, Any]: "observation_ids": list(self.observation_ids), "policy_decision": dict(self.policy_decision), "generated_code_ref": self.generated_code_ref, - "approval_id": self.approval_id, + "proposal_approval_id": self.proposal_approval_id, + "mutation_approval_id": self.mutation_approval_id, "install_result": dict(self.install_result), "test_results": [dict(item) for item in self.test_results], "trust_state": dict(self.trust_state), @@ -81,7 +109,8 @@ def from_dict(cls, data: Mapping[str, Any]) -> "CapabilityProposalItem": observation_ids=tuple(str(item) for item in data.get("observation_ids") or ()), policy_decision=dict(data.get("policy_decision") or {}), generated_code_ref=str(data.get("generated_code_ref") or ""), - approval_id=str(data.get("approval_id") or ""), + proposal_approval_id=str(data.get("proposal_approval_id") or ""), + mutation_approval_id=str(data.get("mutation_approval_id") or ""), install_result=dict(data.get("install_result") or {}), test_results=tuple( dict(item) for item in data.get("test_results") or () if isinstance(item, Mapping) @@ -93,15 +122,29 @@ def from_dict(cls, data: Mapping[str, Any]) -> "CapabilityProposalItem": ) -class JsonCapabilityProposalQueue: - """Profile-scoped durable queue of adaptive evolution proposals.""" +_STATUS_EVENT_TYPES: dict[str, str] = { + "PENDING": EvolutionEventType.PROPOSAL_CREATED, + "GENERATED": EvolutionEventType.PROPOSAL_GENERATED, + "APPROVED": EvolutionEventType.PROPOSAL_APPROVED, + "INSTALLED": EvolutionEventType.PLUGIN_INSTALLED, + "PROBATION": EvolutionEventType.PLUGIN_PROBATION_STARTED, + "VERIFIED": EvolutionEventType.PLUGIN_VERIFIED, + "REJECTED": EvolutionEventType.PROPOSAL_REJECTED, + "FAILED": EvolutionEventType.PROPOSAL_FAILED, + "QUARANTINED": EvolutionEventType.PLUGIN_QUARANTINED, + "SUPERSEDED": EvolutionEventType.PROPOSAL_SUPERSEDED, + "EXPIRED": EvolutionEventType.PROPOSAL_EXPIRED, + "NO_OP": EvolutionEventType.PROPOSAL_NO_OP, +} - def __init__(self, path: Path) -> None: - self._path = Path(path) - @property - def path(self) -> Path: - return self._path +class EvolutionCapabilityProposalStore: + """Event-sourced capability proposal lifecycle used by production runtime.""" + + def __init__(self, event_store: Any, *, profile_id: str) -> None: + self._event_store = event_store + self._profile_id = str(profile_id) + self._lock = threading.RLock() def enqueue( self, @@ -113,32 +156,68 @@ def enqueue( observation_ids: Sequence[str] = (), metadata: Mapping[str, Any] | None = None, ) -> CapabilityProposalItem: - """Create or return an active proposal for the requirement/environment pair.""" + with self._lock: + item, event = self.prepare_enqueue( + requirements=requirements, + environment=environment, + risk=risk, + source=source, + observation_ids=observation_ids, + metadata=metadata, + ) + if event is None: + return item + self._event_store.append(event) + return self.get(item.proposal_id) or item + + def prepare_enqueue( + self, + *, + requirements: Sequence[CapabilityRequirement | Mapping[str, Any]], + environment: Mapping[str, Any] | None = None, + risk: Mapping[str, Any] | None = None, + source: str = "runtime", + observation_ids: Sequence[str] = (), + metadata: Mapping[str, Any] | None = None, + occurred_at: float | None = None, + ) -> tuple[CapabilityProposalItem, EvolutionEvent | None]: + """Build an idempotent creation event without writing it. + + Durable workers use this seam to commit the proposal in the same + transaction as the teacher result. Ordinary callers can keep using + :meth:`enqueue`, which appends the prepared event immediately. + """ req_payload = tuple(_requirement_dict(item) for item in requirements) - proposal_id = self._proposal_id(req_payload, environment or {}) - existing = self.get(proposal_id) - if existing is not None and existing.status in _ACTIVE_STATUSES: - return existing - now = time.time() - item = CapabilityProposalItem( - proposal_id=proposal_id, - status="PENDING", - requirements=req_payload, - environment=dict(environment or {}), - risk=dict(risk or {}), - source=str(source or "runtime"), - observation_ids=tuple(str(item) for item in observation_ids), - created_at=now, - updated_at=now, - metadata=dict(metadata or {}), - ) - self._upsert(item) - return item + proposal_id = _proposal_identity(req_payload, environment or {}) + with self._lock: + existing = self.get(proposal_id) + if existing is not None: + return existing, None + now = time.time() if occurred_at is None else float(occurred_at) + item = CapabilityProposalItem( + proposal_id=proposal_id, + status="PENDING", + requirements=req_payload, + environment=dict(environment or {}), + risk=dict(risk or {}), + source=str(source or "runtime"), + observation_ids=tuple(str(item) for item in observation_ids), + created_at=now, + updated_at=now, + metadata=dict(metadata or {}), + ) + return item, self._state_event(item, previous_status="") def get(self, proposal_id: str) -> CapabilityProposalItem | None: - for item in self.list_items(limit=0): - if item.proposal_id == proposal_id: - return item + records = self._event_store.read( + profile_id=self._profile_id, + proposal_id=str(proposal_id), + limit=5000, + ) + for record in reversed(records): + payload = record.event.to_dict()["payload"].get("proposal_state") + if isinstance(payload, Mapping): + return CapabilityProposalItem.from_dict(payload) return None def update( @@ -148,138 +227,208 @@ def update( status: ProposalStatus | None = None, policy_decision: Mapping[str, Any] | None = None, generated_code_ref: str | None = None, - approval_id: str | None = None, + proposal_approval_id: str | None = None, + mutation_approval_id: str | None = None, install_result: Mapping[str, Any] | None = None, test_results: Sequence[Mapping[str, Any]] | None = None, trust_state: Mapping[str, Any] | None = None, metadata: Mapping[str, Any] | None = None, ) -> CapabilityProposalItem | None: - item = self.get(proposal_id) - if item is None: - return None - updated = CapabilityProposalItem( - proposal_id=item.proposal_id, - status=_coerce_status(status or item.status), - requirements=item.requirements, - environment=item.environment, - risk=item.risk, - source=item.source, - observation_ids=item.observation_ids, - policy_decision=dict( - policy_decision if policy_decision is not None else item.policy_decision - ), - generated_code_ref=item.generated_code_ref - if generated_code_ref is None - else str(generated_code_ref), - approval_id=item.approval_id if approval_id is None else str(approval_id), - install_result=dict( - install_result if install_result is not None else item.install_result - ), - test_results=tuple( - dict(result) - for result in (test_results if test_results is not None else item.test_results) - ), - trust_state=dict(trust_state if trust_state is not None else item.trust_state), - created_at=item.created_at, - updated_at=time.time(), - metadata={**dict(item.metadata), **dict(metadata or {})}, - ) - self._upsert(updated) - return updated + with self._lock: + item = self.get(proposal_id) + if item is None: + return None + target = _coerce_status(status or item.status) + if target != item.status and target not in _ALLOWED_TRANSITIONS.get( + item.status, frozenset() + ): + raise ValueError( + f"illegal proposal transition: {item.status} -> {target}" + ) + updated = CapabilityProposalItem( + proposal_id=item.proposal_id, + status=target, + requirements=item.requirements, + environment=item.environment, + risk=item.risk, + source=item.source, + observation_ids=item.observation_ids, + policy_decision=dict( + policy_decision if policy_decision is not None else item.policy_decision + ), + generated_code_ref=( + item.generated_code_ref + if generated_code_ref is None + else str(generated_code_ref) + ), + proposal_approval_id=( + item.proposal_approval_id + if proposal_approval_id is None + else str(proposal_approval_id) + ), + mutation_approval_id=( + item.mutation_approval_id + if mutation_approval_id is None + else str(mutation_approval_id) + ), + install_result=dict( + install_result if install_result is not None else item.install_result + ), + test_results=tuple( + dict(result) + for result in ( + test_results if test_results is not None else item.test_results + ) + ), + trust_state=dict( + trust_state if trust_state is not None else item.trust_state + ), + created_at=item.created_at, + updated_at=time.time(), + metadata={**dict(item.metadata), **dict(metadata or {})}, + ) + return self._append_state(updated, previous_status=item.status) + + def transition( + self, + proposal_id: str, + status: ProposalStatus, + **changes: Any, + ) -> CapabilityProposalItem: + with self._lock: + current = self.get(proposal_id) + if current is None: + raise KeyError(f"unknown capability proposal: {proposal_id}") + target = _coerce_status(status) + if target == current.status: + updated = self.update(proposal_id, **changes) if changes else current + if updated is None: + raise KeyError(f"unknown capability proposal: {proposal_id}") + return updated + if target not in _ALLOWED_TRANSITIONS.get(current.status, frozenset()): + raise ValueError( + f"illegal proposal transition: {current.status} -> {target}" + ) + updated = self.update(proposal_id, status=target, **changes) + if updated is None: + raise KeyError(f"unknown capability proposal: {proposal_id}") + return updated def list_items( self, *, status: ProposalStatus | str = "", limit: int = 50 ) -> list[CapabilityProposalItem]: - payload = self._load_payload() - items = [ - CapabilityProposalItem.from_dict(item) - for item in payload.get("proposals", []) - if isinstance(item, Mapping) - ] + latest: dict[str, CapabilityProposalItem] = {} + cursor = 0 + while True: + records = self._event_store.read( + profile_id=self._profile_id, + proposal_events_only=True, + after_sequence=cursor, + limit=5000, + ) + if not records: + break + for record in records: + payload = record.event.to_dict()["payload"].get("proposal_state") + if isinstance(payload, Mapping): + item = CapabilityProposalItem.from_dict(payload) + latest[item.proposal_id] = item + cursor = records[-1].sequence + if len(records) < 5000: + break + items = list(latest.values()) if status: - status_value = str(status) - items = [item for item in items if item.status == status_value] + items = [item for item in items if item.status == str(status)] items.sort(key=lambda item: item.updated_at or item.created_at, reverse=True) return items if limit <= 0 else items[:limit] + def find_by_metadata(self, key: str, value: str) -> CapabilityProposalItem | None: + target = str(value) + for item in self.list_items(limit=0): + if str(item.metadata.get(key) or "") == target: + return item + return None + def active(self, *, limit: int = 50) -> list[CapabilityProposalItem]: - # ``limit <= 0`` means "all", matching ``list_items``. Slicing ``[:limit]`` - # unconditionally made ``active(limit=0)`` return an empty list -- the opposite - # of "no cap" -- which silently emptied any caller that asked for the full set. items = [item for item in self.list_items(limit=0) if item.status in _ACTIVE_STATUSES] return items if limit <= 0 else items[:limit] - def _upsert(self, item: CapabilityProposalItem) -> None: - payload = self._load_payload() - proposals = [entry for entry in payload.get("proposals", []) if isinstance(entry, Mapping)] - proposals = [entry for entry in proposals if entry.get("proposal_id") != item.proposal_id] - proposals.append(item.to_dict()) - payload["proposals"] = proposals - self._write_payload(payload) - - def _proposal_id( + def _append_state( self, - requirements: Sequence[Mapping[str, Any]], - environment: Mapping[str, Any], - ) -> str: - """A content id over *stable identity only*, so dedup survives rewording. - - Hashing the whole requirement payload made the id a function of the free-text - ``evidence`` (the world model's hypothesis) and its metadata, so the same - capability re-proposed with different wording every session minted a fresh id - and the queue filled with duplicates -- the health of the queue then measured - how long the process had run rather than how many real gaps existed. Identity is - what a requirement *is* (its id, capability, origin, risk ceiling and platform - needs) plus the environment fingerprint it was raised in; the prose that - justifies it is not identity. ``observation_ids`` are carried on the item for - the causal ledger but deliberately excluded here: two profiles observing the - same gap mint different observation ids, and folding those into identity would - defeat dedup for the very case it exists to collapse. - """ - identity = [ - { - "requirement_id": str(item.get("requirement_id") or ""), - "capability": str(item.get("capability") or ""), - "origin": str(item.get("origin") or ""), - "max_risk_level": str(item.get("max_risk_level") or ""), - "required_platform_capabilities": sorted( - str(cap) for cap in (item.get("required_platform_capabilities") or []) - ), - } - for item in requirements - ] - material = { - "identity": identity, - "environment": { - "fingerprint_id": environment.get("fingerprint_id", ""), - "platform_capabilities": environment.get("platform_capabilities", []), - "workspace_markers": environment.get("workspace_markers", []), + item: CapabilityProposalItem, + *, + previous_status: str, + ) -> CapabilityProposalItem: + self._event_store.append(self._state_event(item, previous_status=previous_status)) + stored = self.get(item.proposal_id) + return stored or item + + def _state_event(self, item: CapabilityProposalItem, *, previous_status: str) -> EvolutionEvent: + event_type = ( + _STATUS_EVENT_TYPES[item.status] + if item.status != previous_status + else EvolutionEventType.PROPOSAL_UPDATED + ) + state = item.to_dict() + identity = dict(state) + identity.pop("updated_at", None) + first_requirement = dict(item.requirements[0]) if item.requirements else {} + return EvolutionEvent.create( + event_type, + context=EvolutionContext( + profile_id=self._profile_id, + workspace_id=str(item.environment.get("workspace_id") or ""), + session_id=str(item.environment.get("session_id") or ""), + requirement_id=str(first_requirement.get("requirement_id") or ""), + proposal_id=item.proposal_id, + artifact_id=item.generated_code_ref, + plugin_id=str(item.metadata.get("plugin_id") or ""), + correlation_id=item.proposal_id, + ), + payload={ + "proposal_state": state, + "previous_status": previous_status, + "status": item.status, + "reason": str(item.metadata.get("terminal_reason") or ""), }, - } - text = json.dumps(material, sort_keys=True, ensure_ascii=False, default=str) - import hashlib - - return "prop-" + hashlib.sha256(text.encode("utf-8")).hexdigest()[:16] - - def _load_payload(self) -> dict[str, Any]: - if not self._path.exists(): - return {"version": 1, "proposals": []} - try: - data = json.loads(self._path.read_text(encoding="utf-8")) - if isinstance(data, Mapping) and isinstance(data.get("proposals"), list): - return {"version": int(data.get("version") or 1), "proposals": data["proposals"]} - except (OSError, json.JSONDecodeError, TypeError, ValueError): - return {"version": 1, "proposals": []} - return {"version": 1, "proposals": []} - - def _write_payload(self, payload: Mapping[str, Any]) -> None: - self._path.parent.mkdir(parents=True, exist_ok=True) - self._path.write_text( - json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True), - encoding="utf-8", + producer="proposal.orchestrator", + privacy_class="profile", + occurred_at=item.updated_at, + dedup_key=( + f"proposal.created:{item.proposal_id}" + if not previous_status + else f"proposal.state:{item.proposal_id}:{item.status}:{content_hash(identity)}" + ), ) +def _proposal_identity( + requirements: Sequence[Mapping[str, Any]], + environment: Mapping[str, Any], +) -> str: + identity = [ + { + "requirement_id": str(item.get("requirement_id") or ""), + "capability": str(item.get("capability") or ""), + "origin": str(item.get("origin") or ""), + "max_risk_level": str(item.get("max_risk_level") or ""), + "required_platform_capabilities": sorted( + str(cap) for cap in (item.get("required_platform_capabilities") or []) + ), + } + for item in requirements + ] + material = { + "identity": identity, + "environment": { + "fingerprint_id": environment.get("fingerprint_id", ""), + "platform_capabilities": environment.get("platform_capabilities", []), + "workspace_markers": environment.get("workspace_markers", []), + }, + } + return "prop-" + content_hash(material)[:16] + + def _coerce_status(value: Any) -> ProposalStatus: raw = str(value or "PENDING").upper() allowed = ProposalStatus.__args__ # type: ignore[attr-defined] @@ -292,4 +441,8 @@ def _requirement_dict(item: CapabilityRequirement | Mapping[str, Any]) -> Mappin return dict(item) -__all__ = ["CapabilityProposalItem", "JsonCapabilityProposalQueue", "ProposalStatus"] +__all__ = [ + "CapabilityProposalItem", + "EvolutionCapabilityProposalStore", + "ProposalStatus", +] diff --git a/src/leapflow/storage/distilled_knowledge_store.py b/src/leapflow/storage/distilled_knowledge_store.py index 1b041964..0401da6c 100644 --- a/src/leapflow/storage/distilled_knowledge_store.py +++ b/src/leapflow/storage/distilled_knowledge_store.py @@ -1,17 +1,20 @@ # Copyright (c) Alibaba, Inc. and its affiliates. -"""Durable home for what the teacher distilled, and the rules that retire it. +"""What the teacher distilled, projected from the append-only evolution log. This is the C1 channel: the cheapest way the system adapts to a changed environment. Three of the four adaptation actions change nothing except what the acting agent knows, so a statement like "the send control is now labelled Dispatch and lives in the toolbar" lets the next session succeed with no code written, no approval, and no trust rebuilt. +The single source of truth is ``evolution_events``: the durable teacher worker commits a +``TEACHER_VERDICT_RECORDED`` fact per verdict, and this store *projects* those facts into +the in-memory read model the acting agent consults. There is no second durable store and +no write-back path; the projection is rebuilt from events on demand. + **Retirement is designed in, not bolted on.** An assertion about a world that keeps changing is only true for a while, and stale knowledge does not merely go unused -- it actively misleads, because the acting agent has no way to tell a current fact from one -that expired three upgrades ago. Telling it "the send control is labelled Dispatch" after -the control was renamed again is worse than telling it nothing. So an entry leaves in -exactly three ways: +that expired three upgrades ago. So an entry leaves in exactly three ways: * **Superseded** -- a newer verdict about the same capability replaces the older one. One live entry per capability, because the teacher's latest conclusion is its @@ -19,52 +22,28 @@ contradictory past as though every version were current. * **Expired** -- entries have a bounded lifetime, configurable rather than fixed. Unbounded accumulation would eventually dominate the context it was meant to improve. -* **Retracted** -- an explicit call, used when a capability is observed working again and - the knowledge describing its failure is therefore obsolete. +* **Retracted** -- an explicit ``KNOWLEDGE_RETRACTED`` fact, used when a capability is + observed working again and the knowledge describing its failure is therefore obsolete. What is deliberately *not* a retirement rule: an environment fingerprint that no longer matches the current one. It is recorded and disclosed, never used to filter. Whether an OS point release invalidates "the send control is labelled Dispatch" is a judgement about meaning, and the storage layer guessing it would be a hard rule with no ability to -generalise -- precisely the kind that looks safe and quietly discards good knowledge. The -mismatch is surfaced so the reader can weigh it; the reader is a language model, and this -is the sort of thing it is better at than a predicate. +generalise. The mismatch is surfaced so the reader -- a language model -- can weigh it. """ from __future__ import annotations -import json import logging +import threading import time from dataclasses import dataclass -from pathlib import Path -from typing import Any, Mapping +from typing import Any -logger = logging.getLogger(__name__) +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent, EvolutionEventRecord -#: Fields persisted for one entry. An explicit allow-list, matching the observation -#: store's convention -- and carrying its scar: a field absent from that store's list was -#: silently dropped, so a fact reached the teacher with ``None`` where an identity should -#: have been and nothing raised. Adding a field to the record means adding it here. -#: -#: Bound to ``DistilledKnowledge.to_dict()`` *exactly*, not loosely, and a test asserts -#: it. A field the dataclass has and this set lacks is the historical silent drop; an -#: entry here with no matching field is the mirror image -- it claims to persist something -#: that never existed, which is how a whitelist stops being trustworthy. ``"environment"`` -#: was exactly that: a leftover from considering whether to store the whole fingerprint. -_ENTRY_FIELDS: frozenset[str] = frozenset( - { - "capability", - "knowledge", - "action", - "verdict_id", - "confidence", - "rationale", - "target", - "environment_id", - "created_at", - } -) +logger = logging.getLogger(__name__) @dataclass(frozen=True) @@ -83,170 +62,63 @@ class DistilledKnowledge: environment_id: str = "" created_at: float = 0.0 - @classmethod - def from_verdict( - cls, verdict: Any, *, environment: Mapping[str, Any] | None = None - ) -> DistilledKnowledge: - """Project an ``AdaptationVerdict`` into a storable entry. - - Takes the verdict duck-typed rather than imported, so storage does not depend on - the domain module that depends on it. - """ - env = dict(environment or {}) - return cls( - capability=str(getattr(verdict, "capability", "") or ""), - knowledge=str(getattr(verdict, "knowledge", "") or ""), - action=str(getattr(verdict, "action", "") or ""), - verdict_id=str(getattr(verdict, "verdict_id", "") or ""), - confidence=float(getattr(verdict, "confidence", 0.0) or 0.0), - rationale=str(getattr(verdict, "rationale", "") or ""), - target=str(getattr(verdict, "target", "") or ""), - environment_id=str(env.get("fingerprint_id") or ""), - created_at=float(getattr(verdict, "created_at", 0.0) or time.time()), - ) - - def to_dict(self) -> dict[str, Any]: - return { - "capability": self.capability, - "knowledge": self.knowledge, - "action": self.action, - "verdict_id": self.verdict_id, - "confidence": self.confidence, - "rationale": self.rationale, - "target": self.target, - "environment_id": self.environment_id, - "created_at": self.created_at, - } - - @classmethod - def from_dict(cls, payload: Mapping[str, Any]) -> DistilledKnowledge: - return cls( - capability=str(payload.get("capability") or ""), - knowledge=str(payload.get("knowledge") or ""), - action=str(payload.get("action") or ""), - verdict_id=str(payload.get("verdict_id") or ""), - confidence=float(payload.get("confidence") or 0.0), - rationale=str(payload.get("rationale") or ""), - target=str(payload.get("target") or ""), - environment_id=str(payload.get("environment_id") or ""), - created_at=float(payload.get("created_at") or 0.0), - ) - - -class JsonDistilledKnowledgeStore: - """Profile-scoped store for distilled knowledge, keyed by capability. - JSON rather than the semantic memory provider, for a reason that decided the design: - the reader needs *every* live entry, and semantic memory answers keyword queries. A - fact the agent needs is not necessarily a fact whose words appear in the request -- - "the send control is now Dispatch" is exactly what a request saying "reply to Ana" - needs and would never retrieve. Complete enumeration is the requirement, so the store - that offers it is the right one. +class EvolutionDistilledKnowledgeStore: + """In-memory knowledge read model derived only from evolution events. - Reads are hot (every turn that discloses knowledge) and writes are cold (once per - session, at grading time), which is why an entry cache is kept and invalidated on - write rather than re-reading the file per turn. + Hydration and refresh are cold-path operations. ``live`` and + ``rebind_preferences`` only read the in-memory snapshot, so adding this + always-on context channel does not add a DuckDB query to every turn. """ - def __init__(self, path: Path, *, ttl_seconds: float = 0.0) -> None: - self._path = Path(path) + def __init__(self, event_store: Any, *, profile_id: str, ttl_seconds: float = 0.0) -> None: + self._event_store = event_store + self._profile_id = str(profile_id) self._ttl = max(0.0, float(ttl_seconds)) - self._cache: tuple[DistilledKnowledge, ...] | None = None - - @property - def path(self) -> Path: - return self._path + self._entries: dict[str, DistilledKnowledge] = {} + self._last_sequence = 0 + self._lock = threading.RLock() @property def ttl_seconds(self) -> float: return self._ttl - # ── writes (cold path) ──────────────────────────────────────────────────── - - def record( - self, verdict: Any, *, environment: Mapping[str, Any] | None = None - ) -> DistilledKnowledge | None: - """Store one verdict's knowledge, superseding any earlier entry for it. - - Returns the stored entry, or ``None`` when the verdict carries nothing usable. - Refusing silently here would be wrong in the other direction: a verdict without - knowledge is a defect in the parser, which already rejects that shape, so - reaching this point means something upstream changed. - """ - entry = DistilledKnowledge.from_verdict(verdict, environment=environment) - if not entry.capability or not entry.knowledge: - logger.debug( - "distilled_knowledge: refused entry without capability or knowledge (%r)", - entry.verdict_id, - ) - return None - # Supersession, not append: the teacher's latest conclusion about a capability is - # its conclusion, and keeping the older one live would show the agent a - # capability's contradictory past as though every version were current. - kept = [e for e in self._load() if e.capability != entry.capability] - kept.append(entry) - self._write(kept) - return entry - - def record_all( - self, verdicts: Any, *, environment: Mapping[str, Any] | None = None - ) -> tuple[DistilledKnowledge, ...]: - """Store a batch, one write for the lot. - - Later verdicts about the same capability win, matching ``record``'s supersession - within the batch as well as across batches. - """ - incoming: dict[str, DistilledKnowledge] = {} - for verdict in verdicts or (): - entry = DistilledKnowledge.from_verdict(verdict, environment=environment) - if entry.capability and entry.knowledge: - incoming[entry.capability] = entry - if not incoming: - return () - kept = [e for e in self._load() if e.capability not in incoming] - kept.extend(incoming.values()) - self._write(kept) - return tuple(incoming.values()) - - def retract(self, capability: str, *, reason: str = "") -> bool: - """Drop the entry for one capability. Used when its knowledge is obsolete. - - The third retirement path, and the only one a caller drives: a capability - observed working again makes knowledge describing its failure misleading, and - nothing about supersession or expiry would remove it -- no newer verdict is - coming precisely because there is no longer anything wrong. - """ - name = str(capability or "").strip() - if not name: - return False - entries = self._load() - kept = [e for e in entries if e.capability != name] - if len(kept) == len(entries): - return False - logger.debug( - "distilled_knowledge: retracted %s (%s)", name, reason or "no reason given" - ) - self._write(kept) - return True - - # ── reads (hot path) ────────────────────────────────────────────────────── + def refresh(self) -> int: + """Apply newly committed facts and return the latest consumed sequence.""" + with self._lock: + cursor = self._last_sequence + while True: + records = self._event_store.read( + profile_id=self._profile_id, + after_sequence=cursor, + limit=5000, + ) + if not records: + break + for record in records: + self._apply(record) + cursor = records[-1].sequence + if len(records) < 5000: + break + self._last_sequence = cursor + return cursor def live(self, *, now: float | None = None) -> tuple[DistilledKnowledge, ...]: - """Every entry still considered true, newest first. + """Return the current projected knowledge without performing I/O. Expiry is applied on read rather than by a sweep, so a stale entry cannot be disclosed just because no write happened to trigger a cleanup. """ - entries = self._load() + with self._lock: + entries = list(self._entries.values()) if self._ttl > 0.0: cutoff = (time.time() if now is None else now) - self._ttl - entries = [e for e in entries if e.created_at >= cutoff] - return tuple(sorted(entries, key=lambda e: e.created_at, reverse=True)) + entries = [entry for entry in entries if entry.created_at >= cutoff] + return tuple(sorted(entries, key=lambda entry: entry.created_at, reverse=True)) def for_capability(self, capability: str) -> DistilledKnowledge | None: - """The live entry for one capability, if any.""" name = str(capability or "").strip() - return next((e for e in self.live() if e.capability == name), None) + return next((entry for entry in self.live() if entry.capability == name), None) def rebind_preferences(self) -> tuple[tuple[str, str], ...]: """``(capability, preferred provider)`` for every live ``rebind`` entry. @@ -255,9 +127,6 @@ def rebind_preferences(self) -> tuple[tuple[str, str], ...]: An ``escalate`` target names what a *person* must do and an ``absorb`` has no target at all, so admitting them would turn an instruction to a human into a selection preference. - - Expiry and retraction apply, so a preference stops being read when the knowledge - behind it stops being true -- there is nothing to unlearn. """ return tuple( (entry.capability, entry.target) @@ -268,50 +137,64 @@ def rebind_preferences(self) -> tuple[tuple[str, str], ...]: def count(self) -> int: return len(self.live()) - # ── persistence ─────────────────────────────────────────────────────────── - - def _load(self) -> list[DistilledKnowledge]: - if self._cache is not None: - return list(self._cache) - entries: list[DistilledKnowledge] = [] - if self._path.exists(): - try: - payload = json.loads(self._path.read_text(encoding="utf-8") or "{}") - for raw in payload.get("entries", []) or (): - if isinstance(raw, Mapping): - entries.append(DistilledKnowledge.from_dict(raw)) - except (OSError, ValueError, TypeError): - # A corrupt file must not break a turn. Distilled knowledge is an - # improvement to context, so its absence degrades quality rather than - # correctness -- exactly the case for starting empty over raising. - logger.debug( - "distilled_knowledge: unreadable store at %s", self._path, exc_info=True - ) - entries = [] - self._cache = tuple(entries) - return list(entries) + def retract(self, capability: str, *, reason: str = "") -> bool: + """Record retirement as a fact, then update the local read model. - def _write(self, entries: list[DistilledKnowledge]) -> None: - self._cache = tuple(entries) - payload = { - "version": 1, - "entries": [ - {k: v for k, v in e.to_dict().items() if k in _ENTRY_FIELDS} - for e in entries - ], - } - try: - self._path.parent.mkdir(parents=True, exist_ok=True) - tmp = self._path.with_suffix(self._path.suffix + ".tmp") - tmp.write_text(json.dumps(payload, indent=2), encoding="utf-8") - tmp.replace(self._path) - except OSError: - logger.debug( - "distilled_knowledge: could not persist to %s", self._path, exc_info=True + The one retirement neither supersession nor expiry covers: no newer verdict is + coming precisely because there is no longer anything wrong. + """ + name = str(capability or "").strip() + if not name: + return False + with self._lock: + current = self._entries.get(name) + if current is None: + return False + event = EvolutionEvent.create( + EvolutionEventType.KNOWLEDGE_RETRACTED, + context=EvolutionContext( + profile_id=self._profile_id, + decision_id=current.verdict_id, + correlation_id=current.verdict_id, + ), + payload={"capability": name, "reason": str(reason or "")}, + producer="evolution.knowledge_projection", + privacy_class="profile", + dedup_key=f"knowledge.retracted:{name}:{current.verdict_id}", + ) + inserted = bool(self._event_store.append(event)) + self.refresh() + return inserted + + def _apply(self, record: EvolutionEventRecord) -> None: + event = record.event + payload = event.to_dict()["payload"] + if event.event_type == EvolutionEventType.TEACHER_VERDICT_RECORDED: + # Every verdict carries mandatory knowledge, and all four actions are + # disclosed to the student: an ``escalate`` tells it a person must act, an + # ``acquire`` tells it nothing installed serves the capability, and the two + # cheap verdicts describe the environment. ``rebind_preferences`` narrows to + # rebind on read, so recording all four here loses nothing. + entry = DistilledKnowledge( + capability=str(payload.get("capability") or ""), + knowledge=str(payload.get("knowledge") or ""), + action=str(payload.get("action") or ""), + verdict_id=str(payload.get("verdict_id") or event.context.decision_id), + confidence=float(payload.get("confidence") or 0.0), + rationale=str(payload.get("rationale") or ""), + target=str(payload.get("target") or ""), + environment_id=str(payload.get("environment_id") or ""), + created_at=float(payload.get("created_at") or event.occurred_at), ) + if entry.capability and entry.knowledge: + # Supersession, not append: the teacher's latest conclusion about a + # capability is its conclusion, keyed by capability. + self._entries[entry.capability] = entry + elif event.event_type == EvolutionEventType.KNOWLEDGE_RETRACTED: + self._entries.pop(str(payload.get("capability") or ""), None) __all__ = [ "DistilledKnowledge", - "JsonDistilledKnowledgeStore", + "EvolutionDistilledKnowledgeStore", ] diff --git a/src/leapflow/storage/evolution_event_store.py b/src/leapflow/storage/evolution_event_store.py new file mode 100644 index 00000000..c7c73cda --- /dev/null +++ b/src/leapflow/storage/evolution_event_store.py @@ -0,0 +1,792 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""DuckDB append-only store for causal self-evolution events. + +All instances share the daemon-owned ConnectionHolder. The process lock protects +sequence allocation and multi-row transactions across thread-local DuckDB cursors; +callers must still respect the architectural single-writer rule. +""" +from __future__ import annotations + +import json +import threading +import time +from pathlib import Path +from typing import Any, Iterable, Mapping, Sequence, Union + +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import ( + EvolutionContext, + EvolutionEvent, + EvolutionEventRecord, + canonical_json, + content_hash, +) +from leapflow.storage.connection import ConnectionHolder, LocalConnectionHolder +from leapflow.storage.schema import ensure_schema + + +_INSERT_SQL = """ +INSERT INTO evolution_events ( + sequence, event_id, event_type, + profile_id, workspace_id, session_id, session_generation, + turn_id, frame_id, action_id, observation_id, requirement_id, + decision_id, proposal_id, artifact_id, plugin_id, version_id, + correlation_id, causation_id, occurred_at, producer, producer_version, + privacy_class, schema_version, payload_json, payload_hash, dedup_key +) VALUES ( + nextval('evolution_event_sequence'), ?, ?, + ?, ?, ?, ?, + ?, ?, ?, ?, ?, + ?, ?, ?, ?, ?, + ?, ?, ?, ?, ?, + ?, ?, ?, ?, ? +) +ON CONFLICT (profile_id, dedup_key) DO NOTHING +RETURNING sequence +""" + + +class DuckDBEvolutionEventStore: + """Append and query immutable evolution events.""" + + def __init__(self, source: Union[ConnectionHolder, Path, str]) -> None: + self._owns_holder = isinstance(source, (str, Path)) + if self._owns_holder: + source = LocalConnectionHolder(Path(source)) + self._holder: ConnectionHolder = source + self._write_lock = threading.Lock() + ensure_schema(self._conn) + + @property + def _conn(self) -> Any: + """Resolve on every call so LocalConnectionHolder preserves thread affinity.""" + return self._holder.connection + + def append(self, event: EvolutionEvent) -> bool: + """Append one event; return ``False`` when its dedup key already exists.""" + with self._write_lock: + row = self._conn.execute(_INSERT_SQL, self._params(event)).fetchone() + return row is not None + + def append_many(self, events: Sequence[EvolutionEvent]) -> int: + """Atomically append a batch, ignoring idempotent duplicates.""" + if not events: + return 0 + with self._write_lock: + connection = self._conn + connection.execute("BEGIN TRANSACTION") + inserted = 0 + try: + for event in events: + row = connection.execute(_INSERT_SQL, self._params(event)).fetchone() + if row is not None: + inserted += 1 + connection.execute("COMMIT") + except Exception: + connection.execute("ROLLBACK") + raise + return inserted + + def read( + self, + *, + profile_id: str = "", + session_id: str = "", + session_generation: int | None = None, + correlation_id: str = "", + proposal_id: str = "", + proposal_events_only: bool = False, + event_type: str = "", + after_sequence: int = 0, + through_sequence: int = 0, + limit: int = 500, + ) -> list[EvolutionEventRecord]: + """Read a bounded event slice with its durable causal cursor.""" + clauses = ["sequence > ?"] + params: list[Any] = [max(0, int(after_sequence))] + if through_sequence > 0: + clauses.append("sequence <= ?") + params.append(int(through_sequence)) + for column, value in ( + ("profile_id", profile_id), + ("session_id", session_id), + ("correlation_id", correlation_id), + ("proposal_id", proposal_id), + ("event_type", event_type), + ): + if value: + clauses.append(f"{column} = ?") + params.append(str(value)) + if proposal_events_only: + clauses.append("proposal_id <> ''") + if session_generation is not None: + clauses.append("session_generation = ?") + params.append(int(session_generation)) + params.append(min(max(1, int(limit)), 5000)) + rows = self._conn.execute( + f""" + SELECT sequence, event_id, event_type, + profile_id, workspace_id, session_id, session_generation, + turn_id, frame_id, action_id, observation_id, requirement_id, + decision_id, proposal_id, artifact_id, plugin_id, version_id, + correlation_id, causation_id, occurred_at, producer, + producer_version, privacy_class, schema_version, payload_json, + payload_hash, dedup_key + FROM evolution_events + WHERE {' AND '.join(clauses)} + ORDER BY sequence ASC + LIMIT ? + """, + params, + ).fetchall() + return [self._from_row(row) for row in rows] + + def latest_sequence(self, *, profile_id: str = "", session_id: str = "") -> int: + clauses = ["1=1"] + params: list[Any] = [] + if profile_id: + clauses.append("profile_id = ?") + params.append(str(profile_id)) + if session_id: + clauses.append("session_id = ?") + params.append(str(session_id)) + row = self._conn.execute( + f"SELECT COALESCE(MAX(sequence), 0) FROM evolution_events WHERE {' AND '.join(clauses)}", + params, + ).fetchone() + return int(row[0] if row else 0) + + def latest_evidence_sequence( + self, + *, + profile_id: str, + session_id: str, + session_generation: int | None = None, + ) -> int: + """Return the latest hot-path input cursor eligible for teacher grading.""" + event_types = ( + EvolutionEventType.ACTION_STARTED, + EvolutionEventType.ACTION_COMPLETED, + EvolutionEventType.ACTION_FAILED, + EvolutionEventType.ENVIRONMENT_OBSERVED, + ) + placeholders = ", ".join("?" for _ in event_types) + generation_clause = "" + params: list[Any] = [str(profile_id), str(session_id), *event_types] + if session_generation is not None: + generation_clause = " AND session_generation=?" + params.append(int(session_generation)) + row = self._conn.execute( + f""" + SELECT COALESCE(MAX(sequence), 0) + FROM evolution_events + WHERE profile_id=? AND session_id=? AND event_type IN ({placeholders}) + {generation_clause} + """, + params, + ).fetchone() + return int(row[0] if row else 0) + + def evidence_sessions(self, *, profile_id: str = "") -> list[dict[str, Any]]: + """List session heads that contain finalizable hot-path evidence.""" + event_types = ( + EvolutionEventType.ACTION_STARTED, + EvolutionEventType.ACTION_COMPLETED, + EvolutionEventType.ACTION_FAILED, + EvolutionEventType.ENVIRONMENT_OBSERVED, + ) + placeholders = ", ".join("?" for _ in event_types) + clauses = ["session_id <> ''", f"event_type IN ({placeholders})"] + params: list[Any] = list(event_types) + if profile_id: + clauses.append("profile_id = ?") + params.append(str(profile_id)) + rows = self._conn.execute( + f""" + SELECT profile_id, workspace_id, session_id, session_generation, + MAX(sequence) AS through_sequence + FROM evolution_events + WHERE {' AND '.join(clauses)} + GROUP BY profile_id, workspace_id, session_id, session_generation + ORDER BY through_sequence ASC + """, + params, + ).fetchall() + keys = ( + "profile_id", + "workspace_id", + "session_id", + "session_generation", + "through_sequence", + ) + return [dict(zip(keys, row)) for row in rows] + + def count(self, *, profile_id: str = "", event_type: str = "") -> int: + clauses = ["1=1"] + params: list[Any] = [] + if profile_id: + clauses.append("profile_id = ?") + params.append(str(profile_id)) + if event_type: + clauses.append("event_type = ?") + params.append(str(event_type)) + row = self._conn.execute( + f"SELECT COUNT(*) FROM evolution_events WHERE {' AND '.join(clauses)}", + params, + ).fetchone() + return int(row[0] if row else 0) + + def finalize_session( + self, + *, + profile_id: str, + workspace_id: str, + session_id: str, + session_generation: int, + from_sequence: int, + through_sequence: int, + reason: str, + goal: str = "", + model: str = "", + ) -> tuple[str, str]: + """Atomically finalize one evidence slice and enqueue its teacher job. + + Returns ``(episode_id, job_id)``. Repeating the same finalization is + idempotent because both identities derive from the immutable sequence range. + """ + if not session_id: + raise ValueError("session_id is required") + if through_sequence <= from_sequence: + return "", "" + identity = { + "profile_id": profile_id, + "workspace_id": workspace_id, + "session_id": session_id, + "session_generation": int(session_generation), + "from_sequence": int(from_sequence), + "through_sequence": int(through_sequence), + } + digest = content_hash(identity) + episode_id = f"episode-{digest[:24]}" + job_id = f"teacher-{digest[:24]}" + context = EvolutionContext( + profile_id=profile_id, + workspace_id=workspace_id, + session_id=session_id, + session_generation=int(session_generation), + correlation_id=episode_id, + ) + finalized = EvolutionEvent.create( + EvolutionEventType.SESSION_FINALIZED, + context=context, + payload={ + "episode_id": episode_id, + "from_sequence": int(from_sequence), + "through_sequence": int(through_sequence), + "reason": str(reason), + "goal": str(goal), + }, + producer="session.finalizer", + dedup_key=f"session.finalized:{episode_id}", + ) + queued = EvolutionEvent.create( + EvolutionEventType.TEACHER_JOB_QUEUED, + context=context.with_ids(causation_id=finalized.event_id), + payload={ + "episode_id": episode_id, + "job_id": job_id, + "model": str(model), + "from_sequence": int(from_sequence), + "through_sequence": int(through_sequence), + }, + producer="session.finalizer", + dedup_key=f"teacher.job_queued:{job_id}", + ) + now = time.time() + with self._write_lock: + connection = self._conn + connection.execute("BEGIN TRANSACTION") + try: + connection.execute(_INSERT_SQL, self._params(finalized)).fetchone() + connection.execute(_INSERT_SQL, self._params(queued)).fetchone() + connection.execute( + """ + INSERT INTO evolution_teacher_jobs ( + job_id, profile_id, workspace_id, session_id, + session_generation, episode_id, from_sequence, + through_sequence, reason, goal, status, model, + created_at, updated_at + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'PENDING', ?, ?, ?) + ON CONFLICT (profile_id, episode_id) DO NOTHING + """, + [ + job_id, + profile_id, + workspace_id, + session_id, + int(session_generation), + episode_id, + int(from_sequence), + int(through_sequence), + str(reason), + str(goal), + str(model), + now, + now, + ], + ) + connection.execute("COMMIT") + except Exception: + connection.execute("ROLLBACK") + raise + return episode_id, job_id + + def claim_teacher_job( + self, + *, + lease_owner: str, + profile_id: str = "", + lease_seconds: float = 120.0, + now: float | None = None, + ) -> dict[str, Any] | None: + """Lease the oldest due teacher job for one worker.""" + instant = float(now if now is not None else time.time()) + with self._write_lock: + connection = self._conn + connection.execute("BEGIN TRANSACTION") + try: + clauses = [ + "((status IN ('PENDING', 'FAILED_RETRYABLE') AND next_attempt_at <= ?) " + "OR (status = 'RUNNING' AND lease_until <= ?))", + ] + params: list[Any] = [instant, instant] + if profile_id: + clauses.append("profile_id = ?") + params.append(str(profile_id)) + row = connection.execute( + f""" + SELECT job_id, profile_id, workspace_id, session_id, + session_generation, episode_id, from_sequence, + through_sequence, reason, goal, attempts, model, + prompt_hash, created_at + FROM evolution_teacher_jobs + WHERE {' AND '.join(clauses)} + ORDER BY created_at ASC + LIMIT 1 + """, + params, + ).fetchone() + if row is None: + connection.execute("COMMIT") + return None + lease_until = instant + max(1.0, float(lease_seconds)) + connection.execute( + """ + UPDATE evolution_teacher_jobs + SET status='RUNNING', lease_owner=?, lease_until=?, + attempts=attempts+1, updated_at=? + WHERE job_id=? + """, + [str(lease_owner), lease_until, instant, row[0]], + ) + connection.execute("COMMIT") + except Exception: + connection.execute("ROLLBACK") + raise + keys = ( + "job_id", + "profile_id", + "workspace_id", + "session_id", + "session_generation", + "episode_id", + "from_sequence", + "through_sequence", + "reason", + "goal", + "attempts", + "model", + "prompt_hash", + "created_at", + ) + claimed = dict(zip(keys, row)) + claimed["attempts"] = int(claimed["attempts"] or 0) + 1 + claimed["session_generation"] = int(claimed["session_generation"] or 0) + claimed["from_sequence"] = int(claimed["from_sequence"] or 0) + claimed["through_sequence"] = int(claimed["through_sequence"] or 0) + claimed["lease_owner"] = str(lease_owner) + claimed["lease_until"] = lease_until + return claimed + + def renew_teacher_job( + self, + job_id: str, + *, + lease_owner: str, + lease_seconds: float, + now: float | None = None, + ) -> bool: + """Extend a running job lease only when the caller still owns it.""" + instant = float(now if now is not None else time.time()) + with self._write_lock: + row = self._conn.execute( + """ + UPDATE evolution_teacher_jobs + SET lease_until=?, updated_at=? + WHERE job_id=? AND status='RUNNING' AND lease_owner=? + RETURNING job_id + """, + [ + instant + max(1.0, float(lease_seconds)), + instant, + str(job_id), + str(lease_owner), + ], + ).fetchone() + return row is not None + + def complete_teacher_job( + self, + job_id: str, + *, + lease_owner: str, + events: Sequence[EvolutionEvent] = (), + prompt_hash: str = "", + result_artifact_id: str = "", + ) -> bool: + """Append teacher facts and complete a job only for its current lease owner.""" + with self._write_lock: + connection = self._conn + connection.execute("BEGIN TRANSACTION") + try: + owned = connection.execute( + """ + SELECT 1 FROM evolution_teacher_jobs + WHERE job_id=? AND status='RUNNING' AND lease_owner=? + """, + [str(job_id), str(lease_owner)], + ).fetchone() + if owned is None: + connection.execute("ROLLBACK") + return False + for event in events: + connection.execute(_INSERT_SQL, self._params(event)).fetchone() + updated = connection.execute( + """ + UPDATE evolution_teacher_jobs + SET status='COMPLETED', lease_owner='', lease_until=0, + prompt_hash=?, result_artifact_id=?, completed_at=?, + updated_at=?, error='' + WHERE job_id=? AND status='RUNNING' AND lease_owner=? + RETURNING job_id + """, + [ + str(prompt_hash), + str(result_artifact_id), + time.time(), + time.time(), + str(job_id), + str(lease_owner), + ], + ).fetchone() + connection.execute("COMMIT") + return updated is not None + except Exception: + connection.execute("ROLLBACK") + raise + + def fail_teacher_job( + self, + job_id: str, + error: str, + *, + lease_owner: str, + retryable: bool, + retry_after_s: float = 5.0, + events: Sequence[EvolutionEvent] = (), + ) -> bool: + """Record a teacher failure only while the caller owns the lease.""" + now = time.time() + with self._write_lock: + connection = self._conn + connection.execute("BEGIN TRANSACTION") + try: + owned = connection.execute( + """ + SELECT 1 FROM evolution_teacher_jobs + WHERE job_id=? AND status='RUNNING' AND lease_owner=? + """, + [str(job_id), str(lease_owner)], + ).fetchone() + if owned is None: + connection.execute("ROLLBACK") + return False + for event in events: + connection.execute(_INSERT_SQL, self._params(event)).fetchone() + row = connection.execute( + """ + UPDATE evolution_teacher_jobs + SET status=?, lease_owner='', lease_until=0, next_attempt_at=?, + updated_at=?, error=? + WHERE job_id=? AND status='RUNNING' AND lease_owner=? + RETURNING job_id + """, + [ + "FAILED_RETRYABLE" if retryable else "FAILED_FINAL", + now + max(0.0, float(retry_after_s)) if retryable else 0.0, + now, + str(error)[:2000], + str(job_id), + str(lease_owner), + ], + ).fetchone() + connection.execute("COMMIT") + return row is not None + except Exception: + connection.execute("ROLLBACK") + raise + + def teacher_job(self, job_id: str) -> dict[str, Any] | None: + row = self._conn.execute( + """ + SELECT job_id, profile_id, workspace_id, session_id, + session_generation, episode_id, from_sequence, through_sequence, + reason, goal, status, lease_owner, lease_until, attempts, model, + prompt_hash, result_artifact_id, next_attempt_at, created_at, + updated_at, completed_at, error + FROM evolution_teacher_jobs WHERE job_id=? + """, + [str(job_id)], + ).fetchone() + if row is None: + return None + keys = ( + "job_id", "profile_id", "workspace_id", "session_id", + "session_generation", "episode_id", "from_sequence", "through_sequence", + "reason", "goal", "status", "lease_owner", "lease_until", "attempts", + "model", "prompt_hash", "result_artifact_id", "next_attempt_at", + "created_at", "updated_at", "completed_at", "error", + ) + return dict(zip(keys, row)) + + def load_projection( + self, + *, + projection_name: str, + profile_id: str, + scope_key: str, + ) -> tuple[int, dict[str, Any]] | None: + row = self._conn.execute( + """ + SELECT last_sequence, state_json + FROM evolution_projections + WHERE projection_name=? AND profile_id=? AND scope_key=? + """, + [str(projection_name), str(profile_id), str(scope_key)], + ).fetchone() + if row is None: + return None + try: + state = json.loads(row[1] or "{}") + except (json.JSONDecodeError, TypeError): + return None + return int(row[0] or 0), state if isinstance(state, dict) else {} + + def save_projection( + self, + *, + projection_name: str, + profile_id: str, + scope_key: str, + last_sequence: int, + state: dict[str, Any], + ) -> None: + with self._write_lock: + self._conn.execute( + """ + INSERT INTO evolution_projections ( + projection_name, profile_id, scope_key, last_sequence, + state_json, updated_at + ) VALUES (?, ?, ?, ?, ?, ?) + ON CONFLICT (projection_name, profile_id, scope_key) DO UPDATE SET + last_sequence=excluded.last_sequence, + state_json=excluded.state_json, + updated_at=excluded.updated_at + """, + [ + str(projection_name), + str(profile_id), + str(scope_key), + int(last_sequence), + canonical_json(state), + time.time(), + ], + ) + + def delete_projection( + self, + *, + projection_name: str, + profile_id: str, + scope_key: str, + ) -> None: + with self._write_lock: + self._conn.execute( + """ + DELETE FROM evolution_projections + WHERE projection_name=? AND profile_id=? AND scope_key=? + """, + [str(projection_name), str(profile_id), str(scope_key)], + ) + + def last_finalized_sequence( + self, + *, + profile_id: str, + session_id: str, + session_generation: int | None = None, + ) -> int: + """Return the highest evidence cursor finalized for one session generation.""" + records = self.read( + profile_id=profile_id, + session_id=session_id, + session_generation=session_generation, + event_type=EvolutionEventType.SESSION_FINALIZED, + limit=5000, + ) + return max( + ( + int(record.event.payload.get("through_sequence") or 0) + for record in records + ), + default=0, + ) + + def close(self) -> None: + if self._owns_holder: + self._holder.close() + + @staticmethod + def _params(event: EvolutionEvent) -> list[Any]: + context = event.context + return [ + event.event_id, + event.event_type, + context.profile_id, + context.workspace_id, + context.session_id, + context.session_generation, + context.turn_id, + context.frame_id, + context.action_id, + context.observation_id, + context.requirement_id, + context.decision_id, + context.proposal_id, + context.artifact_id, + context.plugin_id, + context.version_id, + context.correlation_id, + context.causation_id, + event.occurred_at, + event.producer, + event.producer_version, + event.privacy_class, + event.schema_version, + canonical_json(dict(event.payload)), + event.payload_hash, + event.dedup_key, + ] + + @staticmethod + def _from_row(row: Sequence[Any]) -> EvolutionEventRecord: + context = EvolutionContext( + profile_id=str(row[3] or ""), + workspace_id=str(row[4] or ""), + session_id=str(row[5] or ""), + session_generation=int(row[6] or 0), + turn_id=str(row[7] or ""), + frame_id=str(row[8] or ""), + action_id=str(row[9] or ""), + observation_id=str(row[10] or ""), + requirement_id=str(row[11] or ""), + decision_id=str(row[12] or ""), + proposal_id=str(row[13] or ""), + artifact_id=str(row[14] or ""), + plugin_id=str(row[15] or ""), + version_id=str(row[16] or ""), + correlation_id=str(row[17] or ""), + causation_id=str(row[18] or ""), + ) + try: + payload = json.loads(row[24] or "{}") + except (json.JSONDecodeError, TypeError): + payload = {} + return EvolutionEventRecord( + sequence=int(row[0]), + event=EvolutionEvent( + event_id=str(row[1] or ""), + event_type=str(row[2] or ""), + context=context, + payload=payload if isinstance(payload, dict) else {}, + occurred_at=float(row[19] or 0.0), + producer=str(row[20] or ""), + producer_version=str(row[21] or ""), + privacy_class=str(row[22] or "system"), + schema_version=int(row[23] or 1), + payload_hash=str(row[25] or ""), + dedup_key=str(row[26] or ""), + ), + ) + + +class EvolutionTraceEventStore: + """Adapt framework traces onto the append-only evolution event stream.""" + + def __init__(self, store: DuckDBEvolutionEventStore, *, profile_id: str) -> None: + self._store = store + self._profile_id = str(profile_id) + + def append(self, traces: Iterable[Mapping[str, Any]]) -> int: + events: list[EvolutionEvent] = [] + for trace in traces: + payload = dict(trace) + trace_id = str(payload.get("trace_id") or content_hash(payload)) + correlation = dict(payload.get("correlation") or {}) + context = EvolutionContext( + profile_id=self._profile_id, + proposal_id=str(correlation.get("proposal_id") or ""), + plugin_id=str(correlation.get("plugin_id") or ""), + correlation_id=str( + correlation.get("episode_id") + or correlation.get("proposal_id") + or trace_id + ), + ) + events.append( + EvolutionEvent.create( + EvolutionEventType.FRAMEWORK_TRACE_RECORDED, + context=context, + payload=payload, + producer="framework.evolution_tap", + privacy_class="profile", + occurred_at=float(payload.get("ts") or time.time()), + dedup_key=f"framework.trace_recorded:{trace_id}", + ) + ) + return self._store.append_many(events) + + def list_traces(self, *, limit: int = 200) -> list[dict[str, Any]]: + records = self._store.read( + profile_id=self._profile_id, + event_type=EvolutionEventType.FRAMEWORK_TRACE_RECORDED, + limit=5000, + ) + rows = [dict(record.event.to_dict()["payload"]) for record in reversed(records)] + return rows if limit <= 0 else rows[:limit] + + def count(self) -> int: + return len(self.list_traces(limit=0)) + + +__all__ = ["DuckDBEvolutionEventStore", "EvolutionTraceEventStore"] diff --git a/src/leapflow/storage/evolution_store.py b/src/leapflow/storage/evolution_store.py index a06d5125..3282fd3e 100644 --- a/src/leapflow/storage/evolution_store.py +++ b/src/leapflow/storage/evolution_store.py @@ -4,8 +4,8 @@ Design: - Write-behind: buffer episodes in-memory, flush to DuckDB periodically or on shutdown - Read-through: on initialize, load recent episodes from DuckDB into in-memory provider -- Schema is simple: one table with JSON-serialized episode data -- Idempotent schema creation (no migration chains) +- Schema is managed by the shared ordered migration/bootstrap layer +- Episode payloads remain JSON-serialized inside typed skill tables - Write-retry with jitter for concurrent access This module does NOT replace EvolutionMemoryProvider — it augments it with persistence. @@ -20,6 +20,7 @@ from typing import Any, Dict, List, Optional, Union from leapflow.storage.connection import ConnectionHolder, LocalConnectionHolder +from leapflow.storage.schema import ensure_schema from leapflow.storage.write_buffer import execute_with_retry logger = logging.getLogger(__name__) @@ -37,7 +38,7 @@ def __init__(self, source: Union[ConnectionHolder, Path, str]) -> None: source = LocalConnectionHolder(Path(source)) self._holder = source self._db_path = str(self._holder.db_path) - self._initialize_schema() + ensure_schema(self._conn) @property def _conn(self) -> Any: @@ -50,33 +51,6 @@ def _conn(self) -> Any: """ return self._holder.connection - def _initialize_schema(self) -> None: - self._conn.execute(""" - CREATE TABLE IF NOT EXISTS skill_episodes ( - episode_id VARCHAR PRIMARY KEY, - skill_name VARCHAR NOT NULL, - actions_json VARCHAR DEFAULT '[]', - outcome VARCHAR DEFAULT '', - reward DOUBLE DEFAULT 0.0, - context_json VARCHAR DEFAULT '{}', - created_at DOUBLE DEFAULT 0.0 - ) - """) - self._conn.execute(""" - CREATE INDEX IF NOT EXISTS idx_episodes_skill - ON skill_episodes (skill_name, created_at DESC) - """) - self._conn.execute(""" - CREATE TABLE IF NOT EXISTS skill_patterns ( - pattern_id VARCHAR PRIMARY KEY, - skill_name VARCHAR NOT NULL, - pattern_json VARCHAR DEFAULT '{}', - confidence DOUBLE DEFAULT 0.0, - episode_count INTEGER DEFAULT 0, - created_at DOUBLE DEFAULT 0.0 - ) - """) - def _execute_write(self, sql: str, params: Any = None) -> None: execute_with_retry(self._conn, sql, params) diff --git a/src/leapflow/storage/evolution_trace_store.py b/src/leapflow/storage/evolution_trace_store.py deleted file mode 100644 index c2396fe3..00000000 --- a/src/leapflow/storage/evolution_trace_store.py +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright (c) Alibaba, Inc. and its affiliates. -"""Durable store for framework-evolution traces. - -⚠️ Not to be confused with :mod:`leapflow.storage.evolution_store`, whose -``DuckDBEvolutionStore.save_episode`` persists *skill learning* episodes. Two -different meanings of "evolution" live in this package, and both use the word -"episode": that one means "the agent practised a skill", this one means "the -framework changed itself". Named for ``EvolutionTrace`` rather than for evolution -in general precisely so the two cannot be mistaken for each other at a call site. - -**JSON rather than DuckDB, deliberately.** The roadmap called for a DuckDB table; -this is a considered deviation: - -* *Volume does not justify it.* Traces are written when the framework mutates -- - a plugin installs, a trust level moves, the world model proposes. Those are rare - by nature, not per-turn. A table sized for time-series volume would carry - connection-holder, schema and retry machinery for a file that gains a handful of - rows a day. -* *It matches its neighbours.* The ledger already reads - ``capability_plans.json``, ``capability_observations.json`` and - ``proposal_queue.json`` from this same directory. One idiom for the causal - history means one failure mode, not two. -* *Inspectable and additively versioned*, for the same reason the sibling - capability stores chose JSON: an older record stays readable after the schema - grows. - -Retention is a hard cap on record count rather than an age, because what matters -is that the newest traces are always present -- an operator reading the board after -an incident needs the last mutations, not a complete history. -""" - -from __future__ import annotations - -import json -import logging -from pathlib import Path -from typing import Any, Iterable, Mapping - -logger = logging.getLogger(__name__) - -#: Keep the newest N traces. Generous relative to the write rate, and bounded so -#: the file cannot grow without limit on a long-lived profile. -DEFAULT_MAX_TRACES = 2000 - - -class JsonEvolutionTraceStore: - """Append-only, count-bounded JSON store for evolution traces. - - Every method degrades rather than raising: this store backs a transparency - panel, and losing the panel is preferable to failing the operation a trace was - describing. A corrupt or unreadable file reads as empty and is overwritten by - the next append, which is the same choice the sibling capability stores make. - """ - - def __init__(self, path: Path, *, max_traces: int = DEFAULT_MAX_TRACES) -> None: - self._path = Path(path) - self._max = max(1, int(max_traces)) - - @property - def path(self) -> Path: - return self._path - - def append(self, traces: Iterable[Mapping[str, Any]]) -> int: - """Append serialised traces, trimming to the newest ``max_traces``. - - Takes a batch because the sink buffers: one file rewrite per flush rather - than one per trace keeps the cost off whatever produced them. - """ - incoming = [dict(trace) for trace in traces if isinstance(trace, Mapping)] - if not incoming: - return 0 - try: - payload = self._load() - records = payload["traces"] - records.extend(incoming) - # Order by time so a trim keeps the newest regardless of arrival order. - records.sort(key=lambda item: float(item.get("ts") or 0.0)) - if len(records) > self._max: - del records[: len(records) - self._max] - self._write(payload) - return len(incoming) - except (OSError, TypeError, ValueError): - logger.debug("evolution trace store: append failed", exc_info=True) - return 0 - - def list_traces(self, *, limit: int = 200) -> list[dict[str, Any]]: - """Return newest traces first.""" - records = self._load()["traces"] - records.sort(key=lambda item: float(item.get("ts") or 0.0), reverse=True) - return records if limit <= 0 else records[:limit] - - def count(self) -> int: - return len(self._load()["traces"]) - - # ── file access ─────────────────────────────────────────────────────── - - def _load(self) -> dict[str, Any]: - if not self._path.exists(): - return {"version": 1, "traces": []} - try: - data = json.loads(self._path.read_text(encoding="utf-8")) - if isinstance(data, Mapping): - traces = data.get("traces") - if isinstance(traces, list): - return { - "version": int(data.get("version") or 1), - "traces": [dict(t) for t in traces if isinstance(t, Mapping)], - } - except (OSError, json.JSONDecodeError, TypeError, ValueError): - logger.debug("evolution trace store: unreadable, treating as empty", exc_info=True) - return {"version": 1, "traces": []} - - def _write(self, payload: Mapping[str, Any]) -> None: - self._path.parent.mkdir(parents=True, exist_ok=True) - self._path.write_text( - json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True), - encoding="utf-8", - ) - - -__all__ = ["DEFAULT_MAX_TRACES", "JsonEvolutionTraceStore"] diff --git a/src/leapflow/storage/plugin_outcome_store.py b/src/leapflow/storage/plugin_outcome_store.py index a78e3f07..1f5c7c1a 100644 --- a/src/leapflow/storage/plugin_outcome_store.py +++ b/src/leapflow/storage/plugin_outcome_store.py @@ -1,24 +1,22 @@ # Copyright (c) Alibaba, Inc. and its affiliates. -"""Profile-scoped audit store for adaptive plugin execution outcomes.""" +"""Event-sourced audit store for adaptive plugin execution outcomes.""" from __future__ import annotations -import json import time import uuid -from pathlib import Path from typing import Any, Mapping +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent -class JsonPluginOutcomeStore: - """Append-only outcome timeline used by lifecycle governance.""" - def __init__(self, path: Path) -> None: - self._path = Path(path) +class EvolutionPluginOutcomeStore: + """Plugin outcome projection backed by the append-only evolution event stream.""" - @property - def path(self) -> Path: - return self._path + def __init__(self, event_store: Any, *, profile_id: str) -> None: + self._event_store = event_store + self._profile_id = str(profile_id) def add_outcome( self, @@ -33,10 +31,11 @@ def add_outcome( side_effect_state: str = "none", metadata: Mapping[str, Any] | None = None, ) -> dict[str, Any]: - """Append one execution outcome summary.""" + outcome_id = f"out-{uuid.uuid4().hex}" + created_at = time.time() record = { - "outcome_id": f"out-{uuid.uuid4().hex}", - "created_at": time.time(), + "outcome_id": outcome_id, + "created_at": created_at, "plugin_id": str(plugin_id), "tool_name": str(tool_name), "ok": bool(ok), @@ -47,21 +46,38 @@ def add_outcome( "side_effect_state": str(side_effect_state or "none"), "metadata": dict(metadata or {}), } - payload = self._load_payload() - payload.setdefault("outcomes", []).append(record) - self._write_payload(payload) + event = EvolutionEvent.create( + EvolutionEventType.PLUGIN_OUTCOME_RECORDED, + context=EvolutionContext( + profile_id=self._profile_id, + requirement_id=record["requirement_id"], + plugin_id=record["plugin_id"], + correlation_id=record["plan_id"] or outcome_id, + ), + payload=record, + producer="plugin.lifecycle_governor", + privacy_class="profile", + occurred_at=created_at, + dedup_key=f"plugin.outcome_recorded:{outcome_id}", + ) + if not self._event_store.append(event): + raise RuntimeError(f"duplicate plugin outcome: {outcome_id}") return record def list_outcomes(self, *, plugin_id: str = "", limit: int = 100) -> list[dict[str, Any]]: - payload = self._load_payload() - records = [dict(item) for item in payload.get("outcomes", []) if isinstance(item, Mapping)] - if plugin_id: - records = [record for record in records if record.get("plugin_id") == plugin_id] - records.sort(key=lambda item: float(item.get("created_at") or 0.0), reverse=True) - return records if limit <= 0 else records[:limit] + records = self._event_store.read( + profile_id=self._profile_id, + event_type=EvolutionEventType.PLUGIN_OUTCOME_RECORDED, + limit=5000, + ) + outcomes = [ + dict(record.event.to_dict()["payload"]) + for record in reversed(records) + if not plugin_id or record.event.context.plugin_id == plugin_id + ] + return outcomes if limit <= 0 else outcomes[:limit] def failure_streak(self, plugin_id: str) -> int: - """Return consecutive latest failures for a plugin.""" streak = 0 for record in self.list_outcomes(plugin_id=plugin_id, limit=0): if record.get("ok") is True: @@ -69,23 +85,5 @@ def failure_streak(self, plugin_id: str) -> int: streak += 1 return streak - def _load_payload(self) -> dict[str, Any]: - if not self._path.exists(): - return {"version": 1, "outcomes": []} - try: - data = json.loads(self._path.read_text(encoding="utf-8")) - if isinstance(data, Mapping) and isinstance(data.get("outcomes"), list): - return {"version": int(data.get("version") or 1), "outcomes": data["outcomes"]} - except (OSError, json.JSONDecodeError, TypeError, ValueError): - return {"version": 1, "outcomes": []} - return {"version": 1, "outcomes": []} - - def _write_payload(self, payload: Mapping[str, Any]) -> None: - self._path.parent.mkdir(parents=True, exist_ok=True) - self._path.write_text( - json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True), - encoding="utf-8", - ) - -__all__ = ["JsonPluginOutcomeStore"] +__all__ = ["EvolutionPluginOutcomeStore"] diff --git a/src/leapflow/storage/plugin_proposal_store.py b/src/leapflow/storage/plugin_proposal_store.py deleted file mode 100644 index e0265b97..00000000 --- a/src/leapflow/storage/plugin_proposal_store.py +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright (c) Alibaba, Inc. and its affiliates. -"""Profile-scoped JSON store for plugin proposals. - -The store intentionally uses the path supplied by ProfileLayout -(``profile_layout.plugin_proposals_path``). It does not infer profile roots or -assemble managed paths itself. -""" - -from __future__ import annotations - -import json -from pathlib import Path -from typing import Any - -from leapflow.domain.plugin_proposal import ( - BehaviorTestCase, - GapEvidence, - PluginProposal, - ProposalStatus, - ProposedToolSpec, -) - - -class JsonPluginProposalStore: - """Durable profile-local store for reviewable plugin proposals.""" - - def __init__(self, path: Path) -> None: - self._path = Path(path) - - @property - def path(self) -> Path: - return self._path - - def list(self) -> list[PluginProposal]: - return [self._proposal_from_dict(item) for item in self._load()] - - def get(self, proposal_id: str) -> PluginProposal | None: - target = str(proposal_id or "") - for proposal in self.list(): - if proposal.proposal_id == target: - return proposal - return None - - def save(self, proposal: PluginProposal) -> PluginProposal: - items = [item for item in self._load() if item.get("proposal_id") != proposal.proposal_id] - items.append(proposal.to_dict()) - self._save(items) - return proposal - - def update_status(self, proposal_id: str, status: ProposalStatus) -> PluginProposal | None: - proposal = self.get(proposal_id) - if proposal is None: - return None - updated = PluginProposal( - proposal_id=proposal.proposal_id, - plugin_id=proposal.plugin_id, - capability_summary=proposal.capability_summary, - gap_type=proposal.gap_type, - risk_level=proposal.risk_level, - status=status, - evidence=proposal.evidence, - proposed_tools=proposal.proposed_tools, - test_cases=proposal.test_cases, - created_at=proposal.created_at, - ) - return self.save(updated) - - def _load(self) -> list[dict[str, Any]]: - try: - raw = json.loads(self._path.read_text(encoding="utf-8")) - except FileNotFoundError: - return [] - except (json.JSONDecodeError, OSError, ValueError): - return [] - if not isinstance(raw, list): - return [] - return [item for item in raw if isinstance(item, dict)] - - def _save(self, items: list[dict[str, Any]]) -> None: - self._path.parent.mkdir(parents=True, exist_ok=True) - self._path.write_text(json.dumps(items, ensure_ascii=False, indent=2), encoding="utf-8") - - @staticmethod - def _proposal_from_dict(raw: dict[str, Any]) -> PluginProposal: - evidence = tuple( - GapEvidence.create( - str(item.get("evidence_type") or "unknown"), - str(item.get("summary") or ""), - confidence=float(item.get("confidence") or 0.0), - metadata=dict(item.get("metadata") or {}), - ) - for item in raw.get("evidence", []) - if isinstance(item, dict) - ) - tools = tuple( - ProposedToolSpec( - name=str(item.get("name") or "generated_tool"), - description=str(item.get("description") or ""), - risk_level=str(item.get("risk_level") or "read_only"), # type: ignore[arg-type] - mutates_state=bool(item.get("mutates_state", False)), - ) - for item in raw.get("proposed_tools", []) - if isinstance(item, dict) - ) - tests = tuple( - BehaviorTestCase.create( - str(item.get("tool_name") or ""), - arguments=dict(item.get("arguments") or {}), - expected_subset=dict(item.get("expected_subset") or {}), - description=str(item.get("description") or ""), - ) - for item in raw.get("test_cases", []) - if isinstance(item, dict) - ) - return PluginProposal( - proposal_id=str(raw.get("proposal_id") or ""), - plugin_id=str(raw.get("plugin_id") or "generated_plugin"), - capability_summary=str(raw.get("capability_summary") or ""), - gap_type=str(raw.get("gap_type") or "tool_plugin"), # type: ignore[arg-type] - risk_level=str(raw.get("risk_level") or "read_only"), # type: ignore[arg-type] - status=str(raw.get("status") or "draft"), # type: ignore[arg-type] - evidence=evidence, - proposed_tools=tools, - test_cases=tests, - created_at=float(raw.get("created_at") or 0.0), - ) diff --git a/src/leapflow/storage/plugin_version_store.py b/src/leapflow/storage/plugin_version_store.py index 7d37552b..595e7362 100644 --- a/src/leapflow/storage/plugin_version_store.py +++ b/src/leapflow/storage/plugin_version_store.py @@ -46,10 +46,12 @@ def record_source( "created_at": time.time(), "metadata": dict(metadata or {}), } - self._write_json(plugin_dir / "active.json", entry) index = [item for item in self._read_index(plugin_id) if item.get("version") != version_id] index.append(entry) + # Commit the active pointer last. A failed index write may leave an immutable + # snapshot behind, but it cannot make a partially recorded version active. self._write_json(plugin_dir / "versions.json", index) + self._write_json(plugin_dir / "active.json", entry) return entry def active(self, plugin_id: str) -> dict[str, Any] | None: @@ -60,6 +62,32 @@ def active(self, plugin_id: str) -> dict[str, Any] | None: def versions(self, plugin_id: str) -> list[dict[str, Any]]: return self._read_index(plugin_id) + def snapshot_state(self, plugin_id: str) -> dict[str, Any]: + """Capture active pointer and version index for transactional rollback.""" + return { + "active": self.active(plugin_id), + "versions": self.versions(plugin_id), + } + + def restore_state(self, plugin_id: str, snapshot: dict[str, Any]) -> None: + """Restore metadata captured before a failed file/runtime mutation.""" + plugin_dir = self._plugin_dir(plugin_id) + active_path = plugin_dir / "active.json" + active = snapshot.get("active") + if isinstance(active, dict): + self._write_json(active_path, active) + else: + active_path.unlink(missing_ok=True) + self._write_json(plugin_dir / "versions.json", list(snapshot.get("versions") or ())) + + def restore_source(self, target_path: Path, data: bytes | None) -> None: + """Atomically restore a source snapshot, or remove a previously absent file.""" + target = Path(target_path) + if data is None: + target.unlink(missing_ok=True) + return + self._write_bytes(target, data) + def source_for(self, plugin_id: str, version: str) -> Path | None: for item in self._read_index(plugin_id): if str(item.get("version")) == str(version): diff --git a/src/leapflow/storage/schema.py b/src/leapflow/storage/schema.py index 3f5e022f..9c3c524f 100644 --- a/src/leapflow/storage/schema.py +++ b/src/leapflow/storage/schema.py @@ -9,14 +9,16 @@ from __future__ import annotations import logging +import time from dataclasses import dataclass, field -from typing import List +from typing import Callable, List import duckdb logger = logging.getLogger(__name__) -CURRENT_SCHEMA_VERSION = 1 +BASE_SCHEMA_VERSION = 1 +CURRENT_SCHEMA_VERSION = 6 @dataclass(frozen=True) @@ -288,30 +290,28 @@ class TableDef: "CREATE INDEX IF NOT EXISTS idx_cmsg_session ON conv_messages(session_id, created_at)", ], ), - # ── Evolution ── + # ── Skill evolution memory ── TableDef( - name="evo_episodes", + name="skill_episodes", ddl=""" - CREATE TABLE IF NOT EXISTS evo_episodes ( + CREATE TABLE IF NOT EXISTS skill_episodes ( episode_id VARCHAR PRIMARY KEY, skill_name VARCHAR NOT NULL, actions_json VARCHAR DEFAULT '[]', outcome VARCHAR DEFAULT '', reward DOUBLE DEFAULT 0.0, context_json VARCHAR DEFAULT '{}', - created_at DOUBLE DEFAULT 0.0, - workspace_id TEXT DEFAULT '', - session_id TEXT DEFAULT '' + created_at DOUBLE DEFAULT 0.0 ) """, indexes=[ - "CREATE INDEX IF NOT EXISTS idx_evep_skill ON evo_episodes(skill_name, created_at DESC)", + "CREATE INDEX IF NOT EXISTS idx_episodes_skill ON skill_episodes(skill_name, created_at DESC)", ], ), TableDef( - name="evo_patterns", + name="skill_patterns", ddl=""" - CREATE TABLE IF NOT EXISTS evo_patterns ( + CREATE TABLE IF NOT EXISTS skill_patterns ( pattern_id VARCHAR PRIMARY KEY, skill_name VARCHAR NOT NULL, pattern_json VARCHAR DEFAULT '{}', @@ -362,27 +362,191 @@ class TableDef: ] -def ensure_schema(conn: duckdb.DuckDBPyConnection) -> int: - """Create all tables and indexes if they don't exist. +@dataclass(frozen=True) +class MigrationDef: + """One ordered, transactional schema migration.""" - Returns the current schema version after applying. - """ - for table_def in TABLES: - conn.execute(table_def.ddl) - for idx_sql in table_def.indexes: - conn.execute(idx_sql) + version: int + name: str + apply: Callable[[duckdb.DuckDBPyConnection], None] - row = conn.execute( - "SELECT MAX(version) FROM _schema_version" - ).fetchone() - current = row[0] if row and row[0] is not None else 0 - if current < CURRENT_SCHEMA_VERSION: - import time - conn.execute( - "INSERT INTO _schema_version VALUES (?, ?)", - [CURRENT_SCHEMA_VERSION, time.time()], +def _apply_evolution_tables(conn: duckdb.DuckDBPyConnection) -> None: + """Create the append-only event stream and durable cold-path work queues.""" + statements = ( + """ + CREATE TABLE evolution_events ( + sequence BIGINT NOT NULL, + event_id VARCHAR PRIMARY KEY, + event_type VARCHAR NOT NULL, + profile_id VARCHAR NOT NULL DEFAULT '', + workspace_id VARCHAR NOT NULL DEFAULT '', + session_id VARCHAR NOT NULL DEFAULT '', + session_generation INTEGER NOT NULL DEFAULT 0, + turn_id VARCHAR NOT NULL DEFAULT '', + frame_id VARCHAR NOT NULL DEFAULT '', + action_id VARCHAR NOT NULL DEFAULT '', + observation_id VARCHAR NOT NULL DEFAULT '', + requirement_id VARCHAR NOT NULL DEFAULT '', + decision_id VARCHAR NOT NULL DEFAULT '', + proposal_id VARCHAR NOT NULL DEFAULT '', + artifact_id VARCHAR NOT NULL DEFAULT '', + plugin_id VARCHAR NOT NULL DEFAULT '', + version_id VARCHAR NOT NULL DEFAULT '', + correlation_id VARCHAR NOT NULL DEFAULT '', + causation_id VARCHAR NOT NULL DEFAULT '', + occurred_at DOUBLE NOT NULL, + producer VARCHAR NOT NULL, + producer_version VARCHAR NOT NULL DEFAULT '', + privacy_class VARCHAR NOT NULL DEFAULT 'system', + schema_version INTEGER NOT NULL, + payload_json VARCHAR NOT NULL DEFAULT '{}', + payload_hash VARCHAR NOT NULL, + dedup_key VARCHAR NOT NULL, + UNIQUE(profile_id, dedup_key) ) - logger.info("schema: applied version %d", CURRENT_SCHEMA_VERSION) + """, + """ + CREATE TABLE evolution_teacher_jobs ( + job_id VARCHAR PRIMARY KEY, + profile_id VARCHAR NOT NULL, + workspace_id VARCHAR NOT NULL DEFAULT '', + session_id VARCHAR NOT NULL DEFAULT '', + session_generation INTEGER NOT NULL DEFAULT 0, + episode_id VARCHAR NOT NULL, + from_sequence BIGINT NOT NULL DEFAULT 0, + through_sequence BIGINT NOT NULL DEFAULT 0, + reason VARCHAR NOT NULL DEFAULT '', + goal VARCHAR NOT NULL DEFAULT '', + status VARCHAR NOT NULL, + lease_owner VARCHAR NOT NULL DEFAULT '', + lease_until DOUBLE NOT NULL DEFAULT 0.0, + attempts INTEGER NOT NULL DEFAULT 0, + model VARCHAR NOT NULL DEFAULT '', + prompt_hash VARCHAR NOT NULL DEFAULT '', + result_artifact_id VARCHAR NOT NULL DEFAULT '', + next_attempt_at DOUBLE NOT NULL DEFAULT 0.0, + created_at DOUBLE NOT NULL, + updated_at DOUBLE NOT NULL, + completed_at DOUBLE NOT NULL DEFAULT 0.0, + error VARCHAR NOT NULL DEFAULT '', + UNIQUE(profile_id, episode_id) + ) + """, + "CREATE INDEX idx_evo_event_session ON evolution_events(profile_id, session_id, sequence)", + "CREATE INDEX idx_evo_event_correlation ON evolution_events(profile_id, correlation_id, sequence)", + "CREATE INDEX idx_evo_event_type ON evolution_events(profile_id, event_type, sequence)", + "CREATE INDEX idx_evo_teacher_status ON evolution_teacher_jobs(profile_id, status, next_attempt_at)", + ) + for statement in statements: + conn.execute(statement) + + +def _apply_evolution_sequence(conn: duckdb.DuckDBPyConnection) -> None: + """Create a database-global cursor after any pre-sequence event rows.""" + conn.execute( + "CREATE UNIQUE INDEX idx_evo_event_sequence ON evolution_events(sequence)" + ) + row = conn.execute("SELECT COALESCE(MAX(sequence), 0) + 1 FROM evolution_events").fetchone() + start = max(1, int(row[0] if row else 1)) + conn.execute(f"CREATE SEQUENCE evolution_event_sequence START {start}") + + +def _apply_teacher_job_context(conn: duckdb.DuckDBPyConnection) -> None: + """Make every durable teacher job independently executable and auditable.""" + statements = ( + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS workspace_id VARCHAR DEFAULT ''", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS session_id VARCHAR DEFAULT ''", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS session_generation INTEGER DEFAULT 0", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS from_sequence BIGINT DEFAULT 0", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS through_sequence BIGINT DEFAULT 0", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS reason VARCHAR DEFAULT ''", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS goal VARCHAR DEFAULT ''", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS result_artifact_id VARCHAR DEFAULT ''", + "ALTER TABLE evolution_teacher_jobs ADD COLUMN IF NOT EXISTS completed_at DOUBLE DEFAULT 0.0", + ) + for statement in statements: + conn.execute(statement) + + +def _apply_evolution_projection(conn: duckdb.DuckDBPyConnection) -> None: + """Create checkpointed read models derived exclusively from the event stream.""" + conn.execute( + """ + CREATE TABLE evolution_projections ( + projection_name VARCHAR NOT NULL, + profile_id VARCHAR NOT NULL, + scope_key VARCHAR NOT NULL, + last_sequence BIGINT NOT NULL DEFAULT 0, + state_json VARCHAR NOT NULL DEFAULT '{}', + updated_at DOUBLE NOT NULL, + PRIMARY KEY (projection_name, profile_id, scope_key) + ) + """ + ) + + +def _apply_proposal_event_index(conn: duckdb.DuckDBPyConnection) -> None: + """Retire the unused work table and index event-sourced proposal replay.""" + conn.execute("DROP TABLE IF EXISTS evolution_proposal_work") + conn.execute( + "CREATE INDEX idx_evo_event_proposal " + "ON evolution_events(profile_id, proposal_id, sequence)" + ) + + +MIGRATIONS: tuple[MigrationDef, ...] = ( + MigrationDef(2, "evolution event stream", _apply_evolution_tables), + MigrationDef(3, "database-global evolution cursor", _apply_evolution_sequence), + MigrationDef(4, "durable teacher job context", _apply_teacher_job_context), + MigrationDef(5, "checkpointed evolution projections", _apply_evolution_projection), + MigrationDef(6, "event-sourced proposal index", _apply_proposal_event_index), +) + + +def ensure_schema(conn: duckdb.DuckDBPyConnection) -> int: + """Bootstrap the baseline and apply every pending migration atomically.""" + conn.execute("BEGIN TRANSACTION") + try: + for table_def in TABLES: + conn.execute(table_def.ddl) + for idx_sql in table_def.indexes: + conn.execute(idx_sql) + + row = conn.execute("SELECT MAX(version) FROM _schema_version").fetchone() + current = int(row[0]) if row and row[0] is not None else 0 + if current > CURRENT_SCHEMA_VERSION: + raise RuntimeError( + f"database schema {current} is newer than supported {CURRENT_SCHEMA_VERSION}" + ) + if current == 0: + conn.execute( + "INSERT INTO _schema_version VALUES (?, ?)", + [BASE_SCHEMA_VERSION, time.time()], + ) + current = BASE_SCHEMA_VERSION + + for migration in MIGRATIONS: + if migration.version <= current: + continue + if migration.version != current + 1: + raise RuntimeError( + f"schema migration gap: current={current}, next={migration.version}" + ) + migration.apply(conn) + conn.execute( + "INSERT INTO _schema_version VALUES (?, ?)", + [migration.version, time.time()], + ) + current = migration.version + logger.info("schema: applied version %d (%s)", current, migration.name) - return CURRENT_SCHEMA_VERSION + if current != CURRENT_SCHEMA_VERSION: + raise RuntimeError( + f"schema migration incomplete: current={current}, expected={CURRENT_SCHEMA_VERSION}" + ) + conn.execute("COMMIT") + return current + except Exception: + conn.execute("ROLLBACK") + raise diff --git a/src/leapflow/tools/name_resolver.py b/src/leapflow/tools/name_resolver.py index c0ec98d7..508413ae 100644 --- a/src/leapflow/tools/name_resolver.py +++ b/src/leapflow/tools/name_resolver.py @@ -28,28 +28,6 @@ ResolutionConfidence = Literal["high", "medium", "low"] RiskLevel = Literal["read_only", "mutating", "external"] -_READ_ONLY_TOOLS = { - "file_list", - "file_read", - "time_get", - "env_info", - "text_search", - "skills_list", - "skill_view", - "memory_search", - # Network reads: a GET has no side effect, so the loop must not treat it as a - # mutation. Egress safety is enforced by the tool's own target gate, not by - # pretending the call mutates state. - "web_fetch", - # Verification/inspection tools: read-oriented for the loop even though some - # names contain a mutating signal (e.g. test_run) or execute via a gated - # underlying tool (test_run/lint_check delegate to the shell_run gate). - "test_run", - "lint_check", - "terminal_read", - "terminal_list", -} - _NO_EFFECT_CLAIMS = frozenset({"read_only", "none"}) """The only declared ``risk_level`` values that assert a call has no effect. @@ -127,10 +105,11 @@ class ToolSpec: description: str = "" parameters: frozenset[str] = field(default_factory=frozenset) required: frozenset[str] = field(default_factory=frozenset) - risk_level: RiskLevel = "read_only" + risk_level: RiskLevel = "mutating" mutates_state: bool = False effect_scope: str = "local" idempotency_scope: str = "turn" + execution_policy: str = "" @dataclass(frozen=True) @@ -144,7 +123,7 @@ class ToolResolution: reason: str suggestions: tuple[str, ...] = () auto_executable: bool = False - risk_level: RiskLevel = "read_only" + risk_level: RiskLevel = "mutating" @property def is_resolved(self) -> bool: @@ -212,8 +191,7 @@ def from_definitions( metadata = function.get("x_leapflow", {}) or definition.get("x_leapflow", {}) or {} mutates_state = bool(metadata.get("mutates_state", False)) risk_level = _resolve_risk_level( - name, - bridge_mutates=mutates_state, + mutates_state=mutates_state, declared=str(metadata.get("risk_level") or ""), ) specs[name] = ToolSpec( @@ -224,7 +202,11 @@ def from_definitions( risk_level=risk_level, mutates_state=mutates_state, effect_scope=str(metadata.get("effect_scope") or ("external" if risk_level == "external" else "local")), - idempotency_scope=str(metadata.get("idempotency_scope") or ("session" if risk_level == "external" else "turn")), + idempotency_scope=str( + metadata.get("idempotency_scope") + or ("session" if risk_level == "external" else "turn") + ), + execution_policy=str(metadata.get("execution_policy") or ""), ) for name in handlers.keys(): canonical = str(name).removeprefix("gp_") @@ -232,13 +214,14 @@ def from_definitions( mutates_state = False # A handler with no schema declares nothing at all, so it gets the # unclaimed default rather than being read as read-only. - risk_level = _resolve_risk_level(canonical, bridge_mutates=mutates_state) + risk_level = _resolve_risk_level(mutates_state=mutates_state) specs[canonical] = ToolSpec( name=canonical, risk_level=risk_level, mutates_state=mutates_state, - effect_scope="external" if risk_level == "external" else "local", - idempotency_scope="session" if risk_level == "external" else "turn", + effect_scope="external", + idempotency_scope="session", + execution_policy="external_side_effect", ) validated_aliases: dict[str, str] = {} @@ -360,32 +343,12 @@ def _suggestions(self, tool_name: str, arguments: Mapping[str, Any]) -> tuple[st return tuple(shape_matches[:5]) -def _resolve_risk_level(name: str, *, bridge_mutates: bool, declared: str = "") -> RiskLevel: - """Classify a tool's *effect* for the execution policy. - - ``declared`` is ``x_leapflow.risk_level``, and it is consulted rather than - honoured wholesale, because that key carries two different vocabularies. The - disclosure side (``CapabilityManifest``) grades how much a call needs to be - explained and approved -- ``none``/``read_only``/``low``/``medium``/``high`` -- - while this side answers a narrower question: does the call have an effect, and - can it be replayed. "medium" is not an answer to that; copying it into this - field would put a value outside ``RiskLevel`` into a typed slot and match none - of the comparisons that read it. - - So only the values where the two vocabularies genuinely agree are taken as a - claim of no effect. Everything else -- a graded risk, or no declaration at all - -- resolves to ``mutating``. Absence of a declaration is not a claim of - safety: read as one, a third-party tool with an innocuous name got the - ``read_only`` policy, which skips the execution ledger entirely, runs freely - in parallel, and is exempt from side-effect gating. - - Order matters. An explicit no-effect claim outranks the name heuristic, - because the heuristic is a substring guess: ``test_run`` contains "run" but is - an inspection. A mutating *bridge* still wins over both, since a declaration - that contradicts the handler's own answer is the stale one. - """ - if name.startswith(("gateway_", "hub_", "platform_")) or declared == "external": +def _resolve_risk_level(*, mutates_state: bool, declared: str = "") -> RiskLevel: + """Classify effect risk from declarations without inspecting the tool name.""" + if declared == "external": return "external" - if not bridge_mutates and (declared in _NO_EFFECT_CLAIMS or name in _READ_ONLY_TOOLS): + if not mutates_state and declared in _NO_EFFECT_CLAIMS: return "read_only" + if mutates_state or declared: + return "mutating" return "mutating" diff --git a/src/leapflow/world_model/prediction.py b/src/leapflow/world_model/prediction.py index 3a83805c..54000669 100644 --- a/src/leapflow/world_model/prediction.py +++ b/src/leapflow/world_model/prediction.py @@ -18,7 +18,7 @@ import time from collections import deque from dataclasses import dataclass, replace -from typing import TYPE_CHECKING, Any, Awaitable, Callable, Optional, Tuple +from typing import TYPE_CHECKING, Any, Callable, Optional if TYPE_CHECKING: from leapflow.world_model.budget import LearningBudgetController @@ -99,12 +99,10 @@ class PredictionOutcome: class PredictionLoop: - """Core on-policy learning engine: Predict → Execute → Compare → Learn. + """Legacy prediction and comparison model used by explicit observation flows. - Wraps action execution to transparently inject prediction and comparison. - When disabled or budget-exhausted, passes through execution unchanged. - - Maintains a trajectory buffer for OPD trajectory-level teacher grading. + Action execution is owned by ``ActionExecutor``. This component may grade an + already-observed transition, but it never wraps or replays an action. """ def __init__( @@ -191,89 +189,6 @@ def record_failure(self, action_desc: str, error: str) -> None: except Exception: logger.debug("record_failure failed", exc_info=True) - async def wrap_execution( - self, - action_desc: str, - execute_fn: Callable[..., Awaitable[Any]], - *args: Any, - fidelity: Optional["SnapshotFidelity"] = None, - **kwargs: Any, - ) -> Tuple[Any, Optional[PredictionOutcome]]: - """Wrap an action execution with the prediction-comparison loop. - - Returns (execution_result, prediction_outcome_or_none). - """ - if not self._enabled or not self._budget.has_tokens("prediction"): - result = await execute_fn(*args, **kwargs) - return result, None - - try: - return await self._run_loop(action_desc, execute_fn, args, kwargs, fidelity) - except Exception: - logger.debug("prediction_loop.wrap_execution failed; executing raw", exc_info=True) - result = await execute_fn(*args, **kwargs) - return result, None - - async def _run_loop( - self, - action_desc: str, - execute_fn: Callable[..., Awaitable[Any]], - args: tuple, - kwargs: dict, - fidelity: Optional["SnapshotFidelity"], - ) -> Tuple[Any, Optional[PredictionOutcome]]: - from leapflow.perception.state_snapshot import SnapshotFidelity - - fid = fidelity or SnapshotFidelity.LIGHT - - # Phase 1: Capture pre-state - pre = await self._snapshot.capture(fid) - - # Phase 2: Predict - prediction = await self._predict(action_desc, pre) - - # Phase 3: Execute - result = await execute_fn(*args, **kwargs) - - # Phase 4: Capture post-state - post = await self._snapshot.capture(fid) - - # Phase 5: Compare - outcome = await self._compare(prediction, pre, post) - - # Phase 6: Store experience - exp_id = self._store.store( - action_description=action_desc, - app_context=pre.app_bundle_id, - predicted_effect=prediction.expected_effect, - actual_effect=outcome.actual_effect, - delta=outcome.delta, - pre_state_summary=pre.to_prompt_context(budget_tokens=100), - post_state_summary=post.to_prompt_context(budget_tokens=100), - ) - - outcome = replace(outcome, experience_id=exp_id) - - # Phase 7: Accumulate trajectory for OPD grading - self._trajectory_buffer.append({ - "experience_id": exp_id, - "action_description": action_desc, - "app_context": pre.app_bundle_id, - "predicted_effect": prediction.expected_effect, - "actual_effect": outcome.actual_effect, - "delta": outcome.delta, - }) - - self._budget.spend("prediction") - - if self._on_outcome is not None: - try: - self._on_outcome(outcome) - except Exception: - logger.debug("on_prediction_outcome callback failed", exc_info=True) - - return result, outcome - async def _predict(self, action_desc: str, pre: "StateSnapshot") -> Prediction: """Generate a prediction using LLM with retrieval-augmented context.""" similar = self._store.retrieve_similar( diff --git a/src/leapflow/world_model/trajectory_grader.py b/src/leapflow/world_model/trajectory_grader.py index b4fc4f55..b55de62c 100644 --- a/src/leapflow/world_model/trajectory_grader.py +++ b/src/leapflow/world_model/trajectory_grader.py @@ -14,7 +14,7 @@ from __future__ import annotations import logging -from dataclasses import dataclass +from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, List, Mapping, Sequence if TYPE_CHECKING: @@ -362,6 +362,7 @@ class TeacherVerdict: grades: tuple[ActionGrade, ...] = () verdicts: tuple[AdaptationVerdict, ...] = () + raw_payload: Mapping[str, Any] = field(default_factory=dict) @property def intents(self) -> tuple[EvolutionIntent, ...]: @@ -426,6 +427,7 @@ async def grade_and_propose( goal: str = "", *, degraded_capabilities: Sequence[Mapping[str, Any]] = (), + raise_on_error: bool = False, ) -> "TeacherVerdict": """Grade the trajectory *and* propose capability gaps, in one LLM call. @@ -446,8 +448,11 @@ async def grade_and_propose( traj_text = self._format_trajectory(trajectory) payload = await self._call_teacher_raw( - traj_text, goal, propose_gaps=True, + traj_text, + goal, + propose_gaps=True, degraded_capabilities=degraded_capabilities, + raise_on_error=raise_on_error, ) self._budget.spend("grading") @@ -455,6 +460,7 @@ async def grade_and_propose( return TeacherVerdict( tuple(grades), self._parse_verdicts(payload, goal, degraded_capabilities), + dict(payload), ) async def _call_teacher_raw( @@ -464,6 +470,7 @@ async def _call_teacher_raw( *, propose_gaps: bool = False, degraded_capabilities: Sequence[Mapping[str, Any]] = (), + raise_on_error: bool = False, ) -> dict: """Single LLM call: teacher evaluates with full hindsight. @@ -493,6 +500,8 @@ async def _call_teacher_raw( ) return extract_json_object(resp.content or "") or {} except Exception: + if raise_on_error: + raise logger.debug("trajectory_grader.call_teacher failed", exc_info=True) return {} diff --git a/src/leapspace/app_space/harness.py b/src/leapspace/app_space/harness.py index 8824eb1f..6b3dcf06 100644 --- a/src/leapspace/app_space/harness.py +++ b/src/leapspace/app_space/harness.py @@ -293,6 +293,21 @@ async def _run_signal(self, config: AppTaskConfig, actor: LeapAppActor) -> int: logger.error( "verdict: task %s failed expect (exit %d)", config.id, result.returncode ) + result_dir = state_root / config.id + await actor.fs_mkdir(str(result_dir)) + await actor.fs_write( + str(result_dir / "result.json"), + json.dumps( + { + "task_id": config.id, + "outcome": "PASS" if result.returncode == 0 else "FAIL", + "exit_code": result.returncode, + "app_ids": list(config.app_ids), + "observed_at": time.time(), + }, + ensure_ascii=False, + ), + ) return result.returncode async def _await_sentinel( diff --git a/tests/_fixtures/cassettes/r1_conversation/cassette-model-367e09460741491b.cassette.json b/tests/_fixtures/cassettes/r1_conversation/cassette-model-367e09460741491b.cassette.json new file mode 100644 index 00000000..10dc95cc --- /dev/null +++ b/tests/_fixtures/cassettes/r1_conversation/cassette-model-367e09460741491b.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "367e09460741491b1993580005a5bbeed016185dbf1e29b1b44b4ed55fad793f", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Say hello.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Say hello.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Say hello.\nSay hello." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Hello from LeapFlow.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r1_conversation/cassette-model-9b6460bbb9f20b6f.cassette.json b/tests/_fixtures/cassettes/r1_conversation/cassette-model-9b6460bbb9f20b6f.cassette.json new file mode 100644 index 00000000..60b6de29 --- /dev/null +++ b/tests/_fixtures/cassettes/r1_conversation/cassette-model-9b6460bbb9f20b6f.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "9b6460bbb9f20b6ff5fc173abb997b32c67a66e625cd42a16bd3cc0a4c35aa15", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Hello from LeapFlow.\n- [user] Use the file_read tool on invoice.txt and report the total.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Use the file_read tool on invoice.txt and report the total.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Hello from LeapFlow." + }, + { + "role": "user", + "content": "Use the file_read tool on invoice.txt and report the total.\nUse the file_read tool on invoice.txt and report the total." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "file_read" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"kind\": \"file_read_evidence\", \"path\": \"\", \"lines\": 2, \"truncated\": false, \"mode\": \"raw\", \"excerpt\": \"Invoice 42\\nTotal: 128.50 USD\", \"start_line\": 1, \"end_line\": 2, \"selected_lines\": 2}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"The invoice total is 128.50 USD.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r1_conversation/cassette-model-bc00bc1c3adb5c03.cassette.json b/tests/_fixtures/cassettes/r1_conversation/cassette-model-bc00bc1c3adb5c03.cassette.json new file mode 100644 index 00000000..724161a6 --- /dev/null +++ b/tests/_fixtures/cassettes/r1_conversation/cassette-model-bc00bc1c3adb5c03.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "bc00bc1c3adb5c032a334b6431c7b10b91c539cd0af768196ae358a074aa07ed", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Hello from LeapFlow.\n- [user] Use the file_read tool on invoice.txt and report the total.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Use the file_read tool on invoice.txt and report the total.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Hello from LeapFlow." + }, + { + "role": "user", + "content": "Use the file_read tool on invoice.txt and report the total.\nUse the file_read tool on invoice.txt and report the total." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"file_read\", \"arguments\": \"{\\\"path\\\": \\\"invoice.txt\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r1_conversation/cassette-model-d963d1a7c85f827a.cassette.json b/tests/_fixtures/cassettes/r1_conversation/cassette-model-d963d1a7c85f827a.cassette.json new file mode 100644 index 00000000..a9a69566 --- /dev/null +++ b/tests/_fixtures/cassettes/r1_conversation/cassette-model-d963d1a7c85f827a.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "d963d1a7c85f827a9ed648bf1bfc955676c4ce2e222e4a3fed7833c7e23b5000", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Semantic Focus Plane\nCurrent task focus:\n- Target: invoice.txt\n- Type: file\n- Evidence refs: file_read:invoice.txt\nResolved user reference:\n- file -> invoice.txt (task_semantic, confidence=0.92)\nUse Current task focus for deictic task references such as 'the above paper'; use control-plane events only when the user explicitly asks about runtime settings.\n\n\n## Recent Session Summary\n- [assistant] The invoice total is 128.50 USD.\n- [user] Is that the same invoice?\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Is that the same invoice?\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "The invoice total is 128.50 USD." + }, + { + "role": "user", + "content": "Is that the same invoice?\nIs that the same invoice?" + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Yes, that is the same invoice.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r2_isolation/cassette-model-21df7e8e74778e3f.cassette.json b/tests/_fixtures/cassettes/r2_isolation/cassette-model-21df7e8e74778e3f.cassette.json new file mode 100644 index 00000000..6af38931 --- /dev/null +++ b/tests/_fixtures/cassettes/r2_isolation/cassette-model-21df7e8e74778e3f.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "21df7e8e74778e3f6aa6866b0923ce2cc98e0072408b928be525bd9aed592ee7", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Hello from B.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Hello from B.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Hello from B.\nHello from B." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Workspace B acknowledged.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r2_isolation/cassette-model-73ddd7ce361986cc.cassette.json b/tests/_fixtures/cassettes/r2_isolation/cassette-model-73ddd7ce361986cc.cassette.json new file mode 100644 index 00000000..8c28ce3b --- /dev/null +++ b/tests/_fixtures/cassettes/r2_isolation/cassette-model-73ddd7ce361986cc.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "73ddd7ce361986cc46ac429df381a3489347c8aebc15b7b35794cc6474c6dc89", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Workspace B acknowledged.\n- [user] Second B turn.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Second B turn.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Workspace B acknowledged." + }, + { + "role": "user", + "content": "Second B turn.\nSecond B turn." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Still workspace B.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r2_isolation/cassette-model-aff723a22088e665.cassette.json b/tests/_fixtures/cassettes/r2_isolation/cassette-model-aff723a22088e665.cassette.json new file mode 100644 index 00000000..e517617d --- /dev/null +++ b/tests/_fixtures/cassettes/r2_isolation/cassette-model-aff723a22088e665.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "aff723a22088e6657d3e1e44df0572c1ec08913184833d791cee35004532f565", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Workspace A acknowledged.\n- [user] Second A turn.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Second A turn.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Workspace A acknowledged." + }, + { + "role": "user", + "content": "Second A turn.\nSecond A turn." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Still workspace A.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r2_isolation/cassette-model-ef55f6a7257d5165.cassette.json b/tests/_fixtures/cassettes/r2_isolation/cassette-model-ef55f6a7257d5165.cassette.json new file mode 100644 index 00000000..3905868e --- /dev/null +++ b/tests/_fixtures/cassettes/r2_isolation/cassette-model-ef55f6a7257d5165.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "ef55f6a7257d5165de4af8f42068832348aa86d3cf09b80cf6b9fe5b18e18650", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Hello from A.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Hello from A.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Hello from A.\nHello from A." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Workspace A acknowledged.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r3_control_plane/cassette-model-4ecd277d081b281e.cassette.json b/tests/_fixtures/cassettes/r3_control_plane/cassette-model-4ecd277d081b281e.cassette.json new file mode 100644 index 00000000..ec587be0 --- /dev/null +++ b/tests/_fixtures/cassettes/r3_control_plane/cassette-model-4ecd277d081b281e.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "4ecd277d081b281e9a9324cc714092a2ed827389d2082ec3fa905018533df9b0", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Anything to report?\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Anything to report?\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Anything to report?\nAnything to report?" + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Acknowledged.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r4_recovery/cassette-model-114913c6ced49c00.cassette.json b/tests/_fixtures/cassettes/r4_recovery/cassette-model-114913c6ced49c00.cassette.json new file mode 100644 index 00000000..31646fe8 --- /dev/null +++ b/tests/_fixtures/cassettes/r4_recovery/cassette-model-114913c6ced49c00.cassette.json @@ -0,0 +1,60 @@ +{ + "fingerprint": "114913c6ced49c000271ba14cd9aa443a429df524ac31b9f2bffd1f947be2147", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Summarize the situation.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Summarize the situation.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Summarize the situation.\nSummarize the situation." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 429, + "content_type": "application/json", + "body": "{\"error\": {\"message\": \"Rate limit reached for requests\", \"type\": \"rate_limit_error\", \"code\": \"rate_limit_exceeded\"}}" + }, + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Recovered after a rate limit.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r4_recovery/cassette-model-8f4a60fd5352920b.cassette.json b/tests/_fixtures/cassettes/r4_recovery/cassette-model-8f4a60fd5352920b.cassette.json new file mode 100644 index 00000000..04dc2930 --- /dev/null +++ b/tests/_fixtures/cassettes/r4_recovery/cassette-model-8f4a60fd5352920b.cassette.json @@ -0,0 +1,64 @@ +{ + "fingerprint": "8f4a60fd5352920b7c500e4d1b16a5ccb41659017b540716c3f607f93d8f7a24", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Recovered after a rate limit.\n- [user] And now?\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: And now?\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Recovered after a rate limit." + }, + { + "role": "user", + "content": "And now?\nAnd now?" + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 500, + "content_type": "application/json", + "body": "{\"error\": {\"message\": \"The server had an error\", \"type\": \"server_error\", \"code\": \"internal_error\"}}" + }, + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Recovered after a server error.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r4_recovery/cassette-model-bd1578d59776ef42.cassette.json b/tests/_fixtures/cassettes/r4_recovery/cassette-model-bd1578d59776ef42.cassette.json new file mode 100644 index 00000000..2103e12a --- /dev/null +++ b/tests/_fixtures/cassettes/r4_recovery/cassette-model-bd1578d59776ef42.cassette.json @@ -0,0 +1,64 @@ +{ + "fingerprint": "bd1578d59776ef4247e95de673cbb23ba80ebc3301c6a6388d06c79d2ca5d8bd", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Recovered after a server error.\n- [user] Keep going with more context.\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Keep going with more context.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Recovered after a server error." + }, + { + "role": "user", + "content": "Keep going with more context.\nKeep going with more context." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 400, + "content_type": "application/json", + "body": "{\"error\": {\"message\": \"This model's maximum context length is 8192 tokens. However, your messages resulted in 9001 tokens.\", \"type\": \"invalid_request_error\", \"code\": \"context_length_exceeded\"}}" + }, + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Recovered after compressing context.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r4_recovery/cassette-model-f4840e1191c49c9c.cassette.json b/tests/_fixtures/cassettes/r4_recovery/cassette-model-f4840e1191c49c9c.cassette.json new file mode 100644 index 00000000..6f19d24f --- /dev/null +++ b/tests/_fixtures/cassettes/r4_recovery/cassette-model-f4840e1191c49c9c.cassette.json @@ -0,0 +1,64 @@ +{ + "fingerprint": "f4840e1191c49c9c300c0c2aaf5e5a4cb9255ca92b83498d50cbebe65acb05b6", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Recovered after compressing context.\n- [user] Do the impossible thing.\n\n## Task Contract\n- Task ID: turn-4\n- Original user request: Do the impossible thing.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Recovered after compressing context." + }, + { + "role": "user", + "content": "Do the impossible thing.\nDo the impossible thing." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 400, + "content_type": "application/json", + "body": "{\"error\": {\"message\": \"The requested configuration is not supported by this model\", \"type\": \"invalid_request_error\", \"code\": \"unsupported_value\"}}" + }, + { + "status": 400, + "content_type": "application/json", + "body": "{\"error\": {\"message\": \"The requested configuration is not supported by this model\", \"type\": \"invalid_request_error\", \"code\": \"unsupported_value\"}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r5_learning/cassette-model-06eeece3f570a148.cassette.json b/tests/_fixtures/cassettes/r5_learning/cassette-model-06eeece3f570a148.cassette.json new file mode 100644 index 00000000..317b4baf --- /dev/null +++ b/tests/_fixtures/cassettes/r5_learning/cassette-model-06eeece3f570a148.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "06eeece3f570a148c58d9c26be673787a9124142d2b711b8c7c959e6102125d1", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Let me show you something.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Let me show you something.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Let me show you something.\nLet me show you something." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Noted the first step.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r5_learning/cassette-model-077a17b141c44fb6.cassette.json b/tests/_fixtures/cassettes/r5_learning/cassette-model-077a17b141c44fb6.cassette.json new file mode 100644 index 00000000..78c01e0f --- /dev/null +++ b/tests/_fixtures/cassettes/r5_learning/cassette-model-077a17b141c44fb6.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "077a17b141c44fb6392901e4f453a63e34d75dbc6665390246901b4cef07f80a", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Noted the first step.\n- [user] Now sort them by month.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Now sort them by month.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Noted the first step." + }, + { + "role": "user", + "content": "Now sort them by month.\nNow sort them by month." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Noted the second step.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r5_learning/cassette-model-31d350ae8f4ff81e.cassette.json b/tests/_fixtures/cassettes/r5_learning/cassette-model-31d350ae8f4ff81e.cassette.json new file mode 100644 index 00000000..d4a4ac8c --- /dev/null +++ b/tests/_fixtures/cassettes/r5_learning/cassette-model-31d350ae8f4ff81e.cassette.json @@ -0,0 +1,67 @@ +{ + "fingerprint": "31d350ae8f4ff81eb9cbb900be46a0a74f7494e1babb49d2c7797c7265f093a9", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Noted the second step.\n- [user] Thanks, that is all.\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Thanks, that is all.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Noted the second step." + }, + { + "role": "user", + "content": "Thanks, that is all.\nThanks, that is all." + }, + { + "role": "assistant", + "content": "{\"title\": \"Tidy invoices\", \"trigger_phrases\": [\"tidy invoices\", \"sort invoices\"], \"steps\": [\"List the invoice folder\", \"Classify by month\", \"Move into folders\"], \"parameters\": [{\"name\": \"path\", \"description\": \"invoice folder\"}], \"pre_conditions\": [], \"confidence\": 0.7}" + }, + { + "role": "user", + "content": "Tool result (path):\n{\"ok\": false, \"error\": \"Unknown tool: path\", \"error_type\": \"unknown_tool\", \"retryable\": true}\nSYSTEM: The previous tool call used an unavailable tool name. Original tool: path. Resolution: unknown (no exact canonical tool name match). Suggested canonical tools: assess_compatibility, capability_expand, code_intel, code_search, config_get. Available tools include: assess_compatibility, capability_expand, code_intel, code_search, config_get, config_list, config_set, delegate_task, edit_file, env_info, file_find, file_list. Retry once using an exact canonical tool name from the available list and valid arguments. Do not invent tool names, use aliases, or infer a tool from argument shape; answer without a tool if no exact tool fits." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Done \\u2014 nothing further needed.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r5_learning/cassette-model-8bfb5eaeaf86d401.cassette.json b/tests/_fixtures/cassettes/r5_learning/cassette-model-8bfb5eaeaf86d401.cassette.json new file mode 100644 index 00000000..9f6f9bbc --- /dev/null +++ b/tests/_fixtures/cassettes/r5_learning/cassette-model-8bfb5eaeaf86d401.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "8bfb5eaeaf86d4015d3a48f80b3e528471c432d6721b728b4716c7620ae36c13", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Noted the second step.\n- [user] Thanks, that is all.\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Thanks, that is all.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Noted the second step." + }, + { + "role": "user", + "content": "Thanks, that is all.\nThanks, that is all." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"{\\\"title\\\": \\\"Tidy invoices\\\", \\\"trigger_phrases\\\": [\\\"tidy invoices\\\", \\\"sort invoices\\\"], \\\"steps\\\": [\\\"List the invoice folder\\\", \\\"Classify by month\\\", \\\"Move into folders\\\"], \\\"parameters\\\": [{\\\"name\\\": \\\"path\\\", \\\"description\\\": \\\"invoice folder\\\"}], \\\"pre_conditions\\\": [], \\\"confidence\\\": 0.7}\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-158ec6b3661786da.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-158ec6b3661786da.cassette.json new file mode 100644 index 00000000..18796824 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-158ec6b3661786da.cassette.json @@ -0,0 +1,76 @@ +{ + "fingerprint": "158ec6b3661786daf7c8db8a18fb1a41cf63db2821d13a6ee697312a6117bfaa", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Installed the hermetic DSH plugin.\n- [user] Invoke fixture_echo with the text before restart.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Invoke fixture_echo with the text before restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Installed the hermetic DSH plugin." + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text before restart.\nInvoke fixture_echo with the text before restart." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "fixture_echo" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"echo\": \"before restart\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"The DSH tool ran before restart.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-17557e9ee9842679.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-17557e9ee9842679.cassette.json new file mode 100644 index 00000000..88f582be --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-17557e9ee9842679.cassette.json @@ -0,0 +1,72 @@ +{ + "fingerprint": "17557e9ee9842679a73ce2909cf1934bea3a4725b28aaa65af1c672779c5b98a", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Invoke fixture_echo with the text after restart.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Invoke fixture_echo with the text after restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text after restart.\nInvoke fixture_echo with the text after restart." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "fixture_echo" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"echo\": \"after restart\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"The DSH tool ran after restart.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-1e18a0da1790b11f.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-1e18a0da1790b11f.cassette.json new file mode 100644 index 00000000..7757747e --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-1e18a0da1790b11f.cassette.json @@ -0,0 +1,60 @@ +{ + "fingerprint": "1e18a0da1790b11fd0b5ce2ba238b549c29b83cb800be8d85e67261a8d35b4a4", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Installed the hermetic DSH plugin.\n- [user] Invoke fixture_echo with the text before restart.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Invoke fixture_echo with the text before restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Installed the hermetic DSH plugin." + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text before restart.\nInvoke fixture_echo with the text before restart." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"fixture_echo\", \"arguments\": \"{\\\"text\\\": \\\"before restart\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-30b7ab3ad4a5a107.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-30b7ab3ad4a5a107.cassette.json new file mode 100644 index 00000000..cdf005e6 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-30b7ab3ad4a5a107.cassette.json @@ -0,0 +1,60 @@ +{ + "fingerprint": "30b7ab3ad4a5a1071809626dd70071cb5a3a8216ed7ba5ba0f391cf58e05179f", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Installed the hermetic DSH plugin.\n- [user] Invoke fixture_echo with the text before restart.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Invoke fixture_echo with the text before restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Installed the hermetic DSH plugin." + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text before restart.\nInvoke fixture_echo with the text before restart." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"fixture_echo\", \"arguments\": \"{\\\"text\\\": \\\"before restart\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-3798e4163d6b2128.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-3798e4163d6b2128.cassette.json new file mode 100644 index 00000000..fe4d2818 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-3798e4163d6b2128.cassette.json @@ -0,0 +1,56 @@ +{ + "fingerprint": "3798e4163d6b21284618d883782d25a4605f6f7ee2d54c047bb71ea3635db16f", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Invoke fixture_echo with the text after restart.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Invoke fixture_echo with the text after restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text after restart.\nInvoke fixture_echo with the text after restart." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"fixture_echo\", \"arguments\": \"{\\\"text\\\": \\\"after restart\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-4d1f12200292b229.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-4d1f12200292b229.cassette.json new file mode 100644 index 00000000..bf20443a --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-4d1f12200292b229.cassette.json @@ -0,0 +1,60 @@ +{ + "fingerprint": "4d1f12200292b229783742bfd980e4922919dfd94be402a09fe76bc80f243899", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] The DSH tool ran after restart.\n- [user] Remove the hermetic DSH echo plugin completely.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Remove the hermetic DSH echo plugin completely.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "The DSH tool ran after restart." + }, + { + "role": "user", + "content": "Remove the hermetic DSH echo plugin completely.\nRemove the hermetic DSH echo plugin completely." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"plugin_remove\", \"arguments\": \"{\\\"plugin_id\\\": \\\"r6_dsh_echo\\\", \\\"delete_source\\\": true}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-898001f1b5122a8a.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-898001f1b5122a8a.cassette.json new file mode 100644 index 00000000..be863115 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-898001f1b5122a8a.cassette.json @@ -0,0 +1,71 @@ +{ + "fingerprint": "898001f1b5122a8aefedd1329646046f49a652cea721d87b6fa9fe1d5e106eee", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Install the hermetic DSH echo plugin from this workspace.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Install the hermetic DSH echo plugin from this workspace.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Install the hermetic DSH echo plugin from this workspace.\nInstall the hermetic DSH echo plugin from this workspace." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "plugin_install" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"action\": \"install\", \"plugin_id\": \"r6_dsh_echo\", \"installed_tools\": [\"fixture_echo\"], \"state\": \"active\", \"version\": \"r6\", \"source_kind\": \"dsh_package\", \"bundle_sha256\": \"\", \"descriptor_path\": \"\", \"verdict\": \"adaptable\", \"limitations\": [], \"client_components\": [], \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"mutating_once\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Installed the hermetic DSH plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-a7782cf136290032.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-a7782cf136290032.cassette.json new file mode 100644 index 00000000..34d6a6a3 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-a7782cf136290032.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "a7782cf1362900327b43e19b0f1193e2e3ea915c3b60ba84b5607896e87afeaa", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Install the hermetic DSH echo plugin from this workspace.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Install the hermetic DSH echo plugin from this workspace.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Install the hermetic DSH echo plugin from this workspace.\nInstall the hermetic DSH echo plugin from this workspace." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"plugin_install\", \"arguments\": \"{\\\"plugin_id\\\": \\\"r6_dsh_echo\\\", \\\"source_path\\\": \\\"/tmp/lfj-r6_lifecycle/workspaces/life/dsh-echo\\\", \\\"version_label\\\": \\\"r6\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-ada1fc7ddc57492e.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-ada1fc7ddc57492e.cassette.json new file mode 100644 index 00000000..7cb99854 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-ada1fc7ddc57492e.cassette.json @@ -0,0 +1,76 @@ +{ + "fingerprint": "ada1fc7ddc57492ea2c39ad8617214214852c9cc6d84ab011e74a57aa6c823d2", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] The DSH tool ran after restart.\n- [user] Remove the hermetic DSH echo plugin completely.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Remove the hermetic DSH echo plugin completely.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "The DSH tool ran after restart." + }, + { + "role": "user", + "content": "Remove the hermetic DSH echo plugin completely.\nRemove the hermetic DSH echo plugin completely." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "plugin_remove" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"action\": \"remove\", \"plugin_id\": \"r6_dsh_echo\", \"state\": \"disposed\", \"source_path\": \"\", \"source_deleted\": true, \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"mutating_once\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Removed the hermetic DSH plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b5a61ebb6aabdcfb.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b5a61ebb6aabdcfb.cassette.json new file mode 100644 index 00000000..78d9c197 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b5a61ebb6aabdcfb.cassette.json @@ -0,0 +1,76 @@ +{ + "fingerprint": "b5a61ebb6aabdcfb41ddc9528feeae96325bba26f0b828ddfd0cccc0bc2e63ef", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Installed the hermetic DSH plugin.\n- [user] Invoke fixture_echo with the text before restart.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Invoke fixture_echo with the text before restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Installed the hermetic DSH plugin." + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text before restart.\nInvoke fixture_echo with the text before restart." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "fixture_echo" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"echo\": \"before restart\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"The DSH tool ran before restart.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b9831df577183d53.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b9831df577183d53.cassette.json new file mode 100644 index 00000000..0e261b35 --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-b9831df577183d53.cassette.json @@ -0,0 +1,60 @@ +{ + "fingerprint": "b9831df577183d531ff66444d95913bb830d92fb027bd4d21de3dbae41a80cbd", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] The DSH tool ran after restart.\n- [user] Remove the hermetic DSH echo plugin completely.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Remove the hermetic DSH echo plugin completely.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "The DSH tool ran after restart." + }, + { + "role": "user", + "content": "Remove the hermetic DSH echo plugin completely.\nRemove the hermetic DSH echo plugin completely." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"plugin_remove\", \"arguments\": \"{\\\"plugin_id\\\": \\\"r6_dsh_echo\\\", \\\"delete_source\\\": true}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-c0ef153884a21ac7.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-c0ef153884a21ac7.cassette.json new file mode 100644 index 00000000..bbde7feb --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-c0ef153884a21ac7.cassette.json @@ -0,0 +1,72 @@ +{ + "fingerprint": "c0ef153884a21ac7026067d0d3307b85a005005173f88a3a4b6ae77cab3adcb1", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Invoke fixture_echo with the text after restart.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Invoke fixture_echo with the text after restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text after restart.\nInvoke fixture_echo with the text after restart." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "fixture_echo" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"echo\": \"after restart\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"The DSH tool ran after restart.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-d352b6f5b033a2d7.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-d352b6f5b033a2d7.cassette.json new file mode 100644 index 00000000..550f597b --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-d352b6f5b033a2d7.cassette.json @@ -0,0 +1,56 @@ +{ + "fingerprint": "d352b6f5b033a2d7103824567c0db6ead185ec01ec155a5da8032ccb4745794d", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Invoke fixture_echo with the text after restart.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Invoke fixture_echo with the text after restart.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Invoke fixture_echo with the text after restart.\nInvoke fixture_echo with the text after restart." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"fixture_echo\", \"arguments\": \"{\\\"text\\\": \\\"after restart\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-e6109a845a1dd79f.cassette.json b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-e6109a845a1dd79f.cassette.json new file mode 100644 index 00000000..08992daf --- /dev/null +++ b/tests/_fixtures/cassettes/r6_lifecycle/cassette-model-e6109a845a1dd79f.cassette.json @@ -0,0 +1,76 @@ +{ + "fingerprint": "e6109a845a1dd79fc8f5b1d5b3518fdbecccbad0b7a860e3e5758ea99acb0b88", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **fixture_echo**(text): Return the supplied text from a pre-built DSH package.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] The DSH tool ran after restart.\n- [user] Remove the hermetic DSH echo plugin completely.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Remove the hermetic DSH echo plugin completely.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "The DSH tool ran after restart." + }, + { + "role": "user", + "content": "Remove the hermetic DSH echo plugin completely.\nRemove the hermetic DSH echo plugin completely." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "plugin_remove" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"action\": \"remove\", \"plugin_id\": \"r6_dsh_echo\", \"state\": \"disposed\", \"source_path\": \"\", \"source_deleted\": true, \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"mutating_once\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "fixture_echo", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Removed the hermetic DSH plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-33afdab4bc90b747.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-33afdab4bc90b747.cassette.json new file mode 100644 index 00000000..ef7f7438 --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-33afdab4bc90b747.cassette.json @@ -0,0 +1,119 @@ +{ + "fingerprint": "33afdab4bc90b747d65e3a9cf85c72291d0d6d0ec51f30ae861d76cf7c557696", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Try the missing_json_pretty_e2e tool so LeapFlow records a capability gap.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Try the missing_json_pretty_e2e tool so LeapFlow records a capability gap.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Try the missing_json_pretty_e2e tool so LeapFlow records a capability gap.\nTry the missing_json_pretty_e2e tool so LeapFlow records a capability gap." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "missing_json_pretty_e2e" + ] + }, + { + "role": "tool", + "content": "{\"ok\": false, \"error\": \"Unknown tool: missing_json_pretty_e2e\", \"error_type\": \"unknown_tool\", \"retryable\": true}", + "tool_result": true + }, + { + "role": "user", + "content": "SYSTEM: The previous tool call used an unavailable tool name. Original tool: missing_json_pretty_e2e. Resolution: unknown (no exact canonical tool name match). Suggested canonical tools: text_search, text_replace, research_note, gateway_send. Available tools include: assess_compatibility, capability_expand, code_intel, code_search, config_get, config_list, config_set, delegate_task, edit_file, env_info, file_find, file_list. Retry once using an exact canonical tool name from the available list and valid arguments. Do not invent tool names, use aliases, or infer a tool from argument shape; answer without a tool if no exact tool fits." + } + ], + "tools": [ + "assess_compatibility", + "capability_expand", + "click", + "code_intel", + "code_search", + "config_get", + "config_list", + "config_set", + "delegate_task", + "edit_file", + "env_info", + "file_find", + "file_list", + "file_read", + "file_write", + "gateway_connect", + "gateway_send", + "get_clipboard", + "git_query", + "git_write", + "hub_pull", + "hub_push", + "hub_search", + "hub_sync", + "lint_check", + "list_apps", + "list_windows", + "memory_add", + "memory_search", + "observe_ui", + "open_url", + "platform_action", + "platform_connect", + "plugin_disable", + "plugin_enable", + "plugin_generate", + "plugin_install", + "plugin_list", + "plugin_propose", + "plugin_reload", + "plugin_remove", + "plugin_rollback", + "plugin_status", + "plugin_versions", + "read_text", + "repo_map", + "research_note", + "right_click", + "schedule_reentry", + "scm_sync", + "screenshot", + "scroll", + "select_text", + "session_detail", + "session_list", + "session_search", + "set_clipboard", + "shell_run", + "shortcut", + "skill_view", + "skills_list", + "switch_app", + "terminal_close", + "terminal_list", + "terminal_open", + "terminal_read", + "terminal_send", + "test_run", + "text_replace", + "text_search", + "time_get", + "type_text", + "wait", + "wait_until", + "wait_until_stable", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Observed the missing JSON pretty tool.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-3705093e647723c3.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-3705093e647723c3.cassette.json new file mode 100644 index 00000000..ad530977 --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-3705093e647723c3.cassette.json @@ -0,0 +1,55 @@ +{ + "fingerprint": "3705093e647723c34866ef3db598960e617f8d1b97f0474419b2cddd5893ea97", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] Try the missing_json_pretty_e2e tool so LeapFlow records a capability gap.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: Try the missing_json_pretty_e2e tool so LeapFlow records a capability gap.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "Try the missing_json_pretty_e2e tool so LeapFlow records a capability gap.\nTry the missing_json_pretty_e2e tool so LeapFlow records a capability gap." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"missing_json_pretty_e2e\", \"arguments\": \"{\\\"text\\\": \\\"{\\\\\\\"b\\\\\\\":2,\\\\\\\"a\\\\\\\":1}\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-38aa0b5a67f18052.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-38aa0b5a67f18052.cassette.json new file mode 100644 index 00000000..391d357b --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-38aa0b5a67f18052.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "38aa0b5a67f18052205e955bbcc792a94b07393d88c87abe9f0c441f42a61360", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The isolated sandbox smoke test runs later, at install-time. Returns the validated code but DOES NOT install it — installation is a separate approval-gated step via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Observed the missing JSON pretty tool.\n- [user] Install the prepared adaptive JSON pretty plugin.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Install the prepared adaptive JSON pretty plugin.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Observed the missing JSON pretty tool." + }, + { + "role": "user", + "content": "Install the prepared adaptive JSON pretty plugin.\nInstall the prepared adaptive JSON pretty plugin." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "plugin_install" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"action\": \"install\", \"plugin_id\": \"json_pretty_loop_e2e\", \"installed_tools\": [\"json_pretty_loop_e2e\"], \"state\": \"active\", \"shadow_validated\": true, \"behavior_tests\": [], \"version\": \"r7\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"mutating_once\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Installed json pretty plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-6dccb60364d7af34.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-6dccb60364d7af34.cassette.json new file mode 100644 index 00000000..102d0b0e --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-6dccb60364d7af34.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "6dccb60364d7af34bb7860a3b8b520d3a9a6c918d52005f88c07d652d4cdae19", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Formatted JSON with the new plugin.\n- [user] Remove the adaptive JSON pretty plugin completely.\n\n## Task Contract\n- Task ID: turn-4\n- Original user request: Remove the adaptive JSON pretty plugin completely.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Formatted JSON with the new plugin." + }, + { + "role": "user", + "content": "Remove the adaptive JSON pretty plugin completely.\nRemove the adaptive JSON pretty plugin completely." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "plugin_remove" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"action\": \"remove\", \"plugin_id\": \"json_pretty_loop_e2e\", \"state\": \"disposed\", \"source_path\": \"\", \"source_deleted\": true, \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"mutating_once\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Removed json pretty plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-7ad0336ee1e5a800.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-7ad0336ee1e5a800.cassette.json new file mode 100644 index 00000000..7c08e74f --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-7ad0336ee1e5a800.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "7ad0336ee1e5a8003620f0862acb4ad3e2080ed88a25b12d0e658669822dde01", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Observed the missing JSON pretty tool.\n- [user] Install the prepared adaptive JSON pretty plugin.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Install the prepared adaptive JSON pretty plugin.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Observed the missing JSON pretty tool." + }, + { + "role": "user", + "content": "Install the prepared adaptive JSON pretty plugin.\nInstall the prepared adaptive JSON pretty plugin." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "plugin_install" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"action\": \"install\", \"plugin_id\": \"json_pretty_loop_e2e\", \"installed_tools\": [\"json_pretty_loop_e2e\"], \"state\": \"active\", \"shadow_validated\": true, \"behavior_tests\": [], \"version\": \"r7\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"mutating_once\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Installed json pretty plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-a690658cc3ac97da.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-a690658cc3ac97da.cassette.json new file mode 100644 index 00000000..60c39411 --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-a690658cc3ac97da.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "a690658cc3ac97da7919ffdc944599034488b86701694741d7a6c7855c41c3f1", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Formatted JSON with the new plugin.\n- [user] Remove the adaptive JSON pretty plugin completely.\n\n## Task Contract\n- Task ID: turn-4\n- Original user request: Remove the adaptive JSON pretty plugin completely.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Formatted JSON with the new plugin." + }, + { + "role": "user", + "content": "Remove the adaptive JSON pretty plugin completely.\nRemove the adaptive JSON pretty plugin completely." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"plugin_remove\", \"arguments\": \"{\\\"plugin_id\\\": \\\"json_pretty_loop_e2e\\\", \\\"delete_source\\\": true}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-b5283e275ca539f0.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-b5283e275ca539f0.cassette.json new file mode 100644 index 00000000..a69f52a1 --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-b5283e275ca539f0.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "b5283e275ca539f0b4e6123b04912d1a3dba5d6cc246f302418596379c115978", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Observed the missing JSON pretty tool.\n- [user] Install the prepared adaptive JSON pretty plugin.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Install the prepared adaptive JSON pretty plugin.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Observed the missing JSON pretty tool." + }, + { + "role": "user", + "content": "Install the prepared adaptive JSON pretty plugin.\nInstall the prepared adaptive JSON pretty plugin." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"plugin_install\", \"arguments\": \"{\\\"plugin_id\\\": \\\"json_pretty_loop_e2e\\\", \\\"code\\\": \\\"from __future__ import annotations\\\\n\\\\nimport json\\\\nfrom typing import Any\\\\n\\\\nfrom leapflow.plugins.protocol import ToolMetadata\\\\n\\\\n\\\\nasync def json_pretty_loop_e2e(text: str = \\\\\\\"\\\\\\\", **kwargs: Any) -> dict[str, Any]:\\\\n payload = text or kwargs.get(\\\\\\\"payload\\\\\\\") or \\\\\\\"{}\\\\\\\"\\\\n try:\\\\n parsed = json.loads(str(payload))\\\\n except json.JSONDecodeError as exc:\\\\n return {\\\\\\\"ok\\\\\\\": False, \\\\\\\"error\\\\\\\": str(exc)}\\\\n return {\\\\\\\"ok\\\\\\\": True, \\\\\\\"content\\\\\\\": json.dumps(parsed, ensure_ascii=False, indent=2, sort_keys=True)}\\\\n\\\\n\\\\nclass JsonPrettyLoopE2EPlugin:\\\\n @property\\\\n def plugin_id(self) -> str:\\\\n return \\\\\\\"json_pretty_loop_e2e\\\\\\\"\\\\n\\\\n @property\\\\n def category(self) -> str:\\\\n return \\\\\\\"formatting\\\\\\\"\\\\n\\\\n @property\\\\n def dependencies(self) -> list[str]:\\\\n return []\\\\n\\\\n @property\\\\n def tools(self) -> list[ToolMetadata]:\\\\n return [\\\\n ToolMetadata(\\\\n name=\\\\\\\"json_pretty_loop_e2e\\\\\\\",\\\\n description=\\\\\\\"Pretty-print JSON for the adaptive closed-loop journey.\\\\\\\",\\\\n parameters_schema={\\\\n \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n \\\\\\\"properties\\\\\\\": {\\\\n \\\\\\\"text\\\\\\\": {\\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\", \\\\\\\"description\\\\\\\": \\\\\\\"JSON text to format\\\\\\\"}\\\\n },\\\\n },\\\\n handler=json_pretty_loop_e2e,\\\\n x_leapflow={\\\\n \\\\\\\"category\\\\\\\": \\\\\\\"formatting\\\\\\\",\\\\n \\\\\\\"risk_level\\\\\\\": \\\\\\\"read_only\\\\\\\",\\\\n \\\\\\\"schema_cost\\\\\\\": \\\\\\\"low\\\\\\\",\\\\n \\\\\\\"requires_approval\\\\\\\": False,\\\\n },\\\\n provides_capabilities=(\\\\\\\"json.pretty\\\\\\\",),\\\\n requires_platform_capabilities=(\\\\\\\"file.ops\\\\\\\",),\\\\n )\\\\n ]\\\\n\\\\n def bind_runtime(self, **deps: Any) -> None:\\\\n return None\\\\n\\\\n\\\\nplugin = JsonPrettyLoopE2EPlugin()\\\\n\\\", \\\"version_label\\\": \\\"r7\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-cc5cd4f23919fe0b.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-cc5cd4f23919fe0b.cassette.json new file mode 100644 index 00000000..14bdfec1 --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-cc5cd4f23919fe0b.cassette.json @@ -0,0 +1,76 @@ +{ + "fingerprint": "cc5cd4f23919fe0beddc3a44d9f40eb55a54c02f0c5522000c18230d1d69ade0", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **json_pretty_loop_e2e**(text): Pretty-print JSON for the adaptive closed-loop journey.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Installed json pretty plugin.\n- [user] Use the json_pretty_loop_e2e tool to format the sample JSON.\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Use the json_pretty_loop_e2e tool to format the sample JSON.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Installed json pretty plugin." + }, + { + "role": "user", + "content": "Use the json_pretty_loop_e2e tool to format the sample JSON.\nUse the json_pretty_loop_e2e tool to format the sample JSON." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "json_pretty_loop_e2e" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"content\": \"{\\n \\\"a\\\": 1,\\n \\\"b\\\": 2\\n}\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "json_pretty_loop_e2e", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Formatted JSON with the new plugin.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-d6eb6c82ef17961b.cassette.json b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-d6eb6c82ef17961b.cassette.json new file mode 100644 index 00000000..91c49003 --- /dev/null +++ b/tests/_fixtures/cassettes/r7_adaptive_plugin_loop/cassette-model-d6eb6c82ef17961b.cassette.json @@ -0,0 +1,60 @@ +{ + "fingerprint": "d6eb6c82ef17961be90a9e34b95aaf82889ba27326e7f7579d3db13773ba700b", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **json_pretty_loop_e2e**(text): Pretty-print JSON for the adaptive closed-loop journey.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [assistant] Installed json pretty plugin.\n- [user] Use the json_pretty_loop_e2e tool to format the sample JSON.\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Use the json_pretty_loop_e2e tool to format the sample JSON.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Installed json pretty plugin." + }, + { + "role": "user", + "content": "Use the json_pretty_loop_e2e tool to format the sample JSON.\nUse the json_pretty_loop_e2e tool to format the sample JSON." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "json_pretty_loop_e2e", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"json_pretty_loop_e2e\", \"arguments\": \"{\\\"text\\\": \\\"{\\\\\\\"b\\\\\\\":2,\\\\\\\"a\\\\\\\":1}\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-14785ee2b98ad8a2.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-14785ee2b98ad8a2.cassette.json new file mode 100644 index 00000000..191fc3d5 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-14785ee2b98ad8a2.cassette.json @@ -0,0 +1,59 @@ +{ + "fingerprint": "14785ee2b98ad8a23306b054cfb4fc576b713824f5a5e33c9bd201ac7d8cf191", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] List the connected hardware devices, then describe bench_r8 in full.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: List the connected hardware devices, then describe bench_r8 in full.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "List the connected hardware devices, then describe bench_r8 in full.\nList the connected hardware devices, then describe bench_r8 in full." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_describe", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_list\", \"arguments\": \"{}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-2ecead8ad64bd2b2.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-2ecead8ad64bd2b2.cassette.json new file mode 100644 index 00000000..a5fcfd03 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-2ecead8ad64bd2b2.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "2ecead8ad64bd2b26def688b4f518f774c0016919e61b42b957c5eda506196c9", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-4\n- Original user request: Configure the bench_r8 homed channel to true to complete homing.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Discovered the simulated bench and read its channel limits." + }, + { + "role": "user", + "content": "Read the current value of the setpoint channel on bench_r8." + }, + { + "role": "assistant", + "content": "[Called: hw_read]\nRead the setpoint channel." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 60.\nConfigure the bench_r8 homed channel to true to complete homing.\nConfigure the bench_r8 homed channel to true to complete homing." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_configure\", \"arguments\": \"{\\\"device_id\\\": \\\"bench_r8\\\", \\\"channel_id\\\": \\\"homed\\\", \\\"value\\\": true}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-3253e1220413e5f3.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-3253e1220413e5f3.cassette.json new file mode 100644 index 00000000..9a321fe3 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-3253e1220413e5f3.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "3253e1220413e5f3bd0ab56097dc4972da20136aaeb691fd7a305a79f3687c6b", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-5\n- Original user request: Preview an actuate of bench_r8 setpoint to 55, dry run only.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Read the setpoint channel." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 60.\nConfigure the bench_r8 homed channel to true to complete homing." + }, + { + "role": "assistant", + "content": "[Called: hw_configure]\nHomed the device; the readiness gate is now satisfied." + }, + { + "role": "user", + "content": "Preview an actuate of bench_r8 setpoint to 55, dry run only.\nPreview an actuate of bench_r8 setpoint to 55, dry run only." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_actuate\", \"arguments\": \"{\\\"device_id\\\": \\\"bench_r8\\\", \\\"channel_id\\\": \\\"setpoint\\\", \\\"value\\\": 55.0, \\\"dry_run\\\": true}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-3dc49087c1103fb6.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-3dc49087c1103fb6.cassette.json new file mode 100644 index 00000000..1336bfc2 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-3dc49087c1103fb6.cassette.json @@ -0,0 +1,87 @@ +{ + "fingerprint": "3dc49087c1103fb60c64d4ae4800585a6bbf6f061370bcc4481e42695aa0473b", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] List the connected hardware devices, then describe bench_r8 in full.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: List the connected hardware devices, then describe bench_r8 in full.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "List the connected hardware devices, then describe bench_r8 in full.\nList the connected hardware devices, then describe bench_r8 in full." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_list" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"devices\": [{\"device_id\": \"bench_r8\", \"display_name\": \"R8 Simulated Bench\", \"location\": \"journey-lab\", \"channels\": 3, \"writable\": 2, \"streaming\": 1, \"quantities\": [\"state.homed\", \"temperature\"], \"verified\": true, \"halt_supported\": true}], \"count\": 1, \"hint\": \"Call hw_describe(device_id) for channel limits before commanding a device.\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_describe" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"kind\": \"\", \"truncated\": true, \"original_chars\": 846, \"budget_chars\": 819}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_describe", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Discovered the simulated bench and read its channel limits.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-5be074139ef16c9a.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-5be074139ef16c9a.cassette.json new file mode 100644 index 00000000..f2953ea5 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-5be074139ef16c9a.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "5be074139ef16c9ada53b1bf68e92e1961f1b37badb7ec65f1cb7ffb6e4dc98c", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-6\n- Original user request: Actuate the bench_r8 setpoint to 65.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "[Called: hw_configure]\nHomed the device; the readiness gate is now satisfied." + }, + { + "role": "user", + "content": "Preview an actuate of bench_r8 setpoint to 55, dry run only." + }, + { + "role": "assistant", + "content": "[Called: hw_actuate]\nDry run confirmed the setpoint command is feasible after homing." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 65.\nActuate the bench_r8 setpoint to 65." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_actuate\", \"arguments\": \"{\\\"device_id\\\": \\\"bench_r8\\\", \\\"channel_id\\\": \\\"setpoint\\\", \\\"value\\\": 65.0}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-5fa148b50481fec6.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-5fa148b50481fec6.cassette.json new file mode 100644 index 00000000..0873c5db --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-5fa148b50481fec6.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "5fa148b50481fec6028d1ae0e8ed1ca7486accd1d30936d11e537af1df2cb6fe", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-3\n- Original user request: Actuate the bench_r8 setpoint to 60.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "[Called: hw_describe]\nDiscovered the simulated bench and read its channel limits." + }, + { + "role": "user", + "content": "Read the current value of the setpoint channel on bench_r8." + }, + { + "role": "assistant", + "content": "[Called: hw_read]\nRead the setpoint channel." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 60.\nActuate the bench_r8 setpoint to 60." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_actuate\", \"arguments\": \"{\\\"device_id\\\": \\\"bench_r8\\\", \\\"channel_id\\\": \\\"setpoint\\\", \\\"value\\\": 60.0}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-63f72b6ae055dd95.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-63f72b6ae055dd95.cassette.json new file mode 100644 index 00000000..b05195ac --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-63f72b6ae055dd95.cassette.json @@ -0,0 +1,91 @@ +{ + "fingerprint": "63f72b6ae055dd95c893468b4ffefd6388390f8b2149164290529e357fb830e2", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-6\n- Original user request: Actuate the bench_r8 setpoint to 65.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "[Called: hw_configure]\nHomed the device; the readiness gate is now satisfied." + }, + { + "role": "user", + "content": "Preview an actuate of bench_r8 setpoint to 55, dry run only." + }, + { + "role": "assistant", + "content": "[Called: hw_actuate]\nDry run confirmed the setpoint command is feasible after homing." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 65.\nActuate the bench_r8 setpoint to 65." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_actuate" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"device_id\": \"bench_r8\", \"channel_id\": \"setpoint\", \"side_effect_state\": \"committed\", \"settled\": true, \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"external_side_effect\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Commanded the setpoint through the approval path.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-6d0e8558c8ee265e.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-6d0e8558c8ee265e.cassette.json new file mode 100644 index 00000000..85484540 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-6d0e8558c8ee265e.cassette.json @@ -0,0 +1,71 @@ +{ + "fingerprint": "6d0e8558c8ee265e8c0cb711015135a4af257d7c9888afde9d307bef7a3437e0", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Read the current value of the setpoint channel on bench_r8.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "List the connected hardware devices, then describe bench_r8 in full." + }, + { + "role": "assistant", + "content": "[Called: hw_list]\n[Called: hw_describe]\nDiscovered the simulated bench and read its channel limits." + }, + { + "role": "user", + "content": "Read the current value of the setpoint channel on bench_r8.\nRead the current value of the setpoint channel on bench_r8." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_read\", \"arguments\": \"{\\\"device_id\\\": \\\"bench_r8\\\", \\\"channel_id\\\": \\\"setpoint\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-81c3f24286673f15.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-81c3f24286673f15.cassette.json new file mode 100644 index 00000000..549cb76e --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-81c3f24286673f15.cassette.json @@ -0,0 +1,87 @@ +{ + "fingerprint": "81c3f24286673f15c72d08fc203902ad75433208c60d3bf272ee606f5d8debed", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-2\n- Original user request: Read the current value of the setpoint channel on bench_r8.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "List the connected hardware devices, then describe bench_r8 in full." + }, + { + "role": "assistant", + "content": "[Called: hw_list]\n[Called: hw_describe]\nDiscovered the simulated bench and read its channel limits." + }, + { + "role": "user", + "content": "Read the current value of the setpoint channel on bench_r8.\nRead the current value of the setpoint channel on bench_r8." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_read" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"reading\": {\"device_id\": \"bench_r8\", \"channel_id\": \"setpoint\", \"value\": 50.0, \"quantity\": \"temperature\", \"unit\": \"C\", \"observed_at\": , \"sequence\": 1, \"quality\": \"ok\"}, \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Read the setpoint channel.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-bb795810fcb3b193.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-bb795810fcb3b193.cassette.json new file mode 100644 index 00000000..57fd14e0 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-bb795810fcb3b193.cassette.json @@ -0,0 +1,91 @@ +{ + "fingerprint": "bb795810fcb3b193ada6131d7c8ef89723d9973ce1fe1f38c0e24aaa0297beee", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-5\n- Original user request: Preview an actuate of bench_r8 setpoint to 55, dry run only.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Read the setpoint channel." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 60.\nConfigure the bench_r8 homed channel to true to complete homing." + }, + { + "role": "assistant", + "content": "[Called: hw_configure]\nHomed the device; the readiness gate is now satisfied." + }, + { + "role": "user", + "content": "Preview an actuate of bench_r8 setpoint to 55, dry run only.\nPreview an actuate of bench_r8 setpoint to 55, dry run only." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_actuate" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"kind\": \"\", \"truncated\": true, \"original_chars\": 888, \"budget_chars\": 819}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Dry run confirmed the setpoint command is feasible after homing.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-d70fc70163a8902a.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-d70fc70163a8902a.cassette.json new file mode 100644 index 00000000..c164fd62 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-d70fc70163a8902a.cassette.json @@ -0,0 +1,75 @@ +{ + "fingerprint": "d70fc70163a8902ae54831dd553c73b3970cadd33af82d7bc2e1782f2447cc30", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n\n## Recent Session Summary\n- [user] List the connected hardware devices, then describe bench_r8 in full.\n\n## Task Contract\n- Task ID: turn-1\n- Original user request: List the connected hardware devices, then describe bench_r8 in full.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "user", + "content": "List the connected hardware devices, then describe bench_r8 in full.\nList the connected hardware devices, then describe bench_r8 in full." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_list" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"devices\": [{\"device_id\": \"bench_r8\", \"display_name\": \"R8 Simulated Bench\", \"location\": \"journey-lab\", \"channels\": 3, \"writable\": 2, \"streaming\": 1, \"quantities\": [\"state.homed\", \"temperature\"], \"verified\": true, \"halt_supported\": true}], \"count\": 1, \"hint\": \"Call hw_describe(device_id) for channel limits before commanding a device.\", \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"read_only\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_describe", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"\", \"tool_calls\": [{\"id\": \"call_1\", \"type\": \"function\", \"function\": {\"name\": \"hw_describe\", \"arguments\": \"{\\\"device_id\\\": \\\"bench_r8\\\"}\"}}]}, \"finish_reason\": \"tool_calls\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/_fixtures/cassettes/r8_hardware/cassette-model-ef8c4f88764ca616.cassette.json b/tests/_fixtures/cassettes/r8_hardware/cassette-model-ef8c4f88764ca616.cassette.json new file mode 100644 index 00000000..4e2b06b7 --- /dev/null +++ b/tests/_fixtures/cassettes/r8_hardware/cassette-model-ef8c4f88764ca616.cassette.json @@ -0,0 +1,91 @@ +{ + "fingerprint": "ef8c4f88764ca616e03f2ddca60cf85a4ab00a8393d0a23158ca56e4b6c17348", + "note": "captured in seed mode", + "request": { + "model": "cassette-model", + "stream": false, + "messages": [ + { + "role": "system", + "content": "You are LeapFlow, an intelligent assistant that can both converse naturally and take real actions on the user's computer.\n\n## Capabilities\nThe tool index below lists **every** registered tool by name and a one-line summary — this is the complete\ncapability contract; nothing else exists. Only a subset is directly callable this turn (via native tool calling,\nnot a JSON block in your reply). If you need a tool from the index that is not yet callable, call\n`capability_expand` with its category name first — the matching tools become callable immediately after.\nWhen the user asks what LeapFlow itself supports, whether it supports plugins, or which runtime capabilities\nare available, use the live capability evidence exposed by `plugin_list` before making capability claims; report\nconfiguration-dependent or unavailable capabilities as limitations instead of inferring from documentation.\n- **text_search**(text, pattern): Search for a regex pattern in text.\n- **text_replace**(text, old, new, count) [capability_expand category: write]: Replace occurrences of a substring in text.\n- **time_get**(): Get current date and time.\n- **env_info**(): Get system environment information (OS, Python version, cwd).\n- **skills_list**(query, category, source): List available learned skills. Use when user asks about capabilities or you need a specific skill.\n- **skill_view**(name): View the full content of a specific skill document.\n- **code_intel**(path, operation): Precise document symbols (outline) for a source file: classes, functions, and methods with line ranges. Python uses an exact AST parse; other languages use a keyword-prefix scan. Prefer over file_read mode=symbols for accurate navigation before editing. Read-only.\n- **repo_map**(path): Compact project orientation for a repository root: languages, detected test/lint commands, top-level structure, entry points, manifest, and VCS branch. Call this first when entering an unfamiliar codebase. Read-only.\n- **scm_sync**(action, cwd, remote, pull_ref, push_ref, timeout) [capability_expand category: scm]: Run a typed git SCM action. Use this instead of shell_run for git pull/push/status. For 'pull origin main then push', set action='pull_then_push', remote='origin', pull_ref='main', and omit push_ref so LeapFlow pushes the current local branch.\n- **git_query**(action, cwd, ref, path, staged, max_count, stat): Read-only structured git inspection: action=diff|log|status|branch|show. Prefer over shell_run for reading repo state — output is clipped, redacted, and log/branch are parsed into structured fields. Use scm_sync for pull/push.\n- **git_write**(action, cwd, message, stage_all, name, ref, create) [capability_expand category: scm]: Mutating git actions: action=commit (message, stage_all), branch (create+switch), checkout (switch; create=true for -b). Approval-gated. Use scm_sync for pull/push and git_query for reads.\n- **test_run**(command, cwd, timeout): Run the project's test suite and return structured results (framework, passed/failed counts, failing tests). Auto-detects the runner (pytest/npm/go/cargo) or uses a configured/explicit command; executes via the governed shell. ok=true means the runner executed — see 'success' for pass/fail.\n- **lint_check**(command, cwd, timeout): Run the project's linter and return a structured clean/issue result. Auto-detects the linter (ruff/eslint/go vet/clippy) or uses a configured/explicit command; executes via the governed shell. ok=true means the linter ran — see 'clean'.\n- **file_list**(path, pattern, depth): List files and directories at a given path. Use depth=1 or depth=2 to get a recursive tree in one call instead of listing each sub-directory separately.\n- **file_read**(path, max_lines, start_line, max_chars, mode): Read text file content with adaptive context governance. For large or unfamiliar files, prefer mode='outline' or mode='symbols' first, then use mode='raw' with start_line/max_lines for the specific range you actually need. For LeapFlow's own settings, use config_list / config_get / config_set — its config files are outside the workspace and not readable here.\n- **file_write**(path, content, mode) [capability_expand category: write]: Write content to a file (overwrite or append).\n- **code_search**(pattern, patterns, path, glob, ignore_case, multiline, max_results, context_lines): Search file CONTENTS by regex pattern across a directory tree (ripgrep-backed). Requires a regex pattern. NOT for listing or browsing directory contents — use file_list for that. Prefer this over shell_run grep: faster, skips VCS/dependency/build dirs, and returns structured path:line:column matches. Batch related lookups into ONE call via `patterns` (OR-combined, single pass) instead of issuing several separate searches. Use file_read for the surrounding context of a hit.\n- **file_find**(glob, path, max_results): Find files by a recursive glob pattern under a base path (e.g. '**/test_*.py' or '*.md'). Prefer this over shell_run find; skips VCS/dependency/build dirs.\n- **edit_file**(path, edits, dry_run, diff) [capability_expand category: write]: Apply targeted, anchored search-replace edits to an EXISTING text file (use file_write to create/overwrite). Each edit is {original_text, new_text, replace_all?}; original_text must match exactly and uniquely (or set replace_all) — a non-unique or missing anchor is rejected so files are never corrupted. Set dry_run to preview. Alternatively pass a unified 'diff' to apply its hunks as anchored edits. Far cheaper and safer than rewriting a whole file.\n- **shell_run**(command, cwd, timeout) [capability_expand category: shell]: Execute a one-shot shell command with timeout protection. Runs in the active workspace; paths resolving outside it are refused. Reach for a structured tool first when one fits — web_fetch for anything over HTTP(S), git_query/scm_sync for git, code_search/file_find/file_read for the repo, config_get/config_set for LeapFlow's own settings — because those report typed results, while a failed shell command can only be diagnosed from its exit code and stderr. Every shell run counts as an external side effect, so a failure stops the rest of the batch and is not retried automatically.\n- **terminal_open**(command, cwd, shell) [capability_expand category: terminal]: Open a PERSISTENT shell session (REPL/dev server/watch), returning a session_id for terminal_send/read/close. Disabled unless tools.terminal_session_enabled is set. For one-shot commands use shell_run instead.\n- **terminal_send**(session_id, input, wait) [capability_expand category: terminal]: Send a line of input to a persistent terminal session and return output captured shortly after.\n- **terminal_read**(session_id, wait): Drain buffered output from a persistent terminal session (optionally waiting briefly first).\n- **terminal_close**(session_id) [capability_expand category: terminal]: Terminate a persistent terminal session and release its process group.\n- **terminal_list**(): List active persistent terminal sessions.\n- **config_list**(category, limit): List LeapFlow's own writable settings (model, provider, daemon, memory, perception, gateway, …) with current values. Use this to discover the exact key before changing anything. Optionally narrow by `category`. This is the only correct way to inspect LeapFlow configuration — never read config files from disk.\n- **config_get**(key): Read one LeapFlow setting by key (e.g. 'llm.model', 'daemon.log_level'), returning its current value, type, scopes, and whether a change needs a daemon restart. Never read LeapFlow config files from disk — use this.\n- **config_set**(key, value, scope) [capability_expand category: config]: Change one LeapFlow setting by key, e.g. switch the model with key='llm.model'. Values are validated and coerced; credentials are stored in the vault automatically. Call config_list or config_get first if unsure of the key. The result states whether a `leap daemon restart` is required. Never edit LeapFlow config files directly.\n- **web_fetch**(url, select, timeout, max_bytes): Read a URL over HTTP(S) and get back extracted, context-sized content: parsed JSON for API endpoints, readable text plus links for web pages. Use this for anything on the internet — prices, docs, releases, articles — instead of running curl through shell_run: it reports real HTTP status codes, retries rate limits on its own, and is a plain read so a retry is always safe. For JSON APIs pass `select` with a dotted path (e.g. 'chart.result.0.meta') to return just that part instead of the whole payload.\n- **memory_search**(query, limit): Search agent memory for relevant past experiences, observations, and facts.\n- **memory_add**(content, kind) [capability_expand category: write]: Store a new observation or insight in memory for future reference.\n- **research_note**(kind, text): Record a compact, structured note about the current task's state so it survives context compression on long / multi-step tasks. Use for durable findings, open questions still to resolve, decisions / excluded paths, and the immediate next step. One concise sentence per note.\n- **capability_expand**(category): Fetch the full callable schema for every tool in a capability category (e.g. 'hub', 'gateway', 'desktop', 'delegate', 'file', 'memory', 'skill'). The compact tool index always lists every registered tool by name and a one-line summary, but only a static low-risk subset is directly callable each turn. If you need a tool from the index that is not yet callable, call capability_expand with its category first; the matching tools become callable in this turn. Never invent a tool name — expand the category instead.\n- **delegate_task**(goal, context) [capability_expand category: delegate]: Delegate a complex sub-task to an isolated subagent. The subagent gets a fresh context and restricted tool access. Use when a task is self-contained and can be solved independently.\n- **schedule_reentry**(kind, reason, delay_seconds, event_match, max_reentries, deadline_seconds): Register a re-entry so this task can resume later from its current orientation (findings / open questions / next step). Use when work must pause and continue after a delay (kind=time) or when a matching platform event arrives (kind=event), instead of finishing now. The research-ledger state is carried over automatically.\n- **hub_push**(skill_name, visibility, version) [capability_expand category: hub]: Push a local skill to the ModelScope Hub for sharing or backup.\n- **hub_pull**(repo_id, version) [capability_expand category: hub]: Pull a skill from the ModelScope Hub to install locally.\n- **hub_search**(query) [capability_expand category: hub]: Search for skills on the Hub by keyword or description.\n- **hub_sync**(mode, dry_run) [capability_expand category: hub]: Preview or execute sync between local skills and Hub.\n- **platform_action**(platform, action, payload, backend_kind) [capability_expand category: gateway]: Execute an exact registered business action on an external platform through LeapFlow's App Connector layer. Actions must be copied from the App Connector Capability Index and are addressed as domain.operation, e.g. im.send_message or docs.create_markdown. All business fields (chat_id, text, query, etc.) MUST be placed inside `payload`, never at the top level. Example: {\"platform\":\"feishu\",\"action\":\"im.send_message\",\"payload\":{\"chat_id\":\"oc_xxx\",\"text\":\"hello\"}}. Do not invent action names, do not use management actions such as list/guide/connect/status here.\n- **platform_connect**(action, platform, credentials, options, checkpoint) [capability_expand category: gateway]: List, guide, connect, disconnect, remove, or check status for external platforms using the App Connector management namespace. Supports REST and CLI backends. Use this for management actions such as list/guide/preflight/connect/status; use platform_action only for exact registered business actions.\n- **gateway_send**(platform, chat_id, text, thread_id) [capability_expand category: gateway]: Send a message to a connected external platform (Feishu group, Telegram chat, DingTalk conversation, etc.). Requires the platform to be connected via gateway_connect first. Use gateway_connect with action='list' to see connected platforms and available chat IDs.\n- **gateway_connect**(action, platform, credentials, options) [capability_expand category: gateway]: Connect, configure, or manage external platform integrations (Feishu, DingTalk, Telegram, Slack, Discord, etc.). Conversational flow: 1) call 'guide' to get setup steps + required fields, 2) present the steps to the user and ask for ALL required credentials in a single message, 3) call 'connect' with the credentials. Goal: complete in 1–2 user turns. NEVER include credential values in your text response.\n- **plugin_list**(): List the live plugin registry and cross-subsystem capability evidence. Use this before answering questions about whether LeapFlow supports plugins, self-evolution, plugin installation, hot reload, versioning, or other runtime capabilities.\n- **plugin_status**(plugin_id): Get detailed status of a specific plugin: its declared category, runtime dependencies, contributed tools, and fiber lifecycle state.\n- **plugin_versions**(plugin_id): List recorded source versions and active pointer for a profile-scoped plugin.\n- **plugin_propose**(requested_capability, plugin_id, proposed_tools, test_cases, risk_level, evidence): Create a side-effect-free PluginProposal from explicit capability-gap evidence. Use this before plugin_generate when a missing capability should be reviewed. Does not call an LLM, write files, or install anything.\n- **assess_compatibility**(manifest, source_path) [capability_expand category: plugin_management]: Assess whether a foreign plugin manifest or real DSH source bundle is compatible with LeapFlow. A source bundle assessment is static: runtime_ready stays false until restricted Node discovery during plugin_install. Returns component-level verdicts and limitations.\n- **plugin_generate**(plugin_id, description, proposal_id) [capability_expand category: system]: Generate a new ToolPlugin from a natural-language capability description. The LLM produces code that conforms to the ToolPlugin Protocol; it is then rigorously validated (syntax, structure, import, protocol conformance). The generated source is stored in CAS and receives explicit content approval. It DOES NOT install the plugin — installation requires a second, mutation-specific approval via plugin_install.\n- **plugin_install**(plugin_id, code, marketplace_name, source_path, proposal_id, version_label) [capability_expand category: system]: Install a plugin from exactly one source: validated Python code, the configured Python marketplace, or a real DSH source bundle. DSH bundles run restricted Node discovery before registration; only public host tools are installed and client UI limitations are reported. Writes profile-scoped state and mutates the process-global registry. REQUIRES APPROVAL.\n- **plugin_rollback**(plugin_id, version) [capability_expand category: system]: Rollback a profile-scoped plugin to a recorded source version and reload it. REQUIRES APPROVAL.\n- **plugin_reload**(plugin_id, version_label) [capability_expand category: system]: Hot-reload a plugin at runtime. Disposes the old plugin fiber, re-imports its module, and registers a fresh instance. Existing in-flight turns are unaffected (snapshot isolation). REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_disable**(plugin_id) [capability_expand category: system]: Disable a plugin by disposing its fiber, removing its tools from the runtime registry. Cannot disable self_management itself. REQUIRES APPROVAL — this is a self-modification action.\n- **plugin_remove**(plugin_id, delete_source) [capability_expand category: system]: Terminally remove a plugin: dispose its fiber, unregister its tools, remove reload metadata, and optionally delete its profile-scoped source file. Cannot remove self_management itself. REQUIRES APPROVAL.\n- **plugin_enable**(plugin_id) [capability_expand category: system]: Re-enable a previously disabled plugin by reloading its module and registering a fresh instance. REQUIRES APPROVAL.\n- **hw_list**(): List connected hardware devices with their channel counts and measured quantities. Start here; it does not include operating limits.\n- **hw_describe**(device_id): Return the full reference for one device: every channel, its unit, its operating envelope, rate limit, reversibility, and required interlocks, plus any prior outcomes recorded for its writable channels. Required before commanding a device.\n- **hw_read**(device_id, channel_id): Read the current value of one device channel. Has no physical effect.\n- **hw_status**(device_id): Report connection health, halt capability, and recent notable events (threshold excursions, lost samples, stalled channels) for one device.\n- **hw_configure**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Set a configuration value or setpoint on a channel declaring effect=configure. Setpoints often have inertia: the value may need time to stabilise.\n- **hw_actuate**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Command motion or output on a channel declaring effect=actuate. This moves physical hardware; a repeat from an unknown state is not a safe retry.\n- **hw_dispense**(device_id, channel_id, value, conditions, dry_run) [capability_expand category: hardware]: Consume an irreversible resource on a channel declaring effect=dispense. Running this twice dispenses twice; never repeat it after a failure without first verifying what already happened.\n- **hw_estop**(device_id) [capability_expand category: hardware]: Stop all motion and output on a device immediately. Never requires approval; use it whenever device behaviour is unexpected.\n- **session_search**(query, limit) [capability_expand category: unclassified]: Search past conversation sessions in the current workspace for relevant context.\n- **session_list**(limit): List recent conversation sessions in the current workspace with stable ids, titles, dates, and summaries. Use for browsing past tasks or when user asks to see history without specific search terms. No keywords needed — returns chronological list.\n- **session_detail**(session_id, limit, offset, include_inactive) [capability_expand category: unclassified]: Read a paginated persisted transcript for one past conversation session in the current workspace. Use after session_list or session_search returns a session_id.\n- **click**(element_index) [capability_expand category: desktop]: Click a UI element by its element_index (from the latest observe_ui snapshot)\n- **get_clipboard**() [capability_expand category: desktop]: Read current clipboard text content\n- **list_apps**(filter, running_only) [capability_expand category: desktop]: List available applications on this system. Use to discover correct bundle_id before switch_app.\n- **list_windows**() [capability_expand category: desktop]: List all top-level windows with pid, window_id, title, and per-window state (minimized, on-screen). Call this first to pick the pid and window_id that observe_ui and other window tools require.\n- **observe_ui**(pid, window_id, query) [capability_expand category: desktop]: Snapshot one window's actionable UI elements, each tagged with an element_index for click/right_click/read_text. Re-observe after actions — indices belong to one snapshot. Requires the window's pid and window_id from list_windows.\n- **open_url**(url, app_id) [capability_expand category: desktop]: Open a URL in the default or specified browser\n- **read_text**(element_index) [capability_expand category: desktop]: Read the text content of a specific UI element from the latest snapshot\n- **right_click**(element_index) [capability_expand category: desktop]: Right-click a UI element to open its context menu. Returns visible menu items.\n- **screenshot**(pid, window_id) [capability_expand category: desktop]: Capture a screenshot for visual verification. With pid + window_id captures that window (works across all displays); defaults to the last observed window, or the full desktop when no window has been observed.\n- **scroll**(element_index, direction, amount, pid, window_id) [capability_expand category: desktop]: Scroll a scrollable area of a window. Omit element_index to scroll the window's focused/page scroller; pass one to scroll an exact element from the latest snapshot.\n- **select_text**(element_index) [capability_expand category: desktop]: Select all text in a UI element (focus + select-all, for subsequent copy)\n- **set_clipboard**(text) [capability_expand category: desktop]: Write text to the clipboard\n- **shortcut**(keys) [capability_expand category: desktop]: Execute a keyboard shortcut\n- **switch_app**(app_id) [capability_expand category: desktop]: Switch to an app (launch if needed, activate, verify)\n- **type_text**(text) [capability_expand category: desktop]: Type text into the currently focused element\n- **wait**(seconds) [capability_expand category: desktop]: Wait for a specified duration before continuing\n- **wait_until**(condition, pid, window_id, timeout, poll_interval) [capability_expand category: desktop]: Wait until a UI condition is met (polls UI tree). Returns elements when found or on timeout.\n- **wait_until_stable**(timeout, poll_interval, pid, window_id) [capability_expand category: desktop]: Wait until the UI stops changing (element set stabilizes across polls).\n\n## App Connector Capability Index\nLeapFlow can onboard and manage external apps through `platform_connect` and execute exact registered business actions through `platform_action`.\nFor requests about connecting, setting up, configuring, enabling, or managing a supported app, use `platform_connect` first instead of generating SDK/Webhook sample code.\n`platform_connect.action` is the management namespace: list, guide, preflight, connect, disconnect, remove, status, events_start, events_stop, events_status.\n`platform_action.action` is only for exact registered platform business actions listed below, such as `im.send_message`; never use management actions like `list` or `guide` there.\nAll business fields MUST go inside `payload`; top-level keys are only `platform`, `action`, and `payload`.\nDo not invent platform IDs or platform action names. If the needed action is not listed, ask for discovery/clarification instead of guessing.\nUse `platform_connect` with `action='guide'` and the matching `platform` to start onboarding; use `action='list'` when the app is unclear.\nWhen a pending onboarding state is present, continue from that state with `platform_connect` instead of asking the user to restate the app.\nSupported apps:\n- `api_server`: API Server (OpenAI Compatible) (category=api; backend=adapter; platform_action actions=none registered)\n- `dingtalk`: 钉钉 (DingTalk) (category=im; backend=adapter; platform_action actions=none registered)\n- `feishu`: 飞书 (Feishu/Lark) (category=im; backend=cli)\n - `calendar.create_event` payload={summary*, start_time*, end_time*, attendees} [write/high]\n - `docs.create_markdown` payload={title*, markdown*, folder_token} [write/medium]\n - `drive.search` payload={query*, limit} [read/medium]\n - `im.add_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.download_resource` payload={message_id*, file_key*, type*} [read/low]\n - `im.get_messages` payload={message_ids*} [read/low]\n - `im.list_chats` payload={page_size} [read/low]\n - `im.list_messages` payload={chat_id*} [read/low]\n - `im.list_thread_messages` payload={thread*} [read/low]\n - `im.remove_reaction` payload={message_id*, emoji_type*} [write/low]\n - `im.reply_message` payload={message_id*, text*} [send/high]\n - `im.search_chats` payload={query*, page_size} [read/low]\n - `im.search_messages` payload={query*} [read/medium]\n - `im.send_message` payload={chat_id*, text*, thread_id} [send/high]\n - `im.update_card` payload={token*, card*} [write/medium]\n - `im.update_message` payload={message_id*, text*} [write/medium]\n - `mail.search_unread` payload={query, limit} [read/high]\n - `sheets.append_row` payload={spreadsheet_token*, sheet_id*, values*} [write/medium]\n - `task.create` payload={title*, description, due_time} [write/medium]\n- `telegram`: Telegram (category=social; backend=adapter; platform_action actions=none registered)\n- `webhook`: Webhook (Generic) (category=webhook; backend=adapter; platform_action actions=none registered)\n\n## Tool Usage\nTools are normally invoked through the native function-calling mechanism, not by writing JSON in your reply\ntext. Only if the provider signals that native function calling is unavailable for this turn, fall back to a\nsingle JSON code block: `{\"name\": \"tool_name\", \"arguments\": {\"key\": \"value\"}}` — use this fallback format\nonly, never both. Only call a tool whose exact name appears in the tool index above and is currently callable\n(or reachable via `capability_expand`). Never invent, rename, alias, or guess a tool name, platform ID, or\nplatform action from argument shape or wording — if the index does not list it, it does not exist.\n`platform_connect.action` (list/guide/preflight/connect/disconnect/remove/status/events_start/events_stop/\nevents_status) is the App Connector management namespace; `platform_action.action` only accepts exact\nregistered business actions such as `im.send_message` shown in the App Connector Capability Index — never mix\nthe two namespaces. If a tool call returns an unknown/unavailable result, use the returned suggestions or\navailable names for a single retry instead of trying further variations of the same guess.\n\n**Side-effect action rule** (`platform_action` with effect=send/write/execute):\n- Call each unique action+payload **exactly once**. Never include duplicates in the same turn.\n- Once the result returns `\"completed\": true`, that action is DONE for this task. Do NOT call it again\n in any subsequent turn — immediately summarize the result for the user instead.\n- The system enforces idempotency: duplicate calls are blocked and will not execute.\n- If the user explicitly requests sending/writing multiple times, use distinct payloads per call.\n\n**Resource identifier provenance rule**:\n- NEVER fabricate, guess, or infer resource identifiers (chat_id, message_id, file_key, user_id, etc.).\n Every resource ID used in a side-effect action MUST come from a successful API response in this session.\n- If a read/list action fails (e.g. authorization error), you do NOT have valid resource IDs.\n Report the failure to the user — do NOT attempt the dependent write/send action with a guessed ID.\n- When a tool result contains `\"llm_instruction\"`, follow it exactly.\n\n## Guidelines\n1. **Direct answers first**: If you already know the answer, respond directly without tools.\n2. **Avoid redundant tool calls**: Do not call the same tool with the same arguments more than once in the same user turn. When an existing tool result already answers the user's request, stop calling tools and answer directly.\n3. **Use tools proactively**: When the user asks about files, time, system state, or needs actions performed, use the appropriate tool.\n4. **Chain tools when needed**: You can call multiple tools in sequence (e.g., list files → read file → summarize).\n5. **Handle failures gracefully**: If a tool fails, explain what went wrong and suggest alternatives. If it failed because of an unknown tool/platform/action name, retry once with an exact name from the returned suggestions, then explain rather than keep guessing.\n6. **Summarize results naturally**: After tool execution, synthesize the results into a helpful answer rather than dumping raw output.\n7. **Stay conversational**: Maintain a natural, helpful tone. Acknowledge context from earlier in the conversation.\n8. **Recall past work**:\n - Broad queries (\"之前做了什么\", \"列出任务\"): answer from the \"Recent Task History\" section already in your context. If insufficient, call session_list.\n - Specific lookups (\"上次那个配置怎么改的\"): call session_search with relevant phrases (NOT single characters).\n - Do NOT call search tools repeatedly with keyword fragments. One well-phrased call is better than ten fragmented ones.\n\n## Coding & Verification\nWhen working with code, prefer the precise built-in tools over ad-hoc shell: use `repo_map` to orient in an\nunfamiliar project, `code_search`/`file_find` to locate and `code_intel` for symbols, `edit_file` (anchored\nsearch-replace, or a unified `diff`) to change files — never rewrite a whole file to change a few lines — and\n`git_query` to inspect diffs/log. After edits, check `syntax_ok` in the result and run `test_run`/`lint_check`\nbefore declaring the work done. Batch independent read-only calls (search/read/query) into a single turn — they\nrun in parallel.\n\n## Presentation Style\n1. **Polished Markdown only**: Format user-facing answers with clean Markdown headings, short paragraphs, and concise bullets. Use tables only when they improve comparison or scanning.\n2. **Terminal-friendly layout**: Keep lines readable in a TUI; avoid dense walls of text, deeply nested lists, oversized ASCII art, or heavy visual blocks.\n3. **Elegant emphasis**: Use bold text sparingly for key terms and conclusions. Avoid excessive emojis, decorative symbols, repeated separators, or visual noise.\n4. **Theme-safe colors**: Do not emit ANSI escape codes, HTML color tags, Rich markup, or hardcoded color names. Rely on the TUI theme to render Markdown professionally.\n5. **No leaked tool protocol**: Never show tool-call JSON, internal schemas, raw observations, tool result payloads, or hidden reasoning in the final answer unless the user explicitly asks for raw/debug output. Treat any prior `{\"name\": ..., \"arguments\": ...}` blocks and `Tool result (...)` messages as internal execution context only.\n6. **Professional closure**: End with a concise conclusion or next step when helpful; avoid rambling after the useful answer is complete.\n\nWhen finished with all tool calls, respond normally without a JSON block, tool-call transcript, or process log.\n\n## Task Contract\n- Task ID: turn-4\n- Original user request: Configure the bench_r8 homed channel to true to complete homing.\n- Workspace root: \n- Allowed roots: \n- Treat relative project paths as relative to the workspace root; never infer `.` as the project root when a workspace root is provided.\n- Workspace boundary is enforced by tools: do not read, search, edit, or run commands against paths outside the allowed roots unless the user explicitly requests an external path and the tool/approval policy permits it.\n- LeapFlow workspace config is optional at `/.leapflow/config.yaml`; runtime config is loaded from `~/.leapflow/config/user.yaml` and `~/.leapflow/profiles//config/*.yaml`.\n- Preserve this task contract across summarization, compression, tool loops, and memory retrieval.\n" + }, + { + "role": "assistant", + "content": "Discovered the simulated bench and read its channel limits." + }, + { + "role": "user", + "content": "Read the current value of the setpoint channel on bench_r8." + }, + { + "role": "assistant", + "content": "[Called: hw_read]\nRead the setpoint channel." + }, + { + "role": "user", + "content": "Actuate the bench_r8 setpoint to 60.\nConfigure the bench_r8 homed channel to true to complete homing.\nConfigure the bench_r8 homed channel to true to complete homing." + }, + { + "role": "assistant", + "content": "", + "tool_calls": [ + "hw_configure" + ] + }, + { + "role": "tool", + "content": "{\"ok\": true, \"device_id\": \"bench_r8\", \"channel_id\": \"homed\", \"side_effect_state\": \"committed\", \"settled\": true, \"execution_id\": \"\", \"idempotency_key\": \"\", \"execution_policy\": \"external_side_effect\", \"tool_call_id\": \"call_1\", \"execution_status\": \"completed\"}", + "tool_result": true + }, + { + "role": "assistant", + "content": "Operation interrupted. Continuing..." + } + ], + "tools": [ + "capability_expand", + "code_intel", + "code_search", + "config_get", + "config_list", + "env_info", + "file_find", + "file_list", + "file_read", + "git_query", + "hw_actuate", + "hw_configure", + "hw_describe", + "hw_dispense", + "hw_estop", + "hw_list", + "hw_read", + "hw_status", + "lint_check", + "memory_search", + "plugin_list", + "plugin_propose", + "plugin_status", + "plugin_versions", + "repo_map", + "research_note", + "schedule_reentry", + "session_list", + "skill_view", + "skills_list", + "terminal_list", + "terminal_read", + "test_run", + "text_search", + "time_get", + "web_fetch" + ] + }, + "responses": [ + { + "status": 200, + "content_type": "application/json", + "body": "{\"id\": \"chatcmpl-cassette\", \"object\": \"chat.completion\", \"model\": \"cassette-model\", \"choices\": [{\"index\": 0, \"message\": {\"role\": \"assistant\", \"content\": \"Homed the device; the readiness gate is now satisfied.\"}, \"finish_reason\": \"stop\"}], \"usage\": {\"prompt_tokens\": 64, \"completion_tokens\": 16, \"total_tokens\": 80}}" + } + ] +} diff --git a/tests/test_action_recorder_wiring.py b/tests/test_action_recorder_wiring.py new file mode 100644 index 00000000..ca7bb04f --- /dev/null +++ b/tests/test_action_recorder_wiring.py @@ -0,0 +1,209 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Execution-boundary tests for the no-LLM ActionExecutor wiring.""" +from __future__ import annotations + +import tempfile + +import pytest + +from conftest import StubLLM, make_settings +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent +from leapflow.engine.action_executor import ActionInvocation, RecordedActionExecutor +from leapflow.engine.engine import AgentEngine, build_default_registry +from leapflow.engine.intent_classifier import Intent +from leapflow.evolution.action_recorder import ActionEvidenceUnavailable +from leapflow.memory import EpisodicMemoryProvider, SemanticMemoryProvider, WorkingMemoryProvider +from leapflow.platform.mock import MockBridge + + +class _Recorder: + def __init__(self, *, fail_start: bool = False, fail_complete: bool = False) -> None: + self.fail_start = fail_start + self.fail_complete = fail_complete + self.started_calls: list[dict] = [] + self.completed_calls: list[dict] = [] + self.failed_calls: list[dict] = [] + + async def started(self, **kwargs): + self.started_calls.append(kwargs) + if self.fail_start: + raise OSError("writer unavailable") + return EvolutionEvent.create( + "action.started", + context=kwargs["context"], + payload={}, + producer="test", + ) + + async def completed(self, **kwargs): + self.completed_calls.append(kwargs) + if self.fail_complete: + raise OSError("writer unavailable") + return EvolutionEvent.create( + "action.completed", + context=kwargs["context"], + payload={}, + producer="test", + ) + + async def failed_exception(self, **kwargs): + self.failed_calls.append(kwargs) + return EvolutionEvent.create( + "action.failed", + context=kwargs["context"], + payload={}, + producer="test", + ) + + +def _invocation(policy: str = "read_only") -> ActionInvocation: + return ActionInvocation( + action_type="tool", + action_name="file_read", + arguments={"path": "x"}, + execution_id="exec-1", + execution_policy=policy, # type: ignore[arg-type] + context=EvolutionContext.create( + profile_id="profile-a", + workspace_id="workspace-a", + session_id="session-a", + turn_id="turn-a", + frame_id="command-a", + action_id="exec-1", + ), + goal="read x", + ) + + +class _FixedClassifier: + def __init__(self) -> None: + self._intent = Intent(label="complex", reason="test") + + async def classify(self, user_text: str) -> Intent: + return self._intent + + +async def _return(value): + return value + + +@pytest.mark.asyncio +async def test_executor_records_identity_and_completion() -> None: + recorder = _Recorder() + executor = RecordedActionExecutor(recorder) + + result = await executor.execute( + _invocation(), + lambda: _return({"ok": True, "value": 1}), + ) + + assert result["ok"] is True + assert len(recorder.started_calls) == 1 + assert len(recorder.completed_calls) == 1 + context = recorder.started_calls[0]["context"] + assert context.profile_id == "profile-a" + assert context.session_id == "session-a" + assert context.action_id == "exec-1" + assert recorder.started_calls[0]["critical"] is False + + +@pytest.mark.asyncio +async def test_mutating_action_fails_closed_when_start_fact_cannot_persist() -> None: + recorder = _Recorder(fail_start=True) + executor = RecordedActionExecutor(recorder) + executed = False + + async def execute(): + nonlocal executed + executed = True + return {"ok": True} + + with pytest.raises(ActionEvidenceUnavailable, match="audit start"): + await executor.execute(_invocation("mutating_idempotent"), execute) + assert executed is False + + +@pytest.mark.asyncio +async def test_read_only_action_degrades_when_recorder_is_unavailable() -> None: + executor = RecordedActionExecutor(_Recorder(fail_start=True)) + result = await executor.execute(_invocation(), lambda: _return({"ok": True})) + assert result == {"ok": True} + + +@pytest.mark.asyncio +async def test_execution_exception_is_recorded_then_reraised() -> None: + recorder = _Recorder() + executor = RecordedActionExecutor(recorder) + + async def execute(): + raise ValueError("boom") + + with pytest.raises(ValueError, match="boom"): + await executor.execute(_invocation("external_side_effect"), execute) + assert len(recorder.failed_calls) == 1 + assert recorder.failed_calls[0]["critical"] is True + + +@pytest.mark.asyncio +async def test_mutating_completion_record_failure_marks_effect_uncertain() -> None: + executor = RecordedActionExecutor(_Recorder(fail_complete=True)) + result = await executor.execute( + _invocation("mutating_once"), + lambda: _return({"ok": True}), + ) + assert result["audit_incomplete"] is True + assert result["side_effect_uncertain"] is True + + +@pytest.mark.asyncio +async def test_no_recorder_preserves_execution_result() -> None: + executor = RecordedActionExecutor(None) + result = await executor.execute(_invocation(), lambda: _return({"ok": True, "value": 2})) + assert result == {"ok": True, "value": 2} + + +@pytest.mark.asyncio +async def test_real_agent_engine_routes_tool_through_action_executor() -> None: + with tempfile.TemporaryDirectory() as directory: + settings = make_settings(directory) + rpc = MockBridge() + llm = StubLLM([]) + working = WorkingMemoryProvider(max_tokens=1024) + semantic = SemanticMemoryProvider(source=settings.duckdb_path) + episodic = EpisodicMemoryProvider() + recorder = _Recorder() + calls: list[dict] = [] + + async def file_list_handler(args): + calls.append(dict(args)) + return {"ok": True, "entries": []} + + try: + registry = build_default_registry(rpc, llm, working, semantic) + engine = AgentEngine( + settings, + rpc, + llm, + working, + semantic, + episodic, + registry, + _FixedClassifier(), + action_executor=RecordedActionExecutor(recorder), + ) + engine._current_session_id = "session-a" + engine._session_turn_count = 1 + engine._begin_turn_context("list files") + + result = await engine._execute_tool_with_ledger( + {"name": "file_list", "arguments": {"path": "."}}, + {"file_list": file_list_handler}, + tool_call_id="tool-call-a", + ) + + assert result["ok"] is True + assert calls == [{"path": "."}] + assert recorder.started_calls[0]["context"].session_id == "session-a" + assert recorder.started_calls[0]["execution_policy"] == "read_only" + finally: + semantic.close() diff --git a/tests/test_active_signal_source.py b/tests/test_active_signal_source.py index d9d874d5..edb98548 100644 --- a/tests/test_active_signal_source.py +++ b/tests/test_active_signal_source.py @@ -9,8 +9,8 @@ import asyncio import time -from typing import Any, Callable, List -from unittest.mock import AsyncMock, MagicMock, patch +from typing import Any, List +from unittest.mock import AsyncMock, MagicMock import pytest @@ -597,7 +597,6 @@ class TestPerceptionSessionIntegration: def _make_session(self, active_source_manager=None): """Build a minimal PerceptionSession for testing active source hooks.""" - from unittest.mock import MagicMock from leapflow.perception.config import PerceptionConfig from leapflow.perception.session import PerceptionSession @@ -651,7 +650,6 @@ async def test_session_teardown_respects_shutdown_timeout( self, ) -> None: """PerceptionSession.stop() completes bounded by shutdown_timeout_s even with hung sources.""" - from unittest.mock import MagicMock from leapflow.perception.config import PerceptionConfig from leapflow.perception.session import PerceptionSession from leapflow.domain.trajectory import RecordingMode diff --git a/tests/test_adaptation_verdict.py b/tests/test_adaptation_verdict.py index 7d51eabb..b08bed36 100644 --- a/tests/test_adaptation_verdict.py +++ b/tests/test_adaptation_verdict.py @@ -15,7 +15,6 @@ from __future__ import annotations -import asyncio from typing import Any import pytest @@ -25,7 +24,6 @@ ADAPTATION_ACTIONS, AdaptationVerdict, ) -from leapflow.learning.world_model_driver import WorldModelEvolutionDriver from leapflow.world_model.trajectory_grader import TeacherVerdict, TrajectoryGrader @@ -179,109 +177,24 @@ def test_a_goal_restatement_is_still_rejected(): assert grader._parse_verdicts(payload, goal="chat cosmetic example") == () -# ── the driver dispatches by action ──────────────────────────────────────────── +# ── the teacher verdict carries all four actions ──────────────────────────────────────── -class _Teacher: - def __init__(self, verdict: TeacherVerdict) -> None: - self._verdict = verdict - - async def grade_and_propose(self, trajectory, goal="", **kwargs): - return self._verdict - - -class _Intake: - """Stands in for ``CapabilityObservationService``. - - ``requirements`` derives a need for whatever was just observed, because that is what - a real store does: the driver asks at ``min_count=1``, so the observation written a - moment earlier already clears the threshold. A stub that returned nothing here would - quietly assert the opposite of the shipped contract -- that the driver queues an - acquisition the detector never turned into a requirement -- and the driver now - records that case as a ``requirement_not_derived`` no-op instead of acting on it. - """ - - def __init__(self) -> None: - self.observed: list[str] = [] - - def observe_result(self, result, **kwargs): - capability = str((result or {}).get("capability") or "") - if capability: - self.observed.append(capability) - return {"observation_id": "o1"} - - def requirements(self, *, min_count: int = 1, limit: int = 50): - from leapflow.domain.capability_requirement import CapabilityRequirement - - return tuple( - CapabilityRequirement.create( - capability, - "world_model", - max_risk_level="read_only", - requirement_id=f"req-{capability}", - ) - for capability in dict.fromkeys(self.observed) - ) - - -def _drive(verdicts, sink=None): - queued: list[Any] = [] - driver = WorldModelEvolutionDriver( - teacher=_Teacher(TeacherVerdict(grades=(), verdicts=tuple(verdicts))), - intake=_Intake(), - proposal_sink=sink or (lambda p: queued.append(p) or p.proposal_id), - ) - return asyncio.run(driver.drive([{"action": "a"}], "reply in the thread")), queued - - -def test_only_the_acquire_verdict_reaches_the_proposal_queue(): - result, queued = _drive( - [ - _verdict("absorb", "chat.react"), - _verdict("rebind", "chat.reply", target="chat_reply_v3"), - _verdict(ACQUIRE, "mail.send"), - _verdict("escalate", "drive.upload", target="grant drive.file"), - ] - ) - - assert result.to_dict()["by_action"] == { - "absorb": 1, "rebind": 1, "acquire": 1, "escalate": 1 - } - assert len(queued) == 1 - assert dict(queued[0].evidence[0].metadata)["capability"] == "mail.send" - - -def test_the_cheap_verdicts_survive_on_the_result(): +def test_the_cheap_verdicts_survive_on_a_teacher_verdict(): """Dropping them for not writing code would discard the common correct answer.""" - result, _ = _drive( - [ + teacher_verdict = TeacherVerdict( + grades=(), + verdicts=( _verdict("absorb", "chat.react"), _verdict("rebind", "chat.reply", target="chat_reply_v3"), _verdict("escalate", "drive.upload"), - ] + ), ) - cheap = tuple(v for v in result.verdicts if not v.writes_code) + cheap = tuple(v for v in teacher_verdict.verdicts if not v.writes_code) assert {v.action for v in cheap} == {"absorb", "rebind", "escalate"} assert all(v.knowledge for v in cheap) - - -def test_a_session_that_only_absorbed_is_not_reported_as_idle(): - """The cheapest answer must be visible, or adapting well looks like doing nothing.""" - result, queued = _drive([_verdict("absorb", "chat.react")]) - - assert queued == [], "absorb writes no code" - assert result.to_dict()["by_action"]["absorb"] == 1 - assert len(result.verdicts) == 1 - assert result.proposed == 0, "absorb is not a proposal" - - -def test_a_teacher_with_nothing_to_say_stays_empty(): - result, queued = _drive([]) - assert result.verdicts == () and queued == [] - assert result.to_dict()["by_action"] == { - "absorb": 0, "rebind": 0, "acquire": 0, "escalate": 0 - } + assert teacher_verdict.intents == (), "none of the three cheap verdicts writes code" # ── review findings: the derivation must be pure and the rule single ─────────── diff --git a/tests/test_agent_execution.py b/tests/test_agent_execution.py index c38b04b0..34de1bd0 100644 --- a/tests/test_agent_execution.py +++ b/tests/test_agent_execution.py @@ -293,6 +293,8 @@ def test_engine_recalibrate_difficulty_applies_and_resets(tmp_path) -> None: """ import dataclasses + from leapflow.domain.event_types import EvolutionEventType + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore from leapflow.storage.evolution_store import DuckDBEvolutionStore settings = dataclasses.replace(make_settings(str(tmp_path)), agent_calibration_enabled=True) @@ -304,10 +306,12 @@ def test_engine_recalibrate_difficulty_applies_and_resets(tmp_path) -> None: lt = SemanticMemoryProvider(source=settings.duckdb_path) imm = EpisodicMemoryProvider() store = DuckDBEvolutionStore(str(tmp_path / "evo.duckdb")) + audit_store = DuckDBEvolutionEventStore(tmp_path / "audit.duckdb") try: reg = build_default_registry(rpc, llm, wm, lt) classifier = _FixedClassifier("complex") engine = AgentEngine(settings, rpc, llm, wm, lt, imm, reg, classifier) + engine.set_calibration_event_store(audit_store) baseline = engine._budget_config.scale_k # 20 over-predicted turns: high difficulty costs *less* effort than low. @@ -324,10 +328,17 @@ def test_engine_recalibrate_difficulty_applies_and_resets(tmp_path) -> None: assert result.applied is True assert engine._budget_config.scale_k < baseline # over-predicted -> reduce assert 0.25 <= engine._budget_config.scale_k <= 3.0 # clamped + events = audit_store.read( + profile_id=settings.profile, + event_type=EvolutionEventType.CALIBRATION_UPDATED, + ) + assert len(events) == 1 + assert events[0].event.payload["parameter"] == "difficulty_scale" engine.reset_calibration() assert engine._budget_config.scale_k == baseline # exact revert finally: + audit_store.close() store.close() lt.close() diff --git a/tests/test_capability_proposal_policy.py b/tests/test_capability_proposal_policy.py index e40367c4..bff4ae84 100644 --- a/tests/test_capability_proposal_policy.py +++ b/tests/test_capability_proposal_policy.py @@ -6,11 +6,11 @@ import pytest from leapflow.domain.capability_requirement import CapabilityRequirement +from leapflow.evolution.projection import EvolutionProjectionRunner from leapflow.learning.plugin_trust import PluginTrustLevel -from leapflow.plugins.adaptive_loop import AdaptivePluginLoop from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy -from leapflow.storage.capability_plan_store import JsonCapabilityPlanStore -from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore def _req(risk: str = "external") -> CapabilityRequirement: @@ -23,7 +23,9 @@ def _req(risk: str = "external") -> CapabilityRequirement: def test_proposal_queue_enqueues_and_updates_status(tmp_path) -> None: - queue = JsonCapabilityProposalQueue(tmp_path / "proposals.json") + queue = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "events.duckdb"), profile_id="profile-1" + ) item = queue.enqueue( requirements=(_req("read_only"),), @@ -45,59 +47,70 @@ def test_proposal_queue_enqueues_and_updates_status(tmp_path) -> None: assert queue.active()[0].proposal_id == item.proposal_id -def test_adaptive_policy_requires_approval_for_generated_high_risk(tmp_path) -> None: - queue = JsonCapabilityProposalQueue(tmp_path / "proposals.json") - proposal = queue.enqueue( - requirements=(_req("external"),), - risk={"risk_level": "external"}, - ) - proposal = queue.update(proposal.proposal_id, status="GENERATED") +def test_prepare_enqueue_does_not_publish_before_atomic_owner_commit(tmp_path) -> None: + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(events, profile_id="profile-1") - decision = AdaptiveEvolutionPolicy(autonomy_level="trusted_autonomous").decide( - proposal, - trust_level=PluginTrustLevel.DRAFT, - sandbox_validated=True, + item, event = queue.prepare_enqueue( + requirements=(_req("read_only"),), + environment={"fingerprint_id": "env-a"}, + occurred_at=10.0, ) - assert decision.action == "request_approval" - assert decision.requires_approval is True + assert event is not None + assert queue.get(item.proposal_id) is None + events.append(event) + assert queue.get(item.proposal_id) == item + events.close() @pytest.mark.asyncio -async def test_loop_applies_policy_install_through_actor(tmp_path) -> None: - class Actor: - async def install(self, **kwargs): - return {"ok": True, "plugin_id": kwargs["plugin_id"], "action": "install"} +async def test_event_sourced_proposal_store_replays_the_latest_lifecycle_state(tmp_path) -> None: + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(events, profile_id="profile-1") + item = queue.enqueue( + requirements=(_req("read_only"),), + environment={"fingerprint_id": "env-a", "session_id": "session-a"}, + metadata={"plugin_id": "json_pretty_plugin"}, + ) + queue.transition(item.proposal_id, "GENERATED", generated_code_ref="sha256:test") + queue.transition( + item.proposal_id, + "APPROVED", + proposal_approval_id="approval-content", + mutation_approval_id="approval-mutation", + ) - async def disable(self, **kwargs): - return {"ok": True} + replayed = EvolutionCapabilityProposalStore(events, profile_id="profile-1") + restored = replayed.get(item.proposal_id) - async def remove(self, **kwargs): - return {"ok": True} + assert restored is not None and restored.status == "APPROVED" + assert restored.generated_code_ref == "sha256:test" + assert replayed.active(limit=0) == [restored] + assert len(events.read(profile_id="profile-1", proposal_id=item.proposal_id)) == 3 + projection = await EvolutionProjectionRunner(events).project_aggregate( + profile_id="profile-1" + ) + assert projection["proposals"][0]["status"] == "APPROVED" + assert projection["mutation_matrix"][0]["lifecycle_status"] == "APPROVED" + events.close() - queue = JsonCapabilityProposalQueue(tmp_path / "proposals.json") + +def test_adaptive_policy_requires_approval_for_generated_high_risk(tmp_path) -> None: + queue = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "events.duckdb"), profile_id="profile-1" + ) proposal = queue.enqueue( - requirements=(_req("read_only"),), - risk={"risk_level": "read_only"}, - metadata={"plugin_id": "json_pretty_plugin"}, + requirements=(_req("external"),), + risk={"risk_level": "external"}, ) proposal = queue.update(proposal.proposal_id, status="GENERATED") + decision = AdaptiveEvolutionPolicy(autonomy_level="trusted_autonomous").decide( proposal, + trust_level=PluginTrustLevel.DRAFT, sandbox_validated=True, ) - loop = AdaptivePluginLoop( - registry=object(), - plan_store=JsonCapabilityPlanStore(tmp_path / "plans.json"), - lifecycle_actor=Actor(), - ) - result = await loop.apply_policy_decision( - proposal, - decision, - proposal_queue=queue, - generated_code="# code", - ) - - assert result["ok"] is True - assert queue.get(proposal.proposal_id).status == "INSTALLED" + assert decision.action == "request_approval" + assert decision.requires_approval is True diff --git a/tests/test_capability_replacement_trigger.py b/tests/test_capability_replacement_trigger.py index d8c14ec7..a86d0d05 100644 --- a/tests/test_capability_replacement_trigger.py +++ b/tests/test_capability_replacement_trigger.py @@ -8,20 +8,21 @@ providers admissible at once, and the question "is the replacement actually better?" never being asked, because the incumbent is gone by the time the rival arrives. -These tests cover the three pieces that make the other ordering possible: +These tests cover the pieces that make the other ordering possible: * **T1** governance reports a failure that left the plugin *in service* -- the state between healthy and quarantined, which had no expression at all. * **T2** the teacher is shown those facts and adjudicates. A failure count cannot tell a wrong implementation from a moved environment; both produce the same streak and want opposite actions. -* **T3** an admitted intent becomes a queued proposal, with an identity that lets a - rival coexist with the incumbent it competes against. +* **T3** an admitted intent becomes a proposal whose identity lets a rival coexist with + the incumbent it competes against. The end-to-end queueing now runs in the durable + teacher worker (see ``test_durable_teacher.py``); here we hold the proposal-identity + contract that makes coexistence possible. """ from __future__ import annotations -from types import SimpleNamespace from typing import Any import pytest @@ -34,10 +35,6 @@ CapabilityEvidenceClassifier, CapabilityObservationService, ) -from leapflow.learning.world_model_driver import ( - CapabilityGapTeacher, - WorldModelEvolutionDriver, -) from leapflow.plugins.lifecycle_governor import LifecycleGovernor from leapflow.storage.capability_observation_store import JsonCapabilityObservationStore @@ -227,86 +224,7 @@ def test_a_healthy_session_adds_nothing_to_the_prompt(): assert _degraded_capability_section([{"capability": ""}]) == "" -class _Teacher: - """Records the context it was handed.""" - - def __init__(self, intents: tuple[EvolutionIntent, ...] = ()) -> None: - self.intents = intents - self.saw_degraded: Any = None - - async def grade_and_propose(self, trajectory, goal="", **kwargs): - self.saw_degraded = kwargs.get("degraded_capabilities") - return type("V", (), {"grades": (), "intents": self.intents})() - - -class _OldTeacher: - """A teacher predating the extra context, to prove the contract stays open.""" - - def __init__(self) -> None: - self.called = False - - async def grade_and_propose(self, trajectory, goal=""): - self.called = True - return type("V", (), {"grades": (), "intents": ()})() - - -class _Intake: - def __init__(self, admit: bool = True) -> None: - self.admit = admit - self.results: list[Any] = [] - - def observe_result(self, result, **kwargs): - self.results.append(result) - return {"observation_id": "o1"} if self.admit else None - - def requirements(self, *, min_count: int = 1, limit: int = 50): - return () - - -@pytest.mark.asyncio -async def test_the_driver_passes_degradation_facts_to_the_teacher(): - teacher = _Teacher() - facts = ({"capability": "chat.reply", "plugin_id": "chat_reply_v1", "failure_streak": 2},) - driver = WorldModelEvolutionDriver( - teacher=teacher, intake=_Intake(), degraded_capabilities=lambda: facts - ) - - await driver.drive([{"action": "reply"}], "reply in the thread") - - assert teacher.saw_degraded == facts - - -@pytest.mark.asyncio -async def test_a_teacher_that_predates_the_context_still_grades(): - """Losing the episode's grading over an unknown keyword would be a bad trade.""" - teacher = _OldTeacher() - driver = WorldModelEvolutionDriver( - teacher=teacher, intake=_Intake(), degraded_capabilities=lambda: ({"capability": "x"},) - ) - - await driver.drive([{"action": "a"}]) - - assert teacher.called is True - assert isinstance(teacher, CapabilityGapTeacher) - - -@pytest.mark.asyncio -async def test_unavailable_degradation_facts_degrade_grading_not_the_session(): - def explode(): - raise RuntimeError("store down") - - teacher = _Teacher() - driver = WorldModelEvolutionDriver( - teacher=teacher, intake=_Intake(), degraded_capabilities=explode - ) - - result = await driver.drive([{"action": "a"}]) - - assert teacher.saw_degraded == () - assert result.proposed == 0 - - -# ── T3: an admitted intent becomes a queued proposal ────────────────────────── +# ── T3: rival identity: the collision that would stop competition ───────────── def _intent(capability: str = "chat.reply") -> EvolutionIntent: @@ -318,76 +236,6 @@ def _intent(capability: str = "chat.reply") -> EvolutionIntent: ) -@pytest.mark.asyncio -async def test_an_admitted_intent_reaches_the_proposal_queue(): - """The last hop: without it an intent becomes a requirement and stops there. - - Resolution reports the capability unmet and nothing turns that into an acquisition, - which is why ``proposal_from_evolution_intent`` had no caller at all. - """ - queued: list[Any] = [] - driver = WorldModelEvolutionDriver( - teacher=_Teacher((_intent(),)), - intake=_Intake(admit=True), - proposal_sink=lambda proposal: queued.append(proposal) or proposal.proposal_id, - ) - - result = await driver.drive([{"action": "a"}]) - - assert len(queued) == 1 - assert result.queued_proposal_ids == (queued[0].proposal_id,) - assert result.to_dict()["queued"] == 1 - - -@pytest.mark.asyncio -async def test_an_unadmitted_intent_is_never_queued(): - """The opt-in gate must not be bypassable through the proposal path.""" - queued: list[Any] = [] - driver = WorldModelEvolutionDriver( - teacher=_Teacher((_intent(),)), - intake=_Intake(admit=False), - proposal_sink=lambda proposal: queued.append(proposal), - ) - - result = await driver.drive([{"action": "a"}]) - - assert result.proposed == 1, "the teacher still proposed" - assert result.admitted == 0 - assert queued == [], "not admitted must mean not queued" - - -@pytest.mark.asyncio -async def test_no_sink_means_no_proposals_and_no_error(): - driver = WorldModelEvolutionDriver(teacher=_Teacher((_intent(),)), intake=_Intake()) - result = await driver.drive([{"action": "a"}]) - assert result.queued_proposal_ids == () - - -@pytest.mark.asyncio -async def test_one_failing_sink_call_does_not_stop_the_others(): - calls: list[str] = [] - - def sink(proposal): - calls.append(proposal.plugin_id) - if len(calls) == 1: - raise RuntimeError("queue full") - return proposal.proposal_id - - driver = WorldModelEvolutionDriver( - teacher=_Teacher((_intent("chat.reply"), _intent("chat.react"))), - intake=_Intake(admit=True), - proposal_sink=sink, - ) - - result = await driver.drive([{"action": "a"}]) - - assert len(calls) == 2, "the second intent must still be attempted" - assert len(result.queued_proposal_ids) == 1 - - -# ── rival identity: the collision that would stop competition ───────────────── - - def test_a_rival_gets_an_identity_that_can_coexist_with_the_incumbent(): """A plugin id derived from the capability alone cannot compete with itself. @@ -425,29 +273,6 @@ def test_successive_rivals_for_one_capability_stay_distinct(): assert first.plugin_id != second.plugin_id -@pytest.mark.asyncio -async def test_the_driver_marks_a_rival_only_when_the_capability_is_degraded(): - """Rival versus gap fill is a registry fact, never a reading of the hypothesis.""" - queued: list[Any] = [] - driver = WorldModelEvolutionDriver( - teacher=_Teacher((_intent("chat.reply"), _intent("chat.react"))), - intake=_Intake(admit=True), - degraded_capabilities=lambda: ( - {"capability": "chat.reply", "plugin_id": "chat_reply_v1", "failure_streak": 2}, - ), - proposal_sink=lambda proposal: queued.append(proposal) or proposal.proposal_id, - ) - - await driver.drive([{"action": "a"}]) - - by_capability = { - dict(p.evidence[0].metadata)["capability"]: dict(p.evidence[0].metadata) - for p in queued - } - assert by_capability["chat.reply"]["replaces"] == "chat_reply_v1" - assert "replaces" not in by_capability["chat.react"], "an absent provider is a gap" - - def test_a_rival_cannot_widen_the_risk_ceiling(): """More autonomy than filling a gap, so the clamp must still hold.""" intent = EvolutionIntent.create( @@ -463,125 +288,6 @@ def test_a_rival_cannot_widen_the_risk_ceiling(): assert dict(rival.evidence[0].metadata)["requested_max_risk_level"] == "external" -# ── the whole chain, against the real store ─────────────────────────────────── - - -@pytest.mark.asyncio -async def test_the_trigger_chain_survives_the_real_observation_store(tmp_path): - """T1 to T3 with the durable store in the middle, which is where it broke. - - Every unit above passes with a fake intake. The real store persists only an - allow-listed set of payload keys, and ``plugin_id``/``failure_streak`` were not on - it -- so the degradation facts arrived carrying ``None`` for both. The teacher then - could not tell what would be replaced, and proposal identity fell back to the - capability-derived name that collides with the incumbent. Nothing raised. - """ - from leapflow.domain.evolution_intent import WORLD_MODEL_INTENT - - store = JsonCapabilityObservationStore(tmp_path / "obs.json") - service = CapabilityObservationService( - store, - classifier=CapabilityEvidenceClassifier.from_kinds( - ["unknown_tool", CAPABILITY_DEGRADED, WORLD_MODEL_INTENT] - ), - ) - declared = {"chat_reply_v1": ("chat.reply",)} - - def sink( - *, plugin_id: str, failure_streak: int, trust_level: str, failure_class: str = "" - ) -> None: - for capability in declared.get(plugin_id, ()): - service.observe_result( - { - "error_type": CAPABILITY_DEGRADED, - "capability": capability, - "plugin_id": plugin_id, - "failure_streak": failure_streak, - "trust_level": trust_level, - "failure_class": failure_class, - } - ) - - governor = LifecycleGovernor( - proposal_queue=_Queue(), outcome_store=_Outcomes(2), degradation_sink=sink - ) - await _record(governor, ok=False) - - # The service's own reader, so the filter and the environment tag are applied - # once rather than re-derived by every consumer. - degraded = service.degraded_capabilities - - # The incumbent must survive the round trip through the store. - facts = degraded() - assert facts and facts[0]["plugin_id"] == "chat_reply_v1", facts - assert str(facts[0]["failure_streak"]) == "2", facts - - teacher = _Teacher((_intent("chat.reply"),)) - queued: list[Any] = [] - driver = WorldModelEvolutionDriver( - teacher=teacher, - intake=service, - degraded_capabilities=degraded, - proposal_sink=lambda proposal: queued.append(proposal) or proposal.proposal_id, - ) - - result = await driver.drive([{"action": "reply"}], "reply in the thread") - - assert result.admitted == 1 and len(result.queued_proposal_ids) == 1 - rival = queued[0] - assert dict(rival.evidence[0].metadata)["replaces"] == "chat_reply_v1" - - # And it can coexist with what a gap fill for the same capability would be named. - gap_fill = CapabilityGapDetector().proposal_from_evolution_intent(_intent("chat.reply")) - assert rival.plugin_id != gap_fill.plugin_id - - # The degradation record is not erased by the incumbent still being found. - service.resolve_capability("chat.reply", reason="incumbent serves it") - assert degraded(), "degradation evidence must outlive a met resolution" - - -@pytest.mark.asyncio -async def test_a_partially_admitted_batch_queues_only_what_was_admitted(): - """The side door the opt-in gate exists to prevent. - - Collecting only the admitted observation *ids* was enough to count admissions and - not enough to act on them: queueing then received every intent whenever any one of - them was admitted, so a rejected hypothesis reached the proposal queue anyway. It is - invisible today because the shipped intake accepts a kind wholesale, and becomes a - real bypass the moment admission is decided per intent. - """ - - class _Selective: - """Admits only the capability it was told to.""" - - def __init__(self, allow: str) -> None: - self.allow = allow - self.seen: list[str] = [] - - def observe_result(self, result, **kwargs): - capability = str((result or {}).get("capability") or "") - self.seen.append(capability) - return {"observation_id": f"o-{capability}"} if capability == self.allow else None - - def requirements(self, *, min_count: int = 1, limit: int = 50): - return () - - intake = _Selective("chat.reply") - queued: list[Any] = [] - driver = WorldModelEvolutionDriver( - teacher=_Teacher((_intent("chat.reply"), _intent("chat.react"))), - intake=intake, - proposal_sink=lambda proposal: queued.append(proposal) or proposal.proposal_id, - ) - - result = await driver.drive([{"action": "a"}]) - - assert intake.seen == ["chat.reply", "chat.react"], "both were offered to the gate" - assert result.proposed == 2 and result.admitted == 1 - assert len(queued) == 1, "only the admitted intent may be queued" - assert dict(queued[0].evidence[0].metadata)["capability"] == "chat.reply" - - # ── A4-A6: the facts must be classified, filtered and environment-tagged ────── @@ -773,63 +479,3 @@ def test_one_degradation_is_not_told_it_might_be_several(): ] ) assert "one change rather than several" in two - - -def test_an_unknown_environment_does_not_mark_every_alternative_unusable(): - """Undescribed must read as "cannot judge", not "nothing is available". - - The other reading would mark every alternative a misfit and push every verdict toward - acquire -- the most expensive branch -- for the sole reason that the environment could - not be described. - """ - from leapflow.learning.degradation_sink import build_alternatives_provider - from leapflow.plugins.protocol import ToolMetadata - - tool = ToolMetadata( - name="chat_reply_v2", - description="reply", - parameters_schema={"type": "object", "properties": {}}, - handler=lambda **kwargs: None, - x_leapflow={"category": "chat", "risk_level": "read_only"}, - provides_capabilities=("chat.reply",), - requires_environment_affordances=("app.chat.v2",), - ) - registry = SimpleNamespace( - plugins={"v2": SimpleNamespace(tools=[tool])}, - tool_owners={"chat_reply_v2": "v2"}, - tool_handlers={"chat_reply_v2": tool.handler}, - ) - - unknown = build_alternatives_provider( - registry_provider=lambda: registry, affordances_provider=lambda: () - )("chat.reply", "v1") - assert unknown and unknown[0]["fits_here"] is True - - absent = build_alternatives_provider( - registry_provider=lambda: registry, affordances_provider=lambda: ("app.chat.v1",) - )("chat.reply", "v1") - assert absent and absent[0]["fits_here"] is False - - -def test_the_incumbent_is_not_offered_as_its_own_alternative(): - """Rebinding to the thing that is failing is not an option.""" - from leapflow.learning.degradation_sink import build_alternatives_provider - from leapflow.plugins.protocol import ToolMetadata - - tool = ToolMetadata( - name="chat_reply_v1", - description="reply", - parameters_schema={"type": "object", "properties": {}}, - handler=lambda **kwargs: None, - x_leapflow={"category": "chat", "risk_level": "read_only"}, - provides_capabilities=("chat.reply",), - ) - registry = SimpleNamespace( - plugins={"v1": SimpleNamespace(tools=[tool])}, - tool_owners={"chat_reply_v1": "v1"}, - tool_handlers={"chat_reply_v1": tool.handler}, - ) - provider = build_alternatives_provider(registry_provider=lambda: registry) - - assert provider("chat.reply", "v1") == () - assert len(provider("chat.reply", "")) == 1 diff --git a/tests/test_capability_resolver.py b/tests/test_capability_resolver.py index 40c98b8c..26fda270 100644 --- a/tests/test_capability_resolver.py +++ b/tests/test_capability_resolver.py @@ -4,13 +4,16 @@ from __future__ import annotations from dataclasses import dataclass +from types import SimpleNamespace from typing import Any, Sequence import pytest +from leapflow.domain.adaptation_verdict import AdaptationVerdict from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.domain.environment_fingerprint import EnvironmentFingerprint from leapflow.domain.platform import Capability, PlatformID, PlatformManifest +from leapflow.learning.degradation_sink import build_live_capability_resolver from leapflow.learning.plugin_stats import PluginUsageTracker from leapflow.learning.plugin_trust import PluginTrustLedger from leapflow.plugins.capability_resolver import ( @@ -90,6 +93,42 @@ def bind_runtime(self, **deps: Any) -> None: return None +def test_live_acquisition_gate_resolves_against_current_registry() -> None: + tool = ToolMetadata( + name="repo_read", + description="Read repository files", + parameters_schema={"type": "object", "properties": {}}, + handler=_handler, + x_leapflow={"risk_level": "read_only", "category": "test"}, + provides_capabilities=("repository.inspect",), + ) + registry = SimpleNamespace( + plugins={"repository_builtin": _Plugin("repository_builtin", [tool])}, + tool_owners={"repo_read": "repository_builtin"}, + tool_handlers={"repo_read": _handler}, + assemble=lambda: None, + ) + resolve = build_live_capability_resolver( + registry_provider=lambda: registry, + environment_provider=lambda: _env(Capability.FILE_OPS), + ) + available = AdaptationVerdict.create( + "acquire", "repository.inspect", "Repository inspection is required." + ).to_intent() + missing = AdaptationVerdict.create( + "acquire", "mail.send", "Mail delivery is required." + ).to_intent() + + available_result = resolve(available, {"session_id": "s1", "workspace_id": "w1"}) + missing_result = resolve(missing, {"session_id": "s1", "workspace_id": "w1"}) + + assert available_result["resolved"] is True + assert available_result["satisfied"] is True + assert available_result["selected_plugin_id"] == "repository_builtin" + assert missing_result["resolved"] is True + assert missing_result["satisfied"] is False + + def test_resolver_selects_highest_scoring_declared_candidate() -> None: req = _req("json.pretty") env = _env(Capability.FILE_OPS) diff --git a/tests/test_coevolution_sweep_wiring.py b/tests/test_coevolution_sweep_wiring.py index 7f21aa93..b2e94f04 100644 --- a/tests/test_coevolution_sweep_wiring.py +++ b/tests/test_coevolution_sweep_wiring.py @@ -330,11 +330,14 @@ def test_active_proposal_ids_targets_the_newest_record_for_a_plugin(tmp_path): from leapflow.cli.context import Context from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.layout import ProfileLayout - from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue + from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore layout = ProfileLayout(root=tmp_path / "profile", profile_id="p") layout.root.mkdir(parents=True, exist_ok=True) - queue = JsonCapabilityProposalQueue(layout.capability_proposal_queue_path) + queue = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "events.duckdb"), profile_id="p" + ) queue.enqueue( requirements=( CapabilityRequirement.create("chat.reply", "world_model", requirement_id="req-a"), @@ -350,7 +353,10 @@ def test_active_proposal_ids_targets_the_newest_record_for_a_plugin(tmp_path): # Bump the second record so it is unambiguously the most recently touched. queue.update(newer.proposal_id, status="GENERATED") - ctx = _Ctx(settings=SimpleNamespace(profile_layout=layout)) + ctx = _Ctx( + settings=SimpleNamespace(profile_layout=layout), + _capability_proposal_queue=queue, + ) mapping = Context._active_proposal_ids(ctx) assert mapping["shared_plugin"] == newer.proposal_id diff --git a/tests/test_dashboard_view.py b/tests/test_dashboard_view.py index 268b854d..1ff4eaa1 100644 --- a/tests/test_dashboard_view.py +++ b/tests/test_dashboard_view.py @@ -3,6 +3,7 @@ from __future__ import annotations +import asyncio from typing import Any from leapflow.dashboard import ( @@ -20,10 +21,12 @@ def __init__( watches: list[dict], findings: list[dict], signal_result: dict[str, Any] | None = None, + evolution_projection: dict[str, Any] | None = None, ) -> None: self._watches = watches self._findings = findings self._signal_result = signal_result or {"metrics": {}, "signal_stream": []} + self._evolution_projection = evolution_projection or {} async def watches(self) -> list[dict[str, Any]]: return list(self._watches) @@ -35,6 +38,15 @@ async def findings(self, *, watch_id: str = "", limit: int = 50) -> list[dict[st async def signal_metrics(self) -> dict[str, Any]: return dict(self._signal_result) + async def evolution_projection(self, *, session_id: str) -> dict[str, Any]: + result = dict(self._evolution_projection) + result["session_id"] = session_id + result["scope"] = "session" + return {"ok": True, "projection": result} + + async def evolution_projection_aggregate(self) -> dict[str, Any]: + return {"ok": True, "projection": dict(self._evolution_projection)} + def _flatten(spec: dict) -> list[dict]: flat: list[dict] = [] @@ -506,12 +518,36 @@ def _evolution_provider(*, live_has_findings: bool = False) -> _FakeProvider: def _build(provider: _FakeProvider, template: str = "evolution") -> dict: - import asyncio - builder = DashboardViewBuilder(TemplateLibrary()) return asyncio.run(builder.build(DashboardIntent(template=template), provider)) +def test_evolution_view_overlays_the_event_projection_for_an_explicit_session(): + provider = _evolution_provider() + provider._evolution_projection = { + "summary": {"episode_count": 2, "by_action": {"absorb": 1}}, + "timeline": [{"title": "world_model → absorb", "summary": "repo.inspect"}], + "episodes": [{"episode_id": "ep-1", "status": "committed"}], + "mutation_matrix": [], + "degraded": False, + } + builder = DashboardViewBuilder(TemplateLibrary()) + spec = asyncio.run( + builder.build(DashboardIntent(template="evolution", session_id="session-a"), provider) + ) + + stats = { + node["props"].get("label"): node["props"].get("value") + for node in _flatten(spec) + if node.get("type") == "Stat" + } + assert stats["Recent episodes"] == 2 + assert stats["Plugins"] == 17 + assert spec["meta"]["evolution_projection"]["session_id"] == "session-a" + timeline = next(node for node in _flatten(spec) if node.get("type") == "Timeline") + assert timeline["props"]["data"][0]["summary"] == "repo.inspect" + + def test_a_second_watch_on_a_domain_cannot_blank_the_board(): """The data existed under a sibling watch, and the page rendered em dashes. diff --git a/tests/test_degradation_feedback_loop.py b/tests/test_degradation_feedback_loop.py index 59d36ef7..895d1fd4 100644 --- a/tests/test_degradation_feedback_loop.py +++ b/tests/test_degradation_feedback_loop.py @@ -23,7 +23,9 @@ import pytest from leapflow.domain.adaptation_verdict import AdaptationVerdict -from leapflow.engine.engine import AgentEngine +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent +from leapflow.evolution.teacher_worker import DurableTeacherWorker from leapflow.learning.capability_observation import ( CAPABILITY_DEGRADED, CapabilityEvidenceClassifier, @@ -33,15 +35,25 @@ build_degradation_sink, declared_capabilities_by_plugin, ) -from leapflow.learning.world_model_driver import WorldModelEvolutionDriver from leapflow.plugins.lifecycle_governor import LifecycleGovernor from leapflow.plugins.protocol import ToolMetadata from leapflow.storage.capability_observation_store import JsonCapabilityObservationStore -from leapflow.storage.distilled_knowledge_store import JsonDistilledKnowledgeStore -from leapflow.world_model.trajectory_grader import ( - TeacherVerdict, - _degraded_capability_section, -) +from leapflow.storage.distilled_knowledge_store import EvolutionDistilledKnowledgeStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore +from leapflow.world_model.trajectory_grader import _degraded_capability_section + + +def _seed_verdict(events: DuckDBEvolutionEventStore, verdict: AdaptationVerdict) -> None: + """Commit one verdict as a durable fact, as the teacher worker would.""" + events.append( + EvolutionEvent.create( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + context=EvolutionContext(profile_id="p", decision_id=verdict.verdict_id), + payload=verdict.to_dict(), + producer="test", + dedup_key=f"teacher.verdict_recorded:{verdict.verdict_id}", + ) + ) def _tool(name: str, *capabilities: str) -> ToolMetadata: @@ -96,7 +108,9 @@ def wired(tmp_path): ["unknown_tool", CAPABILITY_DEGRADED] ), ) - knowledge = JsonDistilledKnowledgeStore(tmp_path / "dk.json") + knowledge_events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + knowledge = EvolutionDistilledKnowledgeStore(knowledge_events, profile_id="p") + knowledge.refresh() registry = _registry(chat_reply_v1=(_tool("chat_reply", "chat.reply"),)) outcomes = _Outcomes() governor = LifecycleGovernor( @@ -109,7 +123,22 @@ def wired(tmp_path): ), ) return SimpleNamespace( - service=service, knowledge=knowledge, governor=governor, outcomes=outcomes + service=service, + knowledge=knowledge, + events=knowledge_events, + governor=governor, + outcomes=outcomes, + ) + + +def _worker(wired: Any) -> DurableTeacherWorker: + """A worker built only far enough to exercise degradation enrichment.""" + return DurableTeacherWorker( + store=SimpleNamespace(), + artifact_store=SimpleNamespace(), + teacher=SimpleNamespace(), + degraded_capabilities=wired.service.degraded_capabilities, + knowledge_projection=wired.knowledge, ) @@ -209,25 +238,16 @@ def test_the_teacher_is_shown_what_it_concluded_last_time(wired): """Without this the loop is open: the same evidence can only produce the same answer.""" wired.outcomes.streak = 2 _record(wired.governor, ok=False, failure_class="affordance_removed") - wired.knowledge.record( + _seed_verdict( + wired.events, AdaptationVerdict.create( "absorb", "chat.reply", "the send control moved to the toolbar" - ) + ), ) + wired.knowledge.refresh() - seen: list[Any] = [] - - class _Teacher: - async def grade_and_propose(self, trajectory, goal="", **kwargs): - seen.append(kwargs.get("degraded_capabilities")) - return TeacherVerdict() - - driver = WorldModelEvolutionDriver( - teacher=_Teacher(), intake=wired.service, knowledge_store=wired.knowledge - ) - asyncio.run(driver.drive([{"action": "a"}], "reply")) + facts = _worker(wired)._collect_degraded_capabilities() - facts = seen[0] assert facts[0]["prior_action"] == "absorb" assert "moved to the toolbar" in facts[0]["prior_knowledge"] @@ -240,10 +260,7 @@ def test_a_capability_with_no_prior_verdict_is_unchanged(wired): wired.outcomes.streak = 2 _record(wired.governor, ok=False) - driver = WorldModelEvolutionDriver( - teacher=SimpleNamespace(), intake=wired.service, knowledge_store=wired.knowledge - ) - facts = driver._collect_degraded() + facts = _worker(wired)._collect_degraded_capabilities() assert facts and "prior_action" not in facts[0] @@ -284,9 +301,12 @@ def test_recovery_retires_the_knowledge_that_described_the_failure(wired): No newer verdict is coming precisely because there is no longer anything wrong, so without this the knowledge outlives the failure and misleads every later session. """ - wired.knowledge.record( - AdaptationVerdict.create("absorb", "chat.reply", "the control is missing") + wired.knowledge.count() # projection is live + _seed_verdict( + wired.events, + AdaptationVerdict.create("absorb", "chat.reply", "the control is missing"), ) + wired.knowledge.refresh() assert wired.knowledge.count() == 1 wired.outcomes.streak = 0 @@ -296,9 +316,11 @@ def test_recovery_retires_the_knowledge_that_described_the_failure(wired): def test_a_still_failing_capability_keeps_its_knowledge(wired): - wired.knowledge.record( - AdaptationVerdict.create("absorb", "chat.reply", "the control is missing") + _seed_verdict( + wired.events, + AdaptationVerdict.create("absorb", "chat.reply", "the control is missing"), ) + wired.knowledge.refresh() wired.outcomes.streak = 2 _record(wired.governor, ok=False) @@ -317,58 +339,6 @@ def test_retirement_without_a_knowledge_store_is_harmless(tmp_path): sink(plugin_id="v1", failure_streak=0, trust_level="DRAFT") # must not raise -# ── D3: the recommendation reaches the student ───────────────────────────────── - - -def _reader(store: Any) -> AgentEngine: - engine = AgentEngine.__new__(AgentEngine) - engine._knowledge_store = store - engine._environment_fingerprint_id = "" - engine._settings = SimpleNamespace(distilled_knowledge_limit=12) - return engine - - -def test_a_rebind_target_tells_the_student_what_to_prefer(tmp_path): - """Stored and never read by anyone is the failure mode this closes. - - The student would be told a problem exists without being told the answer that was - already worked out. - """ - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - AdaptationVerdict.create( - "rebind", "chat.reply", "the app is now v3", target="chat_reply_v3" - ) - ) - - block = _reader(store)._distilled_knowledge_context() - assert "Prefer chat_reply_v3." in block - - -def test_an_escalation_target_names_what_a_person_must_do(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - AdaptationVerdict.create( - "escalate", - "drive.upload", - "uploading is refused", - target="grant the drive.file scope", - ) - ) - - block = _reader(store)._distilled_knowledge_context() - assert "This needs a person to: grant the drive.file scope." in block - - -def test_a_verdict_without_a_target_adds_no_hint(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record(AdaptationVerdict.create("absorb", "chat.react", "it moved")) - - block = _reader(store)._distilled_knowledge_context() - assert "- chat.react: it moved" in block - assert "Prefer" not in block and "needs a person" not in block - - # ── the whole loop, over two sessions ────────────────────────────────────────── @@ -379,37 +349,25 @@ def test_two_sessions_close_the_loop(wired): governor was never constructed, so no evidence was produced, so no verdict was reachable, so nothing was distilled and nothing could be reconsidered. """ - # Session one: the capability degrades and the teacher absorbs it. + worker = _worker(wired) + + # Session one: the capability degrades and nothing is known yet. wired.outcomes.streak = 2 _record(wired.governor, ok=False, failure_class="affordance_removed") + first = worker._collect_degraded_capabilities() + assert first and "prior_action" not in first[0], "nothing was known yet" - verdicts = ( + # The teacher absorbs it -- committed as a durable verdict fact. + _seed_verdict( + wired.events, AdaptationVerdict.create("absorb", "chat.reply", "the control moved to the toolbar"), ) - seen: list[Any] = [] - - class _Teacher: - def __init__(self, out) -> None: - self.out = out - - async def grade_and_propose(self, trajectory, goal="", **kwargs): - seen.append(kwargs.get("degraded_capabilities")) - return TeacherVerdict(grades=(), verdicts=self.out) - - first = WorldModelEvolutionDriver( - teacher=_Teacher(verdicts), intake=wired.service, knowledge_store=wired.knowledge - ) - result = asyncio.run(first.drive([{"action": "a"}], "reply")) - assert result.distilled == ("chat.reply",) - assert seen[0] and "prior_action" not in seen[0][0], "nothing was known yet" + wired.knowledge.refresh() # Session two: it still fails, and now the teacher sees its own previous answer. _record(wired.governor, ok=False, failure_class="affordance_removed") - second = WorldModelEvolutionDriver( - teacher=_Teacher(()), intake=wired.service, knowledge_store=wired.knowledge - ) - asyncio.run(second.drive([{"action": "a"}], "reply")) - assert seen[1][0]["prior_action"] == "absorb" + second = worker._collect_degraded_capabilities() + assert second[0]["prior_action"] == "absorb" # Session three: it works again, and the knowledge retires itself. wired.outcomes.streak = 0 @@ -433,20 +391,35 @@ def test_the_production_path_actually_builds_a_governor(tmp_path): layout = SimpleNamespace( distilled_knowledge_path=tmp_path / "dk.json", capability_observations_path=tmp_path / "obs.json", - capability_proposal_queue_path=tmp_path / "queue.json", - plugin_outcomes_path=tmp_path / "outcomes.json", ) + from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore + from leapflow.storage.distilled_knowledge_store import EvolutionDistilledKnowledgeStore + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + from leapflow.storage.plugin_outcome_store import EvolutionPluginOutcomeStore + context = Context.__new__(Context) context.settings = SimpleNamespace( + profile="test", profile_layout=layout, distilled_knowledge_ttl_s=0.0, accepted_evidence_kinds=("capability_degraded",), workspace_root=str(tmp_path), ) + event_store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + context._capability_proposal_queue = EvolutionCapabilityProposalStore( + event_store, profile_id="test" + ) + context._plugin_outcome_store = EvolutionPluginOutcomeStore( + event_store, profile_id="test" + ) + context._evolution_knowledge_store = EvolutionDistilledKnowledgeStore( + event_store, profile_id="test" + ) governor = context._resolve_lifecycle_governor() assert governor is not None, "the sweep would run with governor=None" + event_store.close() assert context._resolve_lifecycle_governor() is governor, "built once, not per sweep" # And the sink must be attached, or the chain is wired but silent. assert governor._degradation_sink is not None diff --git a/tests/test_distilled_knowledge.py b/tests/test_distilled_knowledge.py index 762f7aed..ce73d04e 100644 --- a/tests/test_distilled_knowledge.py +++ b/tests/test_distilled_knowledge.py @@ -1,10 +1,10 @@ # Copyright (c) Alibaba, Inc. and its affiliates. -"""C1-C3: the distillation channel, from teacher's conclusion to student's context. +"""C1: the distillation channel, from the teacher's committed verdict to the student. -This is the cheapest way the system adapts, and until now the only edge from teacher to -student was a single bit -- which tools are visible. Everything the teacher concluded -about *why* the environment behaved as it did was graded, traced, and thrown away, so a -correct judgement bought nothing and the next session repeated the same mistake. +This is the cheapest way the system adapts. The durable teacher worker commits a +``TEACHER_VERDICT_RECORDED`` fact per verdict; ``EvolutionDistilledKnowledgeStore`` +projects those facts into the read model the acting agent consults. There is no second +durable store — the projection is the single source, rebuilt from events. Retirement is tested as heavily as recording, because stale knowledge does not merely go unused: the acting agent cannot tell a current fact from one that expired three upgrades @@ -14,43 +14,54 @@ from __future__ import annotations -import asyncio import time from types import SimpleNamespace from typing import Any from leapflow.domain.adaptation_verdict import AdaptationVerdict -from leapflow.domain.environment_fingerprint import EnvironmentFingerprint -from leapflow.domain.platform import Capability, PlatformID, PlatformManifest +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent from leapflow.engine.engine import AgentEngine -from leapflow.learning.world_model_driver import WorldModelEvolutionDriver from leapflow.storage.distilled_knowledge_store import ( DistilledKnowledge, - JsonDistilledKnowledgeStore, + EvolutionDistilledKnowledgeStore, ) -from leapflow.world_model.trajectory_grader import TeacherVerdict +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore -def _env(os_version: str = "15.0", extra: bool = False) -> EnvironmentFingerprint: - names = sorted(c.name for c in Capability) - caps = {Capability[names[0]]} - if extra: - caps.add(Capability[names[1]]) - return EnvironmentFingerprint.from_platform_manifest( - PlatformManifest(PlatformID.DARWIN_15, os_version, frozenset(caps)) +def _verdict(action: str, capability: str, knowledge: str, **kw: Any) -> AdaptationVerdict: + return AdaptationVerdict.create(action, capability, knowledge, **kw) + + +def _events(tmp_path) -> DuckDBEvolutionEventStore: + return DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + + +def _seed(store: DuckDBEvolutionEventStore, verdict: AdaptationVerdict, *, seq: int = 0) -> None: + """Commit one verdict as a durable fact, exactly as the teacher worker would.""" + payload = verdict.to_dict() + store.append( + EvolutionEvent.create( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + context=EvolutionContext(profile_id="p", decision_id=verdict.verdict_id), + payload=payload, + producer="test", + dedup_key=f"teacher.verdict_recorded:{verdict.verdict_id}:{seq}", + ) ) -def _verdict(action: str, capability: str, knowledge: str, **kw: Any) -> AdaptationVerdict: - return AdaptationVerdict.create(action, capability, knowledge, **kw) +def _knowledge(tmp_path, *verdicts: AdaptationVerdict, ttl_seconds: float = 0.0): + events = _events(tmp_path) + for index, verdict in enumerate(verdicts): + _seed(events, verdict, seq=index) + store = EvolutionDistilledKnowledgeStore(events, profile_id="p", ttl_seconds=ttl_seconds) + store.refresh() + return events, store def _reader(store: Any, *, fingerprint: str = "", limit: int = 12) -> AgentEngine: - """An engine with only what this context layer reads, bound directly. - - Bound rather than resolved, so the test exercises the rendering rather than the lazy - lookup -- which has its own test below. - """ + """An engine with only what this context layer reads, bound directly.""" engine = AgentEngine.__new__(AgentEngine) engine._knowledge_store = store engine._knowledge_store_unavailable = False @@ -59,44 +70,42 @@ def _reader(store: Any, *, fingerprint: str = "", limit: int = 12) -> AgentEngin return engine -# ── recording ───────────────────────────────────────────────────────────────── +# ── recording: a committed verdict becomes durable, replayable knowledge ──────── -def test_a_verdict_becomes_a_durable_fact(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - entry = store.record( - _verdict("rebind", "chat.reply", "the send control is now labelled Dispatch"), - environment=_env().to_dict(), +def test_a_committed_verdict_becomes_durable_knowledge(tmp_path): + events, store = _knowledge( + tmp_path, + _verdict("rebind", "chat.reply", "the send control is now labelled Dispatch", + target="chat_v2"), ) + entry = store.for_capability("chat.reply") assert isinstance(entry, DistilledKnowledge) assert entry.capability == "chat.reply" - assert entry.environment_id == _env().fingerprint_id - - # And it survives a fresh reader, which is the whole point of persisting it. - assert JsonDistilledKnowledgeStore(tmp_path / "dk.json").count() == 1 - - -def test_a_verdict_without_knowledge_is_refused(tmp_path): - """The parser already rejects this shape, so reaching here means something changed.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - assert store.record(SimpleNamespace(capability="chat.reply", knowledge="")) is None - assert store.record(SimpleNamespace(capability="", knowledge="something")) is None - assert store.count() == 0 - + assert store.count() == 1 -def test_a_batch_is_one_write_and_the_last_word_wins(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - stored = store.record_all( - [ - _verdict("absorb", "chat.reply", "first conclusion"), - _verdict("rebind", "chat.reply", "second conclusion"), - _verdict("absorb", "chat.react", "unrelated"), - ] + # A fresh projection over the same events reconstructs the entry: the events are + # the source, not any in-memory state. + replayed = EvolutionDistilledKnowledgeStore(events, profile_id="p") + replayed.refresh() + assert replayed.count() == 1 + events.close() + + +def test_all_four_actions_are_disclosed_as_knowledge(tmp_path): + """Every verdict carries mandatory knowledge; the student sees all four actions.""" + _events_store, store = _knowledge( + tmp_path, + _verdict("absorb", "chat.react", "the control moved to the overflow menu"), + _verdict("rebind", "chat.reply", "the app is v3", target="chat_reply_v3"), + _verdict("acquire", "mail.send", "nothing installed sends mail"), + _verdict("escalate", "drive.upload", "a person must grant the drive scope", + target="grant drive.file"), ) - assert len(stored) == 2, "one entry per capability, even within a batch" - assert store.for_capability("chat.reply").knowledge == "second conclusion" + assert store.count() == 4 + _events_store.close() # ── retirement: three ways out, and only three ───────────────────────────────── @@ -104,70 +113,58 @@ def test_a_batch_is_one_write_and_the_last_word_wins(tmp_path): def test_a_newer_verdict_supersedes_the_older_one(tmp_path): """Keeping both live would show the agent a capability's contradictory past.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record(_verdict("rebind", "chat.reply", "v3: the control is Dispatch")) - store.record(_verdict("absorb", "chat.reply", "v4: the control is Send again")) + events, store = _knowledge( + tmp_path, + _verdict("rebind", "chat.reply", "v3: the control is Dispatch"), + ) + later = AdaptationVerdict.create( + "absorb", "chat.reply", "v4: the control is Send again", + created_at=time.time() + 10, + ) + _seed(events, later, seq=1) + store.refresh() assert store.count() == 1 assert store.for_capability("chat.reply").knowledge.startswith("v4") + events.close() def test_knowledge_expires_and_expiry_is_applied_on_read(tmp_path): """A sweep would leave stale facts disclosed until some unrelated write happened.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json", ttl_seconds=1.0) - store.record(_verdict("absorb", "mail.send", "the sent folder was renamed")) + _events_store, store = _knowledge( + tmp_path, + _verdict("absorb", "mail.send", "the sent folder was renamed"), + ttl_seconds=1.0, + ) assert store.count() == 1 assert store.live(now=time.time() + 5) == () + _events_store.close() def test_ttl_zero_disables_expiry(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json", ttl_seconds=0.0) - store.record(_verdict("absorb", "mail.send", "still true")) + _events_store, store = _knowledge( + tmp_path, + _verdict("absorb", "mail.send", "still true"), + ttl_seconds=0.0, + ) assert len(store.live(now=time.time() + 10_000_000)) == 1 + _events_store.close() def test_knowledge_can_be_retracted_when_it_is_obsolete(tmp_path): - """The only retirement a caller drives, and the only one that covers recovery. - - A capability observed working again makes knowledge describing its failure - misleading, and neither supersession nor expiry removes it -- no newer verdict is - coming precisely because there is no longer anything wrong. - """ - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record(_verdict("absorb", "chat.react", "the control is missing")) - store.record(_verdict("absorb", "chat.reply", "unrelated")) + """The only retirement a caller drives, and the only one that covers recovery.""" + events, store = _knowledge( + tmp_path, + _verdict("absorb", "chat.react", "the control is missing"), + _verdict("absorb", "chat.reply", "unrelated"), + ) assert store.retract("chat.react", reason="observed working") is True assert [e.capability for e in store.live()] == ["chat.reply"] assert store.retract("chat.react") is False, "retracting twice is a no-op" assert store.retract("") is False - - -# ── the environment is disclosed, never used to filter ───────────────────────── - - -def test_a_fact_from_another_environment_is_disclosed_as_such(tmp_path): - """Filtering on fingerprint mismatch would discard good knowledge on any upgrade. - - Whether an OS point release invalidates "the send control is labelled Dispatch" is a - judgement about meaning. A predicate here would be a hard rule with no ability to - generalise, so the mismatch is surfaced and the reader weighs it. - """ - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - _verdict("rebind", "chat.reply", "the control is Dispatch"), - environment=_env().to_dict(), - ) - - same = _reader(store, fingerprint=_env().fingerprint_id)._distilled_knowledge_context() - other = _reader( - store, fingerprint=_env("15.7", extra=True).fingerprint_id - )._distilled_knowledge_context() - - assert "different environment" not in same - assert "chat.reply" in other, "knowledge is not dropped for a changed environment" - assert "learned in a different environment" in other + events.close() # ── the student's context ────────────────────────────────────────────────────── @@ -175,21 +172,55 @@ def test_a_fact_from_another_environment_is_disclosed_as_such(tmp_path): def test_the_student_sees_distilled_knowledge_as_observations(tmp_path): """The C1 payload, rendered. Framed as observations because it is not an order.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record(_verdict("rebind", "chat.reply", "the control is now Dispatch")) + _events_store, store = _knowledge( + tmp_path, + _verdict("rebind", "chat.reply", "the control is now Dispatch", target="chat_v2"), + ) block = _reader(store)._distilled_knowledge_context() assert "What is known about this environment" in block assert "- chat.reply: the control is now Dispatch" in block assert "not instructions" in block, "it must not read as a command to the framework" + _events_store.close() + + +def test_a_rebind_target_tells_the_student_what_to_prefer(tmp_path): + _events_store, store = _knowledge( + tmp_path, + _verdict("rebind", "chat.reply", "the app is now v3", target="chat_reply_v3"), + ) + block = _reader(store)._distilled_knowledge_context() + assert "Prefer chat_reply_v3." in block + _events_store.close() + + +def test_an_escalation_target_names_what_a_person_must_do(tmp_path): + _events_store, store = _knowledge( + tmp_path, + _verdict("escalate", "drive.upload", "the scope was revoked", + target="grant the drive.file scope"), + ) + block = _reader(store)._distilled_knowledge_context() + assert "This needs a person to: grant the drive.file scope." in block + _events_store.close() + + +def test_a_verdict_without_a_target_adds_no_hint(tmp_path): + _events_store, store = _knowledge( + tmp_path, + _verdict("absorb", "chat.react", "it moved"), + ) + block = _reader(store)._distilled_knowledge_context() + assert "- chat.react: it moved" in block + assert "Prefer" not in block and "needs a person" not in block + _events_store.close() def test_the_disclosed_set_is_bounded(tmp_path): """The channel meant to improve context must not come to dominate it.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - for i in range(20): - store.record(_verdict("absorb", f"cap{i:02d}.thing", f"fact {i}")) + verdicts = [_verdict("absorb", f"cap{i:02d}.thing", f"fact {i}") for i in range(20)] + _events_store, store = _knowledge(tmp_path, *verdicts) lines = [ line @@ -197,221 +228,68 @@ def test_the_disclosed_set_is_bounded(tmp_path): if line.startswith("- ") ] assert len(lines) == 3 + _events_store.close() def test_an_empty_or_absent_store_produces_no_block(tmp_path): - assert _reader(JsonDistilledKnowledgeStore(tmp_path / "e.json"))._distilled_knowledge_context() == "" + _events_store, store = _knowledge(tmp_path) + assert _reader(store)._distilled_knowledge_context() == "" bare = AgentEngine.__new__(AgentEngine) bare._knowledge_store = None - bare._knowledge_store_unavailable = False + bare._knowledge_store_unavailable = True bare._environment_fingerprint_id = "" - bare._settings = SimpleNamespace(distilled_knowledge_limit=12, profile_layout=None) - assert bare._distilled_knowledge_context() == "", "no profile layout must degrade, not fail" - + bare._settings = SimpleNamespace(distilled_knowledge_limit=12) + assert bare._distilled_knowledge_context() == "", "no store must degrade, not fail" + _events_store.close() -def test_a_corrupt_store_degrades_context_rather_than_failing_a_turn(tmp_path): - """Distilled knowledge is an improvement to context, so absence costs quality only.""" - path = tmp_path / "bad.json" - path.write_text("{not json", encoding="utf-8") - store = JsonDistilledKnowledgeStore(path) - assert store.count() == 0 - assert _reader(store)._distilled_knowledge_context() == "" - - -def test_the_reader_binds_itself_rather_than_depending_on_another_path(tmp_path): - """The adaptive loop builds an equivalent store, but only when resolving a capability. - - Relying on it would make knowledge appear or vanish for reasons unrelated to - knowledge -- so this layer resolves its own reader. - """ +def test_the_reader_uses_the_injected_event_projection(tmp_path): + """The hot path reads a shared projection and never opens a parallel JSON store.""" + _events_store, store = _knowledge( + tmp_path, + _verdict("rebind", "chat.reply", "the control is Dispatch", target="chat_v2"), + ) engine = AgentEngine.__new__(AgentEngine) engine._knowledge_store = None engine._knowledge_store_unavailable = False engine._environment_fingerprint_id = "" engine._settings = SimpleNamespace( distilled_knowledge_limit=12, - distilled_knowledge_ttl_s=0.0, workspace_root=str(tmp_path), - profile_layout=SimpleNamespace(distilled_knowledge_path=tmp_path / "dk.json"), - ) - - store = engine._resolve_knowledge_store() - assert store is not None - assert engine._environment_fingerprint_id, "the current environment must be known" - assert engine._resolve_knowledge_store() is store, "bound once, not per turn" - - -# ── the driver writes it, and writes it whatever else happened ────────────────── - - -class _Teacher: - def __init__(self, verdicts) -> None: - self._verdict = TeacherVerdict(grades=(), verdicts=tuple(verdicts)) - - async def grade_and_propose(self, trajectory, goal="", **kwargs): - return self._verdict - - -class _Intake: - def observe_result(self, result, **kwargs): - return None - - def requirements(self, *, min_count: int = 1, limit: int = 50): - return () - - -def test_a_session_that_only_absorbed_still_taught_the_next_one(tmp_path): - """The cheapest adaptation, and the one that used to leave no trace at all.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - driver = WorldModelEvolutionDriver( - teacher=_Teacher( - [ - _verdict("absorb", "chat.react", "the control moved to the overflow menu"), - _verdict("rebind", "chat.reply", "the app is v3", target="chat_reply_v3"), - ] - ), - intake=_Intake(), - knowledge_store=store, - ) - - result = asyncio.run(driver.drive([{"action": "a"}], "reply", environment=_env())) - - assert set(result.distilled) == {"chat.react", "chat.reply"} - assert result.queued_proposal_ids == (), "no code was written" - assert store.count() == 2 - assert result.to_dict()["distilled"] == list(result.distilled) - # The environment travelled with it, so a later session can see where it came from. - assert store.for_capability("chat.reply").environment_id == _env().fingerprint_id - - -def test_a_failing_store_does_not_fail_the_session(tmp_path): - """Distillation improves the next session; it must never break this one.""" - - class _Broken: - def record_all(self, verdicts, **kwargs): - raise OSError("disk full") - - driver = WorldModelEvolutionDriver( - teacher=_Teacher([_verdict("absorb", "chat.react", "moved")]), - intake=_Intake(), - knowledge_store=_Broken(), - ) - - result = asyncio.run(driver.drive([{"action": "a"}], "reply")) - assert result.distilled == () - assert len(result.verdicts) == 1, "the verdict is still reported" - - -def test_a_driver_without_a_store_still_grades(tmp_path): - driver = WorldModelEvolutionDriver( - teacher=_Teacher([_verdict("absorb", "chat.react", "moved")]), intake=_Intake() - ) - result = asyncio.run(driver.drive([{"action": "a"}], "reply")) - assert result.distilled == () and len(result.verdicts) == 1 - - -# ── review findings: the invariants that keep the whitelist and the set honest ─ - - -def test_the_persisted_fields_and_the_record_agree_exactly(tmp_path): - """Bound in both directions, because each direction has its own failure. - - A field the dataclass has and the whitelist lacks is the historical silent drop: the - value is written nowhere and reads back as a default, with nothing raised. An entry in - the whitelist with no matching field is the mirror image -- it claims to persist - something that never existed, which is how a whitelist stops being trustworthy. - ``"environment"`` was exactly that, left over from considering whether to store the - whole fingerprint. - """ - from leapflow.storage.distilled_knowledge_store import _ENTRY_FIELDS - - assert set(DistilledKnowledge("chat.reply", "k").to_dict()) == _ENTRY_FIELDS - - # And the binding has to hold through a real round trip, not just in the abstract. - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - _verdict("rebind", "chat.reply", "the control is Dispatch", target="v3"), - environment=_env().to_dict(), ) - reloaded = JsonDistilledKnowledgeStore(tmp_path / "dk.json").for_capability("chat.reply") - assert reloaded.target == "v3" - assert reloaded.environment_id == _env().fingerprint_id - assert reloaded.action == "rebind" - - -def test_supersession_bounds_the_store_by_the_capability_count(tmp_path): - """The answer to "does this grow unbounded on the hot path": it cannot. - - One live entry per capability, so the ceiling is the number of capabilities the - system has -- not the number of sessions it has run. Measured at 200 entries, - ``live()`` costs single-digit microseconds, which is why no sweep or index is needed. - """ - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - for round_number in range(50): - store.record(_verdict("absorb", "chat.reply", f"conclusion {round_number}")) - - assert store.count() == 1 - assert store.for_capability("chat.reply").knowledge == "conclusion 49" - - -def test_every_retry_owned_class_is_one_a_classifier_emits(): - """A member with no producer claims to filter something never seen. - - ``"rate_limit"`` was in the set with no producer anywhere in the engine. Harmless in - effect, and corrosive in meaning: the set is supposed to read as a statement about - which failures the retry layer owns, and an invented member makes it fiction. - """ - import re - from pathlib import Path as _Path - from leapflow.learning.capability_observation import RETRY_OWNED_FAILURE_CLASSES + engine.set_distilled_knowledge_store(store) - engine_dir = _Path(__file__).resolve().parent.parent / "src" / "leapflow" / "engine" - emitted = set() - for path in engine_dir.rglob("*.py"): - emitted.update(re.findall(r'"([a-z_]+)"', path.read_text(encoding="utf-8"))) - - missing = RETRY_OWNED_FAILURE_CLASSES - emitted - assert not missing, f"no classifier emits: {sorted(missing)}" + assert engine._resolve_knowledge_store() is store + assert "chat.reply" in engine._distilled_knowledge_context() + assert engine._rebind_preferences() == (("chat.reply", "chat_v2"),) + _events_store.close() def test_an_unknown_action_still_discloses_its_recommendation(tmp_path): """A phrase table, so a fifth action loses nothing while its phrase is missing.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - SimpleNamespace( - capability="chat.reply", - knowledge="something changed", - action="a_future_action", - verdict_id="adv-x", - confidence=0.5, - rationale="", - target="do the thing", - created_at=1.0, + events = _events(tmp_path) + events.append( + EvolutionEvent.create( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + context=EvolutionContext(profile_id="p", decision_id="adv-x"), + payload={ + "capability": "chat.reply", + "knowledge": "something changed", + "action": "a_future_action", + "verdict_id": "adv-x", + "confidence": 0.5, + "target": "do the thing", + "created_at": 1.0, + }, + producer="test", + dedup_key="teacher.verdict_recorded:adv-x", ) ) + store = EvolutionDistilledKnowledgeStore(events, profile_id="p") + store.refresh() block = _reader(store)._distilled_knowledge_context() assert "do the thing" in block, "an unmapped action must not drop its target" - - -def test_a_persistent_lookup_failure_costs_one_attempt_not_one_per_turn(tmp_path): - """The context layer runs every turn, so a failing lookup must not retry every turn.""" - engine = AgentEngine.__new__(AgentEngine) - engine._knowledge_store = None - engine._knowledge_store_unavailable = False - engine._environment_fingerprint_id = "" - engine._settings = SimpleNamespace( - distilled_knowledge_limit=12, - distilled_knowledge_ttl_s=0.0, - workspace_root=str(tmp_path), - profile_layout=SimpleNamespace( - distilled_knowledge_path=property(lambda self: 1 / 0) # raises on access - ), - ) - - assert engine._resolve_knowledge_store() is None - assert engine._knowledge_store_unavailable is True - assert engine._distilled_knowledge_context() == "" + events.close() diff --git a/tests/test_distilled_preference.py b/tests/test_distilled_preference.py index fd7c6afd..537d79d1 100644 --- a/tests/test_distilled_preference.py +++ b/tests/test_distilled_preference.py @@ -21,6 +21,8 @@ from leapflow.domain.adaptation_verdict import AdaptationVerdict from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.domain.environment_fingerprint import EnvironmentFingerprint +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent from leapflow.domain.platform import Capability, PlatformID, PlatformManifest from leapflow.plugins.capability_resolver import ( _DEFAULT_SCORERS, @@ -30,7 +32,29 @@ EnvironmentAffordanceScorer, ResolverContext, ) -from leapflow.storage.distilled_knowledge_store import JsonDistilledKnowledgeStore +from leapflow.storage.distilled_knowledge_store import EvolutionDistilledKnowledgeStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + + +def _seed(events: DuckDBEvolutionEventStore, verdict: AdaptationVerdict, seq: int = 0) -> None: + events.append( + EvolutionEvent.create( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + context=EvolutionContext(profile_id="p", decision_id=verdict.verdict_id), + payload=verdict.to_dict(), + producer="test", + dedup_key=f"teacher.verdict_recorded:{verdict.verdict_id}:{seq}", + ) + ) + + +def _knowledge(tmp_path, *verdicts: AdaptationVerdict): + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + for index, verdict in enumerate(verdicts): + _seed(events, verdict, index) + store = EvolutionDistilledKnowledgeStore(events, profile_id="p") + store.refresh() + return events, store def _env(*affordances: str) -> EnvironmentFingerprint: @@ -73,49 +97,56 @@ def test_only_rebind_verdicts_become_selection_preferences(tmp_path): Admitting either would turn an instruction to a human into a machine's selection preference, which is the one direction this channel must never go. """ - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( + events, store = _knowledge( + tmp_path, AdaptationVerdict.create( "rebind", "chat.reply", "the app is now v2", target="chat_reply_v2_native" - ) - ) - store.record(AdaptationVerdict.create("absorb", "chat.react", "the control moved")) - store.record( + ), + AdaptationVerdict.create("absorb", "chat.react", "the control moved"), AdaptationVerdict.create( "escalate", "drive.upload", "refused", target="grant the drive.file scope" - ) + ), ) assert store.rebind_preferences() == (("chat.reply", "chat_reply_v2_native"),) + events.close() def test_a_rebind_without_a_target_is_not_a_preference(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record(AdaptationVerdict.create("rebind", "chat.reply", "something moved")) + events, store = _knowledge( + tmp_path, + AdaptationVerdict.create("rebind", "chat.reply", "something moved"), + ) assert store.rebind_preferences() == () + events.close() def test_a_preference_retires_with_the_knowledge_behind_it(tmp_path): """Nothing to unlearn: the entry stops being read when it stops being true.""" - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - AdaptationVerdict.create("rebind", "chat.reply", "v2 now", target="chat_reply_v2") + events, store = _knowledge( + tmp_path, + AdaptationVerdict.create("rebind", "chat.reply", "v2 now", target="chat_reply_v2"), ) assert store.rebind_preferences() store.retract("chat.reply", reason="observed working again") assert store.rebind_preferences() == () + events.close() def test_a_newer_verdict_supersedes_the_preference(tmp_path): - store = JsonDistilledKnowledgeStore(tmp_path / "dk.json") - store.record( - AdaptationVerdict.create("rebind", "chat.reply", "v2 now", target="chat_reply_v2") - ) - store.record( - AdaptationVerdict.create("rebind", "chat.reply", "v3 now", target="chat_reply_v3") + import time + + events, store = _knowledge( + tmp_path, + AdaptationVerdict.create("rebind", "chat.reply", "v2 now", target="chat_reply_v2"), + AdaptationVerdict.create( + "rebind", "chat.reply", "v3 now", target="chat_reply_v3", + created_at=time.time() + 10, + ), ) assert store.rebind_preferences() == (("chat.reply", "chat_reply_v3"),) + events.close() # ── preference, not gate ────────────────────────────────────────────────────── @@ -190,8 +221,9 @@ def test_the_engine_reads_preferences_per_resolution_not_once(): """ from leapflow.engine.engine import AgentEngine - tmp = Path(tempfile.mkdtemp()) - store = JsonDistilledKnowledgeStore(tmp / "dk.json") + events = DuckDBEvolutionEventStore(Path(tempfile.mkdtemp()) / "events.duckdb") + store = EvolutionDistilledKnowledgeStore(events, profile_id="p") + store.refresh() engine = AgentEngine.__new__(AgentEngine) engine._knowledge_store = store engine._knowledge_store_unavailable = False @@ -199,12 +231,15 @@ def test_the_engine_reads_preferences_per_resolution_not_once(): engine._settings = SimpleNamespace(distilled_knowledge_limit=12) assert engine._rebind_preferences() == () - store.record( - AdaptationVerdict.create("rebind", "chat.reply", "v2 now", target="chat_reply_v2") + _seed( + events, + AdaptationVerdict.create("rebind", "chat.reply", "v2 now", target="chat_reply_v2"), ) + store.refresh() assert engine._rebind_preferences() == (("chat.reply", "chat_reply_v2"),) store.retract("chat.reply") assert engine._rebind_preferences() == () + events.close() def test_a_failing_store_costs_a_preference_not_a_resolution(): diff --git a/tests/test_durable_teacher.py b/tests/test_durable_teacher.py new file mode 100644 index 00000000..d9755cd4 --- /dev/null +++ b/tests/test_durable_teacher.py @@ -0,0 +1,427 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Durability and isolation contracts for session-finalized teacher work.""" +from __future__ import annotations + +from pathlib import Path + +import pytest + +from leapflow.domain.adaptation_verdict import AdaptationVerdict +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent +from leapflow.evolution.artifact_store import ContentAddressedArtifactStore +from leapflow.evolution.outbox import EvolutionEventOutbox +from leapflow.evolution.session_finalizer import SessionFinalizer +from leapflow.evolution.teacher_worker import DurableTeacherWorker +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.distilled_knowledge_store import EvolutionDistilledKnowledgeStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore +from leapflow.world_model.trajectory_grader import ActionGrade, TeacherVerdict + + +def _action_events(session_id: str, action_id: str, *, workspace_id: str = "ws-1"): + context = EvolutionContext.create( + profile_id="profile-1", + workspace_id=workspace_id, + session_id=session_id, + action_id=action_id, + turn_id="turn-1", + frame_id="frame-1", + ) + started = EvolutionEvent.create( + EvolutionEventType.ACTION_STARTED, + context=context, + payload={ + "action_type": "tool", + "action_name": "file_read", + "goal": "inspect the repository", + }, + producer="test", + dedup_key=f"action.started:{action_id}", + ) + completed = EvolutionEvent.create( + EvolutionEventType.ACTION_COMPLETED, + context=context.with_ids(causation_id=started.event_id), + payload={"ok": True, "result": {"files": 2}}, + producer="test", + dedup_key=f"action.completed:{action_id}", + ) + return started, completed + + +class _Teacher: + def __init__( + self, + error: BaseException | None = None, + *, + action: str = "absorb", + ) -> None: + self.error = error + self.action = action + self.calls: list[tuple[list[dict], str]] = [] + + async def grade_and_propose( + self, + trajectory, + goal="", + *, + degraded_capabilities=(), + raise_on_error=False, + ): + self.calls.append((list(trajectory), str(goal))) + if self.error is not None: + raise self.error + return TeacherVerdict( + grades=(ActionGrade("", 0.8, False, "helpful"),), + verdicts=( + AdaptationVerdict.create( + self.action, + "repository.inspect", + "The environment requires repository inspection adaptation.", + confidence=0.9, + ), + ), + raw_payload={"source": "teacher-test"}, + ) + + +@pytest.mark.asyncio +async def test_finalizer_is_idempotent_and_session_scoped(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + outbox = EvolutionEventOutbox(store, flush_interval_s=0.001) + first = _action_events("session-a", "action-a") + second = _action_events("session-b", "action-b", workspace_id="ws-2") + await outbox.publish(first[0]) + await outbox.publish(first[1]) + await outbox.publish(second[0]) + await outbox.publish(second[1]) + finalizer = SessionFinalizer(store, outbox) + + result = await finalizer.finalize( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + reason="manual", + ) + repeated = await finalizer.finalize( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + reason="manual", + ) + + assert result.queued is True + assert result.evidence_count == 2 + assert repeated.queued is False + job = store.teacher_job(result.job_id) + assert job is not None + assert job["session_id"] == "session-a" + assert job["workspace_id"] == "ws-1" + assert store.latest_evidence_sequence( + profile_id="profile-1", session_id="session-b" + ) > 0 + await outbox.close() + store.close() + + +@pytest.mark.asyncio +async def test_teacher_worker_persists_one_call_result_and_verdict(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + outbox = EvolutionEventOutbox(store, flush_interval_s=0.001) + started, completed = _action_events("session-a", "action-a") + await outbox.publish(started) + await outbox.publish(completed) + finalization = await SessionFinalizer(store, outbox).finalize( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + ) + teacher = _Teacher() + artifacts = ContentAddressedArtifactStore(tmp_path / "artifacts") + knowledge = EvolutionDistilledKnowledgeStore(store, profile_id="profile-1") + worker = DurableTeacherWorker( + store=store, + artifact_store=artifacts, + teacher=teacher, + profile_id="profile-1", + retry_backoff_s=0, + knowledge_projection=knowledge, + ) + + outcome = await worker.run_once() + + assert outcome is not None and outcome.status == "COMPLETED" + assert len(teacher.calls) == 1 + assert teacher.calls[0][1] == "inspect the repository" + job = store.teacher_job(finalization.job_id) + assert job is not None and job["status"] == "COMPLETED" + assert artifacts.get_bytes(job["result_artifact_id"]) + event_types = [ + record.event.event_type + for record in store.read( + profile_id="profile-1", + correlation_id=finalization.episode_id, + ) + ] + assert EvolutionEventType.TEACHER_GRADED in event_types + assert EvolutionEventType.TEACHER_VERDICT_RECORDED in event_types + assert knowledge.for_capability("repository.inspect") is not None + assert worker.metrics.claim_latency.count == 1 + assert worker.metrics.job_latency.count == 1 + await outbox.close() + store.close() + + +def test_expired_teacher_lease_is_reclaimed_and_stale_owner_cannot_complete( + tmp_path: Path, +) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many(_action_events("session-a", "action-a")) + episode_id, job_id = store.finalize_session( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + + first = store.claim_teacher_job(lease_owner="worker-1", lease_seconds=5, now=10) + assert first is not None and first["episode_id"] == episode_id + assert first["attempts"] == 1 + assert store.claim_teacher_job(lease_owner="worker-2", lease_seconds=5, now=14) is None + second = store.claim_teacher_job(lease_owner="worker-2", lease_seconds=5, now=16) + assert second is not None and second["attempts"] == 2 + assert store.complete_teacher_job(job_id, lease_owner="worker-1") is False + assert store.complete_teacher_job(job_id, lease_owner="worker-2") is True + store.close() + + +@pytest.mark.asyncio +async def test_internal_teacher_defect_is_not_retried(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many(_action_events("session-a", "action-a")) + _, job_id = store.finalize_session( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + worker = DurableTeacherWorker( + store=store, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + teacher=_Teacher(TypeError("local bug")), + profile_id="profile-1", + retry_backoff_s=0, + ) + + outcome = await worker.run_once() + + assert outcome is not None and outcome.status == "FAILED_FINAL" + assert store.teacher_job(job_id)["status"] == "FAILED_FINAL" + failures = store.read( + profile_id="profile-1", + event_type=EvolutionEventType.TEACHER_JOB_FAILED, + ) + assert len(failures) == 1 + assert failures[0].event.payload["error_type"] == "TypeError" + store.close() + + +@pytest.mark.asyncio +async def test_background_worker_wakes_and_completes_queued_job(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + outbox = EvolutionEventOutbox(store, flush_interval_s=0.001) + store.append_many(_action_events("session-a", "action-a")) + finalization = await SessionFinalizer(store, outbox).finalize( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + ) + teacher = _Teacher() + worker = DurableTeacherWorker( + store=store, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + teacher=teacher, + profile_id="profile-1", + poll_interval_s=10, + ) + worker.start() + worker.wake() + + job = await worker.wait_for_job(finalization.job_id, timeout_s=2) + + assert job["status"] == "COMPLETED" + assert len(teacher.calls) == 1 + await worker.close() + await outbox.close() + store.close() + + +@pytest.mark.asyncio +async def test_acquire_verdict_queues_one_visible_proposal(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many(_action_events("session-a", "action-a")) + _, job_id = store.finalize_session( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + queue = EvolutionCapabilityProposalStore(store, profile_id="profile-1") + worker = DurableTeacherWorker( + store=store, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + teacher=_Teacher(action="acquire"), + profile_id="profile-1", + proposal_queue=queue, + acquisition_resolver=lambda intent, job: { + "resolved": True, + "satisfied": False, + "reason": "no eligible capability provider", + "environment": { + "workspace_id": job["workspace_id"], + "session_id": job["session_id"], + }, + }, + ) + + outcome = await worker.run_once() + + assert outcome is not None and outcome.status == "COMPLETED" + proposals = queue.list_items() + assert len(proposals) == 1 + assert proposals[0].requirements[0]["capability"] == "repository.inspect" + assert proposals[0].requirements[0]["requirement_id"] == "req-wm-repository.inspect" + resolutions = store.read( + profile_id="profile-1", + event_type=EvolutionEventType.REQUIREMENT_RESOLVED, + ) + assert len(resolutions) == 1 + assert resolutions[0].event.payload["outcome"] == "unmet" + assert resolutions[0].event.context.proposal_id == proposals[0].proposal_id + job = store.teacher_job(job_id) + assert job is not None and job["status"] == "COMPLETED" + store.close() + + +@pytest.mark.asyncio +async def test_acquire_verdict_is_no_op_when_live_capability_resolves(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many(_action_events("session-a", "action-a")) + store.finalize_session( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + queue = EvolutionCapabilityProposalStore(store, profile_id="profile-1") + worker = DurableTeacherWorker( + store=store, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + teacher=_Teacher(action="acquire"), + profile_id="profile-1", + proposal_queue=queue, + acquisition_resolver=lambda intent, job: { + "resolved": True, + "satisfied": True, + "reason": "selected existing provider", + "selected_plugin_id": "repository_builtin", + "selected_tool_name": "file_read", + "environment": {}, + }, + ) + + outcome = await worker.run_once() + + assert outcome is not None and outcome.status == "COMPLETED" + assert queue.list_items() == [] + resolutions = store.read( + profile_id="profile-1", + event_type=EvolutionEventType.REQUIREMENT_RESOLVED, + ) + assert len(resolutions) == 1 + assert resolutions[0].event.payload["outcome"] == "satisfied" + assert resolutions[0].event.payload["reason"] == "capability_already_available" + store.close() + + +@pytest.mark.asyncio +async def test_acquire_verdict_fails_closed_without_live_resolution(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many(_action_events("session-a", "action-a")) + store.finalize_session( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + queue = EvolutionCapabilityProposalStore(store, profile_id="profile-1") + worker = DurableTeacherWorker( + store=store, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + teacher=_Teacher(action="acquire"), + profile_id="profile-1", + proposal_queue=queue, + ) + + await worker.run_once() + + assert queue.list_items() == [] + resolution = store.read( + profile_id="profile-1", + event_type=EvolutionEventType.REQUIREMENT_RESOLVED, + )[0].event + assert resolution.payload["outcome"] == "no_op" + assert resolution.payload["reason"] == "live_resolution_unavailable" + store.close() + + +@pytest.mark.asyncio +async def test_retryable_teacher_failure_exhausts_configured_attempts(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many(_action_events("session-a", "action-a")) + _, job_id = store.finalize_session( + profile_id="profile-1", + workspace_id="ws-1", + session_id="session-a", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + worker = DurableTeacherWorker( + store=store, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + teacher=_Teacher(OSError("provider unavailable")), + profile_id="profile-1", + max_attempts=2, + retry_backoff_s=0, + ) + + first = await worker.run_once() + second = await worker.run_once() + + assert first is not None and first.status == "FAILED_RETRYABLE" + assert second is not None and second.status == "FAILED_FINAL" + assert store.teacher_job(job_id)["attempts"] == 2 + assert len( + store.read( + profile_id="profile-1", + event_type=EvolutionEventType.TEACHER_JOB_FAILED, + ) + ) == 2 + store.close() diff --git a/tests/test_effect_scope.py b/tests/test_effect_scope.py index c964b0bd..441af8e0 100644 --- a/tests/test_effect_scope.py +++ b/tests/test_effect_scope.py @@ -390,7 +390,9 @@ def test_subscribe_with_scope_auto_unsubscribes_on_dispose(self) -> None: scope = EffectScope("sub_scope") called: list = [] - cb = lambda event: called.append(event) + + def cb(event): + called.append(event) bus.subscribe(cb, scope=scope) assert id(cb) in bus._subscribers @@ -405,7 +407,9 @@ def test_subscribe_without_scope_survives_unrelated_dispose(self) -> None: bus._subscribers = {} scope = EffectScope("unrelated") - cb = lambda event: None + + def cb(event): + return None bus.subscribe(cb) # no scope scope.dispose() @@ -418,9 +422,15 @@ def test_multiple_scope_bound_subs_cleaned_together(self) -> None: bus._subscribers = {} scope = EffectScope("shared") - cb1 = lambda e: None - cb2 = lambda e: None - cb3 = lambda e: None # unbound + + def cb1(event): + return None + + def cb2(event): + return None + + def cb3(event): # unbound + return None bus.subscribe(cb1, scope=scope) bus.subscribe(cb2, scope=scope) diff --git a/tests/test_environment_source.py b/tests/test_environment_source.py new file mode 100644 index 00000000..1fff9695 --- /dev/null +++ b/tests/test_environment_source.py @@ -0,0 +1,128 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Contracts for daemon-native task-environment observation.""" +from __future__ import annotations + +import asyncio +import json +from pathlib import Path + +import pytest + +from leapflow.domain.environment_signal import EnvironmentObservation, InterfaceSnapshot +from leapflow.perception.environment_source import EnvironmentSourceManager +from leapflow.perception.leapspace_source import LeapSpaceEnvironmentSource + + +def _write_state(root: Path, *, version: str, affordances: list[str], enabled: bool = True) -> None: + app_dir = root / "chat" + app_dir.mkdir(parents=True, exist_ok=True) + (app_dir / "state.json").write_text( + json.dumps( + { + "app_id": "chat", + "version": version, + "affordances": affordances, + "elements": [{"name": "send", "role": "QPushButton", "enabled": enabled}], + "data": {"draft": "value that must not define structural drift"}, + } + ) + ) + + +def test_interface_delta_uses_structure_not_mutable_app_data() -> None: + before = InterfaceSnapshot.create( + source_id="leapspace", + app_id="chat", + affordances=("chat.send.v1",), + elements=({"name": "send", "role": "button", "enabled": True},), + data={"draft": "one"}, + ) + data_only = InterfaceSnapshot.create( + source_id="leapspace", + app_id="chat", + affordances=("chat.send.v1",), + elements=({"name": "send", "role": "button", "enabled": True},), + data={"draft": "two"}, + ) + changed = InterfaceSnapshot.create( + source_id="leapspace", + app_id="chat", + version="2", + affordances=("chat.send.v2",), + elements=({"name": "submit", "role": "button", "enabled": True},), + ) + + assert EnvironmentObservation.between(before, data_only) is None + delta = EnvironmentObservation.between(before, changed) + assert delta is not None and delta.is_structural + assert delta.removed_affordances == ("chat.send.v1",) + assert delta.capability_results()[0]["capability"] == "chat.send.v1" + + +def test_leapspace_source_emits_snapshot_delta_and_ground_truth_once(tmp_path: Path) -> None: + _write_state(tmp_path, version="1", affordances=["chat.send.v1"]) + source = LeapSpaceEnvironmentSource( + tmp_path, + workspace_id="ws-1", + session_id="session-1", + ) + + initial = source._scan() + assert len(initial) == 1 and initial[0].kind == "snapshot" + + _write_state(tmp_path, version="2", affordances=["chat.send.v2"]) + delta = source._scan() + assert len(delta) == 1 and delta[0].kind == "delta" + assert delta[0].session_id == "session-1" + + result_dir = tmp_path / "task-1" + result_dir.mkdir() + (result_dir / "result.json").write_text( + json.dumps({"task_id": "task-1", "outcome": "FAIL", "capability": "chat.send.v2"}) + ) + outcome = source._scan() + assert len(outcome) == 1 and outcome[0].outcome == "FAIL" + assert outcome[0].capability_results()[0]["error_type"] == "task_outcome_failed" + assert source._scan() == () + + +@pytest.mark.asyncio +async def test_environment_source_manager_owns_source_lifecycle() -> None: + received: list[EnvironmentObservation] = [] + + class _Source: + source_id = "test-source" + + def __init__(self) -> None: + self.stopped = asyncio.Event() + + async def start(self, emit) -> None: + await emit( + EnvironmentObservation.task_outcome( + source_id=self.source_id, + task_id="task-1", + outcome="PASS", + session_id="session-1", + ) + ) + await self.stopped.wait() + + async def stop(self) -> None: + self.stopped.set() + + async def sink(observation: EnvironmentObservation) -> None: + received.append(observation) + + source = _Source() + manager = EnvironmentSourceManager(sink, shutdown_timeout_s=1) + manager.register(source) + await manager.start() + for _ in range(20): + if received: + break + await asyncio.sleep(0.01) + await manager.close() + + assert manager.source_ids == ("test-source",) + assert [item.outcome for item in received] == ["PASS"] + assert source.stopped.is_set() diff --git a/tests/test_evolution_event_store.py b/tests/test_evolution_event_store.py new file mode 100644 index 00000000..73a9ceb8 --- /dev/null +++ b/tests/test_evolution_event_store.py @@ -0,0 +1,378 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Contract tests for the append-only evolution evidence foundation.""" +from __future__ import annotations + +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path + +import duckdb +import pytest + +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent +from leapflow.evolution.action_recorder import ActionRecorder, sanitize_evidence +from leapflow.evolution.artifact_store import ArtifactIntegrityError, ContentAddressedArtifactStore +from leapflow.evolution.outbox import ( + EvolutionEventOutbox, + EvolutionOutboxClosed, + EvolutionOutboxWriteError, +) +from leapflow.layout import ProfileLayout +from leapflow.storage.connection import LocalConnectionHolder +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore +from leapflow.storage.schema import CURRENT_SCHEMA_VERSION, ensure_schema + + +def _context(*, session: str = "s1", action: str = "a1") -> EvolutionContext: + return EvolutionContext.create( + profile_id="p1", + workspace_id="w1", + session_id=session, + turn_id="t1", + frame_id="f1", + action_id=action, + ) + + +def _event(kind: str = "action.started", *, session: str = "s1", action: str = "a1"): + return EvolutionEvent.create( + kind, + context=_context(session=session, action=action), + payload={"ok": True}, + producer="test", + dedup_key=f"{kind}:{session}:{action}", + ) + + +def test_context_mints_one_correlation_id_and_preserves_it_on_updates() -> None: + context = _context() + changed = context.with_ids(causation_id="evt-parent", proposal_id="prop-1") + + assert context.correlation_id.startswith("evo-") + assert changed.correlation_id == context.correlation_id + assert changed.causation_id == "evt-parent" + assert changed.proposal_id == "prop-1" + assert context.causation_id == "" + + +def test_event_payload_hash_and_dedup_are_deterministic() -> None: + context = EvolutionContext(profile_id="p", session_id="s", correlation_id="c") + first = EvolutionEvent.create( + "environment.observed", context=context, payload={"b": 2, "a": 1}, producer="test" + ) + second = EvolutionEvent.create( + "environment.observed", context=context, payload={"a": 1, "b": 2}, producer="test" + ) + + assert first.payload_hash == second.payload_hash + assert first.dedup_key == second.dedup_key + assert first.event_id != second.event_id + + +def test_event_round_trip_preserves_context_and_payload() -> None: + event = _event() + restored = EvolutionEvent.from_dict(event.to_dict()) + assert restored == event + + +def test_store_appends_and_deduplicates(tmp_path: Path) -> None: + holder = LocalConnectionHolder(tmp_path / "events.duckdb") + store = DuckDBEvolutionEventStore(holder) + event = _event() + + assert store.append(event) is True + assert store.append(event) is False + assert store.count(profile_id="p1") == 1 + assert store.latest_sequence(profile_id="p1") == 1 + records = store.read(profile_id="p1") + assert [record.sequence for record in records] == [1] + assert [record.event for record in records] == [event] + holder.close() + + +def test_store_batches_atomically_and_keeps_causal_order(tmp_path: Path) -> None: + holder = LocalConnectionHolder(tmp_path / "events.duckdb") + store = DuckDBEvolutionEventStore(holder) + events = [ + _event("action.started", action="a1"), + _event("action.completed", action="a1"), + _event("action.started", session="s2", action="a2"), + ] + + assert store.append_many(events) == 3 + assert store.append_many(events) == 0 + assert [ + record.event.event_type + for record in store.read(profile_id="p1", session_id="s1") + ] == ["action.started", "action.completed"] + assert store.latest_sequence(profile_id="p1") == 3 + holder.close() + + +def test_store_filters_by_correlation_and_type(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + first = _event("action.started") + second = EvolutionEvent.create( + "teacher.verdict_recorded", + context=first.context, + payload={"action": "absorb"}, + producer="teacher", + ) + store.append_many([first, second]) + + assert [ + record.event for record in store.read(correlation_id=first.context.correlation_id) + ] == [first, second] + assert [ + record.event for record in store.read(event_type="teacher.verdict_recorded") + ] == [second] + store.close() + + +def test_artifact_store_is_immutable_and_content_addressed(tmp_path: Path) -> None: + store = ContentAddressedArtifactStore(tmp_path / "artifacts") + first = store.put_text("same", privacy_class="session") + second = store.put_text("same", privacy_class="session") + other = store.put_text("different", privacy_class="session") + + assert first.digest == second.digest + assert first.digest != other.digest + assert store.get_text(first) == "same" + assert first.relative_path.startswith(first.digest[:2] + "/") + + +def test_artifact_store_rejects_paths_disguised_as_refs(tmp_path: Path) -> None: + store = ContentAddressedArtifactStore(tmp_path / "artifacts") + with pytest.raises(ValueError, match="SHA-256"): + store.resolve("../../secret") + + +def test_artifact_store_rejects_corrupted_content(tmp_path: Path) -> None: + store = ContentAddressedArtifactStore(tmp_path / "artifacts") + ref = store.put_text("trusted") + store.resolve(ref).write_text("tampered") + + with pytest.raises(ArtifactIntegrityError, match="digest mismatch"): + store.get_bytes(ref) + with pytest.raises(ArtifactIntegrityError, match="digest mismatch"): + store.put_text("trusted") + + +def test_profile_layout_owns_the_evolution_cas_path(tmp_path: Path) -> None: + layout = ProfileLayout(root=tmp_path / "profile", profile_id="p1") + assert layout.evolution_artifacts_dir == layout.root / "artifacts" / "sha256" + + +def test_sanitizer_redacts_secrets_and_is_structurally_bounded() -> None: + value = { + "api_key": "sk-secret-value", + "nested": {"password": "hunter2", "safe": "visible"}, + "items": list(range(40)), + "long": "x" * 1200, + } + sanitized = sanitize_evidence(value) + + assert sanitized["api_key"] == "[REDACTED]" + assert sanitized["nested"]["password"] == "[REDACTED]" + assert sanitized["nested"]["safe"] == "visible" + assert sanitized["items"][-1] == {"items_omitted": 8} + assert len(sanitized["long"]) == 1001 + + +@pytest.mark.asyncio +async def test_action_recorder_emits_linked_start_and_completion(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + outbox = EvolutionEventOutbox(store, flush_interval_s=0.001) + recorder = ActionRecorder(outbox, producer_version="test") + context = _context() + + started = await recorder.started( + context=context, + action_type="tool", + action_name="file.read", + arguments={"file_path": "/tmp/x", "token": "secret"}, + execution_policy="read_only", + critical=False, + ) + await recorder.completed( + context=context, + started_event=started, + action_type="tool", + action_name="file.read", + result={"ok": True, "content": "hello"}, + duration_ms=1.5, + ) + await outbox.flush() + + events = [record.event for record in store.read(session_id="s1")] + assert [event.event_type for event in events] == ["action.started", "action.completed"] + assert events[0].payload["arguments"]["token"] == "[REDACTED]" + assert events[1].context.causation_id == events[0].event_id + assert events[1].payload["ok"] is True + assert recorder.metrics.started_latency.count == 1 + assert recorder.metrics.completed_latency.count == 1 + assert outbox.metrics.publish_latency.count == 2 + assert outbox.metrics.write_latency.count >= 1 + await outbox.close() + store.close() + + +@pytest.mark.asyncio +async def test_critical_event_is_durable_before_publish_returns(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + outbox = EvolutionEventOutbox(store, critical_timeout_s=1.0) + event = _event() + + await outbox.publish(event, critical=True) + + assert store.count(profile_id="p1") == 1 + assert outbox.metrics.queued == 0 + await outbox.close() + store.close() + + +@pytest.mark.asyncio +async def test_outbox_rejects_publication_after_close(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + outbox = EvolutionEventOutbox(store) + await outbox.close() + + with pytest.raises(EvolutionOutboxClosed): + await outbox.publish(_event()) + store.close() + + +def test_schema_contains_long_running_evolution_tables(tmp_path: Path) -> None: + holder = LocalConnectionHolder(tmp_path / "schema.duckdb") + DuckDBEvolutionEventStore(holder) + tables = {row[0] for row in holder.connection.execute("SHOW TABLES").fetchall()} + assert { + "evolution_events", + "evolution_teacher_jobs", + "evolution_projections", + } <= tables + assert "evolution_proposal_work" not in tables + versions = [ + row[0] + for row in holder.connection.execute( + "SELECT version FROM _schema_version ORDER BY version" + ).fetchall() + ] + assert versions == list(range(1, CURRENT_SCHEMA_VERSION + 1)) + holder.close() + + +def test_schema_upgrades_a_v1_database_in_order(tmp_path: Path) -> None: + connection = duckdb.connect(str(tmp_path / "old.duckdb")) + connection.execute( + "CREATE TABLE _schema_version (version INTEGER NOT NULL, applied_at DOUBLE NOT NULL)" + ) + connection.execute("INSERT INTO _schema_version VALUES (1, 1.0)") + + assert ensure_schema(connection) == CURRENT_SCHEMA_VERSION + assert [ + row[0] + for row in connection.execute( + "SELECT version FROM _schema_version ORDER BY version" + ).fetchall() + ] == list(range(1, CURRENT_SCHEMA_VERSION + 1)) + assert connection.execute("SELECT nextval('evolution_event_sequence')").fetchone() == (1,) + connection.close() + + +def test_event_payload_is_deeply_immutable_and_hash_checked() -> None: + source = {"nested": {"items": [1, 2]}} + event = EvolutionEvent.create( + "environment.observed", + context=_context(), + payload=source, + producer="test", + ) + source["nested"]["items"].append(3) + + assert event.to_dict()["payload"] == {"nested": {"items": [1, 2]}} + with pytest.raises(TypeError): + event.payload["new"] = True + with pytest.raises(AttributeError): + event.payload["nested"]["items"].append(3) + with pytest.raises(ValueError, match="payload_hash"): + EvolutionEvent( + event_id="evt-bad", + event_type="environment.observed", + context=_context(), + payload={"ok": True}, + occurred_at=1.0, + producer="test", + dedup_key="bad", + payload_hash="incorrect", + ) + + +def test_database_sequence_is_unique_across_store_instances(tmp_path: Path) -> None: + holder = LocalConnectionHolder(tmp_path / "events.duckdb") + first = DuckDBEvolutionEventStore(holder) + second = DuckDBEvolutionEventStore(holder) + + def append_one(index: int) -> None: + store = first if index % 2 else second + assert store.append(_event(action=f"parallel-{index}")) is True + + with ThreadPoolExecutor(max_workers=4) as pool: + list(pool.map(append_one, range(40))) + + records = first.read(profile_id="p1", limit=100) + sequences = [record.sequence for record in records] + assert len(sequences) == 40 + assert len(set(sequences)) == 40 + assert sequences == sorted(sequences) + holder.close() + + +@pytest.mark.asyncio +async def test_outbox_saturation_uses_direct_fallback_without_loss() -> None: + class _Store: + def __init__(self) -> None: + self.events = [] + + def append(self, event: EvolutionEvent) -> bool: + self.events.append(event) + return True + + def append_many(self, events) -> int: + self.events.extend(events) + return len(events) + + store = _Store() + outbox = EvolutionEventOutbox(store, max_events=1, flush_interval_s=0.001) + + await outbox.publish(_event(action="queued")) + await outbox.publish(_event(action="fallback")) + await outbox.flush() + + assert outbox.metrics.direct_fallbacks == 1 + assert outbox.metrics.published == 2 + await outbox.close() + + +@pytest.mark.asyncio +async def test_outbox_write_failure_is_bounded_and_visible() -> None: + class _FailingStore: + def append(self, event: EvolutionEvent) -> bool: + raise OSError("disk unavailable") + + def append_many(self, events) -> int: + raise OSError("disk unavailable") + + outbox = EvolutionEventOutbox( + _FailingStore(), + max_write_attempts=2, + retry_backoff_s=0.001, + write_timeout_s=0.05, + flush_timeout_s=0.5, + ) + await outbox.publish(_event()) + + with pytest.raises(EvolutionOutboxWriteError, match="failed to persist"): + await outbox.flush() + assert outbox.metrics.failures == 1 + with pytest.raises(EvolutionOutboxWriteError): + await outbox.close() diff --git a/tests/test_evolution_governance_reachable.py b/tests/test_evolution_governance_reachable.py index 5a1a5581..7ed78d80 100644 --- a/tests/test_evolution_governance_reachable.py +++ b/tests/test_evolution_governance_reachable.py @@ -2,10 +2,9 @@ """P2(a): the evolution governance tier becomes reachable. `AdaptiveEvolutionPolicy` and `LifecycleGovernor` implement trust, probation and -quarantine. Everything they need was built and path-declared -- and orphaned: -`JsonCapabilityProposalQueue`, `JsonPluginOutcomeStore`, and both -`ProfileLayout` paths had no references outside their own modules, so nothing in -production could ever reach the machinery. +quarantine. These tests guard the production wiring after proposal and outcome +persistence moved onto the append-only evolution event stream; no profile-local +JSON queue may be required for the governance cycle. These tests cover the two halves of the fix: @@ -35,13 +34,15 @@ from leapflow.plugins.lifecycle_governor import LifecycleGovernor from leapflow.storage.capability_proposal_queue import ( CapabilityProposalItem, - JsonCapabilityProposalQueue, + EvolutionCapabilityProposalStore, ) -from leapflow.storage.plugin_outcome_store import JsonPluginOutcomeStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore +from leapflow.storage.plugin_outcome_store import EvolutionPluginOutcomeStore -def _queue(tmp_path) -> JsonCapabilityProposalQueue: - return JsonCapabilityProposalQueue(tmp_path / "lifecycle.json") +def _queue(tmp_path) -> EvolutionCapabilityProposalStore: + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + return EvolutionCapabilityProposalStore(events, profile_id="profile-1") def _requirement() -> CapabilityRequirement: @@ -56,8 +57,12 @@ def _requirement() -> CapabilityRequirement: def test_shipped_types_satisfy_the_new_protocols(tmp_path): item = CapabilityProposalItem(proposal_id="p1", status="PENDING", requirements=()) assert isinstance(item, EvolutionProposalView) - assert isinstance(_queue(tmp_path), EvolutionLifecycleStore) - assert isinstance(JsonPluginOutcomeStore(tmp_path / "o.json"), OutcomeStore) + queue = _queue(tmp_path) + assert isinstance(queue, EvolutionLifecycleStore) + assert isinstance( + EvolutionPluginOutcomeStore(queue._event_store, profile_id="profile-1"), + OutcomeStore, + ) def test_policy_accepts_any_conforming_view(): @@ -132,7 +137,9 @@ def test_review_and_lifecycle_vocabularies_are_distinct(): def test_full_governance_cycle_on_the_shipped_stores(tmp_path): """PENDING -> generate decision -> outcomes -> quarantine, all real components.""" queue = _queue(tmp_path) - outcomes = JsonPluginOutcomeStore(tmp_path / "outcomes.json") + outcomes = EvolutionPluginOutcomeStore( + queue._event_store, profile_id="profile-1" + ) trust = PluginTrustLedger() item = queue.enqueue( requirements=[_requirement()], @@ -147,8 +154,16 @@ def test_full_governance_cycle_on_the_shipped_stores(tmp_path): item, trust_level=PluginTrustLevel.DRAFT ) assert decision.action == "generate" + queue.transition(item.proposal_id, "GENERATED", generated_code_ref="sha256:test") + queue.transition( + item.proposal_id, + "APPROVED", + proposal_approval_id="approval-content", + mutation_approval_id="approval-mutation", + ) + queue.transition(item.proposal_id, "INSTALLED", install_result={"ok": True}) - # The governor transitions that same record from execution outcomes. + # The governor transitions that same installed record from execution outcomes. disabled: list[str] = [] class _Actor: @@ -176,28 +191,34 @@ async def disable(self, *, plugin_id): assert queue.get(item.proposal_id).status == "QUARANTINED" -def test_requarantined_record_is_reset_in_place_but_memory_survives_elsewhere(tmp_path): - """Re-proposing after quarantine resets the record; the safety memory does not live there. +def test_requarantined_record_remains_terminal_and_safety_memory_survives(tmp_path): + """Re-proposing the same identity cannot erase a quarantine fact. - ``proposal_id`` is a content hash of the requirement payload, so re-proposing - the same capability reuses the id and resets it to ``PENDING`` -- the - quarantine history is *overwritten* at the proposal layer rather than a second - record being created. That is safe only because the trigger the governor - actually consults lives elsewhere: the outcome store's ``failure_streak`` and - the trust ledger's freeze both persist independently, so a re-proposed plugin - does not get a clean slate where it matters. + ``proposal_id`` is a content hash of stable requirement identity. The event-sourced + store returns the terminal record instead of resetting it to ``PENDING``; a genuinely + new attempt must carry a new requirement identity and therefore preserves audit history. """ queue = _queue(tmp_path) first = queue.enqueue(requirements=[_requirement()], source="plugin_propose") - queue.update(first.proposal_id, status="QUARANTINED") + queue.transition(first.proposal_id, "GENERATED", generated_code_ref="sha256:test") + queue.transition( + first.proposal_id, + "APPROVED", + proposal_approval_id="approval-content", + mutation_approval_id="approval-mutation", + ) + queue.transition(first.proposal_id, "INSTALLED", install_result={"ok": True}) + queue.transition(first.proposal_id, "QUARANTINED") second = queue.enqueue(requirements=[_requirement()], source="plugin_propose") assert second.proposal_id == first.proposal_id # content-addressed - assert second.status == "PENDING" # reset, ready to retry - assert len(queue.list_items(limit=0)) == 1 # replaced, not appended + assert second.status == "QUARANTINED" # terminal fact is preserved + assert len(queue.list_items(limit=0)) == 1 - # The memory that gates a retry survives the reset. - outcomes = JsonPluginOutcomeStore(tmp_path / "outcomes.json") + # Independent safety evidence remains queryable with the terminal proposal. + outcomes = EvolutionPluginOutcomeStore( + queue._event_store, profile_id="profile-1" + ) for _ in range(3): outcomes.add_outcome(plugin_id="p", tool_name="t", ok=False) assert outcomes.failure_streak("p") == 3 @@ -212,14 +233,10 @@ def test_requarantined_record_is_reset_in_place_but_memory_survives_elsewhere(tm def _plugin_with_stores(tmp_path): from leapflow.plugins.tool_plugins.self_management import SelfManagementPlugin - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore plugin = SelfManagementPlugin() queue = _queue(tmp_path) - plugin.bind_runtime( - plugin_proposal_store=JsonPluginProposalStore(tmp_path / "review.json"), - capability_lifecycle_store=queue, - ) + plugin.bind_runtime(capability_lifecycle_store=queue) return plugin, queue @@ -255,23 +272,19 @@ def test_plugin_propose_opens_a_correlated_lifecycle_record(tmp_path): assert decision.action == "generate" -def test_propose_still_succeeds_when_the_lifecycle_ledger_fails(tmp_path): - """Bookkeeping must never fail the proposal the caller asked for.""" +def test_propose_fails_closed_when_the_lifecycle_ledger_fails(tmp_path): + """A proposal without its sole durable lifecycle record must not escape.""" from leapflow.plugins.tool_plugins.self_management import SelfManagementPlugin - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore class _Broken: def enqueue(self, **kwargs): raise OSError("disk on fire") plugin = SelfManagementPlugin() - plugin.bind_runtime( - plugin_proposal_store=JsonPluginProposalStore(tmp_path / "review.json"), - capability_lifecycle_store=_Broken(), - ) + plugin.bind_runtime(capability_lifecycle_store=_Broken()) result = _propose(plugin, requested_capability="chat.reply", risk_level="read_only") - assert result["ok"] is True # the proposal survived - assert result["lifecycle_proposal_id"] == "" # ...and the failure is visible + assert result["ok"] is False + assert "persistence failed" in result["error"].lower() def test_lifecycle_record_carries_the_declared_risk_ceiling(tmp_path): @@ -284,18 +297,11 @@ def test_lifecycle_record_carries_the_declared_risk_ceiling(tmp_path): assert dict(record.requirements[0])["max_risk_level"] == "medium" -# ── plugin_generate bridges *both* proposal stores (G3) ─────────────────────── +# ── plugin_generate resolves canonical ids and review aliases (G3) ──────────── def test_generate_resolves_a_world_model_lifecycle_proposal(tmp_path): - """A world-model queue id must reach generation, not only a review-store id. - - The world-model driver enqueues into the lifecycle queue (``prop-``); before - the bridge, ``plugin_generate`` looked only in the review store, so Scene C could - never proceed from a real teacher verdict. This drives the resolver that closes - that gap -- no LLM needed, because it is the resolution, not the generation, under - test. - """ + """Both a canonical lifecycle id and its review alias resolve from one store.""" from leapflow.domain.capability_requirement import CapabilityRequirement plugin, queue = _plugin_with_stores(tmp_path) @@ -318,11 +324,11 @@ def test_generate_resolves_a_world_model_lifecycle_proposal(tmp_path): assert provides == ("chat.reply",) # capability preserved for generation assert description # non-empty description derived - # A review-store id still resolves as its own source, unchanged. + # A review alias resolves through metadata on the same lifecycle record. review = _propose(plugin, requested_capability="chat.send", risk_level="read_only") assert plugin._resolve_generation_source( review["proposal"]["proposal_id"] )[0] == "review" - # An id neither store knows resolves to nothing, so generate returns not-found. + # An unknown id resolves to nothing, so generation returns not-found. assert plugin._resolve_generation_source("prop-does-not-exist")[0] == "" diff --git a/tests/test_evolution_producer.py b/tests/test_evolution_producer.py index d122eb34..a7910331 100644 --- a/tests/test_evolution_producer.py +++ b/tests/test_evolution_producer.py @@ -116,8 +116,10 @@ def _install_registry(monkeypatch, registry, *, trust=None, usage=None, fibers=N """ import leapflow.plugins as plugins_pkg from leapflow.monitor import evolution_producer as mod + from leapflow.telemetry import evolution_tap monkeypatch.setattr(plugins_pkg, "get_registry", lambda: registry, raising=False) + monkeypatch.setattr(evolution_tap, "current_sink", lambda: None) monkeypatch.setattr( mod.EvolutionProducer, "_trust_and_usage", staticmethod(lambda: (trust, usage)) ) @@ -377,9 +379,12 @@ class _Obs: def unresolved(self, **_kw): return [{"observation_id": "o1"}, {"observation_id": "o2"}] - class _Queue: - def list_items(self, **_kw): - return [SimpleNamespace(status="PENDING"), SimpleNamespace(status="PROBATION")] + class _Projected(EvolutionProducer): + async def _event_projection(self, ctx): + return { + "proposals": [{"status": "PENDING"}, {"status": "PROBATION"}], + "degraded": False, + } class _Plans: def latest(self): @@ -387,7 +392,6 @@ def latest(self): stores = { "capability_observations_path": _Obs(), - "capability_proposal_queue_path": _Queue(), "capability_plans_path": _Plans(), } _install_registry(monkeypatch, _Registry({})) @@ -397,7 +401,7 @@ def latest(self): staticmethod(lambda layout_attr, *a, **k: stores.get(layout_attr)), ) - rows = _rows(_observe()[0]) + rows = _rows(_observe(_Projected())[0]) assert rows["observations"]["status"] == WIRED assert "2 open" in rows["observations"]["evidence"] assert rows["lifecycle"]["status"] == WIRED @@ -697,12 +701,12 @@ def test_unrebuildable_history_is_not_reported_as_no_activity(monkeypatch): _install_registry(monkeypatch, _Registry({})) class _Broken(EvolutionProducer): - def _episodes(self, ctx): + async def _event_projection(self, ctx): return None class _Empty(EvolutionProducer): - def _episodes(self, ctx): - return () + async def _event_projection(self, ctx): + return {} broken = asyncio.run(_Broken().observe(_ctx()))[0].payload empty = asyncio.run(_Empty().observe(_ctx()))[0].payload diff --git a/tests/test_evolution_projection.py b/tests/test_evolution_projection.py new file mode 100644 index 00000000..86925295 --- /dev/null +++ b/tests/test_evolution_projection.py @@ -0,0 +1,215 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Replay and checkpoint contracts for the evolution read model.""" +from __future__ import annotations + +from pathlib import Path + +import pytest + +from leapflow.domain.event_types import EvolutionEventType +from leapflow.domain.evolution_event import EvolutionContext, EvolutionEvent +from leapflow.evolution.projection import EvolutionProjectionRunner +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + + +def _event( + event_type: str, + *, + session_id: str, + action_id: str = "", + correlation_id: str = "", + payload: dict | None = None, +) -> EvolutionEvent: + return EvolutionEvent.create( + event_type, + context=EvolutionContext.create( + profile_id="profile-1", + workspace_id=f"workspace-{session_id}", + session_id=session_id, + action_id=action_id, + correlation_id=correlation_id, + ), + payload=payload or {}, + producer="test", + dedup_key=f"{event_type}:{session_id}:{action_id}:{correlation_id}", + ) + + +@pytest.mark.asyncio +async def test_full_rebuild_equals_incremental_projection(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many( + ( + _event(EvolutionEventType.ACTION_STARTED, session_id="s1", action_id="a1"), + _event( + EvolutionEventType.ACTION_COMPLETED, + session_id="s1", + action_id="a1", + payload={"ok": True}, + ), + ) + ) + episode_id, _ = store.finalize_session( + profile_id="profile-1", + workspace_id="workspace-s1", + session_id="s1", + session_generation=0, + from_sequence=0, + through_sequence=2, + reason="test", + ) + runner = EvolutionProjectionRunner(store) + first = await runner.project_session(profile_id="profile-1", session_id="s1") + + store.append( + _event( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + session_id="s1", + correlation_id=episode_id, + payload={ + "verdict_id": "v1", + "action": "absorb", + "capability": "repo.inspect", + "knowledge": "The existing reader is sufficient.", + "confidence": 0.9, + }, + ) + ) + incremental = await runner.project_session(profile_id="profile-1", session_id="s1") + rebuilt = await runner.project_session( + profile_id="profile-1", + session_id="s1", + rebuild=True, + ) + + assert first["summary"]["action_count"] == 1 + assert incremental == rebuilt + assert rebuilt["summary"]["by_action"]["absorb"] == 1 + assert rebuilt["episodes"][0]["capability"] == "repo.inspect" + assert runner.metrics.run_latency.count == 3 + assert runner.metrics.run_latency.p99_ms >= 0 + store.close() + + +@pytest.mark.asyncio +async def test_four_verdicts_materialize_their_distinct_read_models(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + for index, action in enumerate(("absorb", "rebind", "acquire", "escalate")): + store.append( + _event( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + session_id="s1", + correlation_id=f"episode-{index}", + payload={ + "verdict_id": f"v-{index}", + "action": action, + "capability": f"capability.{action}", + "knowledge": "retain this fact", + "rationale": "human decision required", + "confidence": 0.8, + "target": "existing_plugin", + }, + ) + ) + + projection = await EvolutionProjectionRunner(store).project_session( + profile_id="profile-1", session_id="s1" + ) + + assert projection["knowledge"][0]["capability"] == "capability.absorb" + assert projection["provider_bindings"][0]["plugin_id"] == "existing_plugin" + assert projection["proposal_candidates"][0]["capability"] == "capability.acquire" + assert projection["human_escalations"][0]["capability"] == "capability.escalate" + store.close() + + +@pytest.mark.asyncio +async def test_resolution_no_op_and_knowledge_retraction_are_projected(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many( + ( + _event( + EvolutionEventType.TEACHER_VERDICT_RECORDED, + session_id="s1", + correlation_id="episode-1", + payload={ + "verdict_id": "v-1", + "action": "absorb", + "capability": "repo.inspect", + "knowledge": "Use the repository reader.", + "confidence": 0.9, + }, + ), + _event( + EvolutionEventType.REQUIREMENT_RESOLVED, + session_id="s1", + correlation_id="episode-1", + payload={ + "requirement": {"capability": "repo.inspect"}, + "outcome": "satisfied", + "reason": "capability_already_available", + "resolution": {"selected_plugin_id": "repo_builtin"}, + }, + ), + _event( + EvolutionEventType.KNOWLEDGE_RETRACTED, + session_id="s1", + correlation_id="episode-1", + payload={"capability": "repo.inspect", "reason": "observed working"}, + ), + ) + ) + + projection = await EvolutionProjectionRunner(store).project_session( + profile_id="profile-1", session_id="s1" + ) + + assert projection["knowledge"] == [] + assert projection["summary"]["no_op_count"] == 1 + assert projection["resolutions"][0]["outcome"] == "satisfied" + assert projection["resolutions"][0]["selected_plugin_id"] == "repo_builtin" + store.close() + + +@pytest.mark.asyncio +async def test_session_projection_never_leaks_another_session(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append_many( + ( + _event(EvolutionEventType.ACTION_STARTED, session_id="s1", action_id="a1"), + _event(EvolutionEventType.ACTION_STARTED, session_id="s2", action_id="a2"), + _event( + EvolutionEventType.ENVIRONMENT_OBSERVED, + session_id="s2", + payload={"kind": "delta", "app_id": "chat"}, + ), + ) + ) + runner = EvolutionProjectionRunner(store) + + session = await runner.project_session(profile_id="profile-1", session_id="s1") + aggregate = await runner.project_aggregate(profile_id="profile-1") + + assert session["scope"] == "session" + assert session["session_id"] == "s1" + assert session["summary"]["action_count"] == 1 + assert session["summary"]["environment_count"] == 0 + assert aggregate["scope"] == "aggregate" + assert aggregate["summary"]["action_count"] == 2 + assert aggregate["summary"]["environment_count"] == 1 + store.close() + + +@pytest.mark.asyncio +async def test_projection_checkpoint_survives_runner_recreation(tmp_path: Path) -> None: + store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store.append(_event(EvolutionEventType.ACTION_STARTED, session_id="s1", action_id="a1")) + first = await EvolutionProjectionRunner(store).project_aggregate(profile_id="profile-1") + store.append(_event(EvolutionEventType.ACTION_STARTED, session_id="s1", action_id="a2")) + + resumed = await EvolutionProjectionRunner(store).project_aggregate(profile_id="profile-1") + + assert first["summary"]["event_count"] == 1 + assert resumed["summary"]["event_count"] == 2 + assert resumed["summary"]["action_count"] == 2 + store.close() diff --git a/tests/test_evolution_tap.py b/tests/test_evolution_tap.py index f6f86354..8ad86412 100644 --- a/tests/test_evolution_tap.py +++ b/tests/test_evolution_tap.py @@ -25,7 +25,10 @@ from leapflow.domain.evolution_trace import EvolutionStage, EvolutionTrace from leapflow.evolution import LedgerEvolutionSink -from leapflow.storage.evolution_trace_store import JsonEvolutionTraceStore +from leapflow.storage.evolution_event_store import ( + DuckDBEvolutionEventStore, + EvolutionTraceEventStore, +) from leapflow.telemetry import evolution_tap @@ -132,28 +135,33 @@ def append(self, traces): # ── the store ──────────────────────────────────────────────────────────────── -def test_store_round_trip_is_newest_first(tmp_path): - store = JsonEvolutionTraceStore(tmp_path / "t.json") +def test_store_round_trip_is_newest_sequence_first(tmp_path): + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store = EvolutionTraceEventStore(events, profile_id="profile-1") store.append([{"trace_id": "a", "ts": 1.0}, {"trace_id": "b", "ts": 3.0}]) store.append([{"trace_id": "c", "ts": 2.0}]) - assert [r["trace_id"] for r in store.list_traces()] == ["b", "c", "a"] + assert [r["trace_id"] for r in store.list_traces()] == ["c", "b", "a"] + events.close() -def test_store_trims_to_the_newest(tmp_path): - """Retention is a count, because the newest traces are what an incident needs.""" - store = JsonEvolutionTraceStore(tmp_path / "t.json", max_traces=3) +def test_store_limits_reads_without_trimming_event_history(tmp_path): + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store = EvolutionTraceEventStore(events, profile_id="profile-1") store.append([{"trace_id": f"t{i}", "ts": float(i)} for i in range(10)]) - kept = [r["trace_id"] for r in store.list_traces()] + kept = [r["trace_id"] for r in store.list_traces(limit=3)] assert kept == ["t9", "t8", "t7"] - assert store.count() == 3 + assert store.count() == 10 + events.close() -def test_corrupt_store_reads_as_empty_rather_than_raising(tmp_path): - path = tmp_path / "t.json" - path.write_text("{ not json", encoding="utf-8") - store = JsonEvolutionTraceStore(path) - assert store.list_traces() == [] - assert store.append([{"trace_id": "a", "ts": 1.0}]) == 1 +def test_store_deduplicates_replayed_trace_ids(tmp_path): + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + store = EvolutionTraceEventStore(events, profile_id="profile-1") + trace = {"trace_id": "a", "ts": 1.0} + assert store.append([trace]) == 1 + assert store.append([trace]) == 0 + assert store.count() == 1 + events.close() # ── probe: registry version bump ───────────────────────────────────────────── @@ -270,62 +278,6 @@ def test_the_pure_trust_ledger_gains_no_telemetry_dependency(): # ── probe: the world model's unadmitted proposals ──────────────────────────── -def test_unadmitted_intents_are_recorded_because_nothing_else_records_them(): - """The single most valuable trace: a proposal that entered no pipeline. - - It writes no observation, so without this the board shows an idle pipeline - while the world model proposes on every session. - """ - import asyncio - from dataclasses import dataclass - - from leapflow.learning.world_model_driver import WorldModelEvolutionDriver - - @dataclass - class _Intent: - intent_id: str = "wmi-1" - capability: str = "ui.chat.send" - hypothesis: str = "no way to send a chat message" - confidence: float = 0.8 - - def to_dict(self): - return { - "intent_id": self.intent_id, - "capability": self.capability, - "hypothesis": self.hypothesis, - "confidence": self.confidence, - } - - def to_observation_result(self, **_kw): - return {"error_type": "world_model_intent", "capability": self.capability} - - class _Teacher: - async def grade_and_propose(self, trajectory, goal): - return type("V", (), {"grades": (), "intents": (_Intent(),)})() - - class _RejectingIntake: - """Mirrors a profile where ``world_model_intent`` is not an accepted kind.""" - - def observe_result(self, *_a, **_kw): - return None - - def requirements(self, **_kw): - return () - - collector = _Collector() - evolution_tap.install_sink(collector) - - driver = WorldModelEvolutionDriver(teacher=_Teacher(), intake=_RejectingIntake()) - result = asyncio.run(driver.drive(trajectory=[{"step": 1}], goal="g")) - - assert result.admitted_observation_ids == () - assert _kinds(collector) == ["world_model_drive"] - detail = collector.traces[0].detail - assert detail["not_admitted_reason"] - assert detail["intents"][0]["hypothesis"] == "no way to send a chat message" - assert detail["admitted_observation_ids"] == [] - - def test_producer_surfaces_unadmitted_proposals_from_traces(): """The payload must carry the model's reasoning, not just a count.""" from leapflow.monitor.evolution_producer import EvolutionProducer diff --git a/tests/test_evolution_trigger_boundary.py b/tests/test_evolution_trigger_boundary.py index 374c2cfc..a07e8067 100644 --- a/tests/test_evolution_trigger_boundary.py +++ b/tests/test_evolution_trigger_boundary.py @@ -35,28 +35,21 @@ # ════════════════════════════════════════════════════════════════ -def _learning_phase_body() -> ast.AST: - """Return the AST of ``_on_session_end_learning``'s trajectory-grading phase.""" +def _learning_boundary_body() -> ast.AST: + """Return the AST of the durable semantic session boundary.""" tree = ast.parse(_CONTEXT_PY.read_text(encoding="utf-8")) for node in ast.walk(tree): - if isinstance(node, ast.AsyncFunctionDef) and node.name == "_on_session_end_learning": + if isinstance(node, ast.AsyncFunctionDef) and node.name == "run_learning_boundary": return node - raise AssertionError("_on_session_end_learning not found") + raise AssertionError("run_learning_boundary not found") -def test_the_governance_sweep_is_not_nested_in_the_trajectory_branch() -> None: - """The defect, asserted structurally so a refactor cannot quietly re-nest it. - - ``_run_coevolution_sweep`` documents that it "runs whether or not the teacher - proposed anything, so its no-op traces distinguish a quiet session from a sweep - that never ran". Nested inside ``if trajectory:`` it did neither, and three - reachability segments read "no sweep trace observed" on a live board for that - reason alone. - """ - phase = _learning_phase_body() - +def test_the_governance_sweep_is_not_nested_in_the_teacher_job_branch() -> None: + """A boundary with no teacher job must still leave governance evidence.""" + boundary = _learning_boundary_body() sweep_calls = [ - node for node in ast.walk(phase) + node + for node in ast.walk(boundary) if isinstance(node, ast.Call) and isinstance(node.func, ast.Attribute) and node.func.attr == "_run_coevolution_sweep" @@ -64,12 +57,11 @@ def test_the_governance_sweep_is_not_nested_in_the_trajectory_branch() -> None: assert len(sweep_calls) == 1, "the sweep must be driven from exactly one place" sweep_line = sweep_calls[0].lineno - # Any `if` whose test mentions the trajectory must not contain the sweep call. - for node in ast.walk(phase): + for node in ast.walk(boundary): if not isinstance(node, ast.If): continue test_names = {n.id for n in ast.walk(node.test) if isinstance(n, ast.Name)} - if "trajectory" not in test_names: + if not ({"jobs", "finalizations"} & test_names): continue guarded = [ child.lineno @@ -78,15 +70,16 @@ def test_the_governance_sweep_is_not_nested_in_the_trajectory_branch() -> None: if hasattr(child, "lineno") ] assert sweep_line not in guarded, ( - "the sweep is nested inside a trajectory guard again; an empty trajectory " - "would skip it and the board would report 'no sweep trace observed'" + "the sweep is nested inside teacher-work availability; a quiet boundary " + "would be indistinguishable from a sweep that never ran" ) -def test_an_empty_trajectory_still_reports_its_phase() -> None: - """The quiet path must remain observable, not silent.""" +def test_the_legacy_shutdown_only_learning_path_is_absent() -> None: + """Teacher work must be driven only by durable session finalization.""" source = _CONTEXT_PY.read_text(encoding="utf-8") - assert '"note": "empty_trajectory"' in source + assert "_on_session_end_learning" not in source + assert "_drive_world_model_evolution" not in source # ════════════════════════════════════════════════════════════════ @@ -117,16 +110,21 @@ def test_cleanup_drives_the_boundary_through_the_public_entry_point() -> None: def test_the_daemon_exposes_the_boundary_as_an_rpc() -> None: - """It has to run in the daemon: that is the process holding the trajectory.""" - from leapflow.daemon.protocol import METHOD_REGISTRY + """It has to run in the daemon: that process owns the durable event stream.""" + from leapflow.daemon.protocol import LeapService, METHOD_REGISTRY assert METHOD_REGISTRY.get("evolution.run") == "evolution_run" + signature = inspect.signature(LeapService.evolution_run) + assert signature.parameters["session_id"].default is inspect.Parameter.empty def test_the_cli_can_run_the_boundary_without_stopping_the_daemon() -> None: from leapflow.cli.commands.evolve import cmd_evolve assert callable(cmd_evolve) + source = (Path(__file__).parents[1] / "src" / "leapflow" / "cli" / "cli.py").read_text() + assert '"--session"' in source + assert "required=True" in source def test_the_trajectory_buffer_is_bounded() -> None: @@ -167,13 +165,15 @@ def producer() -> EvolutionProducer: def _run(producer: EvolutionProducer, queue: object) -> dict: - """Call the segment with a stubbed store, since the store lookup reads settings.""" - original = producer._json_store - producer._json_store = lambda *args, **kwargs: queue # type: ignore[assignment] + """Call the segment with a projection shaped from the supplied lifecycle rows.""" try: - return producer._segment_lifecycle() - finally: - producer._json_store = original # type: ignore[assignment] + proposals = [ + {"status": item.status} + for item in queue.list_items(limit=0) # type: ignore[attr-defined] + ] + except (AttributeError, OSError): + return producer._segment_lifecycle(None) + return producer._segment_lifecycle({"proposals": proposals}) def test_a_queue_that_never_advances_is_not_wired(producer: EvolutionProducer) -> None: diff --git a/tests/test_evolution_verify_and_govern.py b/tests/test_evolution_verify_and_govern.py index b093a04b..4ee71aea 100644 --- a/tests/test_evolution_verify_and_govern.py +++ b/tests/test_evolution_verify_and_govern.py @@ -125,8 +125,9 @@ def test_verdict_feeds_the_governor_and_quarantines_a_useless_artifact(tmp_path) """WM-6 + LF-10: repeated verification failure reclaims the artifact.""" from leapflow.learning.plugin_trust import PluginTrustLedger from leapflow.plugins.lifecycle_governor import LifecycleGovernor - from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue - from leapflow.storage.plugin_outcome_store import JsonPluginOutcomeStore + from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + from leapflow.storage.plugin_outcome_store import EvolutionPluginOutcomeStore disabled: list[str] = [] @@ -135,11 +136,20 @@ async def disable(self, *, plugin_id): disabled.append(plugin_id) return {"ok": True} - queue = JsonCapabilityProposalQueue(tmp_path / "q.json") + event_store = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(event_store, profile_id="profile-1") item = queue.enqueue(requirements=[_requirement()], source="test") + queue.transition(item.proposal_id, "GENERATED", generated_code_ref="sha256:test") + queue.transition( + item.proposal_id, + "APPROVED", + proposal_approval_id="approval-content", + mutation_approval_id="approval-mutation", + ) + queue.transition(item.proposal_id, "INSTALLED", install_result={"ok": True}) governor = LifecycleGovernor( proposal_queue=queue, - outcome_store=JsonPluginOutcomeStore(tmp_path / "o.json"), + outcome_store=EvolutionPluginOutcomeStore(event_store, profile_id="profile-1"), lifecycle_actor=_Actor(), trust_ledger=PluginTrustLedger(), quarantine_after=3, @@ -162,6 +172,7 @@ async def disable(self, *, plugin_id): assert actions[-1] == "quarantine" assert disabled == ["gen_useless"] # the useless artifact was reclaimed + event_store.close() # ── LF-10: the residual case the governor cannot reach ──────────────────────── diff --git a/tests/test_gateway_adapter_registry.py b/tests/test_gateway_adapter_registry.py index d6c271ca..6bb82d6c 100644 --- a/tests/test_gateway_adapter_registry.py +++ b/tests/test_gateway_adapter_registry.py @@ -11,11 +11,11 @@ import sys import types -from unittest.mock import MagicMock, patch +from unittest.mock import patch import pytest -from leapflow.gateway.adapter_registry import GatewayAdapterRegistry, BuiltinAdapterPlugin +from leapflow.gateway.adapter_registry import GatewayAdapterRegistry from leapflow.gateway.scoped_adapter_registry import ScopedGatewayAdapterRegistry from leapflow.gateway.protocol import PlatformAdapter diff --git a/tests/test_hardware_transport_contract.py b/tests/test_hardware_transport_contract.py index 1f6b1278..14950a1e 100644 --- a/tests/test_hardware_transport_contract.py +++ b/tests/test_hardware_transport_contract.py @@ -36,7 +36,7 @@ TransportStatus, WriteOutcome, ) -from leapflow.hardware.transports import available_transports, build_transport +from leapflow.hardware.transports import build_transport, builtin_transports def _conformance_context(transport_kind: str, config: dict[str, Any]) -> HardwareContext: @@ -253,7 +253,7 @@ def test_every_registered_transport_is_covered_or_declared_external() -> None: notices later. """ covered = {case.kind for case in _TRANSPORT_CASES} | _EXTERNAL_ONLY_TRANSPORTS - missing = set(available_transports()) - covered + missing = set(builtin_transports()) - covered assert not missing, ( f"transports {sorted(missing)} are registered but not conformance-tested; " "add a case to _TRANSPORT_CASES or justify it in _EXTERNAL_ONLY_TRANSPORTS" diff --git a/tests/test_inert_wiring_audit.py b/tests/test_inert_wiring_audit.py index d9d654c3..ce14143c 100644 --- a/tests/test_inert_wiring_audit.py +++ b/tests/test_inert_wiring_audit.py @@ -18,9 +18,46 @@ from typing import Any from leapflow.domain.adaptation_verdict import AdaptationVerdict +from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.learning.capability_gap_detector import CapabilityGapDetector -from leapflow.learning.degradation_sink import build_proposal_sink -from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + + +def _enqueue(queue: Any, proposal: Any) -> str: + """The acquisition chain's last hop, inlined: intent -> requirement -> queue. + + Mirrors ``DurableTeacherWorker._plan_acquisitions`` exactly -- a requirement keyed + on the capability, clamped risk, ``world_model`` source -- so the queue's dedup and + risk-clamp contract stays under test without the deleted proposal sink. + """ + evidence = tuple(getattr(proposal, "evidence", ()) or ()) + metadata = dict(getattr(evidence[0], "metadata", {})) if evidence else {} + capability = str(metadata.get("capability") or "").strip() + if not capability: + return "" + requirement = CapabilityRequirement.create( + capability, + "world_model", + evidence=str(getattr(proposal, "capability_summary", "") or capability), + max_risk_level=str(getattr(proposal, "risk_level", "read_only")), + requirement_id=f"req-wm-{capability}", + ) + try: + item = queue.enqueue( + requirements=(requirement,), + source="world_model", + risk={"max_risk_level": requirement.max_risk_level}, + ) + except Exception: # noqa: BLE001 - queueing must not fail the session + return "" + return str(getattr(item, "proposal_id", "")) + + +def _queue(tmp_path: Path) -> EvolutionCapabilityProposalStore: + return EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "events.duckdb"), profile_id="profile-1" + ) def _proposal(capability: str, *, risk: str = "read_only") -> Any: @@ -39,8 +76,8 @@ def test_an_acquire_verdict_reaches_the_proposal_queue(tmp_path): Resolution would report the capability unmet forever, so the teacher's most expensive verdict -- the only one that leads to code -- had no effect whatsoever. """ - queue = JsonCapabilityProposalQueue(tmp_path / "q.json") - identifier = build_proposal_sink(queue=queue)(_proposal("mail.send")) + queue = _queue(tmp_path) + identifier = _enqueue(queue, _proposal("mail.send")) assert identifier items = queue.list_items() @@ -57,12 +94,11 @@ def test_the_same_capability_does_not_pile_up_across_sessions(tmp_path): would face a growing pile of identical items, and the queue's depth would measure how long the process had been running rather than how much was outstanding. """ - queue = JsonCapabilityProposalQueue(tmp_path / "q.json") - sink = build_proposal_sink(queue=queue) + queue = _queue(tmp_path) - first = sink(_proposal("mail.send")) - second = sink(_proposal("mail.send")) - other = sink(_proposal("chat.reply")) + first = _enqueue(queue, _proposal("mail.send")) + second = _enqueue(queue, _proposal("mail.send")) + other = _enqueue(queue, _proposal("chat.reply")) assert first == second, "the same capability must resolve to the same proposal" assert other != first @@ -76,8 +112,8 @@ def test_the_queued_requirement_keeps_the_clamped_risk(tmp_path): to ``read_only`` enter the queue asking for everything -- the exact opposite of what the clamp exists for. """ - queue = JsonCapabilityProposalQueue(tmp_path / "q.json") - build_proposal_sink(queue=queue)(_proposal("shell.run", risk="external")) + queue = _queue(tmp_path) + _enqueue(queue, _proposal("shell.run", risk="external")) requirement = queue.list_items()[0].requirements[0] assert requirement["max_risk_level"] == "read_only", "the model cannot widen its own ask" @@ -85,10 +121,9 @@ def test_the_queued_requirement_keeps_the_clamped_risk(tmp_path): def test_a_proposal_without_a_capability_is_refused(tmp_path): """The queue has nothing to deduplicate on and resolution nothing to satisfy.""" - queue = JsonCapabilityProposalQueue(tmp_path / "q.json") - sink = build_proposal_sink(queue=queue) + queue = _queue(tmp_path) - assert sink(SimpleNamespace(evidence=(), proposal_id="p1")) == "" + assert _enqueue(queue, SimpleNamespace(evidence=(), proposal_id="p1")) == "" assert queue.list_items() == [] @@ -99,7 +134,7 @@ class _Broken: def enqueue(self, **kwargs): raise OSError("disk full") - assert build_proposal_sink(queue=_Broken())(_proposal("mail.send")) == "" + assert _enqueue(_Broken(), _proposal("mail.send")) == "" # ── the audit itself, kept honest ───────────────────────────────────────────── diff --git a/tests/test_lifecycle_governor.py b/tests/test_lifecycle_governor.py index 3f1a7f13..92458dd5 100644 --- a/tests/test_lifecycle_governor.py +++ b/tests/test_lifecycle_governor.py @@ -8,8 +8,9 @@ from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.learning.plugin_trust import PluginTrustLedger, PluginTrustLevel from leapflow.plugins.lifecycle_governor import LifecycleGovernor -from leapflow.storage.capability_proposal_queue import JsonCapabilityProposalQueue -from leapflow.storage.plugin_outcome_store import JsonPluginOutcomeStore +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore +from leapflow.storage.plugin_outcome_store import EvolutionPluginOutcomeStore class _Actor: @@ -21,7 +22,7 @@ async def disable(self, *, plugin_id: str): return {"ok": True, "action": "disable", "plugin_id": plugin_id} -def _proposal(queue: JsonCapabilityProposalQueue): +def _proposal(queue: EvolutionCapabilityProposalStore): requirement = CapabilityRequirement.create( "json.pretty", "explicit_request", @@ -33,16 +34,24 @@ def _proposal(queue: JsonCapabilityProposalQueue): risk={"risk_level": "read_only"}, metadata={"plugin_id": "json_pretty_plugin"}, ) - return queue.update(item.proposal_id, status="INSTALLED") + queue.transition(item.proposal_id, "GENERATED", generated_code_ref="sha256:test") + queue.transition( + item.proposal_id, + "APPROVED", + proposal_approval_id="approval-content", + mutation_approval_id="approval-mutation", + ) + return queue.transition(item.proposal_id, "INSTALLED", install_result={"ok": True}) @pytest.mark.asyncio async def test_lifecycle_governor_promotes_verified_after_successes(tmp_path) -> None: - queue = JsonCapabilityProposalQueue(tmp_path / "proposals.json") + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(events, profile_id="profile-1") proposal = _proposal(queue) governor = LifecycleGovernor( proposal_queue=queue, - outcome_store=JsonPluginOutcomeStore(tmp_path / "outcomes.json"), + outcome_store=EvolutionPluginOutcomeStore(events, profile_id="profile-1"), trust_ledger=PluginTrustLedger(candidate_at=1, verified_at=2, production_at=3), verified_at=PluginTrustLevel.VERIFIED, ) @@ -66,12 +75,13 @@ async def test_lifecycle_governor_promotes_verified_after_successes(tmp_path) -> @pytest.mark.asyncio async def test_lifecycle_governor_quarantines_after_failure_streak(tmp_path) -> None: - queue = JsonCapabilityProposalQueue(tmp_path / "proposals.json") + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(events, profile_id="profile-1") proposal = _proposal(queue) actor = _Actor() governor = LifecycleGovernor( proposal_queue=queue, - outcome_store=JsonPluginOutcomeStore(tmp_path / "outcomes.json"), + outcome_store=EvolutionPluginOutcomeStore(events, profile_id="profile-1"), lifecycle_actor=actor, quarantine_after=2, ) @@ -92,3 +102,34 @@ async def test_lifecycle_governor_quarantines_after_failure_streak(tmp_path) -> assert result.action == "quarantine" assert actor.disabled == ["json_pretty_plugin"] assert queue.get(proposal.proposal_id).status == "QUARANTINED" + + +@pytest.mark.asyncio +async def test_internal_defect_immediately_freezes_and_quarantines(tmp_path) -> None: + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(events, profile_id="profile-1") + proposal = _proposal(queue) + actor = _Actor() + trust = PluginTrustLedger(candidate_at=1, verified_at=2, production_at=3) + governor = LifecycleGovernor( + proposal_queue=queue, + outcome_store=EvolutionPluginOutcomeStore(events, profile_id="profile-1"), + lifecycle_actor=actor, + trust_ledger=trust, + quarantine_after=99, + ) + + result = await governor.record_outcome( + proposal_id=proposal.proposal_id, + plugin_id="json_pretty_plugin", + tool_name="json_pretty", + ok=False, + failure_class="internal_defect", + ) + + assert result.action == "quarantine" + assert trust.is_frozen("json_pretty_plugin") is True + item = queue.get(proposal.proposal_id) + assert item.status == "QUARANTINED" + assert item.trust_state["frozen"] is True + assert item.metadata["terminal_reason"] == "internal_defect" diff --git a/tests/test_llm_coevolution_e2e.py b/tests/test_llm_coevolution_e2e.py index 0bc004f2..9791c823 100644 --- a/tests/test_llm_coevolution_e2e.py +++ b/tests/test_llm_coevolution_e2e.py @@ -11,9 +11,6 @@ This is the ultimate self-evolution capability demonstration. """ -import asyncio -from pathlib import Path -from typing import Any import pytest diff --git a/tests/test_llm_provider_registry.py b/tests/test_llm_provider_registry.py index bfbde5f9..c351b8ec 100644 --- a/tests/test_llm_provider_registry.py +++ b/tests/test_llm_provider_registry.py @@ -12,7 +12,7 @@ import sys import types -from unittest.mock import MagicMock, patch +from unittest.mock import patch import pytest diff --git a/tests/test_marketplace_server.py b/tests/test_marketplace_server.py index 2b7dffc0..3ccd7f73 100644 --- a/tests/test_marketplace_server.py +++ b/tests/test_marketplace_server.py @@ -5,15 +5,12 @@ plugin manifests and code files, matching the API expected by HttpMarketplaceSource. """ -import asyncio import json from pathlib import Path -from typing import List import pytest import httpx -from leapflow.plugins.marketplace.manifest import PluginManifest from leapflow.plugins.marketplace.server import MarketplaceServer diff --git a/tests/test_performance_metrics.py b/tests/test_performance_metrics.py new file mode 100644 index 00000000..692c6da8 --- /dev/null +++ b/tests/test_performance_metrics.py @@ -0,0 +1,33 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Tests for bounded runtime latency summaries.""" +from __future__ import annotations + +from leapflow.performance import RollingLatency + + +def test_rolling_latency_reports_interpolated_percentiles() -> None: + latency = RollingLatency(capacity=5) + for value in (1, 2, 3, 4, 5): + latency.observe(value) + + snapshot = latency.snapshot() + + assert snapshot.count == 5 + assert snapshot.minimum_ms == 1 + assert snapshot.mean_ms == 3 + assert snapshot.p50_ms == 3 + assert snapshot.p95_ms == 4.8 + assert snapshot.p99_ms == 4.96 + assert snapshot.maximum_ms == 5 + + +def test_rolling_latency_is_bounded() -> None: + latency = RollingLatency(capacity=3) + for value in (1, 2, 3, 4): + latency.observe(value) + + snapshot = latency.snapshot() + + assert snapshot.count == 3 + assert snapshot.minimum_ms == 2 + assert snapshot.maximum_ms == 4 diff --git a/tests/test_phase3_learning_autonomy.py b/tests/test_phase3_learning_autonomy.py index f0544159..96650b95 100644 --- a/tests/test_phase3_learning_autonomy.py +++ b/tests/test_phase3_learning_autonomy.py @@ -592,7 +592,7 @@ class FakeSpec: policy = execution_policy_for("some_mcp_tool", spec) assert policy == "read_only" - def test_non_mcp_tool_without_metadata_stays_idempotent(self) -> None: + def test_any_tool_without_metadata_fails_safe_as_external(self) -> None: from leapflow.engine.tool_execution import execution_policy_for @dataclass @@ -604,8 +604,8 @@ class FakeSpec: category: str = "general" spec = FakeSpec() - policy = execution_policy_for("some_tool", spec) - assert policy == "mutating_idempotent" + assert execution_policy_for("file_read", spec) == "external_side_effect" + assert execution_policy_for("gateway_send", spec) == "external_side_effect" # ════════════════════════════════════════════════════════════════ diff --git a/tests/test_plugin_learning.py b/tests/test_plugin_learning.py index c545ec30..707ccae6 100644 --- a/tests/test_plugin_learning.py +++ b/tests/test_plugin_learning.py @@ -12,14 +12,11 @@ import pytest from typing import Any -from unittest.mock import patch, MagicMock from leapflow.learning.plugin_trust import PluginTrustLedger, PluginTrustLevel -from leapflow.learning.plugin_stats import PluginUsageTracker, PluginStats +from leapflow.learning.plugin_stats import PluginUsageTracker from leapflow.learning.plugin_advisor import ( PluginAdvisor, - PluginRecommendation, - get_default_advisor, set_default_advisor, ) diff --git a/tests/test_plugin_proposal_store.py b/tests/test_plugin_proposal_store.py deleted file mode 100644 index e33c7de6..00000000 --- a/tests/test_plugin_proposal_store.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) Alibaba, Inc. and its affiliates. -"""Tests for profile-scoped plugin proposal persistence.""" -from __future__ import annotations - -from leapflow.domain.plugin_proposal import BehaviorTestCase, GapEvidence, PluginProposal, ProposedToolSpec -from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore - - -def test_json_plugin_proposal_store_round_trip(tmp_path) -> None: - store = JsonPluginProposalStore(tmp_path / "proposals.json") - proposal = PluginProposal.create( - plugin_id="json_tools", - capability_summary="Validate JSON", - evidence=(GapEvidence.create("explicit", "Need JSON validation", confidence=0.8),), - proposed_tools=(ProposedToolSpec(name="json_validate", description="Validate JSON"),), - test_cases=(BehaviorTestCase.create("json_validate", arguments={"text": "{}"}, expected_subset={"ok": True}),), - ) - - store.save(proposal) - loaded = store.get(proposal.proposal_id) - - assert loaded == proposal - assert store.path.exists() - assert store.list() == [proposal] - assert loaded.test_cases[0].tool_name == "json_validate" - - -def test_json_plugin_proposal_store_update_status(tmp_path) -> None: - store = JsonPluginProposalStore(tmp_path / "proposals.json") - proposal = store.save( - PluginProposal.create(plugin_id="p", capability_summary="capability") - ) - - updated = store.update_status(proposal.proposal_id, "approved") - - assert updated is not None - assert updated.status == "approved" - assert store.get(proposal.proposal_id).status == "approved" diff --git a/tests/test_plugin_sandbox.py b/tests/test_plugin_sandbox.py index 16c18b48..991c5465 100644 --- a/tests/test_plugin_sandbox.py +++ b/tests/test_plugin_sandbox.py @@ -5,7 +5,6 @@ import asyncio import sys -from typing import Any import pytest @@ -20,6 +19,21 @@ class TestSandboxProtocol: """SandboxRequest/Response serialization roundtrips.""" + def test_resource_limits_validate_configuration(self) -> None: + from leapflow.plugins.sandbox.sandbox_host import SandboxLimits + + limits = SandboxLimits( + invoke_timeout_s=1.5, + shutdown_timeout_s=0.5, + cpu_time_s=7, + max_memory_bytes=128 * 1024 * 1024, + ) + assert limits.cpu_time_s == 7 + with pytest.raises(ValueError, match="timeouts"): + SandboxLimits(invoke_timeout_s=0) + with pytest.raises(ValueError, match="resource limits"): + SandboxLimits(max_memory_bytes=-1) + def test_request_roundtrip_basic(self) -> None: req = SandboxRequest( request_id="abc-123", @@ -183,6 +197,7 @@ def bind_runtime(self, **deps): pass resp = await host.invoke("hang_tool", {"params": {}}) assert resp.ok is False assert "timed out" in resp.error + assert host._proc is None, "a timed-out worker must be terminated" finally: await host.stop() diff --git a/tests/test_plugin_stats_persistence.py b/tests/test_plugin_stats_persistence.py index 4e609bc9..1d4448ff 100644 --- a/tests/test_plugin_stats_persistence.py +++ b/tests/test_plugin_stats_persistence.py @@ -21,7 +21,6 @@ _default_stats_db_path, _load_or_new_trust_ledger, _resolve_stats_store, - _wire_plugin_stats_sink, persist_plugin_trust_state, ) from leapflow.engine.turn_usage import TurnUsageTracker diff --git a/tests/test_proposal_orchestrator.py b/tests/test_proposal_orchestrator.py new file mode 100644 index 00000000..70c58bab --- /dev/null +++ b/tests/test_proposal_orchestrator.py @@ -0,0 +1,303 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Contracts for the durable proposal policy and double-approval boundary.""" +from __future__ import annotations + +import asyncio +from pathlib import Path +from types import SimpleNamespace + +import pytest + +from leapflow.daemon.approval_coordinator import ApprovalCoordinator, _DaemonApprovalGate +from leapflow.daemon.approval_route import approval_route +from leapflow.domain.capability_requirement import CapabilityRequirement +from leapflow.evolution.artifact_store import ContentAddressedArtifactStore +from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy +from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator +from leapflow.security.approval import ApprovalDecision, SessionAwareGate +from leapflow.security.orchestrator import ApprovalOrchestrator +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + + +class _Gate: + def __init__(self, decisions: list[bool | BaseException]) -> None: + self._decisions = list(decisions) + self.actions = [] + + async def evaluate(self, action): + self.actions.append(action) + approved = self._decisions.pop(0) + if isinstance(approved, BaseException): + raise approved + return SimpleNamespace( + approved=approved, + action=action, + reason="user_approved" if approved else "user_denied", + denial_message="denied" if not approved else "", + ) + + +class _RequestGate: + def __init__(self, decisions: list[ApprovalDecision]) -> None: + self._decisions = list(decisions) + self.requests = [] + + async def request_approval(self, request): + self.requests.append(request) + return self._decisions.pop(0) + + +def _queue(tmp_path: Path) -> tuple[EvolutionCapabilityProposalStore, str]: + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + queue = EvolutionCapabilityProposalStore(events, profile_id="profile-1") + item = queue.enqueue( + requirements=( + CapabilityRequirement.create( + "chat.reply", + "world_model", + requirement_id="req-chat-reply", + max_risk_level="read_only", + ), + ), + risk={"risk_level": "read_only"}, + metadata={"plugin_id": "chat_reply_plugin"}, + ) + return queue, item.proposal_id + + +@pytest.mark.asyncio +async def test_generated_proposal_requires_two_distinct_approvals(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + gate = _Gate([True, True]) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=gate, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + + generated = orchestrator.register_generated( + proposal_id, + "plugin = object()\n", + validation={"ok": True, "stage": "passed", "compatibility_ok": True}, + ) + content = await orchestrator.approve_content(proposal_id) + mutation = await orchestrator.authorize_mutation(proposal_id) + installed = orchestrator.record_installed(proposal_id, {"ok": True}) + + assert generated.status == "GENERATED" + assert content.approved and mutation.approved + assert content.approval_id != mutation.approval_id + assert installed.status == "INSTALLED" + assert installed.proposal_approval_id == content.approval_id + assert installed.mutation_approval_id == mutation.approval_id + assert [action.metadata["approval_stage"] for action in gate.actions] == [ + "proposal_content", + "plugin_mutation", + ] + assert orchestrator.generated_code(proposal_id) == "plugin = object()\n" + + +def test_missing_compatibility_evidence_fails_before_cas_admission(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=None, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + + failed = orchestrator.register_generated( + proposal_id, + "plugin = object()\n", + validation={"ok": True}, + ) + + assert failed.status == "FAILED" + assert failed.generated_code_ref == "" + assert failed.metadata["terminal_reason"] == "static or compatibility validation failed" + + +@pytest.mark.asyncio +async def test_content_denial_is_terminal_and_blocks_mutation(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=_Gate([False]), + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + orchestrator.register_generated( + proposal_id, + "plugin = object()\n", + validation={"ok": True, "compatibility_ok": True} + ) + + approval = await orchestrator.approve_content(proposal_id) + + assert approval.approved is False + assert queue.get(proposal_id).status == "REJECTED" + with pytest.raises(PermissionError): + await orchestrator.authorize_mutation(proposal_id) + + +@pytest.mark.asyncio +async def test_missing_gate_fails_closed_with_terminal_rejection(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=None, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + orchestrator.register_generated( + proposal_id, + "plugin = object()\n", + validation={"ok": True, "compatibility_ok": True} + ) + + approval = await orchestrator.approve_content(proposal_id) + + assert approval.approved is False + rejected = queue.get(proposal_id) + assert rejected.status == "REJECTED" + assert rejected.metadata["terminal_reason"] == "approval_gate_missing" + + +@pytest.mark.asyncio +async def test_mutation_denial_is_terminal(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=_Gate([True, False]), + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + orchestrator.register_generated(proposal_id, "plugin = object()\n", validation={"ok": True, "compatibility_ok": True}) + await orchestrator.approve_content(proposal_id) + + approval = await orchestrator.authorize_mutation(proposal_id) + + assert approval.approved is False + rejected = queue.get(proposal_id) + assert rejected.status == "REJECTED" + assert rejected.mutation_approval_id + assert rejected.metadata["terminal_reason"] == "user_denied" + + +@pytest.mark.asyncio +async def test_gate_exception_fails_closed_and_records_reason(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=_Gate([RuntimeError("route unavailable")]), + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + orchestrator.register_generated(proposal_id, "plugin = object()\n", validation={"ok": True, "compatibility_ok": True}) + + approval = await orchestrator.approve_content(proposal_id) + + assert approval.approved is False + rejected = queue.get(proposal_id) + assert rejected.status == "REJECTED" + assert rejected.metadata["terminal_reason"] == "approval_gate_error:RuntimeError" + + +@pytest.mark.asyncio +async def test_production_approval_orchestrator_supports_both_stages(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + request_gate = _RequestGate([ApprovalDecision.ALLOW_ONCE, ApprovalDecision.ALLOW_ONCE]) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=ApprovalOrchestrator(request_gate), + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + orchestrator.register_generated(proposal_id, "plugin = object()\n", validation={"ok": True, "compatibility_ok": True}) + + content = await orchestrator.approve_content(proposal_id) + mutation = await orchestrator.authorize_mutation(proposal_id) + + assert content.approved and mutation.approved + assert content.approval_id != mutation.approval_id + assert [ + request.action.metadata["approval_stage"] for request in request_gate.requests + ] == ["proposal_content", "plugin_mutation"] + + +@pytest.mark.asyncio +async def test_daemon_route_emits_two_separate_approval_requests(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + coordinator = ApprovalCoordinator() + chunks: asyncio.Queue = asyncio.Queue() + gate = SessionAwareGate(_DaemonApprovalGate(coordinator)) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=ApprovalOrchestrator(gate), + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + orchestrator.register_generated( + proposal_id, + "plugin = object()\n", + validation={"ok": True, "compatibility_ok": True}, + ) + token = approval_route.set((chunks, "request-1")) + coordinator.register_route("request-1") + stages: list[str] = [] + try: + for operation in ( + orchestrator.approve_content(proposal_id), + orchestrator.authorize_mutation(proposal_id), + ): + pending = asyncio.create_task(operation) + chunk = await asyncio.wait_for(chunks.get(), timeout=1.0) + approval = chunk.metadata["approval"] + stages.append(approval["action"]["metadata"]["approval_stage"]) + resolved = await coordinator.resolve( + approval["pending_id"], "allow_once", reason="journey approval" + ) + assert resolved["ok"] is True + assert (await pending).approved is True + finally: + coordinator.unregister_route("request-1") + approval_route.reset(token) + + assert stages == ["proposal_content", "plugin_mutation"] + item = queue.get(proposal_id) + assert item is not None + assert item.proposal_approval_id + assert item.mutation_approval_id + assert item.proposal_approval_id != item.mutation_approval_id + + +def test_terminal_resolution_states_record_reasons(tmp_path: Path) -> None: + for target in ("SUPERSEDED", "EXPIRED", "NO_OP"): + queue, proposal_id = _queue(tmp_path / target.lower()) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts" / target.lower()), + approval_gate=None, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + if target == "SUPERSEDED": + item = orchestrator.supersede( + proposal_id, replacement_id="prop-new", reason="new evidence" + ) + assert item.metadata["replacement_proposal_id"] == "prop-new" + elif target == "EXPIRED": + item = orchestrator.expire(proposal_id, reason="review window elapsed") + else: + item = orchestrator.record_noop(proposal_id, reason="capability already available") + assert item.status == target + assert item.metadata["terminal_reason"] + assert queue.active(limit=0) == [] + + +def test_queue_rejects_lifecycle_shortcuts(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + + with pytest.raises(ValueError, match="PENDING -> INSTALLED"): + queue.transition(proposal_id, "INSTALLED") diff --git a/tests/test_scoped_registry.py b/tests/test_scoped_registry.py index 0648d8c0..cbcdb3a0 100644 --- a/tests/test_scoped_registry.py +++ b/tests/test_scoped_registry.py @@ -131,6 +131,56 @@ def llm_registry() -> FakeLLMRegistry: class TestScopedToolRegistryFullLifecycle: """Full lifecycle: create fiber → register → assemble → dispose → tools gone.""" + def test_draft_plugin_is_invisible_until_atomic_promotion( + self, fresh_tool_registry: ToolPluginRegistry + ) -> None: + from leapflow.domain.plugin_fiber import FiberState + + fresh_tool_registry.assemble() + scoped = ScopedToolRegistry(fresh_tool_registry) + plugin = FakeToolPlugin( + _plugin_id="draft-plugin", + _tools=[_make_tool_metadata("draft_tool")], + ) + fiber = scoped.create_draft_fiber(plugin.plugin_id) + scoped.stage_plugin(plugin, fiber) + + assert fiber.state == FiberState.DRAFT + assert fresh_tool_registry.get_plugin(plugin.plugin_id) is None + assert "draft_tool" not in fresh_tool_registry.tool_handlers + + promoted = scoped.promote_draft(plugin.plugin_id) + + assert promoted.state == FiberState.ACTIVE + assert fresh_tool_registry.get_plugin(plugin.plugin_id) is plugin + assert "draft_tool" in fresh_tool_registry.snapshot_handlers() + assert fresh_tool_registry.snapshot_latency.count == 1 + + def test_atomic_promotion_rejects_collision_without_partial_publish( + self, fresh_tool_registry: ToolPluginRegistry + ) -> None: + incumbent = FakeToolPlugin( + _plugin_id="incumbent", + _tools=[_make_tool_metadata("shared_tool")], + ) + fresh_tool_registry.register(incumbent) + fresh_tool_registry.assemble() + handlers_before = dict(fresh_tool_registry.tool_handlers) + scoped = ScopedToolRegistry(fresh_tool_registry) + candidate = FakeToolPlugin( + _plugin_id="candidate", + _tools=[_make_tool_metadata("candidate_tool"), _make_tool_metadata("shared_tool")], + ) + fiber = scoped.create_draft_fiber(candidate.plugin_id) + scoped.stage_plugin(candidate, fiber) + + with pytest.raises(ValueError, match="live conflicts"): + scoped.promote_draft(candidate.plugin_id) + + assert fresh_tool_registry.tool_handlers == handlers_before + assert fresh_tool_registry.get_plugin(candidate.plugin_id) is None + assert scoped.get_fiber(candidate.plugin_id) is None + def test_scoped_tool_registry_full_lifecycle(self, fresh_tool_registry: ToolPluginRegistry) -> None: plugin = FakeToolPlugin( _plugin_id="test-plugin", diff --git a/tests/test_self_evolution_switch.py b/tests/test_self_evolution_switch.py index 44ae0d13..43bcbefe 100644 --- a/tests/test_self_evolution_switch.py +++ b/tests/test_self_evolution_switch.py @@ -34,9 +34,9 @@ def _settings(**overrides: Any) -> SimpleNamespace: def test_self_evolution_is_off_by_default(): """Acquiring a capability is the least reversible thing the system decides.""" - from leapflow.config import get_settings + from leapflow.config import Settings - assert get_settings().evolution_enabled is False + assert Settings.__dataclass_fields__["evolution_enabled"].default is False def test_the_switch_is_discoverable_through_the_config_control_plane(): diff --git a/tests/test_self_management.py b/tests/test_self_management.py index 470a699c..b756bd61 100644 --- a/tests/test_self_management.py +++ b/tests/test_self_management.py @@ -15,6 +15,9 @@ import pytest from typing import Any +from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore +from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + # ════════════════════════════════════════════════════════════════ # Testing infrastructure @@ -90,13 +93,13 @@ def self_mgmt_plugin(): reg.assemble() plugin = reg.get_plugin("self_management") - # Reset gate to None so tests start from fail-closed state - plugin._plugin_approval_gate = None - + # Reset every mutable runtime dependency on the module-level plugin singleton. + _reset_install_deps(plugin) + yield plugin - - # Cleanup: ensure gate and process-global registry state are reset after test - plugin._plugin_approval_gate = None + + # Cleanup: ensure runtime deps and process-global registry state are reset after test. + _reset_install_deps(plugin) _reset_tool_registry_state() @@ -881,9 +884,11 @@ class TestP1Features: @pytest.mark.asyncio async def test_plugin_propose_from_explicit_request(self, self_mgmt_plugin: Any, tmp_path: Any) -> None: - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore - store = JsonPluginProposalStore(tmp_path / "proposals.json") - self_mgmt_plugin.bind_runtime(plugin_proposal_store=store) + store = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "proposals.duckdb"), + profile_id="profile-1", + ) + self_mgmt_plugin.bind_runtime(capability_lifecycle_store=store) result = await self_mgmt_plugin._plugin_propose_handler( requested_capability="Validate JSON and pretty-print it", @@ -900,12 +905,16 @@ async def test_plugin_propose_from_explicit_request(self, self_mgmt_plugin: Any, "json_pretty_print", ] assert result["next_actions"] - assert store.get(proposal["proposal_id"]) is not None + assert store.find_by_metadata("review_proposal_id", proposal["proposal_id"]) is not None @pytest.mark.asyncio async def test_plugin_propose_from_unknown_tool_evidence(self, self_mgmt_plugin: Any, tmp_path: Any) -> None: - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore - self_mgmt_plugin.bind_runtime(plugin_proposal_store=JsonPluginProposalStore(tmp_path / "proposals.json")) + self_mgmt_plugin.bind_runtime( + capability_lifecycle_store=EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "proposals.duckdb"), + profile_id="profile-1", + ) + ) evidence = { "error_type": "unknown_tool", @@ -927,9 +936,6 @@ async def test_plugin_propose_from_unknown_tool_evidence(self, self_mgmt_plugin: @pytest.mark.asyncio async def test_plugin_propose_rejects_empty_request(self, self_mgmt_plugin: Any, tmp_path: Any) -> None: - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore - self_mgmt_plugin.bind_runtime(plugin_proposal_store=JsonPluginProposalStore(tmp_path / "proposals.json")) - result = await self_mgmt_plugin._plugin_propose_handler(requested_capability="") assert result["ok"] is False @@ -939,21 +945,34 @@ async def test_plugin_propose_rejects_empty_request(self, self_mgmt_plugin: Any, async def test_proposal_governed_generate_and_install( self, self_mgmt_plugin: Any, tmp_path: Any ) -> None: + from leapflow.evolution.artifact_store import ContentAddressedArtifactStore from leapflow.plugins import get_registry - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore + from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy + from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator class _FakeLLM: async def achat(self, messages): # type: ignore[no-untyped-def] return _valid_plugin_src("proposal_echo", "proposal_echo_tool") - store = JsonPluginProposalStore(tmp_path / "proposals.json") + lifecycle = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "lifecycle.duckdb"), + profile_id="profile-1", + ) + approval_gate = FakeApprovalGate(approved=True) + orchestrator = ProposalOrchestrator( + queue=lifecycle, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=approval_gate, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) self_mgmt_plugin.bind_runtime( - plugin_proposal_store=store, + capability_lifecycle_store=lifecycle, + proposal_orchestrator=orchestrator, llm_provider=_FakeLLM(), plugin_generation_enabled=True, plugin_install_dir=str(tmp_path / "plugins"), ) - self_mgmt_plugin._plugin_approval_gate = FakeApprovalGate(approved=True) + self_mgmt_plugin._plugin_approval_gate = approval_gate proposed = await self_mgmt_plugin._plugin_propose_handler( requested_capability="Echo a message from a generated plugin", @@ -972,7 +991,8 @@ async def achat(self, messages): # type: ignore[no-untyped-def] generated = await self_mgmt_plugin._plugin_generate_handler(proposal_id=proposal_id) assert generated["ok"], generated assert generated["proposal_id"] == proposal_id - assert store.get(proposal_id).status == "review" + lifecycle_id = generated["lifecycle_proposal_id"] + assert lifecycle.get(lifecycle_id).status == "APPROVED" installed = await self_mgmt_plugin._plugin_install_handler( proposal_id=proposal_id, @@ -981,7 +1001,7 @@ async def achat(self, messages): # type: ignore[no-untyped-def] assert installed["ok"], installed assert installed["proposal_id"] == proposal_id assert installed["behavior_tests"][0]["result"] == {"ok": True, "echoed": "hi"} - assert store.get(proposal_id).status == "approved" + assert lifecycle.get(lifecycle_id).status == "INSTALLED" assert "proposal_echo_tool" in get_registry().tool_handlers try: result = await get_registry().tool_handlers["proposal_echo_tool"](message="hi") @@ -1325,10 +1345,14 @@ def _reset_install_deps(plugin: Any) -> None: """Reset install-related runtime deps a fixture does not clear.""" plugin._plugin_approval_gate = None plugin._plugin_install_dir = None + plugin._plugin_staging_dir = None plugin._marketplace_client = None plugin._trusted_pubkeys = set() - plugin._plugin_proposal_store = None plugin._plugin_version_store = None + plugin._capability_lifecycle_store = None + plugin._proposal_orchestrator = None + plugin._evolution_outbox = None + plugin._evolution_profile_id = "" class TestPluginInstallPath: @@ -1369,6 +1393,77 @@ async def test_install_writes_to_injected_profile_dir_not_package( _cleanup_installed(plugin_id) _reset_install_deps(self_mgmt_plugin) + @pytest.mark.asyncio + async def test_install_behavior_failure_never_publishes_or_commits_source( + self, self_mgmt_plugin: Any, tmp_path: Any + ) -> None: + from leapflow.domain.plugin_proposal import BehaviorTestCase, PluginProposal + from leapflow.evolution.artifact_store import ContentAddressedArtifactStore + from leapflow.plugins import get_registry, get_scoped_registry + from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy + from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator + from leapflow.storage.plugin_version_store import PluginVersionStore + + plugin_id = "tst_shadow_failure" + tool_name = "tst_shadow_failure_tool" + install_dir = tmp_path / "plugins" + staging_dir = tmp_path / "staging" + version_store = PluginVersionStore(tmp_path / "versions") + proposal = PluginProposal.create( + plugin_id=plugin_id, + capability_summary="Must fail before publication", + proposed_tools=(), + test_cases=( + BehaviorTestCase.create( + tool_name, + arguments={"message": "x"}, + expected_subset={"echoed": "different"}, + ), + ), + ) + lifecycle = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "lifecycle.duckdb"), + profile_id="profile-1", + ) + approval_gate = FakeApprovalGate(approved=True) + orchestrator = ProposalOrchestrator( + queue=lifecycle, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=approval_gate, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + self_mgmt_plugin._plugin_approval_gate = approval_gate + self_mgmt_plugin.bind_runtime( + plugin_install_dir=str(install_dir), + plugin_staging_dir=str(staging_dir), + plugin_version_store=version_store, + capability_lifecycle_store=lifecycle, + proposal_orchestrator=orchestrator, + ) + lifecycle_id = self_mgmt_plugin._open_lifecycle_record( + proposal, "Must fail before publication" + ) + code = _valid_plugin_src(plugin_id, tool_name) + orchestrator.register_generated(lifecycle_id, code, validation={"ok": True, "compatibility_ok": True}) + await orchestrator.approve_content(lifecycle_id) + try: + result = await self_mgmt_plugin._plugin_install_handler( + proposal_id=proposal.proposal_id, + code=code, + ) + + assert result["ok"] is False + assert "Behavior tests failed" in result["error"] + assert get_registry().get_plugin(plugin_id) is None + assert get_scoped_registry().get_fiber(plugin_id) is None + assert tool_name not in get_registry().tool_handlers + assert not (install_dir / f"{plugin_id}.py").exists() + assert list(staging_dir.iterdir()) == [] + assert version_store.active(plugin_id) is None + finally: + _cleanup_installed(plugin_id) + _reset_install_deps(self_mgmt_plugin) + @pytest.mark.asyncio async def test_plugin_remove_disposes_fiber_and_deletes_source( self, self_mgmt_plugin: Any, tmp_path: Any @@ -1415,10 +1510,21 @@ async def test_plugin_versions_and_rollback( tool_name = "tst_versioned_tool" install_dir = tmp_path / "plugins" version_store = PluginVersionStore(tmp_path / "versions") + + class _Outbox: + def __init__(self) -> None: + self.events = [] + + async def publish(self, event, *, critical=False): + self.events.append((event, critical)) + + outbox = _Outbox() self_mgmt_plugin._plugin_approval_gate = FakeApprovalGate(approved=True) self_mgmt_plugin.bind_runtime( plugin_install_dir=str(install_dir), plugin_version_store=version_store, + evolution_outbox=outbox, + evolution_profile_id="profile-1", ) def source(label: str) -> str: @@ -1453,6 +1559,8 @@ def source(label: str) -> str: assert rollback["ok"], rollback assert rollback["version"] == "v0" assert (await get_registry().tool_handlers[tool_name](message="x"))["version"] == "v0" + assert outbox.events[-1][0].event_type == "plugin.rolled_back" + assert outbox.events[-1][1] is True finally: _cleanup_installed(plugin_id) _reset_install_deps(self_mgmt_plugin) @@ -1462,34 +1570,45 @@ async def test_plugin_reload_restores_previous_version_when_behavior_tests_fail( self, self_mgmt_plugin: Any, tmp_path: Any ) -> None: from leapflow.domain.plugin_proposal import BehaviorTestCase, PluginProposal + from leapflow.evolution.artifact_store import ContentAddressedArtifactStore from leapflow.plugins import get_registry - from leapflow.storage.plugin_proposal_store import JsonPluginProposalStore + from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy + from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator from leapflow.storage.plugin_version_store import PluginVersionStore plugin_id = "tst_behavior_reload_plug" tool_name = "tst_behavior_reload_tool" install_dir = tmp_path / "plugins" - proposal_store = JsonPluginProposalStore(tmp_path / "proposals.json") version_store = PluginVersionStore(tmp_path / "versions") - proposal = proposal_store.save( - PluginProposal.create( - plugin_id=plugin_id, - capability_summary="Echo a message and preserve the expected behavior marker", - proposed_tools=(), - test_cases=( - BehaviorTestCase.create( - tool_name, - arguments={"message": "x"}, - expected_subset={"ok": True, "echoed": "x", "version": "good"}, - ), + proposal = PluginProposal.create( + plugin_id=plugin_id, + capability_summary="Echo a message and preserve the expected behavior marker", + proposed_tools=(), + test_cases=( + BehaviorTestCase.create( + tool_name, + arguments={"message": "x"}, + expected_subset={"ok": True, "echoed": "x", "version": "good"}, ), - ) + ), ) - self_mgmt_plugin._plugin_approval_gate = FakeApprovalGate(approved=True) + lifecycle = EvolutionCapabilityProposalStore( + DuckDBEvolutionEventStore(tmp_path / "lifecycle.duckdb"), + profile_id="profile-1", + ) + approval_gate = FakeApprovalGate(approved=True) + orchestrator = ProposalOrchestrator( + queue=lifecycle, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=approval_gate, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + self_mgmt_plugin._plugin_approval_gate = approval_gate self_mgmt_plugin.bind_runtime( plugin_install_dir=str(install_dir), - plugin_proposal_store=proposal_store, plugin_version_store=version_store, + capability_lifecycle_store=lifecycle, + proposal_orchestrator=orchestrator, ) def source(label: str) -> str: @@ -1498,10 +1617,17 @@ def source(label: str) -> str: f"return {{'ok': True, 'echoed': message, 'version': {label!r}}}", ) + lifecycle_id = self_mgmt_plugin._open_lifecycle_record( + proposal, "Echo a message and preserve the expected behavior marker" + ) + good_source = source("good") + orchestrator.register_generated(lifecycle_id, good_source, validation={"ok": True, "compatibility_ok": True}) + await orchestrator.approve_content(lifecycle_id) + try: install = await self_mgmt_plugin._plugin_install_handler( proposal_id=proposal.proposal_id, - code=source("good"), + code=good_source, version_label="good", ) assert install["ok"], install diff --git a/tests/test_signal_source.py b/tests/test_signal_source.py index f620cd36..fd5a5dca 100644 --- a/tests/test_signal_source.py +++ b/tests/test_signal_source.py @@ -7,7 +7,6 @@ from __future__ import annotations -import pytest from leapflow.perception.signal_source import ( SignalSourceRegistry, @@ -437,7 +436,6 @@ def test_custom_registry_injection(self) -> None: from unittest.mock import MagicMock from leapflow.perception.config import PerceptionConfig from leapflow.perception.session import PerceptionSession - from leapflow.perception.signal_source import SignalSourceRegistry config = PerceptionConfig( signal_channels=frozenset({"custom"}), diff --git a/tests/test_telegram_signal_source.py b/tests/test_telegram_signal_source.py index 5ab35d6c..413fe743 100644 --- a/tests/test_telegram_signal_source.py +++ b/tests/test_telegram_signal_source.py @@ -15,7 +15,7 @@ import pytest -from leapflow.perception.active_signal_source import ActiveSignalSource, EmitCallback +from leapflow.perception.active_signal_source import ActiveSignalSource from leapflow.perception.active_sources.telegram_bot import TelegramBotSignalSource from leapflow.perception.types import InteractionSignal diff --git a/tests/test_tool_concurrency.py b/tests/test_tool_concurrency.py index 776a846b..e320bb62 100644 --- a/tests/test_tool_concurrency.py +++ b/tests/test_tool_concurrency.py @@ -54,7 +54,14 @@ def test_mutating_once_session_scoped_tool_runs_sequentially() -> None: def test_path_scoped_writes_parallel_iff_non_overlapping() -> None: - specs = {"file_write": ToolSpec(name="file_write", risk_level="mutating", mutates_state=True)} + specs = { + "file_write": ToolSpec( + name="file_write", + risk_level="mutating", + mutates_state=True, + execution_policy="mutating_idempotent", + ) + } policy = _policy(specs) concurrent, sequential = policy.partition( @@ -71,7 +78,12 @@ def test_path_scoped_writes_parallel_iff_non_overlapping() -> None: def test_mutating_idempotent_without_path_is_sequential() -> None: specs = { - "file_write": ToolSpec(name="file_write", risk_level="mutating", mutates_state=True), + "file_write": ToolSpec( + name="file_write", + risk_level="mutating", + mutates_state=True, + execution_policy="mutating_idempotent", + ), "file_read": ToolSpec(name="file_read", risk_level="read_only"), } concurrent, sequential = _policy(specs).partition([_tc("file_read", path="a"), _tc("file_write")]) diff --git a/tests/test_world_model_driver.py b/tests/test_world_model_driver.py deleted file mode 100644 index 7ff353f7..00000000 --- a/tests/test_world_model_driver.py +++ /dev/null @@ -1,335 +0,0 @@ -# Copyright (c) Alibaba, Inc. and its affiliates. -"""WM-B: the world model is now the first driver of capability evolution. - -`grade_and_propose` could form a capability hypothesis and the observation pipeline -could consume one, but nothing joined them -- so the world model's conclusions -reached no part of the system. `WorldModelEvolutionDriver` is that join. - -The tests that matter most here are the negative ones: the driver must not be able -to bypass the opt-in evidence gate, must not widen a risk ceiling, and must never -fail the session that produced the trajectory. -""" - -from __future__ import annotations - -import asyncio -from types import SimpleNamespace - -from leapflow.domain.evolution_intent import WORLD_MODEL_INTENT, EvolutionIntent -from leapflow.learning.capability_observation import ( - CapabilityEvidenceClassifier, - CapabilityObservationService, -) -from leapflow.learning.world_model_driver import ( - CapabilityGapTeacher, - EvidenceIntake, - WorldModelDriveResult, - WorldModelEvolutionDriver, -) -from leapflow.storage.capability_observation_store import JsonCapabilityObservationStore -from leapflow.world_model.trajectory_grader import TeacherVerdict - -_TRAJECTORY = [ - {"experience_id": "e1", "action_description": "click send_button", - "predicted_effect": "sent", "actual_effect": "silently no-op", "delta": "1.0"}, - {"experience_id": "e2", "action_description": "retry", - "predicted_effect": "sent", "actual_effect": "silently no-op", "delta": "1.0"}, -] - - - -def _acquire_verdict(intent): - """Express an intent as the acquire verdict that would have produced it.""" - from leapflow.domain.adaptation_verdict import AdaptationVerdict - - return AdaptationVerdict.create( - "acquire", - intent.capability, - intent.hypothesis or f"nothing installed provides {intent.capability}", - rationale=intent.rationale or intent.hypothesis, - confidence=intent.confidence, - target_affordance=intent.target_affordance, - expected_effect=intent.expected_effect, - max_risk_level=intent.max_risk_level, - ) - - -class _Teacher: - """Stand-in for TrajectoryGrader with a fixed hindsight verdict.""" - - def __init__(self, intents=(), grades=("g1", "g2"), raises=False) -> None: - # Intents are now *derived* from acquire verdicts rather than carried beside - # them, so a teacher stub expressing "I want this capability" says it the way - # the real teacher does: an acquire verdict, which the verdict object turns - # into the intent. Constructing intents directly would test a path production - # no longer has. - self._verdict = TeacherVerdict( - tuple(grades), - tuple(_acquire_verdict(intent) for intent in intents), - ) - self._raises = raises - self.calls = 0 - - async def grade_and_propose(self, trajectory, goal=""): - self.calls += 1 - if self._raises: - raise RuntimeError("teacher exploded") - return self._verdict - - -def _intent(**kw): - base = dict( - confidence=0.8, target_affordance="app.chat.v2", - expected_effect="message appears in the thread", - ) - base.update(kw) - return EvolutionIntent.create("chat.reply", "the send path silently no-ops", **base) - - -def _service(tmp_path, *, opted_in: bool): - store = JsonCapabilityObservationStore(tmp_path / "observations.json") - kinds = [WORLD_MODEL_INTENT] if opted_in else None - classifier = CapabilityEvidenceClassifier.from_kinds(kinds) if kinds else None - return store, CapabilityObservationService(store, classifier=classifier) - - -def _drive(teacher, service, trajectory=_TRAJECTORY, **kw): - driver = WorldModelEvolutionDriver(teacher=teacher, intake=service, **kw) - return asyncio.run(driver.drive(trajectory, "reply in chat")) - - -# ── the join works ──────────────────────────────────────────────────────────── - - -def test_protocols_are_satisfied_by_the_real_components(tmp_path): - _, service = _service(tmp_path, opted_in=True) - assert isinstance(service, EvidenceIntake) - assert isinstance(_Teacher(), CapabilityGapTeacher) - - -def test_teacher_hypothesis_becomes_a_governed_requirement(tmp_path): - """The whole point: hindsight -> intent -> admitted evidence -> requirement.""" - store, service = _service(tmp_path, opted_in=True) - result = _drive(_Teacher(intents=[_intent()]), service) - - assert isinstance(result, WorldModelDriveResult) - assert result.proposed == 1 - assert result.admitted == 1 - assert len(store.unresolved()) == 1 - - requirement = result.requirements[0] - assert requirement.origin == "world_model" # the world model drove this - assert requirement.capability == "chat.reply" - assert requirement.max_risk_level == "read_only" - assert dict(requirement.metadata)["target_affordance"] == "app.chat.v2" - - -def test_grades_are_returned_so_no_second_llm_call_is_needed(tmp_path): - _, service = _service(tmp_path, opted_in=True) - teacher = _Teacher(intents=[_intent()]) - result = _drive(teacher, service) - assert len(result.grades) == 2 - assert teacher.calls == 1 # one hindsight call for grading AND proposing - - -def test_multiple_gaps_all_reach_the_pipeline(tmp_path): - _, service = _service(tmp_path, opted_in=True) - other = EvolutionIntent.create("chat.attach", "no attachment capability exists") - result = _drive(_Teacher(intents=[_intent(), other]), service) - assert result.proposed == 2 and result.admitted == 2 - assert {r.capability for r in result.requirements} == {"chat.reply", "chat.attach"} - - -# ── the driver must not be able to bypass the gate ──────────────────────────── - - -def test_driver_cannot_bypass_the_opt_in_gate(tmp_path): - """Default configuration: proposals are formed but change nothing.""" - store, service = _service(tmp_path, opted_in=False) - result = _drive(_Teacher(intents=[_intent()]), service) - - assert result.proposed == 1 # the world model did form a hypothesis - assert result.admitted == 0 # ...and the gate refused it - assert result.requirements == () - assert store.unresolved() == [] # nothing durable was written - - -def test_driver_cannot_widen_the_risk_ceiling(tmp_path): - _, service = _service(tmp_path, opted_in=True) - greedy = _intent(max_risk_level="external") - result = _drive(_Teacher(intents=[greedy]), service) - requirement = result.requirements[0] - assert requirement.max_risk_level == "read_only" - assert dict(requirement.metadata)["requested_max_risk_level"] == "external" - - -def test_caller_may_tighten_the_ceiling_further(tmp_path): - _, service = _service(tmp_path, opted_in=True) - result = _drive( - _Teacher(intents=[_intent(max_risk_level="medium")]), service, - risk_ceiling="read_only", - ) - assert result.requirements[0].max_risk_level == "read_only" - - -# ── learning must never break the session ───────────────────────────────────── - - -def test_teacher_failure_is_contained(tmp_path): - _, service = _service(tmp_path, opted_in=True) - result = _drive(_Teacher(raises=True), service) - assert result == WorldModelDriveResult() # empty, not an exception - - -def test_intake_failure_is_contained(tmp_path): - class _BrokenIntake: - def observe_result(self, result, **kwargs): - raise OSError("disk on fire") - - def requirements(self, *, min_count=1, limit=50): - return () - - driver = WorldModelEvolutionDriver(teacher=_Teacher(intents=[_intent()]), intake=_BrokenIntake()) - result = asyncio.run(driver.drive(_TRAJECTORY, "goal")) - assert result.proposed == 1 and result.admitted == 0 - - -def test_empty_trajectory_spends_nothing(tmp_path): - _, service = _service(tmp_path, opted_in=True) - teacher = _Teacher(intents=[_intent()]) - result = _drive(teacher, service, trajectory=[]) - assert result == WorldModelDriveResult() - assert teacher.calls == 0 # no LLM spend without an episode - - -def test_no_gaps_still_returns_grades(tmp_path): - _, service = _service(tmp_path, opted_in=True) - result = _drive(_Teacher(intents=[]), service) - assert len(result.grades) == 2 - assert result.proposed == 0 and result.requirements == () - - -def test_drive_result_is_reportable(tmp_path): - _, service = _service(tmp_path, opted_in=True) - payload = _drive(_Teacher(intents=[_intent()]), service).to_dict() - assert payload["proposed"] == 1 - assert payload["admitted"] == 1 - assert payload["capabilities"] == ["chat.reply"] - - -# ── authority gate (P5 in the driver) ────────────────────────────────── - - -def test_admitted_hypothesis_is_queued_with_evidence_linkage(tmp_path): - """An admitted, authorised hypothesis is queued, carrying its observation ids. - - The linkage is what lets the causal ledger join a queued acquisition back to the - evidence that produced it; a proposal minted with no observation ids is an orphan. - """ - _, service = _service(tmp_path, opted_in=True) - captured: dict = {} - - def sink(proposal, *, observation_ids=(), environment=None): - captured["observation_ids"] = tuple(observation_ids) - captured["environment"] = environment - return "prop-unmet" - - driver = WorldModelEvolutionDriver( - teacher=_Teacher(intents=[_intent()]), - intake=service, - proposal_sink=sink, - ) - result = asyncio.run(driver.drive(_TRAJECTORY, "reply in chat")) - - assert result.unauthorised == () - assert result.queued_proposal_ids == ("prop-unmet",) - assert len(captured["observation_ids"]) == 1 - assert captured["observation_ids"][0].startswith("obs-") - - -def test_unauthorised_origin_is_a_durable_no_op(tmp_path): - """With authority restricted away from world_model, the hypothesis cannot acquire.""" - store, service = _service(tmp_path, opted_in=True) - queued: list = [] - - driver = WorldModelEvolutionDriver( - teacher=_Teacher(intents=[_intent()]), - intake=service, - proposal_sink=lambda p, **k: queued.append(p) or "prop-x", - # A drive-the-wiring assertion of P5: the world model's own origin is refused - # authority, so even an admitted hypothesis is retired rather than queued. - authorising_origins=("some_other_origin",), - ) - result = asyncio.run(driver.drive(_TRAJECTORY, "reply in chat")) - - assert result.unauthorised == ("chat.reply",) - assert result.queued_proposal_ids == () - assert queued == [] - # Durable no-op: the observation is retired with a recorded reason. - assert store.unresolved() == [] - - -def test_world_model_origin_is_authorised_when_named(tmp_path): - """Naming world_model in authorising_origins lets its hypothesis through.""" - _, service = _service(tmp_path, opted_in=True) - queued: list = [] - driver = WorldModelEvolutionDriver( - teacher=_Teacher(intents=[_intent()]), - intake=service, - proposal_sink=lambda p, **k: queued.append(p) or "prop-x", - authorising_origins=("world_model",), - ) - result = asyncio.run(driver.drive(_TRAJECTORY, "reply in chat")) - assert result.unauthorised == () - assert result.queued_proposal_ids == ("prop-x",) - - -# ── the real grader satisfies the teacher contract ──────────────────────────── - - -def test_real_trajectory_grader_can_drive_evolution(tmp_path): - """End to end with the REAL TrajectoryGrader, only the LLM substituted.""" - import json - - from leapflow.world_model.budget import LearningBudgetController - from leapflow.world_model.trajectory_grader import TrajectoryGrader - - payload = json.dumps({ - "grades": [ - {"step": 1, "advantage": -0.9, "is_forking": True, "grade_label": "harmful"}, - {"step": 2, "advantage": -0.9, "is_forking": False, "grade_label": "harmful"}, - {"step": 3, "advantage": -0.5, "is_forking": False, "grade_label": "suboptimal"}, - ], - "adaptation_verdicts": [{ - "action": "acquire", - "capability": "chat.reply", - "knowledge": "the send control exists but no longer delivers the message", - "confidence": 0.77, - "target_affordance": "app.chat.v2", - "expected_effect": "the message appears in the thread", - }], - }) - - class _FakeLLM: - async def achat(self, messages, **kwargs): - return SimpleNamespace(content=payload) - - class _Store: - def __getattr__(self, name): - return lambda *a, **k: None - - grader = TrajectoryGrader(_FakeLLM(), _Store(), LearningBudgetController(grading_budget=2)) - assert isinstance(grader, CapabilityGapTeacher) - - _, service = _service(tmp_path, opted_in=True) - trajectory = _TRAJECTORY + [ - {"experience_id": "e3", "action_description": "verify thread", - "predicted_effect": "message present", "actual_effect": "absent", "delta": "1.0"}, - ] - driver = WorldModelEvolutionDriver(teacher=grader, intake=service) - result = asyncio.run(driver.drive(trajectory, "reply in chat")) - - assert result.proposed == 1 - assert result.admitted == 1 - assert result.requirements[0].origin == "world_model" - assert result.requirements[0].capability == "chat.reply" diff --git a/tests/test_world_model_proposal_sink_contract.py b/tests/test_world_model_proposal_sink_contract.py deleted file mode 100644 index 2177068d..00000000 --- a/tests/test_world_model_proposal_sink_contract.py +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright (c) Alibaba, Inc. and its affiliates. -"""A caller-supplied proposal sink keeps its own signature. - -Measured regression: the driver began passing ``observation_ids`` and ``environment`` -to ``proposal_sink`` so the causal ledger could join a proposal to the observations -that caused it. The sink is supplied by the caller and its contract was -``sink(proposal)``, so every sink that had not adopted the new keywords raised -``TypeError`` -- inside a per-intent ``except Exception`` that logged at debug level -and continued. The visible effect was that **no acquisition was ever queued**, with a -green targeted test suite and no warning in the log. - -Two contracts are pinned here, because either alone would have let it through: - -* optional context is offered only to sinks that declare it (or take ``**kwargs``), - so extending the causal payload can never break an existing sink; -* a wiring fault is logged as a warning rather than absorbed, so if this ever breaks - again it says so instead of going quiet. -""" - -from __future__ import annotations - -import asyncio -import logging -from typing import Any - -from leapflow.domain.adaptation_verdict import ACQUIRE, AdaptationVerdict -from leapflow.learning.world_model_driver import WorldModelEvolutionDriver -from leapflow.world_model.trajectory_grader import TeacherVerdict - - -class _Teacher: - def __init__(self, verdict: TeacherVerdict) -> None: - self._verdict = verdict - - async def grade_and_propose(self, *args: Any, **kwargs: Any) -> TeacherVerdict: - return self._verdict - - -class _Intake: - """Minimal stand-in that derives a need for what it just observed.""" - - def __init__(self) -> None: - self.observed: list[str] = [] - - def observe_result(self, result, **kwargs): - capability = str((result or {}).get("capability") or "") - if capability: - self.observed.append(capability) - return {"observation_id": f"o{len(self.observed)}"} - - def requirements(self, *, min_count: int = 1, limit: int = 50): - from leapflow.domain.capability_requirement import CapabilityRequirement - - return tuple( - CapabilityRequirement.create( - capability, "world_model", max_risk_level="read_only", - requirement_id=f"req-{capability}", - ) - for capability in dict.fromkeys(self.observed) - ) - - -def _drive(sink) -> Any: - driver = WorldModelEvolutionDriver( - teacher=_Teacher( - TeacherVerdict( - grades=(), - verdicts=( - AdaptationVerdict.create(ACQUIRE, "mail.send", "the app is now v3"), - ), - ) - ), - intake=_Intake(), - proposal_sink=sink, - ) - return asyncio.run(driver.drive([{"action": "a"}], "reply in the thread")) - - -def test_legacy_single_argument_sink_still_receives_proposals(): - """The original contract: ``sink(proposal)`` and nothing else.""" - seen: list[Any] = [] - - def sink(proposal): - seen.append(proposal) - return proposal.proposal_id - - result = _drive(sink) - assert len(seen) == 1, "a one-argument sink must still be called" - assert result.to_dict()["queued"] == 1 - - -def test_sink_declaring_the_extras_receives_them(): - """A sink that opts in gets the causal context, so the ledger can join it.""" - captured: dict[str, Any] = {} - - def sink(proposal, *, observation_ids=(), environment=None): - captured["observation_ids"] = tuple(observation_ids) - captured["environment"] = environment - return proposal.proposal_id - - result = _drive(sink) - assert result.to_dict()["queued"] == 1 - assert captured["observation_ids"], "observation ids must reach an opted-in sink" - - -def test_var_keyword_sink_receives_the_extras(): - """``**kwargs`` counts as opting in; nothing needs to be listed explicitly.""" - captured: dict[str, Any] = {} - - def sink(proposal, **kwargs): - captured.update(kwargs) - return proposal.proposal_id - - assert _drive(sink).to_dict()["queued"] == 1 - assert "observation_ids" in captured - - -def test_a_sink_that_raises_a_wiring_fault_is_reported_not_swallowed(caplog): - """A TypeError from inside the sink must be visible, not debug-only. - - The loop still continues -- one bad intent may not stop the rest -- but silence is - what turned the original defect into an invisible outage. - """ - def sink(proposal, *, observation_ids=(), environment=None): - raise TypeError("sink is misconfigured") - - with caplog.at_level(logging.WARNING, logger="leapflow.learning.world_model_driver"): - result = _drive(sink) - - assert result.to_dict()["queued"] == 0 - assert any( - "acquisition not queued" in record.message for record in caplog.records - ), "a wiring fault must be logged at warning level" From 6dcd920364c2182d0d7af169e6782ff595d84af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Sat, 19 Sep 2026 15:06:39 +0800 Subject: [PATCH 04/10] update ignore --- .gitignore | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index b762e5b9..2b41683c 100644 --- a/.gitignore +++ b/.gitignore @@ -234,25 +234,7 @@ Package.resolved # OSHost socket path (runtime) leapflow.sock -temp -# The AAAI demo tooling is a reproducible artifact, not disposable scratch data. -# Re-ignore every other temporary artifact after reopening each parent directory. -!temp/ -temp/* -!temp/papers/ -temp/papers/* -!temp/papers/aaai27_demo/ -temp/papers/aaai27_demo/* -!temp/papers/aaai27_demo/aaai_demo/ -!temp/papers/aaai27_demo/aaai_demo/*.py -!temp/papers/aaai27_demo/demo_fixtures/ -!temp/papers/aaai27_demo/demo_fixtures/task-001-structural-drifts.json -!temp/papers/aaai27_demo/demo_fixtures/headless-chat-probe-drifts.json -!temp/papers/aaai27_demo/plan/ -temp/papers/aaai27_demo/plan/* -!temp/papers/aaai27_demo/plan/AAAI-27_Demo_论文写作计划.md -!temp/papers/aaai27_demo/reproduction.md -!temp/papers/aaai27_demo/tests/ -!temp/papers/aaai27_demo/tests/test_demo_artifacts.py +# Entire temp directory is ignored (scratch / transient artifacts only). +temp/ .DS_Store AGENTS.md From 2c46bd2b3daf30cf1e3c4776ebaf647958cd3dd0 Mon Sep 17 00:00:00 2001 From: Cheney Zhang Date: Sat, 19 Sep 2026 16:35:39 +0800 Subject: [PATCH 05/10] feat: close evolution pipeline gaps, LeapBoard polish, and README evolution section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Evolution pipeline gap closure (5 phases): - Proposal expiration/supersession sweep with TTL and CoevolutionSweep stage - Quarantine recovery path (QUARANTINED->PROBATION, trust unfreeze, plugin_unquarantine tool) - DSH bundle rollback via directory-level tar.gz snapshots with SHA-256 verification - Trust change time series in DuckDB (cold-path writes on level transition) - E2E evolution lifecycle integration test covering full 7-phase pipeline LeapBoard: - Rename trust level to maturity across all locales - Fix bar-chart label overlap (max-content label column, nowrap) Documentation: - Add World-Model-Driven Self-Evolution section to README - Add docs/world_model_plugin_harness_evolution.md reference Signed-off-by: 班扬 --- README.md | 46 ++ docs/world_model_plugin_harness_evolution.md | 324 ++++++++++ src/leapflow/config.py | 5 + src/leapflow/dashboard/static/app.js | 10 +- src/leapflow/dashboard/static/styles.css | 3 +- .../dashboard/templates/capability.yaml | 2 +- .../dashboard/templates/evolution.yaml | 10 +- src/leapflow/domain/event_types.py | 1 + src/leapflow/engine/session_factory.py | 34 +- src/leapflow/evolution/sweep.py | 107 +++- src/leapflow/learning/plugin_stats_store.py | 49 ++ src/leapflow/learning/plugin_trust.py | 99 ++- src/leapflow/plugins/proposal_orchestrator.py | 23 +- .../plugins/tool_plugins/self_management.py | 214 ++++++- .../storage/capability_proposal_queue.py | 30 +- src/leapflow/storage/plugin_version_store.py | 141 +++++ src/leapflow/storage/schema.py | 30 +- tests/test_coevolution_sweep_wiring.py | 162 ++++- tests/test_dsh_bundle_rollback.py | 156 +++++ tests/test_evolution_event_store.py | 52 ++ tests/test_evolution_lifecycle_e2e.py | 578 ++++++++++++++++++ tests/test_plugin_stats_persistence.py | 58 +- tests/test_proposal_orchestrator.py | 49 ++ tests/test_quarantine_recovery.py | 65 ++ 24 files changed, 2199 insertions(+), 49 deletions(-) create mode 100644 docs/world_model_plugin_harness_evolution.md create mode 100644 tests/test_dsh_bundle_rollback.py create mode 100644 tests/test_evolution_lifecycle_e2e.py create mode 100644 tests/test_quarantine_recovery.py diff --git a/README.md b/README.md index be0e778c..53bac637 100644 --- a/README.md +++ b/README.md @@ -904,6 +904,52 @@ Full authoring walkthrough: see the [Plugin Developer Guide](temp/deepseek_harne --- +## World-Model-Driven Self-Evolution + +LeapFlow's Harness can **autonomously evolve its plugin composition** in response to dynamic environment changes. A world-model trajectory grader retrospectively evaluates execution evidence and produces a four-value **adaptation verdict** — `absorb` (update knowledge), `rebind` (select a better installed capability), `acquire` (generate a new plugin), or `escalate` (defer to a human) — so most adaptation happens without writing any code at all. + +When a genuine capability gap is detected, the evolution pipeline governs the entire journey from observation to production: + +``` +environment observation + → adaptation verdict (absorb / rebind / acquire / escalate) + → capability gap detection + → resolution-first check (existing catalog) + → proposal + → LLM code generation + → multi-stage validation (syntax → import → Protocol conformance → sandbox smoke) + → dual approval (content + plugin mutation) + → install at DRAFT trust + → progressive trust accrual (DRAFT → CANDIDATE → VERIFIED → PRODUCTION) + → governance (quarantine, rollback, proposal sweep) +``` + +### Enabling Self-Evolution + +Self-evolution is **disabled by default** as a safety constraint — the agent must be explicitly granted the ability to acquire new capabilities: + +```bash +leap config set evolution.enabled true +``` + +When disabled, the world model still produces adaptation verdicts and distils knowledge (absorb/rebind paths remain active), but the `acquire` path that generates and installs new plugins is gated off. + +### Key Features + +- **Resolution-first** — before proposing a new plugin, the pipeline checks whether an existing capability already satisfies the requirement; duplicates are never created +- **Dual approval gate** — generated content is reviewed for correctness, and the plugin mutation itself requires a separate HIGH-risk approval (no permanent grants) +- **Progressive trust lifecycle** — new plugins start at DRAFT and promote through CANDIDATE → VERIFIED → PRODUCTION on consecutive successes; repeated failures trigger automatic demotion +- **Sandbox isolation** — untrusted plugins run in a subprocess over JSON-RPC with bounded invocation timeouts +- **Append-only causal audit trail** — 22 event types record the full causal chain from environment observation through install, validation, approval, trust transitions, and terminal outcomes +- **Cold-path governance** — all evolution machinery (trust ledgers, proposal queues, sweep) runs on boot/reload/dispose paths with zero per-turn overhead +- **Quarantine with recovery** — a plugin that fails hard is frozen at DRAFT with a quarantine record; it can be investigated and restored or removed +- **DSH bundle rollback** — profile plugins maintain versioned source snapshots; `plugin_rollback` restores a previous version and hot-reloads it +- **Proposal TTL and automated sweep** — stale proposals expire after a configurable TTL and are cleaned up by a periodic sweep + +For the formal specification — including system roles, architectural thesis, validation stages, and governance contracts — see [World-Model Plugin & Harness Evolution](docs/world_model_plugin_harness_evolution.md). + +--- + ## LeapBoard — Monitoring Dashboard > **Signals into insight.** diff --git a/docs/world_model_plugin_harness_evolution.md b/docs/world_model_plugin_harness_evolution.md new file mode 100644 index 00000000..dc71404f --- /dev/null +++ b/docs/world_model_plugin_harness_evolution.md @@ -0,0 +1,324 @@ +# World-Model-Driven Harness Self-Evolution Through a Plugin System + +> **Status:** Architecture and implementation reference. This document describes the current LeapFlow design and its intended operational boundaries; it is not a claim that every experimental integration is production-complete. + +## Abstract + +LeapFlow treats environmental change as evidence about a capability gap, rather than as authorization to rewrite the agent runtime. Its self-evolution architecture therefore separates three concerns: (i) a world model that retrospectively interprets execution evidence and distils environmental knowledge, (ii) a plugin system that makes capabilities discoverable, governable, and reversible, and (iii) a stable Harness that supplies the cross-cutting contracts under which capabilities may operate. LeapSpace supplies controlled application environments and observable signals; LeapBoard renders the resulting causal process for human inspection. + +The central claim is deliberately narrow. Most adaptation should occur without writing code: the agent can absorb a change through updated knowledge, rebind a requirement to an installed capability, or escalate a decision to a human. Code generation is reserved for an unmet, task-relevant capability requirement and is introduced as a governed plugin rather than as an arbitrary modification of Harness source code. This division preserves extensibility while retaining lifecycle control, risk gating, auditability, and rollback. + +## 1. Motivation and Scope + +An agent operating in an open and changing environment faces a recurrent problem: an observed failure may indicate an execution error, an obsolete environmental assumption, a missing integration, a policy boundary, or an unavailable credential. Treating every failure as a request to modify framework code is unsafe and analytically unsound. Conversely, treating all change as a prompt-only problem leaves the agent unable to acquire genuinely absent operational capabilities. + +LeapFlow addresses this problem by making adaptation an evidence-driven, layered process. The system is concerned with **capability evolution**, not unrestricted self-modification. A model-generated recommendation is a hypothesis; it must be checked against typed evidence, the active capability catalog, governance policy, approval requirements, sandbox constraints, and observed outcomes before it can change the deployed capability set. + +This document focuses on the relation among four elements: + +1. **World model:** retrospective assessment and knowledge distillation. +2. **Plugin system:** managed acquisition, selection, execution, and retirement of capabilities. +3. **Harness:** stable runtime contracts for safety, isolation, lifecycle, and observability. +4. **LeapSpace and LeapBoard:** respectively, the experimental/environmental surface and the human-observable presentation surface. + +The term *Harness self-evolution* is used in this restricted sense: the Harness can improve its effective composition and learned operating policy through governed capability evolution. It does **not** mean that an LLM receives unrestricted authority to edit the core runtime online. + +## 2. Architectural Thesis + +The architecture follows the principle that a capability should be composed rather than built into the core runtime. Tools, platform adapters, signal sources, and other extensions are specified through runtime-checkable protocols and managed by common discovery and lifecycle machinery. The Harness owns the rules of composition; plugins own concrete capability implementations. + +```text + Environment and execution evidence + │ + ▼ + Observe / filter / persist + │ + ├───────────────┐ + ▼ │ + World-model teacher │ + grade trajectory + infer verdict│ + │ │ + ▼ │ + distilled knowledge / preference│ + │ │ + ▼ │ + student execution loop ◄──┘ + │ + unmet requirement only + ▼ + proposal → validation → approval → sandbox + │ + ▼ + governed plugin lifecycle + │ + ▼ + outcome, trust, quarantine, rollback + │ + ┌────────┴────────┐ + ▼ ▼ + LeapSpace signals LeapBoard presentation +``` + +This organization makes two distinctions explicit. + +First, **learning is not mutation**. A world model may improve future selection by recording what the environment now affords, or by preferring one already installed capability over another. Neither operation changes the capability set. + +Second, **capability acquisition is not core rewriting**. A missing integration is normally supplied as a plugin that conforms to the Harness contracts. If a capability cannot be expressed through an existing protocol, the architectural response is to design a general protocol extension, not to inject a vendor-specific special case into the core. + +## 3. System Roles + +### 3.1 The Harness: Stable Constraints, Not a Mutable Script + +The Harness provides the common runtime substrate: protocol boundaries, session isolation, tool dispatch, context governance, side-effect gating, recovery semantics, approval integration, persistent evidence, and plugin lifecycle control. These responsibilities are cross-cutting: an inconsistent implementation in one integration can otherwise affect unrelated tools, sessions, or clients. + +A stable Harness creates a common operational language. A capability can declare its metadata, dependencies, risk, expected environment affordances, and lifecycle effects in a form that the runtime can reason about uniformly. This supports general mechanisms such as dependency injection, explicit cleanup, per-turn handler snapshots during reload, capability conflict recording, and policy-controlled mutation. + +Thus, the primary benefit of Harness-level evolution is not frequent code generation inside the core. It is the incremental strengthening of reusable **contracts** when repeated evidence reveals a true abstraction gap—for example, a missing general recovery semantic or a capability descriptor that no current plugin can express. Such changes are release-level architectural work and should remain subject to normal engineering review and regression verification. + +### 3.2 Tools and Skills: Behavior and Reusable Procedures + +A tool is a concrete operation exposed to the agent. A skill is a reusable, parameterized procedure that organizes one or more operations around triggers, conditions, and execution knowledge. They are the appropriate adaptation surface when the agent already has the required operational primitives. + +Typical examples include: + +- changing tool arguments or semantic locators after a benign interface change; +- combining existing tools into a revised workflow; +- applying a learned fallback, validation step, or task decomposition; +- preferring a currently installed capability that is better suited to an observed environment. + +Tools and skills alone are insufficient when the environment requires a new long-lived event source, an uninstalled platform adapter, new dependency binding, process isolation, versioning, managed cleanup, or a new externally visible side-effect boundary. These are lifecycle and governance problems, not merely procedural ones. + +### 3.3 Plugins: Governed Capability Units + +Plugins package concrete capabilities behind the Harness extension contract. The plugin layer supplies the mechanism needed to make a generated or newly acquired capability safe to operate over time: + +- capability declaration and deterministic resolution; +- dependency binding and graceful refusal when dependencies are unavailable; +- fiber-based lifecycle transitions and effect-scope cleanup; +- conflict arbitration in the global tool namespace; +- controlled reload, disablement, retirement, and rollback; +- sandboxing and bounded invocation for untrusted code; +- approval, audit, usage evidence, progressive trust, and quarantine. + +In this sense, a tool may be the *behavior* of a capability, while a plugin is the *managed unit through which that behavior enters and exits the running system*. The distinction prevents each individual tool or skill from reimplementing its own incomplete safety and lifecycle framework. + +### 3.4 LeapSpace: Environment and Experiment Surface + +LeapSpace provides a separated application-environment surface for observing and exercising environment-sensitive behavior. Its application harness can start sandboxed applications, coordinate reference actions and hooks, and collect `LeapSignal` records. The `LeapSpaceEnvironmentSource` adapter reads environment state and converts it into observations that LeapFlow can process. + +LeapSpace therefore has two roles: + +1. **Evidence production:** it exposes structured environmental state and task outcomes instead of requiring the world model to infer change from opaque failure text alone. +2. **Experiment control:** it permits controlled investigation of adaptation hypotheses without treating the experiment controller as an authority to mutate production capability state. + +The separation is important. An environmental delta is an observation, not a command. It becomes relevant to evolution only if it is typed, task-relevant, supported by admissible evidence, and unresolved by the live capability catalog. + +### 3.5 LeapBoard: Human-Observable Causal Presentation + +LeapBoard is the presentation and inspection surface for runtime and evolution state. Its server-driven UI compiles templates into a fixed view model and distributes updates to clients through the dashboard server and watch mechanisms. This makes the evolution process inspectable without giving the dashboard authority over evolution decisions. + +For self-evolution, LeapBoard is significant because it can render the causal chain that would otherwise be hidden behind asynchronous workers and persistent events: observations, requirements, resolution outcomes, proposals, validation, approval, lifecycle state, trust changes, and terminal outcomes. The appropriate role of LeapBoard is **explainability and operational oversight**, not autonomous governance. + +## 4. World-Model Adaptation Loop + +### 4.1 Teacher–Student Separation + +LeapFlow separates retrospective evaluation from online task execution. The acting agent executes the current task using the smallest sufficient context and available capabilities. At a session boundary, a durable teacher worker processes recorded evidence and invokes the trajectory grader. The teacher produces action grades and adaptation verdicts; derived knowledge is stored as evidence-backed state for later use by the student. + +This separation has practical benefits: + +- normal turns are not blocked by expensive retrospective reasoning; +- teacher output can be checked, persisted, expired, and audited independently; +- the online agent receives concise, task-relevant knowledge rather than an unbounded trajectory history; +- model advice remains evidence rather than executable authority. + +### 4.2 The Four-Valued Adaptation Verdict + +The adaptation action space is deliberately closed: + +| Verdict | Interpretation | Capability-set consequence | +|---|---|---| +| `absorb` | Existing retry, semantic-addressing, or execution mechanisms already cover the change. | No change. | +| `rebind` | Another installed plugin or tool already satisfies the requirement in the observed environment. | No new code; selection preference may change. | +| `acquire` | No available capability satisfies the typed, task-relevant requirement. | Candidate code may be proposed, subject to governance. | +| `escalate` | A human decision, credential, scope, or policy action is required. | No autonomous mutation. | + +The ordering is intentional: `absorb` and `rebind` are cheaper and safer than `acquire`. Every verdict includes knowledge that informs future execution. Only `acquire` may lead to code generation, and even then it remains a recommendation rather than authorization. + +This design counters a common failure mode in agentic systems: interpreting a changed environment as proof that the incumbent implementation is defective. An incumbent can be correct for a previous application version while an alternate adapter is now more appropriate. The verdict asks what action is supported by evidence, not which component is to blame. + +### 4.3 Event-Sourced Knowledge and Selection + +Evolution evidence is persisted through an append-only event store. Read models, including distilled knowledge and rebind preferences, are projections over that evidence rather than independent sources of truth. A preference extracted from a `rebind` verdict can influence selection, but it is intentionally weaker than structural constraints such as declared capability fit and environment affordances. + +The capability resolver operationalizes this distinction. It scores live candidates from declared matching, environmental compatibility, risk cost, trust, reliability, and—when present—distilled preference. A teacher recommendation cannot make an incompatible capability eligible; it is evidence that informs a deterministic resolution process, not a hidden control channel. + +## 5. From Evidence to Plugin Acquisition + +### 5.1 Resolution Before Acquisition + +Before generating new code, LeapFlow resolves the requirement against the live catalog. An already satisfiable requirement becomes an explicit no-op or rebind result rather than a duplicate proposal. This avoids capability proliferation and ensures that new code is the exception rather than the default response to change. + +The acquisition branch is gated by the user-visible `evolution.enabled` setting, which is disabled by default. The setting controls whether an `acquire` verdict may enter the capability-proposal path. It does not disable world-model grading, knowledge distillation, or read-only selection guidance. Consequently, the system can learn from an environment even while capability mutation remains disabled. + +### 5.2 Governed Acquisition Pipeline + +An eligible acquisition follows a staged path: + +```text +classified evidence + → typed capability requirement + → live-catalog resolution + → proposal + → generation + → syntax / structure / protocol validation + → compatibility assessment + → approval + → artifact write + → sandbox smoke test + → register at DRAFT + → behavior tests and probation + → trust accrual, verification, or quarantine +``` + +The pipeline is intentionally more restrictive than “LLM writes a file and imports it.” It provides an accountable answer to four questions that an unconstrained script cannot answer reliably: + +1. **Why was this capability needed?** The requirement is linked to source evidence and resolution results. +2. **Why is this implementation admissible?** Validation, compatibility assessment, and approval must precede activation. +3. **What happens if it fails?** Outcomes drive demotion, quarantine, disablement, or rollback. +4. **Can the decision be reconstructed?** Causal records include no-op, rejected, and failed branches, not only successful installation. + +### 5.3 Progressive Trust and Reversibility + +New plugins start with limited trust. Trust can advance through observed success and can be reduced by consecutive failures; an internal defect can permanently freeze a capability. Plugins can also be isolated in a subprocess, invoked over bounded JSON-RPC, and removed from service through lifecycle governance. + +This mechanism makes adaptation reversible. It also makes the system more conservative precisely where a model-generated artifact is most uncertain: before the capability has accumulated operational evidence. + +## 6. Why a Plugin System Is Necessary + +It is reasonable to ask whether tools and skills alone could perform self-evolution. For many changes, they can and should. The plugin system is necessary only because some adaptations have properties that cannot be safely represented as a local procedure. + +| Requirement | Tool/skill-only approach | Plugin-governed approach | +|---|---|---| +| Revised procedure using existing operations | Sufficient. | Optional wrapper only. | +| New vendor adapter or native API integration | Ad hoc import and registration risk. | Declared capability, dependency binding, validation, and lifecycle. | +| Long-lived stream, subscription, or polling source | Cleanup and reload ownership are easy to leak. | Fiber and effect scope define ownership and disposal. | +| Untrusted generated code | In-process execution expands blast radius. | Sandbox, timeout, and restricted dependency surface. | +| Capability conflict or version replacement | Local code may silently shadow an incumbent. | First-wins arbitration, conflict record, and managed rollback. | +| Mutation with external side effects | Each implementation may invent inconsistent policy. | Shared risk, approval, audit, and recovery contracts. | +| Multi-session daemon runtime | Local changes can cause nondeterministic shared-state behavior. | Per-turn snapshots and process-global lifecycle discipline. | + +The plugin system is thus not an alternative to tools and skills. It is the governance and operational substrate that allows certain tools, skills, adapters, and signal sources to exist safely as dynamically managed capabilities. + +## 7. When Harness-Level Evolution Is Justified + +Harness-level changes should be exceptional. They are justified when evidence reveals a general deficiency in the extension contract or in a cross-cutting invariant that cannot be solved by a conforming plugin. Examples include a missing neutral protocol for a class of external effects, a session-isolation flaw, or a generic recovery semantic absent from the runtime. + +The expected benefits are system-wide: + +- one corrected contract can improve every current and future plugin; +- common safety invariants become enforceable at a single boundary; +- duplicated vendor-specific work can be replaced by a reusable abstraction; +- observability and rollback remain coherent across all capabilities. + +The expected costs are likewise system-wide: core defects can affect all sessions and all plugins. For this reason, Harness changes require conventional engineering controls—design review, compatibility analysis, targeted and broad regression testing, and deliberate release management. They are not an online action selected directly by a world-model verdict. + +A practical decision rule follows: + +> Prefer knowledge adaptation, then rebind, then a governed plugin. Consider a Harness change only when multiple independently evidenced needs expose a stable, general contract gap. + +## 8. LeapSpace–LeapFlow–LeapBoard Causal Plane + +The three systems form complementary surfaces rather than a monolithic control loop. + +```text +LeapSpace LeapFlow LeapBoard +───────── ──────── ───────── +application state typed observation causal views +reference actions ─────► signal filtering watch updates +LeapSignal records world-model verdicts ─────► evolution lens +sandboxed experiments capability resolution operator inspection + plugin governance notifications +``` + +1. **LeapSpace observes and stages:** it makes environmental conditions and outcomes available through controlled application environments, signals, and an environment-source adapter. +2. **LeapFlow reasons and governs:** it converts admissible observations into knowledge, resolutions, and—only where justified—governed proposals and lifecycle transitions. +3. **LeapBoard exposes and explains:** it presents state and causal outcomes to the operator without bypassing the policy and approval chain. + +This decomposition preserves a critical separation of powers. LeapSpace does not directly register production capabilities; LeapBoard does not approve or execute mutations; the world model does not directly install code. Each component contributes evidence, reasoning, governance, or visibility within its own boundary. + +## 9. Safety and Scientific Integrity Properties + +The architecture is intended to support the following properties. + +### 9.1 Evidence-Bounded Mutation + +An environmental observation or model suggestion is insufficient by itself. Mutation requires a typed, task-relevant, unresolved capability requirement and subsequent governance gates. + +### 9.2 Resolution Completeness + +A requirement already satisfied by the live catalog should produce a recorded no-op or rebind, rather than a new capability artifact. This property controls unnecessary growth and makes non-mutation a visible outcome. + +### 9.3 Causal Traceability + +The causal record should connect environmental evidence, requirement formation, catalog resolution, policy and approval decisions, artifact identity, validation, lifecycle and trust outcomes, and any retirement or rollback. Rejections and no-ops are first-class observations, not missing data. + +### 9.4 Bounded Autonomy + +The agent may improve its knowledge and selection policy without the authority to rewrite its capability set. The capability-writing branch is opt-in and constrained by validation, approval, sandboxing, and post-deployment trust evidence. + +### 9.5 Cold-Path Governance + +Retrospective grading, proposal processing, telemetry, and broad co-evolution sweeps should remain off the ordinary turn-critical path. Learning must not impose material latency or fragility on normal task execution. + +## 10. Limitations and Non-Claims + +The current architecture should be interpreted with the following limitations. + +- `evolution.enabled` is off by default; an `acquire` verdict does not imply that a new capability will be generated or installed. +- LeapSpace's `e2e` application-harness mode is explicitly incomplete; the existence of LeapSpace components should not be read as proof of a complete end-to-end production environment-adaptation path. +- Some telemetry is intentionally optional and depends on sink installation. The absence of a presentation event is not proof that no internal event occurred. +- World-model output is fallible. It is treated as evidence and recommendation, not as a source of authorization or a replacement for declared constraints. +- Plugin mutation is process-global even though session state is isolated. Any change to the active capability set must therefore be evaluated against concurrent-client behavior. +- This document does not claim autonomous architectural redesign of the Harness. Stable core-contract evolution remains an engineering activity, not an automatic side effect of a single trajectory. + +## 11. Evaluation Implications + +A rigorous evaluation should distinguish adaptation quality from mere code-generation frequency. At minimum, experiments should report: + +- the number and provenance of environmental deltas; +- outcomes by verdict class: `absorb`, `rebind`, `acquire`, and `escalate`; +- resolution no-ops versus true unmet requirements; +- proposal acceptance, rejection, expiration, installation, rollback, and quarantine outcomes; +- reliability, latency, and safety effects before and after adaptation; +- evidence coverage and the presence of complete causal records; +- counterfactual baselines, including unchanged environments and irrelevant deltas correctly rejected. + +An evaluation that measures only successful installations risks rewarding unnecessary mutation. A mature system should often demonstrate adaptation through knowledge, re-selection, or deliberate non-action. + +## 12. Conclusion + +World-model-driven self-evolution is most useful when it is framed as **governed capability adaptation** rather than autonomous core rewriting. The world model identifies and distils what changed; the capability resolver determines whether the live system already has a valid response; the plugin system admits, tests, governs, and—when necessary—retires new operational capability; the Harness maintains the common safety and lifecycle invariants; LeapSpace provides controlled environmental evidence; and LeapBoard makes the chain observable to human operators. + +The resulting system favors the least invasive valid response. It learns first, reuses second, acquires cautiously, and escalates when authority or evidence is insufficient. This is the essential rationale for a plugin-based self-evolution architecture: it makes adaptation extensible without converting every environmental change into an unbounded modification of the agent runtime. + +## Appendix A. Primary Implementation Map + +| Concern | Primary implementation references | +|---|---| +| Adaptation action model | [`src/leapflow/domain/adaptation_verdict.py`](../src/leapflow/domain/adaptation_verdict.py) | +| Teacher grading and verdict generation | [`src/leapflow/world_model/trajectory_grader.py`](../src/leapflow/world_model/trajectory_grader.py) | +| Durable retrospective worker | [`src/leapflow/evolution/teacher_worker.py`](../src/leapflow/evolution/teacher_worker.py) | +| Co-evolution cold path | [`src/leapflow/evolution/sweep.py`](../src/leapflow/evolution/sweep.py) | +| Event-backed distilled knowledge | [`src/leapflow/storage/distilled_knowledge_store.py`](../src/leapflow/storage/distilled_knowledge_store.py) | +| Capability resolution | [`src/leapflow/plugins/capability_resolver.py`](../src/leapflow/plugins/capability_resolver.py) | +| Plugin lifecycle governance | [`src/leapflow/plugins/lifecycle_governor.py`](../src/leapflow/plugins/lifecycle_governor.py) | +| Plugin contracts and metadata | [`src/leapflow/plugins/protocol.py`](../src/leapflow/plugins/protocol.py) | +| Plugin lifecycle specification | [`docs/plugins/plugin_lifecycle_management.md`](plugins/plugin_lifecycle_management.md) | +| LeapSpace application harness | [`src/leapspace/app_space/harness.py`](../src/leapspace/app_space/harness.py) | +| LeapSpace signals | [`src/leapspace/app_space/signal.py`](../src/leapspace/app_space/signal.py) | +| LeapSpace-to-LeapFlow adapter | [`src/leapflow/perception/leapspace_source.py`](../src/leapflow/perception/leapspace_source.py) | +| LeapBoard server | [`src/leapflow/dashboard/server.py`](../src/leapflow/dashboard/server.py) | +| LeapBoard templates | [`src/leapflow/dashboard/templates.py`](../src/leapflow/dashboard/templates.py) | +| Configuration and evolution gate | [`src/leapflow/config.py`](../src/leapflow/config.py) | +| Engineering constraints | [`AGENTS.md`](../AGENTS.md) | diff --git a/src/leapflow/config.py b/src/leapflow/config.py index e87643ae..26159ebd 100644 --- a/src/leapflow/config.py +++ b/src/leapflow/config.py @@ -402,6 +402,9 @@ class Settings: evolution_teacher_max_attempts: int = 3 evolution_teacher_retry_backoff_s: float = 5.0 evolution_autonomy_level: str = "generate_only" + # How many hours a capability proposal stays active before the cold-path + # sweep expires it. 0 disables TTL-based expiry entirely. + proposal_ttl_hours: int = 72 environment_mode: str = "production" environment_leapspace_enabled: bool = False environment_leapspace_state_root: str = "" @@ -1019,6 +1022,7 @@ def _build_settings_from_env( evolution_autonomy_level = os.getenv( "LEAPFLOW_EVOLUTION_AUTONOMY_LEVEL", "generate_only" ).strip() + proposal_ttl_hours = int(os.getenv("LEAPFLOW_PROPOSAL_TTL_HOURS", "72")) environment_mode = os.getenv("LEAPFLOW_ENVIRONMENT_MODE", "production").strip().lower() environment_leapspace_enabled = _bool( "LEAPFLOW_ENVIRONMENT_LEAPSPACE_ENABLED", "false" @@ -1491,6 +1495,7 @@ def _tuple_env(key: str, default: tuple) -> tuple: evolution_teacher_max_attempts=evolution_teacher_max_attempts, evolution_teacher_retry_backoff_s=evolution_teacher_retry_backoff_s, evolution_autonomy_level=evolution_autonomy_level, + proposal_ttl_hours=proposal_ttl_hours, environment_mode=environment_mode, environment_leapspace_enabled=environment_leapspace_enabled, environment_leapspace_state_root=environment_leapspace_state_root, diff --git a/src/leapflow/dashboard/static/app.js b/src/leapflow/dashboard/static/app.js index 29473de5..60a53dee 100644 --- a/src/leapflow/dashboard/static/app.js +++ b/src/leapflow/dashboard/static/app.js @@ -316,11 +316,11 @@ // extended: five of seven templates shipped untranslated in every language, and // the i18n test only checked signal keys, so nothing failed. Keyed by the English // source string, so an untranslated key still renders readable English. - zh: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **尚未记录任何效果判定**,因此没有可度量的奖励信号。上面的比率有意留空而非显示 0%。只有当需求声明了预期效果才可能验证,而目前只有世界模型撰写的需求带有预期效果。", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **回归:已闭合的缺口再次复发。** 一次看起来成功的演进并未站住。这是本看板上唯一需要立即处理的发现。", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **仅快照。** 目前尚无可重建的因果历史,因此时间线是「缺席」而非「空白」。原因由管道贯通度中的 `策略决策` 一行说明;实时快照与贯通度表本身不受影响。", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **部分插件因内部缺陷被冻结。** 冻结的插件仍报告 `DRAFT`,而信任维度只做「打分」,因此若未同时注销,它仍可被选中——请查看 `可被选中` 列。", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **验证层级:L2(声明式适配)。** 观测被退役,只意味着某个候选**声明**自己提供该能力,并不意味着该能力被观测到确实生效。效果验证(L3)尚未接线,因此本看板上的任何闭合都不应被读作「已证实」。", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> 需要至少完成一个观测周期才会有内容。若持续为空,请检查调度器是否启用、`framework-evolution` watch 是否已 armed 且未静音。", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> 当一次环境观测导向一次能力决策时,才会写下一条剧集。目前尚无记录——这既可能是系统本就安静,也可能是管道更早就断了:**管道**页签会指出它断在哪一段,以及什么能解除阻塞。", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> 目前没有任何机制自动回收它们。每一个都占着一个工具名、出现在能力列表里,却不可被选中——注册表朝着没有任何需求能用的方向增长。", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> 这些提议未进入任何管道,因此不会出现在任何决策记录或观测中。是否准入是一项配置选择。", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "比值低于 1.0 表示采样循环未能维持其声明的节奏。", "Abstained": "弃权", "Acquisition authority": "获取授权", "Acquisition lifecycle": "获取生命周期", "Action": "动作", "After": "变更后", "An unverified declaration has its writable channels demoted to read-only.": "未核验的声明,其可写通道会被降级为只读。", "Approval": "审批", "Autonomous governance": "自主治理", "Autonomy": "自主级别", "Before": "变更前", "CANDIDATE": "候选级", "Calibrated at": "校准时间", "Calibration health": "校准健康度", "Calls": "调用次数", "Calls (decisions)": "观点(决策)", "Candlestick": "K 线", "Capability": "能力", "Capability adaptation": "能力适配", "Capability observations": "能力观测", "Capability ownership": "能力归属", "Capability topology": "能力拓扑", "Change": "变化", "Channel": "通道", "Channels": "通道数", "Channels that have never been calibrated or whose calibration has expired are shown first.": "从未校准或校准已过期的通道排在最前。", "Command": "命令", "Commanded versus observed, best tracking first": "命令值与实测值对比,跟随最好者在前", "Composition": "组成", "Concerns (open questions)": "关切(待答问题)", "Confidence": "置信度", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "统计所有绘制通道。“接近”指处于声明边界的 5% 以内。", "Cycles run": "已运行周期", "DRAFT": "草稿级", "Days since": "距今天数", "Decision": "决策", "Decisions read as calls; action items as the execution checklist.": "决策即观点,行动项即执行清单。", "Declared Hz": "声明频率 (Hz)", "Desk brief": "交易台简报", "Device": "设备", "Dropped samples": "丢弃的样本", "Each row names one blocked segment and the change that would unblock it.": "每一行指出一个受阻环节,以及能解除阻塞的那项变更。", "Effect verification (L3)": "效果验证(L3)", "Effects declared": "已声明效果", "Entities as references, and recommended next prompts to advance the work.": "实体作为参考,并给出推进工作的后续追问。", "Entities in play and the open risks still to resolve.": "涉及的实体,以及尚未解决的敞口风险。", "Envelope, rate, staleness and quality observations · newest first": "包络、速率、失联与质量观测 · 最新在前", "Environment": "环境", "Environment to framework": "环境 → 框架", "Environment, selected plugin tools, and orchestration order.": "环境、已选插件工具及编排顺序。", "Error rate": "错误率", "Events paced out": "被配速抑制的事件", "Ever used": "是否用过", "Evidence": "证据", "Evidence admission": "证据准入", "Evolution": "演进", "Evolution timeline": "演进时间线", "Executable": "可执行", "Execution checklist": "执行清单", "Extracted from this session's tool/file output (not model-generated).": "数据来自本次会话的工具/文件产物(非模型生成)。", "Failures": "失败次数", "Fiber": "Fiber 状态", "Fiber state changes since the previous cycle, including load retries.": "自上一周期以来的 Fiber 状态变化,含加载重试。", "Finance lens": "金融视图", "Follow-ups": "后续事项", "Framework change": "框架变更", "Framework changes as they happened, from runtime probes.": "来自运行时探针的框架变更实况。", "Framework evolution": "框架演进", "Framework size and how much of the evolution pipeline shows runtime evidence.": "框架规模,以及演进管道中有多少环节呈现运行时证据。", "From": "从", "Frozen plugins": "已冻结插件", "Gap closure": "缺口闭合", "Halt": "可急停", "How closures are verified": "闭合是如何验证的", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "效果信号中有多少可真正用作反馈。这决定了是否值得构建学习策略。", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "框架中有多少是它自己长出来的,以及演进管道中有多少环节呈现运行时证据。", "How often each window sat inside, near, or outside its declared limits": "各窗口处于声明限值内、接近边界或越界的频次", "Inquiry brief": "研究简报", "Insights carded as evidence, capped for fast review.": "洞察以证据卡呈现,数量受限以便快速浏览。", "Instruments & counterparties": "标的与交易对手", "Kept": "保留", "Latest capability decision": "最新能力决策", "Lifecycle records": "生命周期记录", "Lifecycle timeline": "生命周期时间线", "Lifecycle transitions": "生命周期迁移", "Line of inquiry": "研究主线", "Live activity": "实时动态", "Location": "位置", "Loop phase": "循环阶段", "Mean of each downsample window. Declared limits are listed per channel below.": "每个降采样窗口的均值。各通道的声明限值见下方。", "Model's reasoning": "模型的推理", "Mutation": "变更", "Narrative": "叙事", "Narrative pulse": "叙事脉搏", "Needs attention": "需要关注", "Next recal due": "下次校准期限", "Next step": "下一步", "No causal history yet": "尚无因果历史", "Normalized error": "归一化误差", "Normalized error is the residual as a share of the channel's declared span.": "归一化误差是残差占该通道声明量程的比例。", "Not yet observed": "尚未观测", "Nothing has driven a framework change, so there is no episode to narrate.": "尚无任何事驱动过框架变更,因此没有可讲述的剧集。", "OHLC extracted from captured session market data.": "OHLC 提取自本次会话捕获的行情数据。", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "观测待办、提案状态、策略决策与生命周期结果。", "Observations": "观测数", "Observed Hz": "实测频率 (Hz)", "Observed rate against declared rate": "实测速率与声明速率对比", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "单一全局命名空间,先注册者胜。挑战者会被记录,绝不静默丢弃。", "Open": "已连接", "Open risks": "敞口风险", "Open/high/low/close from captured tool output.": "开/高/低/收,来自捕获的工具输出。", "Origin": "来源", "Outcome": "结果", "PRODUCTION": "生产级", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "逐条剧集:触发源、决策、变更,以及缺口是否闭合。", "Per-channel calibration state, freshness, and residual correction": "各通道的校准状态、时效性与残差校正", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "逐段运行时证据。模块存在并不等于有任何代码调用它。", "Pipeline": "管道", "Pipeline evidence": "管道证据", "Pipeline reachability": "管道贯通度", "Plan": "计划", "Plan steps": "计划步骤", "Plugin": "插件", "Plugin roster and trust": "插件名册与信任", "Plugins": "插件数", "Plugins by origin": "按来源分布的插件", "Plugins by trust class": "按信任等级分布的插件", "Policy": "策略", "Policy decisions": "策略决策", "Positions & actions": "持仓与操作", "Posture": "态势", "Price action": "价格行为", "Proposal": "提案", "Proposal status": "提案状态", "Proposed, not admitted": "已提议,未准入", "Pulse": "脉搏", "Quarantine feed": "隔离进料", "Ratio": "比值", "Read live from the registry and trust ledger every cycle.": "每个周期从注册表与信任账本实时读取。", "Recent episodes": "近期剧集", "Reclaim candidates": "可回收候选", "Reclaimable": "可回收", "References & follow-ups": "参考与后续", "References (entities)": "参考(实体)", "Registry": "注册表", "Registry delta": "注册表变化", "Registry version": "注册表版本", "Regressions": "回归", "Rejected": "被拒", "Representative observations, capped for quick scanning.": "代表性观察,数量受限以便快速浏览。", "Requirements": "能力需求", "Research lens": "研究视图", "Residual": "残差", "Reward signal bandwidth": "奖励信号带宽", "Runtime evidence": "运行时证据", "Sampled history per channel, newest on the right": "按通道的采样历史,最新在右侧", "Segment": "管道段", "Segments by status": "按状态分布的管道段", "Selectable": "可被选中", "Selection delta": "选择变化", "Self-acquired": "自获取", "Self-acquired plugins that are registered but unselectable or never once used.": "已注册但不可被选中、或从未被使用过的自获取插件。", "Sentiment lens": "情绪视图", "Series": "序列", "Session analysis": "会话分析", "Signal strength": "信号强度", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "表明某处长错了、或被扣下未放行的信号。无论打开哪个页签都会显示。", "Skipped slots": "跳过的采样点", "State": "状态", "Storyline and signal strength before drilling into positions and actions.": "先看叙事与信号强度,再深入持仓与操作。", "Streaming": "采样中", "Suggested next steps": "建议的下一步", "The line of investigation and where the open questions concentrate.": "研究主线,以及待答问题的集中之处。", "The narrative arc and how strongly themes are trending.": "叙事走向,以及主题的趋势强度。", "The world model asked for these capabilities and nothing took them up.": "世界模型请求了这些能力,但无人受理。", "Theme intensity": "主题强度", "Themes": "主题", "This board reports how the framework changes itself. Nothing has been recorded yet.": "本看板报告框架如何改变自身。目前尚无任何记录。", "To": "到", "Tool": "工具", "Tool-name conflicts": "工具名冲突", "Tools": "工具数", "Transport": "传输方式", "Transport, provenance and channel counts": "传输方式、来源与通道数量", "Trust": "信任级别", "Trust accrual": "信任累积", "Trust class": "信任语义", "Unselectable reclamation": "不可选回收", "Usable": "可用", "VERIFIED": "已验证级", "Verdicts": "判定数", "Verdicts by reason": "按原因分布的判定", "Verified": "已核验", "Verified by": "验证依据", "Voices & concerns": "声音与关切", "Watchlist": "关注列表", "What changed in the environment, and what the framework did about it.": "环境发生了什么变化,框架又为此做了什么。", "Which plugin owns which tool, and which capability that tool provides.": "哪个插件拥有哪个工具,以及该工具提供什么能力。", "Who/what is in the conversation, and the concerns still open.": "谁/什么在被讨论,以及尚未解决的关切。", "Why": "原因", "Why not admitted": "未准入原因", "Why this page is empty": "这个页面为何是空的", "World-model driver": "世界模型驱动器", "Writable": "可写", "aborted": "已中断", "accruing": "正在累积", "active": "运行中", "appeared": "新出现", "armed": "已就绪", "assess_compatibility": "评估兼容性", "built_in": "内置", "capability_expand": "扩展能力", "committed": "已定论", "conformance": "合规", "declared_fitness": "声明式适配", "disable": "停用", "disposed": "已释放", "effect_observed": "效果已观测", "environment_probe": "环境探测", "execution_failed": "执行失败", "expected_effect_absent": "预期效果未出现", "failed": "已失败", "frozen": "已冻结", "gone": "已消失", "idle": "空闲无变化", "install": "安装", "loading": "加载中", "manual": "人工", "moved": "已迁移", "new_unproven": "新,未验证", "no": "否", "no_evidence": "无证据", "no_expected_effect_declared": "未声明预期效果", "no_outcome_observed": "未观测到结果", "none": "无", "not_admitted": "未准入", "not_applicable": "不适用", "observe_only": "仅观察", "observed_effect": "观测效果", "open": "进行中", "pending": "待启", "reload": "重载", "remove": "移除", "reopened": "已复发", "resolved": "已闭合", "rollback": "回滚", "runtime": "运行时", "self_acquired": "自获取", "still_open": "仍未闭合", "tool_reported_no_effect": "工具未报告效果", "trusted": "已信任", "unknown": "未知", "unknown_tool": "未知工具", "unloading": "卸载中", "unscheduled": "未调度", "unverifiable": "无法核实", "unverified": "未验证", "waiting": "等待首个周期", "watching": "监视中", "wired": "已贯通", "world_model": "世界模型", "yes": "是", "Causal trace": "因果追踪", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "单个框架演进快照的只读环境到治理证据。", "Evidence boundary": "证据边界", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "因果追踪展示已记录的事实;不推断缺失的审批或已观测效果。", "Episodes": "剧集", "Declared-fitness closures": "声明式适配闭合", "Counterfactual / mutation matrix": "反事实 / 变更矩阵", "Each row preserves the driver, decision, registry delta, and verification tier.": "每一行保留驱动因素、决策、注册表变化和验证层级。", "Trigger": "触发源", "Evidence tier": "证据层级", "Episode timeline": "剧集时间线", "Rebuilt from existing decision and observation records.": "从现有决策和观测记录重建。", "Durable trace feed": "持久追踪流", "Rejected and no-op decisions remain visible when their trace sink is installed.": "安装追踪接收器后,被拒绝和无操作决策仍保持可见。", "Lifecycle": "生命周期", "Pipeline evidence over time": "管道证据随时间变化", "One point per recorded change in framework state, oldest first.": "每一个点对应一次已记录的框架状态变化,最旧在左。", "Samples": "样本数", "Net change": "净变化"}, - fr: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aucun verdict d'effet n'a encore été enregistré**, il n'y a donc aucun signal de récompense à mesurer. Les taux ci-dessus sont volontairement vides plutôt que nuls. Un effet ne peut être vérifié que si l'exigence en a déclaré un, et seules les exigences rédigées par le modèle du monde en portent aujourd'hui.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Régression : un écart comblé s'est reproduit.** Une évolution qui semblait réussie n'a pas tenu. C'est le seul constat de ce tableau qui exige une attention immédiate.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Instantané seulement.** Aucun historique causal à reconstruire pour l'instant : la chronologie est absente, non vide. La raison est indiquée par la ligne `Décisions de politique` sous la couverture du pipeline ; l'instantané et le tableau de couverture ne sont pas affectés.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Certains plugins sont gelés par un défaut interne.** Un plugin gelé signale toujours `DRAFT`, et la dimension de confiance ne fait que *noter*, donc il reste sélectionnable tant qu'il n'est pas également désenregistré — voir la colonne `Sélectionnable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Niveau de vérification : L2 (aptitude déclarée).** Une observation retirée signifie qu'un candidat a *déclaré* fournir la capacité, non que la capacité a été observée en fonctionnement. La vérification d'effet (L3) n'est pas câblée, donc aucune clôture de ce tableau ne doit être lue comme prouvée.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Un cycle d'observation doit s'achever avant qu'il y ait quoi que ce soit à montrer. Si cela persiste, vérifiez que le planificateur est actif et que la surveillance `framework-evolution` est armée et non silencée.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un épisode est écrit lorsqu'une observation de l'environnement conduit à une décision de capacité. Aucun n'a été enregistré : soit le système est calme, soit le pipeline s'arrête plus tôt — l'onglet **Pipeline** nomme le segment où il s'arrête et ce qui le débloquerait.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Rien ne les récupère automatiquement. Chacun occupe un nom d'outil et figure dans la liste des capacités sans être sélectionnable : le registre grandit dans une direction qu'aucune exigence ne peut utiliser.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Ces propositions n'ont intégré aucun pipeline : elles n'apparaissent donc dans aucun enregistrement de décision ni observation. Les admettre est un choix de configuration.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Un ratio inférieur à 1,0 signifie que la boucle d’échantillonnage ne tient pas sa cadence déclarée.", "Abstained": "Abstention", "Acquisition authority": "Autorité d'acquisition", "Acquisition lifecycle": "Cycle de vie d'acquisition", "Action": "Action", "After": "Après", "An unverified declaration has its writable channels demoted to read-only.": "Une déclaration non vérifiée voit ses canaux inscriptibles rétrogradés en lecture seule.", "Approval": "Approbation", "Autonomous governance": "Gouvernance autonome", "Autonomy": "Autonomie", "Before": "Avant", "CANDIDATE": "Candidat", "Calibrated at": "Calibré le", "Calibration health": "État de calibration", "Calls": "Appels", "Calls (decisions)": "Recommandations (décisions)", "Candlestick": "Chandeliers", "Capability": "Capacité", "Capability adaptation": "Adaptation des capacités", "Capability observations": "Observations de capacités", "Capability ownership": "Propriété des capacités", "Capability topology": "Topologie des capacités", "Change": "Changement", "Channel": "Canal", "Channels": "Canaux", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Les canaux jamais calibrés ou dont la calibration a expiré apparaissent en premier.", "Command": "Commande", "Commanded versus observed, best tracking first": "Commandé contre observé, meilleur suivi d’abord", "Composition": "Composition", "Concerns (open questions)": "Préoccupations (questions ouvertes)", "Confidence": "Confiance", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Compté sur tous les canaux tracés. « près » signifie à moins de 5 % d’une borne déclarée.", "Cycles run": "Cycles exécutés", "DRAFT": "Brouillon", "Days since": "Jours écoulés", "Decision": "Décision", "Decisions read as calls; action items as the execution checklist.": "Les décisions se lisent comme des recommandations ; les actions comme la liste d’exécution.", "Declared Hz": "Hz déclarés", "Desk brief": "Note de desk", "Device": "Appareil", "Dropped samples": "Échantillons perdus", "Each row names one blocked segment and the change that would unblock it.": "Chaque ligne nomme un segment bloqué et le changement qui le débloquerait.", "Effect verification (L3)": "Vérification d'effet (L3)", "Effects declared": "Effets déclarés", "Entities as references, and recommended next prompts to advance the work.": "Entités comme références, et invites suivantes recommandées pour avancer.", "Entities in play and the open risks still to resolve.": "Entités concernées et risques ouverts à résoudre.", "Envelope, rate, staleness and quality observations · newest first": "Observations d’enveloppe, de débit, d’obsolescence et de qualité · les plus récentes d’abord", "Environment": "Environnement", "Environment to framework": "De l'environnement au framework", "Environment, selected plugin tools, and orchestration order.": "Environnement, outils de plugin sélectionnés et ordre d’orchestration.", "Error rate": "Taux d'erreur", "Events paced out": "Événements limités", "Ever used": "Déjà utilisé", "Evidence": "Preuve", "Evidence admission": "Admission des preuves", "Evolution": "Évolution", "Evolution timeline": "Chronologie de l'évolution", "Executable": "Exécutable", "Execution checklist": "Liste d’exécution", "Extracted from this session's tool/file output (not model-generated).": "Extrait des sorties d’outils/fichiers de cette session (non généré par le modèle).", "Failures": "Échecs", "Fiber": "Fibre", "Fiber state changes since the previous cycle, including load retries.": "Changements d'état de fiber depuis le cycle précédent, y compris les tentatives de chargement.", "Finance lens": "Vue finance", "Follow-ups": "Suivis", "Framework change": "Changement du framework", "Framework changes as they happened, from runtime probes.": "Changements du framework en temps réel, via les sondes d'exécution.", "Framework evolution": "Évolution du framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Taille du framework et part du pipeline d'évolution qui présente des preuves d'exécution.", "From": "De", "Frozen plugins": "Plugins gelés", "Gap closure": "Clôture de l'écart", "Halt": "Arrêt", "How closures are verified": "Comment les clôtures sont vérifiées", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Quelle part du signal d'effet est exploitable comme rétroaction. C'est ce qui détermine s'il vaut la peine de construire une politique d'apprentissage.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Quelle part du framework il a fait croître lui-même, et quelle part du pipeline présente des preuves d'exécution.", "How often each window sat inside, near, or outside its declared limits": "Fréquence à laquelle chaque fenêtre était dans, près de, ou hors de ses limites déclarées", "Inquiry brief": "Note d’enquête", "Insights carded as evidence, capped for fast review.": "Analyses présentées comme preuves, limitées pour une revue rapide.", "Instruments & counterparties": "Instruments et contreparties", "Kept": "Conservé", "Latest capability decision": "Dernière décision de capacité", "Lifecycle records": "Enregistrements de cycle de vie", "Lifecycle timeline": "Chronologie du cycle de vie", "Lifecycle transitions": "Transitions de cycle de vie", "Line of inquiry": "Ligne d’enquête", "Live activity": "Activité en direct", "Location": "Emplacement", "Loop phase": "Phase de boucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Moyenne de chaque fenêtre de sous-échantillonnage. Les limites déclarées figurent par canal ci-dessous.", "Model's reasoning": "Raisonnement du modèle", "Mutation": "Mutation", "Narrative": "Récit", "Narrative pulse": "Pouls narratif", "Needs attention": "Requiert attention", "Next recal due": "Prochaine recalibration", "Next step": "Étape suivante", "No causal history yet": "Pas encore d'historique causal", "Normalized error": "Erreur normalisée", "Normalized error is the residual as a share of the channel's declared span.": "L’erreur normalisée est le résidu en proportion de l’étendue déclarée du canal.", "Not yet observed": "Pas encore observé", "Nothing has driven a framework change, so there is no episode to narrate.": "Rien n'a encore déclenché de changement du framework : il n'y a donc aucun épisode à raconter.", "OHLC extracted from captured session market data.": "OHLC extrait des données de marché capturées durant la session.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "File d’observations, état des propositions, décisions de politique et résultats du cycle de vie.", "Observations": "Observations", "Observed Hz": "Hz observés", "Observed rate against declared rate": "Débit observé par rapport au débit déclaré", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un espace de noms global unique, arbitré au premier arrivé. Le concurrent est enregistré, jamais supprimé en silence.", "Open": "Ouvert", "Open risks": "Risques ouverts", "Open/high/low/close from captured tool output.": "Ouverture/haut/bas/clôture issus des sorties d’outils capturées.", "Origin": "Origine", "Outcome": "Résultat", "PRODUCTION": "Production", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Par épisode : le déclencheur, la décision, le changement, et si l'écart a été comblé.", "Per-channel calibration state, freshness, and residual correction": "État de calibration, fraîcheur et correction résiduelle par canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Preuves d'exécution par segment. L'existence d'un module ne prouve pas qu'il soit appelé.", "Pipeline": "Pipeline", "Pipeline evidence": "Preuves du pipeline", "Pipeline reachability": "Accessibilité du pipeline", "Plan": "Plan", "Plan steps": "Étapes du plan", "Plugin": "Plugin", "Plugin roster and trust": "Registre des plugins et confiance", "Plugins": "Plugins", "Plugins by origin": "Plugins par origine", "Plugins by trust class": "Plugins par classe de confiance", "Policy": "Politique", "Policy decisions": "Décisions de politique", "Positions & actions": "Positions et actions", "Posture": "Posture", "Price action": "Action des prix", "Proposal": "Proposition", "Proposal status": "Statut de la proposition", "Proposed, not admitted": "Proposé, non admis", "Pulse": "Pouls", "Quarantine feed": "Flux de quarantaine", "Ratio": "Ratio", "Read live from the registry and trust ledger every cycle.": "Lu en direct depuis le registre et le registre de confiance à chaque cycle.", "Recent episodes": "Épisodes récents", "Reclaim candidates": "Candidats à la récupération", "Reclaimable": "Récupérable", "References & follow-ups": "Références et suivis", "References (entities)": "Références (entités)", "Registry": "Registre", "Registry delta": "Delta du registre", "Registry version": "Version du registre", "Regressions": "Régressions", "Rejected": "Rejeté", "Representative observations, capped for quick scanning.": "Observations représentatives, limitées pour une lecture rapide.", "Requirements": "Exigences", "Research lens": "Vue recherche", "Residual": "Résidu", "Reward signal bandwidth": "Bande passante du signal de récompense", "Runtime evidence": "Preuve d'exécution", "Sampled history per channel, newest on the right": "Historique échantillonné par canal, le plus récent à droite", "Segment": "Segment", "Segments by status": "Segments par statut", "Selectable": "Sélectionnable", "Selection delta": "Delta de sélection", "Self-acquired": "Auto-acquis", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins auto-acquis qui sont enregistrés mais non sélectionnables, ou jamais utilisés une seule fois.", "Sentiment lens": "Vue sentiment", "Series": "Série", "Session analysis": "Analyse de session", "Signal strength": "Force du signal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Signaux indiquant qu'une évolution a mal tourné ou a été retenue. Affichés quel que soit l'onglet ouvert.", "Skipped slots": "Créneaux manqués", "State": "État", "Storyline and signal strength before drilling into positions and actions.": "Récit et force du signal avant d’examiner positions et actions.", "Streaming": "Diffusion", "Suggested next steps": "Prochaines étapes suggérées", "The line of investigation and where the open questions concentrate.": "La ligne d’investigation et où se concentrent les questions ouvertes.", "The narrative arc and how strongly themes are trending.": "L’arc narratif et l’intensité des tendances thématiques.", "The world model asked for these capabilities and nothing took them up.": "Le modèle du monde a demandé ces capacités et personne ne les a prises en charge.", "Theme intensity": "Intensité des thèmes", "Themes": "Thèmes", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Ce tableau rend compte de la façon dont le framework se modifie lui-même. Rien n'a encore été enregistré.", "To": "Vers", "Tool": "Outil", "Tool-name conflicts": "Conflits de noms d'outils", "Tools": "Outils", "Transport": "Transport", "Transport, provenance and channel counts": "Transport, provenance et nombre de canaux", "Trust": "Confiance", "Trust accrual": "Accumulation de confiance", "Trust class": "Classe de confiance", "Unselectable reclamation": "Récupération non sélectionnable", "Usable": "Exploitable", "VERIFIED": "Vérifié", "Verdicts": "Verdicts", "Verdicts by reason": "Verdicts par motif", "Verified": "Vérifié", "Verified by": "Vérifié par", "Voices & concerns": "Voix et préoccupations", "Watchlist": "Liste de suivi", "What changed in the environment, and what the framework did about it.": "Ce qui a changé dans l'environnement, et ce que le framework a fait en réponse.", "Which plugin owns which tool, and which capability that tool provides.": "Quel plugin possède quel outil, et quelle capacité cet outil fournit.", "Who/what is in the conversation, and the concerns still open.": "Qui/quoi est dans la conversation, et les préoccupations encore ouvertes.", "Why": "Pourquoi", "Why not admitted": "Motif de non-admission", "Why this page is empty": "Pourquoi cette page est vide", "World-model driver": "Pilote du modèle du monde", "Writable": "Inscriptible", "aborted": "Abandonné", "accruing": "En accumulation", "active": "Actif", "appeared": "Apparu", "armed": "Armé", "assess_compatibility": "Évaluer la compatibilité", "built_in": "Intégré", "capability_expand": "Étendre les capacités", "committed": "Conclu", "conformance": "Conformité", "declared_fitness": "Aptitude déclarée", "disable": "Désactiver", "disposed": "Libéré", "effect_observed": "Effet observé", "environment_probe": "Sonde d'environnement", "execution_failed": "Échec d'exécution", "expected_effect_absent": "Effet attendu absent", "failed": "Échoué", "frozen": "Gelé", "gone": "Disparu", "idle": "Au repos", "install": "Installer", "loading": "Chargement", "manual": "Manuel", "moved": "Déplacé", "new_unproven": "Nouveau, non éprouvé", "no": "Non", "no_evidence": "Aucune preuve", "no_expected_effect_declared": "Aucun effet attendu déclaré", "no_outcome_observed": "Aucun résultat observé", "none": "Aucun", "not_admitted": "Non admis", "not_applicable": "Sans objet", "observe_only": "Observer seulement", "observed_effect": "Effet observé", "open": "Ouvert", "pending": "En attente", "reload": "Recharger", "remove": "Supprimer", "reopened": "Réouvert", "resolved": "Résolu", "rollback": "Annuler", "runtime": "Exécution", "self_acquired": "Auto-acquis", "still_open": "Toujours ouvert", "tool_reported_no_effect": "L'outil n'a signalé aucun effet", "trusted": "De confiance", "unknown": "Inconnu", "unknown_tool": "Outil inconnu", "unloading": "Déchargement", "unscheduled": "Non planifié", "unverifiable": "Invérifiable", "unverified": "Non vérifié", "waiting": "En attente", "watching": "En surveillance", "wired": "Câblé", "world_model": "Modèle du monde", "yes": "Oui", "Causal trace": "Trace causale", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Preuves en lecture seule reliant l’environnement à la gouvernance pour un instantané d’évolution du framework.", "Evidence boundary": "Limite des preuves", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Une trace causale montre les faits enregistrés ; elle n’infère ni approbation manquante ni effet observé.", "Episodes": "Épisodes", "Declared-fitness closures": "Clôtures par aptitude déclarée", "Counterfactual / mutation matrix": "Matrice contrefactuelle / mutations", "Each row preserves the driver, decision, registry delta, and verification tier.": "Chaque ligne conserve le déclencheur, la décision, le delta du registre et le niveau de vérification.", "Trigger": "Déclencheur", "Evidence tier": "Niveau de preuve", "Episode timeline": "Chronologie des épisodes", "Rebuilt from existing decision and observation records.": "Reconstruite à partir des enregistrements existants de décision et d’observation.", "Durable trace feed": "Flux de traces durables", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Les décisions rejetées et sans action restent visibles lorsque leur récepteur de traces est installé.", "Lifecycle": "Cycle de vie", "Pipeline evidence over time": "Évolution des preuves du convéoyeur", "One point per recorded change in framework state, oldest first.": "Un point par changement enregistré de l’état du framework, du plus ancien au plus récent.", "Samples": "Échantillons", "Net change": "Variation nette"}, - es: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aún no se ha registrado ningún veredicto de efecto**, por lo que no hay señal de recompensa que medir. Las tasas anteriores están en blanco a propósito, no en cero. Un efecto solo puede verificarse si el requisito declaró uno, y hoy solo los requisitos redactados por el modelo del mundo lo llevan.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Regresión: una brecha cerrada ha vuelto a aparecer.** Una evolución que parecía exitosa no se sostuvo. Es el único hallazgo de este panel que exige atención inmediata.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Solo instantánea.** Todavía no hay historia causal que reconstruir, por lo que la cronología está ausente, no vacía. El motivo lo indica la fila `Decisiones de política` bajo la cobertura del pipeline; la instantánea y la tabla de cobertura no se ven afectadas.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Algunos plugins están congelados por un defecto interno.** Un plugin congelado sigue informando `DRAFT`, y la dimensión de confianza solo *puntúa*, por lo que permanece seleccionable a menos que también se desregistre — consulte la columna `Seleccionable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Nivel de verificación: L2 (aptitud declarada).** Una observación retirada significa que un candidato *declaró* que proporciona la capacidad, no que se observara funcionando. La verificación de efecto (L3) no está conectada, así que ningún cierre de este panel debe leerse como probado.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Debe completarse un ciclo de observación antes de que haya algo que mostrar. Si persiste, compruebe que el planificador está activo y que la vigilancia `framework-evolution` está armada y no silenciada.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un episodio se escribe cuando una observación del entorno conduce a una decisión de capacidad. No se ha registrado ninguno: o el sistema está tranquilo o el pipeline se detiene antes — la pestaña **Pipeline** nombra el segmento donde se detiene y qué lo desbloquearía.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Nada los recupera automáticamente. Cada uno ocupa un nombre de herramienta y aparece en la lista de capacidades sin ser seleccionable: el registro crece en una dirección que ningún requisito puede usar.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Estas propuestas no entraron en ningún pipeline, por lo que no aparecen en ningún registro de decisión ni observación. Admitirlas es una elección de configuración.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Una relación inferior a 1,0 significa que el bucle de muestreo no mantiene su cadencia declarada.", "Abstained": "Abstenido", "Acquisition authority": "Autoridad de adquisición", "Acquisition lifecycle": "Ciclo de vida de adquisición", "Action": "Acción", "After": "Después", "An unverified declaration has its writable channels demoted to read-only.": "Una declaración no verificada degrada sus canales escribibles a solo lectura.", "Approval": "Aprobación", "Autonomous governance": "Gobernanza autónoma", "Autonomy": "Autonomía", "Before": "Antes", "CANDIDATE": "Candidato", "Calibrated at": "Calibrado el", "Calibration health": "Estado de calibración", "Calls": "Llamadas", "Calls (decisions)": "Recomendaciones (decisiones)", "Candlestick": "Velas", "Capability": "Capacidad", "Capability adaptation": "Adaptación de capacidades", "Capability observations": "Observaciones de capacidad", "Capability ownership": "Propiedad de capacidades", "Capability topology": "Topología de capacidades", "Change": "Cambio", "Channel": "Canal", "Channels": "Canales", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Los canales nunca calibrados o con calibración vencida se muestran primero.", "Command": "Comando", "Commanded versus observed, best tracking first": "Comandado frente a observado, mejor seguimiento primero", "Composition": "Composición", "Concerns (open questions)": "Inquietudes (preguntas abiertas)", "Confidence": "Confianza", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Contado en todos los canales graficados. «cerca» significa dentro del 5 % de un límite declarado.", "Cycles run": "Ciclos ejecutados", "DRAFT": "Borrador", "Days since": "Días desde", "Decision": "Decisión", "Decisions read as calls; action items as the execution checklist.": "Las decisiones se leen como recomendaciones; las acciones como la lista de ejecución.", "Declared Hz": "Hz declarados", "Desk brief": "Informe de mesa", "Device": "Dispositivo", "Dropped samples": "Muestras descartadas", "Each row names one blocked segment and the change that would unblock it.": "Cada fila nombra un segmento bloqueado y el cambio que lo desbloquearía.", "Effect verification (L3)": "Verificación de efecto (L3)", "Effects declared": "Efectos declarados", "Entities as references, and recommended next prompts to advance the work.": "Entidades como referencias y siguientes preguntas recomendadas para avanzar.", "Entities in play and the open risks still to resolve.": "Entidades implicadas y riesgos abiertos por resolver.", "Envelope, rate, staleness and quality observations · newest first": "Observaciones de envolvente, tasa, obsolescencia y calidad · las más recientes primero", "Environment": "Entorno", "Environment to framework": "Del entorno al framework", "Environment, selected plugin tools, and orchestration order.": "Entorno, herramientas de plugin seleccionadas y orden de orquestación.", "Error rate": "Tasa de error", "Events paced out": "Eventos limitados", "Ever used": "Alguna vez usado", "Evidence": "Evidencia", "Evidence admission": "Admisión de evidencia", "Evolution": "Evolución", "Evolution timeline": "Cronología de la evolución", "Executable": "Ejecutable", "Execution checklist": "Lista de ejecución", "Extracted from this session's tool/file output (not model-generated).": "Extraído de la salida de herramientas/archivos de esta sesión (no generado por el modelo).", "Failures": "Fallos", "Fiber": "Fibra", "Fiber state changes since the previous cycle, including load retries.": "Cambios de estado de fiber desde el ciclo anterior, incluidos los reintentos de carga.", "Finance lens": "Vista financiera", "Follow-ups": "Seguimientos", "Framework change": "Cambio del framework", "Framework changes as they happened, from runtime probes.": "Cambios del framework en tiempo real, desde sondas de ejecución.", "Framework evolution": "Evolución del framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Tamaño del framework y qué parte del pipeline de evolución muestra evidencia en ejecución.", "From": "Desde", "Frozen plugins": "Plugins congelados", "Gap closure": "Cierre de la brecha", "Halt": "Parada", "How closures are verified": "Cómo se verifican los cierres", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Cuánto de la señal de efecto es utilizable como retroalimentación. Esto decide si vale la pena construir una política de aprendizaje.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Cuánto del framework hizo crecer por sí mismo y cuánto del pipeline muestra evidencia de ejecución.", "How often each window sat inside, near, or outside its declared limits": "Con qué frecuencia cada ventana estuvo dentro, cerca o fuera de sus límites declarados", "Inquiry brief": "Informe de indagación", "Insights carded as evidence, capped for fast review.": "Hallazgos presentados como evidencia, limitados para revisión rápida.", "Instruments & counterparties": "Instrumentos y contrapartes", "Kept": "Conservado", "Latest capability decision": "Última decisión de capacidad", "Lifecycle records": "Registros de ciclo de vida", "Lifecycle timeline": "Cronología del ciclo de vida", "Lifecycle transitions": "Transiciones de ciclo de vida", "Line of inquiry": "Línea de indagación", "Live activity": "Actividad en vivo", "Location": "Ubicación", "Loop phase": "Fase del bucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Media de cada ventana de submuestreo. Los límites declarados se listan por canal abajo.", "Model's reasoning": "Razonamiento del modelo", "Mutation": "Mutación", "Narrative": "Narrativa", "Narrative pulse": "Pulso narrativo", "Needs attention": "Requiere atención", "Next recal due": "Próxima recalibración", "Next step": "Siguiente paso", "No causal history yet": "Aún no hay historia causal", "Normalized error": "Error normalizado", "Normalized error is the residual as a share of the channel's declared span.": "El error normalizado es el residuo como fracción del rango declarado del canal.", "Not yet observed": "Aún no observado", "Nothing has driven a framework change, so there is no episode to narrate.": "Nada ha impulsado todavía un cambio del framework, por lo que no hay ningún episodio que narrar.", "OHLC extracted from captured session market data.": "OHLC extraído de los datos de mercado capturados en la sesión.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Cola de observaciones, estado de propuestas, decisiones de política y resultados del ciclo de vida.", "Observations": "Observaciones", "Observed Hz": "Hz observados", "Observed rate against declared rate": "Tasa observada frente a la tasa declarada", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un único espacio de nombres global, arbitrado por orden de llegada. El aspirante queda registrado, nunca se descarta en silencio.", "Open": "Abierto", "Open risks": "Riesgos abiertos", "Open/high/low/close from captured tool output.": "Apertura/máximo/mínimo/cierre desde la salida de herramientas capturada.", "Origin": "Origen", "Outcome": "Resultado", "PRODUCTION": "Producción", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Por episodio: el desencadenante, la decisión, el cambio y si la brecha se cerró.", "Per-channel calibration state, freshness, and residual correction": "Estado de calibración, vigencia y corrección residual por canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Evidencia en ejecución por segmento. Que un módulo exista no prueba que algo lo invoque.", "Pipeline": "Pipeline", "Pipeline evidence": "Evidencia del pipeline", "Pipeline reachability": "Alcanzabilidad del pipeline", "Plan": "Plan", "Plan steps": "Pasos del plan", "Plugin": "Plugin", "Plugin roster and trust": "Registro de plugins y confianza", "Plugins": "Plugins", "Plugins by origin": "Plugins por origen", "Plugins by trust class": "Plugins por clase de confianza", "Policy": "Política", "Policy decisions": "Decisiones de política", "Positions & actions": "Posiciones y acciones", "Posture": "Postura", "Price action": "Acción del precio", "Proposal": "Propuesta", "Proposal status": "Estado de la propuesta", "Proposed, not admitted": "Propuesto, no admitido", "Pulse": "Pulso", "Quarantine feed": "Entrada de cuarentena", "Ratio": "Relación", "Read live from the registry and trust ledger every cycle.": "Leído en vivo del registro y del libro de confianza en cada ciclo.", "Recent episodes": "Episodios recientes", "Reclaim candidates": "Candidatos a recuperación", "Reclaimable": "Recuperable", "References & follow-ups": "Referencias y seguimientos", "References (entities)": "Referencias (entidades)", "Registry": "Registro", "Registry delta": "Delta del registro", "Registry version": "Versión del registro", "Regressions": "Regresiones", "Rejected": "Rechazado", "Representative observations, capped for quick scanning.": "Observaciones representativas, limitadas para lectura rápida.", "Requirements": "Requisitos", "Research lens": "Vista de investigación", "Residual": "Residuo", "Reward signal bandwidth": "Ancho de banda de la señal de recompensa", "Runtime evidence": "Evidencia en ejecución", "Sampled history per channel, newest on the right": "Historial muestreado por canal, el más reciente a la derecha", "Segment": "Segmento", "Segments by status": "Segmentos por estado", "Selectable": "Seleccionable", "Selection delta": "Delta de selección", "Self-acquired": "Autoadquirido", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins autoadquiridos que están registrados pero no son seleccionables, o nunca se han usado.", "Sentiment lens": "Vista de sentimiento", "Series": "Serie", "Session analysis": "Análisis de sesión", "Signal strength": "Fuerza de la señal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Señales de que algo creció mal o fue retenido. Se muestran independientemente de la pestaña abierta.", "Skipped slots": "Ranuras omitidas", "State": "Estado", "Storyline and signal strength before drilling into positions and actions.": "Narrativa y fuerza de la señal antes de entrar en posiciones y acciones.", "Streaming": "Transmisión", "Suggested next steps": "Próximos pasos sugeridos", "The line of investigation and where the open questions concentrate.": "La línea de investigación y dónde se concentran las preguntas abiertas.", "The narrative arc and how strongly themes are trending.": "El arco narrativo y con qué fuerza se mueven los temas.", "The world model asked for these capabilities and nothing took them up.": "El modelo del mundo pidió estas capacidades y nada las asumió.", "Theme intensity": "Intensidad temática", "Themes": "Temas", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Este panel informa de cómo el framework se modifica a sí mismo. Todavía no se ha registrado nada.", "To": "Hasta", "Tool": "Herramienta", "Tool-name conflicts": "Conflictos de nombres de herramientas", "Tools": "Herramientas", "Transport": "Transporte", "Transport, provenance and channel counts": "Transporte, procedencia y número de canales", "Trust": "Confianza", "Trust accrual": "Acumulación de confianza", "Trust class": "Clase de confianza", "Unselectable reclamation": "Recuperación no seleccionable", "Usable": "Utilizable", "VERIFIED": "Verificado", "Verdicts": "Veredictos", "Verdicts by reason": "Veredictos por motivo", "Verified": "Verificado", "Verified by": "Verificado por", "Voices & concerns": "Voces e inquietudes", "Watchlist": "Lista de seguimiento", "What changed in the environment, and what the framework did about it.": "Qué cambió en el entorno y qué hizo el framework al respecto.", "Which plugin owns which tool, and which capability that tool provides.": "Qué plugin posee qué herramienta y qué capacidad proporciona esa herramienta.", "Who/what is in the conversation, and the concerns still open.": "Quién/qué está en la conversación y las inquietudes aún abiertas.", "Why": "Por qué", "Why not admitted": "Motivo de no admisión", "Why this page is empty": "Por qué esta página está vacía", "World-model driver": "Controlador del modelo del mundo", "Writable": "Escribible", "aborted": "Abortado", "accruing": "Acumulando", "active": "Activo", "appeared": "Apareció", "armed": "Armado", "assess_compatibility": "Evaluar compatibilidad", "built_in": "Integrado", "capability_expand": "Ampliar capacidad", "committed": "Concluido", "conformance": "Conformidad", "declared_fitness": "Aptitud declarada", "disable": "Desactivar", "disposed": "Liberado", "effect_observed": "Efecto observado", "environment_probe": "Sonda de entorno", "execution_failed": "Ejecución fallida", "expected_effect_absent": "Efecto esperado ausente", "failed": "Fallido", "frozen": "Congelado", "gone": "Desapareció", "idle": "Inactivo", "install": "Instalar", "loading": "Cargando", "manual": "Manual", "moved": "Se movió", "new_unproven": "Nuevo, no probado", "no": "No", "no_evidence": "Sin evidencia", "no_expected_effect_declared": "Sin efecto esperado declarado", "no_outcome_observed": "Sin resultado observado", "none": "Ninguno", "not_admitted": "No admitido", "not_applicable": "No aplicable", "observe_only": "Solo observar", "observed_effect": "Efecto observado", "open": "Abierto", "pending": "Pendiente", "reload": "Recargar", "remove": "Eliminar", "reopened": "Reabierto", "resolved": "Resuelto", "rollback": "Revertir", "runtime": "Tiempo de ejecución", "self_acquired": "Autoadquirido", "still_open": "Aún abierto", "tool_reported_no_effect": "La herramienta no informó efecto", "trusted": "De confianza", "unknown": "Desconocido", "unknown_tool": "Herramienta desconocida", "unloading": "Descargando", "unscheduled": "No planificado", "unverifiable": "No verificable", "unverified": "No verificado", "waiting": "En espera", "watching": "Vigilando", "wired": "Conectado", "world_model": "Modelo del mundo", "yes": "Sí", "Causal trace": "Traza causal", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Evidencia de solo lectura del entorno a la gobernanza para una instantánea de evolución del framework.", "Evidence boundary": "Límite de evidencia", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Una traza causal muestra hechos registrados; no infiere aprobación ausente ni efecto observado.", "Episodes": "Episodios", "Declared-fitness closures": "Cierres por aptitud declarada", "Counterfactual / mutation matrix": "Matriz contrafactual / de mutaciones", "Each row preserves the driver, decision, registry delta, and verification tier.": "Cada fila conserva el desencadenante, la decisión, el delta del registro y el nivel de verificación.", "Trigger": "Desencadenante", "Evidence tier": "Nivel de evidencia", "Episode timeline": "Cronología de episodios", "Rebuilt from existing decision and observation records.": "Reconstruida a partir de registros existentes de decisión y observación.", "Durable trace feed": "Flujo de trazas durables", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Las decisiones rechazadas y sin acción permanecen visibles cuando se instala su receptor de trazas.", "Lifecycle": "Ciclo de vida", "Pipeline evidence over time": "Evidencia del canal a lo largo del tiempo", "One point per recorded change in framework state, oldest first.": "Un punto por cada cambio registrado del estado del framework, del más antiguo al más reciente.", "Samples": "Muestras", "Net change": "Cambio neto"}, - ar: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **لم يُسجَّل أي حكم على الأثر بعد**، لذا لا توجد إشارة مكافأة لقياسها. النسب أعلاه فارغة عن قصد وليست صفرًا. لا يمكن التحقق من الأثر إلا إذا أعلنه المطلب، واليوم لا تحمل الأثر المتوقع سوى المطالب التي كتبها نموذج العالم.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **انحدار: فجوة أُغلقت عادت للظهور.** تطوّر بدا ناجحًا لم يصمد. هذا هو الاكتشاف الوحيد في هذه اللوحة الذي يستدعي انتباهًا فوريًا.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **لقطة فقط.** لا يوجد بعد تاريخ سببي لإعادة بنائه، لذا فالخط الزمني غائب وليس فارغًا. السبب مبيَّن في صف `قرارات السياسة` تحت تغطية المسار؛ اللقطة الحيّة وجدول التغطية غير متأثرين.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **بعض الإضافات مُجمَّدة بسبب خلل داخلي.** الإضافة المُجمَّدة لا تزال تُبلِّغ `DRAFT`، وبُعد الثقة يقوم بالتقييم فقط، لذا تبقى قابلة للاختيار إلا إذا أُلغي تسجيلها أيضًا — راجع عمود `قابل للاختيار`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **مستوى التحقق: L2 (الملاءمة المُعلنة).** سحب الرصد يعني أن مرشّحًا *أعلن* أنه يوفّر القدرة، لا أن القدرة رُصدت وهي تعمل. التحقق من الأثر (L3) غير موصول، لذا لا ينبغي قراءة أي إغلاق في هذه اللوحة كأمر مُثبَت.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> يجب أن تكتمل دورة مراقبة واحدة قبل ظهور أي محتوى. إذا استمر ذلك، تحقّق من تمكين المُجدول وأن مراقبة `framework-evolution` مُسلّحة وغير مكتومة.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> تُكتب الحلقة عندما يؤدي رصد للبيئة إلى قرار بشأن قدرة. لم يُسجَّل أي منها، وهذا يعني إمّا نظامًا هادئًا أو مسارًا يتوقف قبل ذلك — تبويب **المسار** يحدّد الجزء الذي يتوقف عنده وما الذي يزيل التعطيل.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> لا شيء يستعيدها تلقائيًا. كل واحدة تحتجز اسم أداة وتظهر في قائمة القدرات دون أن تكون قابلة للاختيار، فينمو السجل في اتجاه لا يمكن لأي مطلب استخدامه.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> لم تدخل هذه المقترحات أي مسار، لذا لا تظهر في أي سجل قرار أو رصد. قبولها خيار في الإعدادات.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "نسبة أقل من 1.0 تعني أن حلقة أخذ العينات لا تحافظ على وتيرتها المعلنة.", "Abstained": "امتناع", "Acquisition authority": "سلطة الاكتساب", "Acquisition lifecycle": "دورة حياة الاكتساب", "Action": "الإجراء", "After": "بعد", "An unverified declaration has its writable channels demoted to read-only.": "الإعلان غير المُتحقَّق منه تُخفَّض قنواته القابلة للكتابة إلى القراءة فقط.", "Approval": "الموافقة", "Autonomous governance": "الحكم الذاتي", "Autonomy": "الاستقلالية", "Before": "قبل", "CANDIDATE": "مرشّح", "Calibrated at": "تاريخ المعايرة", "Calibration health": "سلامة المعايرة", "Calls": "الاستدعاءات", "Calls (decisions)": "التوصيات (القرارات)", "Candlestick": "الشموع", "Capability": "القدرة", "Capability adaptation": "تكييف القدرات", "Capability observations": "رصد القدرات", "Capability ownership": "ملكية القدرات", "Capability topology": "طوبولوجيا القدرات", "Change": "التغيير", "Channel": "القناة", "Channels": "القنوات", "Channels that have never been calibrated or whose calibration has expired are shown first.": "تظهر أولاً القنوات التي لم تُعاير قط أو التي انتهت صلاحية معايرتها.", "Command": "الأمر", "Commanded versus observed, best tracking first": "المأمور مقابل المرصود، الأفضل تتبعاً أولاً", "Composition": "التركيب", "Concerns (open questions)": "المخاوف (أسئلة مفتوحة)", "Confidence": "الثقة", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "محسوب على كل قناة مرسومة. \"قريب\" تعني داخل 5% من حد معلن.", "Cycles run": "الدورات المنفَّذة", "DRAFT": "مسوّدة", "Days since": "الأيام المنقضية", "Decision": "القرار", "Decisions read as calls; action items as the execution checklist.": "القرارات تُقرأ كتوصيات؛ والإجراءات كقائمة تنفيذ.", "Declared Hz": "الهرتز المعلن", "Desk brief": "موجز المكتب", "Device": "الجهاز", "Dropped samples": "العينات المفقودة", "Each row names one blocked segment and the change that would unblock it.": "كل صف يحدّد جزءًا معطَّلًا والتغيير الذي يزيل التعطيل.", "Effect verification (L3)": "التحقق من الأثر (L3)", "Effects declared": "الآثار المُعلنة", "Entities as references, and recommended next prompts to advance the work.": "الكيانات كمراجع، والمطالبات التالية الموصى بها لدفع العمل.", "Entities in play and the open risks still to resolve.": "الكيانات المعنية والمخاطر المفتوحة التي لم تُحل.", "Envelope, rate, staleness and quality observations · newest first": "رصدات المغلف والمعدل والتقادم والجودة · الأحدث أولاً", "Environment": "البيئة", "Environment to framework": "من البيئة إلى الإطار", "Environment, selected plugin tools, and orchestration order.": "البيئة والأدوات المختارة وترتيب التنسيق.", "Error rate": "معدل الأخطاء", "Events paced out": "الأحداث المُقيَّدة", "Ever used": "استُخدم سابقًا", "Evidence": "الدليل", "Evidence admission": "قبول الأدلة", "Evolution": "التطور", "Evolution timeline": "الخط الزمني للتطور", "Executable": "قابل للتنفيذ", "Execution checklist": "قائمة التنفيذ", "Extracted from this session's tool/file output (not model-generated).": "مستخرج من مخرجات الأدوات/الملفات في هذه الجلسة (ليس من إنشاء النموذج).", "Failures": "الأعطال", "Fiber": "الخيط", "Fiber state changes since the previous cycle, including load retries.": "تغييرات حالة الـ fiber منذ الدورة السابقة، بما في ذلك محاولات التحميل.", "Finance lens": "منظور مالي", "Follow-ups": "المتابعات", "Framework change": "تغيير الإطار", "Framework changes as they happened, from runtime probes.": "تغييرات الإطار لحظة حدوثها، من مجسّات وقت التشغيل.", "Framework evolution": "تطور الإطار", "Framework size and how much of the evolution pipeline shows runtime evidence.": "حجم الإطار ومقدار ما يُظهره مسار التطور من أدلة وقت التشغيل.", "From": "من", "Frozen plugins": "الإضافات المُجمَّدة", "Gap closure": "إغلاق الفجوة", "Halt": "إيقاف", "How closures are verified": "كيف يُتحقَّق من الإغلاقات", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "ما مقدار إشارة الأثر القابل للاستخدام كتغذية راجعة. هذا يحدّد ما إذا كان بناء سياسة تعلّم يستحق العناء.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "ما مقدار ما نمّاه الإطار بنفسه، وما مقدار المسار الذي يُظهر أدلة وقت التشغيل.", "How often each window sat inside, near, or outside its declared limits": "عدد المرات التي كانت فيها كل نافذة داخل حدودها المعلنة أو قريبة منها أو خارجها", "Inquiry brief": "موجز الاستقصاء", "Insights carded as evidence, capped for fast review.": "الرؤى معروضة كأدلة، ومحدودة العدد للمراجعة السريعة.", "Instruments & counterparties": "الأدوات والأطراف المقابلة", "Kept": "المحتفظ به", "Latest capability decision": "أحدث قرار للقدرات", "Lifecycle records": "سجلات دورة الحياة", "Lifecycle timeline": "الخط الزمني لدورة الحياة", "Lifecycle transitions": "انتقالات دورة الحياة", "Line of inquiry": "خط الاستقصاء", "Live activity": "النشاط المباشر", "Location": "الموقع", "Loop phase": "مرحلة الحلقة", "Mean of each downsample window. Declared limits are listed per channel below.": "متوسط كل نافذة تخفيض للعينات. الحدود المعلنة مدرجة لكل قناة أدناه.", "Model's reasoning": "استدلال النموذج", "Mutation": "التغيير", "Narrative": "السرد", "Narrative pulse": "نبض السرد", "Needs attention": "يستدعي الانتباه", "Next recal due": "موعد إعادة المعايرة", "Next step": "الخطوة التالية", "No causal history yet": "لا يوجد تاريخ سببي بعد", "Normalized error": "الخطأ المعياري", "Normalized error is the residual as a share of the channel's declared span.": "الخطأ المعياري هو المتبقي كنسبة من المدى المعلن للقناة.", "Not yet observed": "لم يُرصد بعد", "Nothing has driven a framework change, so there is no episode to narrate.": "لم يدفع أي شيء بعد إلى تغيير في الإطار، لذا لا توجد حلقة لسردها.", "OHLC extracted from captured session market data.": "OHLC مستخرج من بيانات السوق المسجلة في الجلسة.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "قائمة الرصد وحالة المقترحات وقرارات السياسة ونتائج دورة الحياة.", "Observations": "الرصدات", "Observed Hz": "الهرتز المرصود", "Observed rate against declared rate": "المعدل المرصود مقابل المعدل المعلن", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "مساحة أسماء عالمية واحدة، تُحكَّم بأسبقية التسجيل. يُسجَّل المتنافس ولا يُهمَل بصمت.", "Open": "مفتوح", "Open risks": "المخاطر المفتوحة", "Open/high/low/close from captured tool output.": "الافتتاح/الأعلى/الأدنى/الإغلاق من مخرجات الأدوات المسجلة.", "Origin": "المصدر", "Outcome": "النتيجة", "PRODUCTION": "إنتاج", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "لكل حلقة: المُحفِّز والقرار والتغيير وما إذا أُغلقت الفجوة.", "Per-channel calibration state, freshness, and residual correction": "حالة المعايرة وحداثتها وتصحيح المتبقي لكل قناة", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "أدلة وقت التشغيل لكل مقطع. وجود وحدة لا يعني أن شيئًا يستدعيها.", "Pipeline": "المسار", "Pipeline evidence": "أدلة المسار", "Pipeline reachability": "إمكانية الوصول إلى المسار", "Plan": "الخطة", "Plan steps": "خطوات الخطة", "Plugin": "الملحق", "Plugin roster and trust": "قائمة الملحقات والثقة", "Plugins": "الملحقات", "Plugins by origin": "الإضافات حسب المصدر", "Plugins by trust class": "الإضافات حسب فئة الثقة", "Policy": "السياسة", "Policy decisions": "قرارات السياسة", "Positions & actions": "المراكز والإجراءات", "Posture": "الوضع", "Price action": "حركة السعر", "Proposal": "المقترح", "Proposal status": "حالة المقترح", "Proposed, not admitted": "مُقترح وغير مقبول", "Pulse": "النبض", "Quarantine feed": "تغذية الحجر", "Ratio": "النسبة", "Read live from the registry and trust ledger every cycle.": "يُقرأ مباشرة من السجل ودفتر الثقة في كل دورة.", "Recent episodes": "الحلقات الأخيرة", "Reclaim candidates": "مرشّحو الاسترجاع", "Reclaimable": "قابل للاسترجاع", "References & follow-ups": "المراجع والمتابعات", "References (entities)": "المراجع (الكيانات)", "Registry": "السجل", "Registry delta": "فرق السجل", "Registry version": "إصدار السجل", "Regressions": "الانحدارات", "Rejected": "المرفوض", "Representative observations, capped for quick scanning.": "رصدات تمثيلية، محدودة العدد للقراءة السريعة.", "Requirements": "المتطلبات", "Research lens": "منظور بحثي", "Residual": "المتبقي", "Reward signal bandwidth": "نطاق إشارة المكافأة", "Runtime evidence": "دليل وقت التشغيل", "Sampled history per channel, newest on the right": "سجل العينات لكل قناة، الأحدث على اليمين", "Segment": "المقطع", "Segments by status": "الأجزاء حسب الحالة", "Selectable": "قابل للاختيار", "Selection delta": "فرق الاختيار", "Self-acquired": "مُكتسَب ذاتيًا", "Self-acquired plugins that are registered but unselectable or never once used.": "إضافات مُكتسَبة ذاتيًا مُسجَّلة لكنها غير قابلة للاختيار أو لم تُستخدم قطّ.", "Sentiment lens": "منظور المشاعر", "Series": "السلسلة", "Session analysis": "تحليل الجلسة", "Signal strength": "قوة الإشارة", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "إشارات على أن شيئًا نما بشكل خاطئ أو تم حجبه. تظهر أيًا كان التبويب المفتوح.", "Skipped slots": "الفتحات المتخطاة", "State": "الحالة", "Storyline and signal strength before drilling into positions and actions.": "السرد وقوة الإشارة قبل التوسع في المراكز والإجراءات.", "Streaming": "بث", "Suggested next steps": "الخطوات التالية المقترحة", "The line of investigation and where the open questions concentrate.": "خط البحث وأين تتركز الأسئلة المفتوحة.", "The narrative arc and how strongly themes are trending.": "قوس السرد ومدى قوة اتجاه الموضوعات.", "The world model asked for these capabilities and nothing took them up.": "طلب نموذج العالم هذه القدرات ولم يتبنّها شيء.", "Theme intensity": "شدة الموضوعات", "Themes": "الموضوعات", "This board reports how the framework changes itself. Nothing has been recorded yet.": "تُبلِّغ هذه اللوحة عن كيفية تغيير الإطار لنفسه. لم يُسجَّل أي شيء بعد.", "To": "إلى", "Tool": "الأداة", "Tool-name conflicts": "تعارضات أسماء الأدوات", "Tools": "الأدوات", "Transport": "النقل", "Transport, provenance and channel counts": "النقل والمنشأ وعدد القنوات", "Trust": "الثقة", "Trust accrual": "تراكم الثقة", "Trust class": "فئة الثقة", "Unselectable reclamation": "استرجاع غير القابل للاختيار", "Usable": "قابل للاستخدام", "VERIFIED": "مُتحقَّق", "Verdicts": "الأحكام", "Verdicts by reason": "الأحكام حسب السبب", "Verified": "مُتحقَّق", "Verified by": "تم التحقق بواسطة", "Voices & concerns": "الأصوات والمخاوف", "Watchlist": "قائمة المتابعة", "What changed in the environment, and what the framework did about it.": "ما تغيّر في البيئة، وما فعله الإطار حيال ذلك.", "Which plugin owns which tool, and which capability that tool provides.": "أي ملحق يملك أي أداة، وأي قدرة توفرها تلك الأداة.", "Who/what is in the conversation, and the concerns still open.": "من/ما هو في المحادثة، والمخاوف التي لا تزال مفتوحة.", "Why": "السبب", "Why not admitted": "سبب عدم القبول", "Why this page is empty": "لماذا هذه الصفحة فارغة", "World-model driver": "مُشغِّل نموذج العالم", "Writable": "قابل للكتابة", "aborted": "مُلغى", "accruing": "قيد التراكم", "active": "نشط", "appeared": "ظهر", "armed": "مُسلّح", "assess_compatibility": "تقييم التوافق", "built_in": "مدمج", "capability_expand": "توسيع القدرة", "committed": "مُنجَز", "conformance": "المطابقة", "declared_fitness": "الملاءمة المُعلنة", "disable": "تعطيل", "disposed": "تم التخلص منه", "effect_observed": "تم رصد الأثر", "environment_probe": "مِجَس البيئة", "execution_failed": "فشل التنفيذ", "expected_effect_absent": "الأثر المتوقع غائب", "failed": "فشل", "frozen": "مُجمَّد", "gone": "اختفى", "idle": "خامل", "install": "تثبيت", "loading": "قيد التحميل", "manual": "يدوي", "moved": "انتقل", "new_unproven": "جديد وغير مُثبَت", "no": "لا", "no_evidence": "لا يوجد دليل", "no_expected_effect_declared": "لم يُعلَن أثر متوقع", "no_outcome_observed": "لم يُرصد أي ناتج", "none": "لا شيء", "not_admitted": "غير مقبول", "not_applicable": "غير منطبق", "observe_only": "المراقبة فقط", "observed_effect": "الأثر المرصود", "open": "مفتوح", "pending": "معلّق", "reload": "إعادة تحميل", "remove": "إزالة", "reopened": "أُعيد فتحه", "resolved": "تم الحل", "rollback": "تراجع", "runtime": "وقت التشغيل", "self_acquired": "مُكتسَب ذاتيًا", "still_open": "لا يزال مفتوحًا", "tool_reported_no_effect": "الأداة لم تُبلِّغ عن أثر", "trusted": "موثوق", "unknown": "غير معروف", "unknown_tool": "أداة غير معروفة", "unloading": "قيد الإلغاء", "unscheduled": "غير مُجدول", "unverifiable": "غير قابل للتحقق", "unverified": "غير مُتحقَّق", "waiting": "في الانتظار", "watching": "يراقب", "wired": "موصول", "world_model": "نموذج العالم", "yes": "نعم", "Causal trace": "الأثر السببي", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "دليل للقراءة فقط يربط البيئة بالحوكمة للّقطة واحدة من تطور الإطار.", "Evidence boundary": "حدود الدليل", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "يعرض الأثر السببي الحقائق المسجلة ولا يستنتج موافقة مفقودة أو أثرًا مرصودًا.", "Episodes": "الحلقات", "Declared-fitness closures": "إغلاقات الملاءمة المعلنة", "Counterfactual / mutation matrix": "مصفوفة الافتراضات المضادة / التغييرات", "Each row preserves the driver, decision, registry delta, and verification tier.": "يحفظ كل صف المحفز والقرار وفرق السجل ومستوى التحقق.", "Trigger": "المحفز", "Evidence tier": "طبقة الدليل", "Episode timeline": "الخط الزمني للحلقات", "Rebuilt from existing decision and observation records.": "أُعيد بناؤه من سجلات القرار والرصد الموجودة.", "Durable trace feed": "تدفق آثار دائم", "Rejected and no-op decisions remain visible when their trace sink is installed.": "تبقى القرارات المرفوضة والتي بلا إجراء مرئية عند تثبيت مستقبل آثارها.", "Lifecycle": "دورة الحياة", "Pipeline evidence over time": "أدلة المسار عبر الزمن", "One point per recorded change in framework state, oldest first.": "نقطة واحدة لكل تغيير مسجّل في حالة الإطار، الأقدم أولًا.", "Samples": "العينات", "Net change": "التغير الصافي"}, - ru: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Ни одного заключения об эффекте пока не записано**, поэтому измерять нечего. Показатели выше намеренно пусты, а не равны нулю. Эффект можно проверить только если требование его заявило, а сегодня заявленный эффект несут лишь требования, составленные моделью мира.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Регрессия: закрытый пробел возобновился.** Эволюция, казавшаяся успешной, не удержалась. Это единственный вывод на этой панели, требующий немедленного внимания.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Только снимок.** Причинной истории для восстановления пока нет, поэтому хронология отсутствует, а не пуста. Причина указана в строке `Решения политики` под покрытием конвейера; снимок и таблица покрытия не затронуты.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Некоторые плагины заморожены из-за внутреннего дефекта.** Замороженный плагин по-прежнему сообщает `DRAFT`, а измерение доверия только *оценивает*, поэтому он остаётся выбираемым, пока не будет также снят с регистрации — см. столбец `Выбираемо`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Уровень проверки: L2 (заявленная пригодность).** Снятое наблюдение означает, что кандидат *заявил* о предоставлении возможности, а не что возможность наблюдалась в работе. Проверка эффекта (L3) не подключена, поэтому ни одно закрытие на этой панели не следует считать доказанным.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Прежде чем появятся данные, должен завершиться хотя бы один цикл наблюдения. Если это сохраняется, проверьте, включён ли планировщик и что наблюдение `framework-evolution` активно и не отключено.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Эпизод записывается, когда наблюдение окружения приводит к решению о возможности. Ни одного не зафиксировано: либо система спокойна, либо конвейер останавливается раньше — вкладка **Конвейер** называет сегмент остановки и то, что его разблокирует.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Ничто не утилизирует их автоматически. Каждый занимает имя инструмента и присутствует в списке возможностей, не будучи выбираемым: реестр растёт в направлении, непригодном ни для одного требования.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Эти предложения не вошли ни в один конвейер, поэтому не отражены ни в одной записи решения или наблюдения. Их приём — вопрос конфигурации.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Отношение ниже 1,0 означает, что цикл выборки не выдерживает объявленный ритм.", "Abstained": "Воздержалось", "Acquisition authority": "Право на получение", "Acquisition lifecycle": "Жизненный цикл получения", "Action": "Действие", "After": "После", "An unverified declaration has its writable channels demoted to read-only.": "У непроверенного объявления записываемые каналы понижаются до только чтения.", "Approval": "Согласование", "Autonomous governance": "Автономное управление", "Autonomy": "Автономность", "Before": "До", "CANDIDATE": "Кандидат", "Calibrated at": "Калиброван", "Calibration health": "Состояние калибровки", "Calls": "Вызовы", "Calls (decisions)": "Рекомендации (решения)", "Candlestick": "Свечи", "Capability": "Возможность", "Capability adaptation": "Адаптация возможностей", "Capability observations": "Наблюдения возможностей", "Capability ownership": "Владение возможностями", "Capability topology": "Топология возможностей", "Change": "Изменение", "Channel": "Канал", "Channels": "Каналы", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Каналы, которые никогда не калибровались или чья калибровка истекла, показаны первыми.", "Command": "Команда", "Commanded versus observed, best tracking first": "Заданное против наблюдаемого, лучшее отслеживание первым", "Composition": "Состав", "Concerns (open questions)": "Опасения (открытые вопросы)", "Confidence": "Уверенность", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Подсчитано по всем отображаемым каналам. «У границы» — в пределах 5% от объявленного предела.", "Cycles run": "Выполнено циклов", "DRAFT": "Черновик", "Days since": "Дней с тех пор", "Decision": "Решение", "Decisions read as calls; action items as the execution checklist.": "Решения читаются как рекомендации; действия — как чек-лист исполнения.", "Declared Hz": "Объявл. Гц", "Desk brief": "Сводка деска", "Device": "Устройство", "Dropped samples": "Отброшенные образцы", "Each row names one blocked segment and the change that would unblock it.": "Каждая строка называет заблокированный сегмент и изменение, которое его разблокирует.", "Effect verification (L3)": "Проверка эффекта (L3)", "Effects declared": "Заявлено эффектов", "Entities as references, and recommended next prompts to advance the work.": "Сущности как ссылки и рекомендуемые следующие запросы.", "Entities in play and the open risks still to resolve.": "Задействованные сущности и нерешённые риски.", "Envelope, rate, staleness and quality observations · newest first": "Наблюдения по огибающей, частоте, устареванию и качеству · сначала новые", "Environment": "Окружение", "Environment to framework": "От окружения к фреймворку", "Environment, selected plugin tools, and orchestration order.": "Окружение, выбранные инструменты плагинов и порядок оркестрации.", "Error rate": "Частота ошибок", "Events paced out": "Событий подавлено", "Ever used": "Использовался", "Evidence": "Обоснование", "Evidence admission": "Приём данных", "Evolution": "Эволюция", "Evolution timeline": "Хронология эволюции", "Executable": "Исполнимо", "Execution checklist": "Чек-лист исполнения", "Extracted from this session's tool/file output (not model-generated).": "Извлечено из вывода инструментов/файлов этой сессии (не сгенерировано моделью).", "Failures": "Сбои", "Fiber": "Файбер", "Fiber state changes since the previous cycle, including load retries.": "Изменения состояния fiber с предыдущего цикла, включая повторные загрузки.", "Finance lens": "Финансовый ракурс", "Follow-ups": "Продолжения", "Framework change": "Изменение фреймворка", "Framework changes as they happened, from runtime probes.": "Изменения фреймворка в момент их появления, от рантайм-зондов.", "Framework evolution": "Эволюция фреймворка", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Размер фреймворка и какая часть конвейера эволюции показывает свидетельства времени выполнения.", "From": "Из", "Frozen plugins": "Замороженные плагины", "Gap closure": "Закрытие пробела", "Halt": "Останов", "How closures are verified": "Как проверяются закрытия", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Какая часть сигнала об эффекте пригодна как обратная связь. Это определяет, стоит ли строить обучающую политику.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Какую часть фреймворка он вырастил сам и какая часть конвейера показывает данные времени выполнения.", "How often each window sat inside, near, or outside its declared limits": "Как часто каждое окно было внутри, у границы или вне объявленных пределов", "Inquiry brief": "Сводка исследования", "Insights carded as evidence, capped for fast review.": "Инсайты как карточки-обоснования, ограничены для быстрого просмотра.", "Instruments & counterparties": "Инструменты и контрагенты", "Kept": "Оставлен", "Latest capability decision": "Последнее решение о возможностях", "Lifecycle records": "Записи жизненного цикла", "Lifecycle timeline": "Хронология жизненного цикла", "Lifecycle transitions": "Переходы жизненного цикла", "Line of inquiry": "Линия исследования", "Live activity": "Текущая активность", "Location": "Расположение", "Loop phase": "Фаза цикла", "Mean of each downsample window. Declared limits are listed per channel below.": "Среднее по каждому окну прореживания. Объявленные пределы указаны по каналам ниже.", "Model's reasoning": "Обоснование модели", "Mutation": "Изменение", "Narrative": "Сюжет", "Narrative pulse": "Нарративный пульс", "Needs attention": "Требует внимания", "Next recal due": "Следующая рекалибровка", "Next step": "Следующий шаг", "No causal history yet": "Причинной истории пока нет", "Normalized error": "Нормированная ошибка", "Normalized error is the residual as a share of the channel's declared span.": "Нормированная ошибка — остаток как доля объявленного диапазона канала.", "Not yet observed": "Ещё не наблюдалось", "Nothing has driven a framework change, so there is no episode to narrate.": "Ничто пока не вызвало изменения фреймворка, поэтому рассказывать не о чем.", "OHLC extracted from captured session market data.": "OHLC извлечён из рыночных данных, записанных в сессии.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Очередь наблюдений, состояние предложений, решения политики и итоги жизненного цикла.", "Observations": "Наблюдения", "Observed Hz": "Наблюд. Гц", "Observed rate against declared rate": "Наблюдаемая частота против объявленной", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Единое глобальное пространство имён, арбитраж по первому пришедшему. Претендент записывается, а не отбрасывается молча.", "Open": "Открыт", "Open risks": "Открытые риски", "Open/high/low/close from captured tool output.": "Открытие/максимум/минимум/закрытие из записанного вывода инструментов.", "Origin": "Источник", "Outcome": "Результат", "PRODUCTION": "Продакшн", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "По эпизодам: триггер, решение, изменение и закрылся ли пробел.", "Per-channel calibration state, freshness, and residual correction": "Состояние калибровки, актуальность и остаточная поправка по каналам", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Свидетельства времени выполнения по сегментам. Наличие модуля не доказывает, что его кто-то вызывает.", "Pipeline": "Конвейер", "Pipeline evidence": "Свидетельства конвейера", "Pipeline reachability": "Достижимость конвейера", "Plan": "План", "Plan steps": "Шаги плана", "Plugin": "Плагин", "Plugin roster and trust": "Реестр плагинов и доверие", "Plugins": "Плагины", "Plugins by origin": "Плагины по происхождению", "Plugins by trust class": "Плагины по классу доверия", "Policy": "Политика", "Policy decisions": "Решения политики", "Positions & actions": "Позиции и действия", "Posture": "Состояние", "Price action": "Ценовое движение", "Proposal": "Предложение", "Proposal status": "Статус предложения", "Proposed, not admitted": "Предложено, не принято", "Pulse": "Пульс", "Quarantine feed": "Поток карантина", "Ratio": "Отношение", "Read live from the registry and trust ledger every cycle.": "Читается напрямую из реестра и журнала доверия каждый цикл.", "Recent episodes": "Недавние эпизоды", "Reclaim candidates": "Кандидаты на утилизацию", "Reclaimable": "Утилизируемо", "References & follow-ups": "Ссылки и продолжения", "References (entities)": "Ссылки (сущности)", "Registry": "Реестр", "Registry delta": "Изменение реестра", "Registry version": "Версия реестра", "Regressions": "Регрессии", "Rejected": "Отклонён", "Representative observations, capped for quick scanning.": "Показательные наблюдения, ограничены для быстрого просмотра.", "Requirements": "Требования", "Research lens": "Исследовательский ракурс", "Residual": "Остаток", "Reward signal bandwidth": "Пропускная способность сигнала вознаграждения", "Runtime evidence": "Свидетельство времени выполнения", "Sampled history per channel, newest on the right": "История выборок по каналам, самое новое справа", "Segment": "Сегмент", "Segments by status": "Сегменты по статусу", "Selectable": "Выбираемый", "Selection delta": "Изменение выбора", "Self-acquired": "Самостоятельно получено", "Self-acquired plugins that are registered but unselectable or never once used.": "Самостоятельно полученные плагины, которые зарегистрированы, но невыбираемы или ни разу не использовались.", "Sentiment lens": "Ракурс тональности", "Series": "Серия", "Session analysis": "Анализ сессии", "Signal strength": "Сила сигнала", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Признаки того, что что-то выросло неверно или было задержано. Показываются независимо от открытой вкладки.", "Skipped slots": "Пропущенные слоты", "State": "Состояние", "Storyline and signal strength before drilling into positions and actions.": "Сюжет и сила сигнала до перехода к позициям и действиям.", "Streaming": "Потоковая передача", "Suggested next steps": "Рекомендуемые следующие шаги", "The line of investigation and where the open questions concentrate.": "Линия исследования и где сосредоточены открытые вопросы.", "The narrative arc and how strongly themes are trending.": "Нарративная дуга и насколько сильно растут темы.", "The world model asked for these capabilities and nothing took them up.": "Модель мира запросила эти возможности, и никто их не принял.", "Theme intensity": "Интенсивность тем", "Themes": "Темы", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Эта панель сообщает, как фреймворк изменяет сам себя. Пока ничего не записано.", "To": "В", "Tool": "Инструмент", "Tool-name conflicts": "Конфликты имён инструментов", "Tools": "Инструменты", "Transport": "Транспорт", "Transport, provenance and channel counts": "Транспорт, происхождение и число каналов", "Trust": "Доверие", "Trust accrual": "Накопление доверия", "Trust class": "Класс доверия", "Unselectable reclamation": "Утилизация невыбираемого", "Usable": "Пригодно", "VERIFIED": "Проверено", "Verdicts": "Заключений", "Verdicts by reason": "Заключения по причине", "Verified": "Проверено", "Verified by": "Подтверждено", "Voices & concerns": "Голоса и опасения", "Watchlist": "Список наблюдения", "What changed in the environment, and what the framework did about it.": "Что изменилось в окружении и что фреймворк с этим сделал.", "Which plugin owns which tool, and which capability that tool provides.": "Какой плагин владеет каким инструментом и какую возможность этот инструмент предоставляет.", "Who/what is in the conversation, and the concerns still open.": "Кто/что в разговоре и какие опасения остаются.", "Why": "Почему", "Why not admitted": "Причина отклонения", "Why this page is empty": "Почему эта страница пуста", "World-model driver": "Драйвер модели мира", "Writable": "Записываемый", "aborted": "Прервано", "accruing": "Накапливается", "active": "Активно", "appeared": "Появился", "armed": "Активно", "assess_compatibility": "Оценка совместимости", "built_in": "Встроенный", "capability_expand": "Расширение возможностей", "committed": "Завершено", "conformance": "Соответствие", "declared_fitness": "Заявленная пригодность", "disable": "Отключение", "disposed": "Освобождено", "effect_observed": "Эффект наблюдался", "environment_probe": "Зонд окружения", "execution_failed": "Сбой выполнения", "expected_effect_absent": "Ожидаемый эффект отсутствует", "failed": "Сбой", "frozen": "Заморожено", "gone": "Исчез", "idle": "Простой", "install": "Установка", "loading": "Загрузка", "manual": "Вручную", "moved": "Перешёл", "new_unproven": "Новое, непроверенное", "no": "Нет", "no_evidence": "Нет данных", "no_expected_effect_declared": "Ожидаемый эффект не заявлен", "no_outcome_observed": "Результат не наблюдался", "none": "Нет", "not_admitted": "Не принято", "not_applicable": "Неприменимо", "observe_only": "Только наблюдение", "observed_effect": "Наблюдаемый эффект", "open": "Открыто", "pending": "Ожидает", "reload": "Перезагрузка", "remove": "Удаление", "reopened": "Возобновлено", "resolved": "Закрыто", "rollback": "Откат", "runtime": "Среда выполнения", "self_acquired": "Самостоятельно получено", "still_open": "Всё ещё открыто", "tool_reported_no_effect": "Инструмент не сообщил об эффекте", "trusted": "Доверенное", "unknown": "Неизвестно", "unknown_tool": "Неизвестный инструмент", "unloading": "Выгрузка", "unscheduled": "Не запланировано", "unverifiable": "Не проверяемо", "unverified": "Непроверенное", "waiting": "Ожидание", "watching": "Наблюдает", "wired": "Подключено", "world_model": "Модель мира", "yes": "Да", "Causal trace": "Причинная трасса", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Доказательства только для чтения от окружения к управлению для одного снимка эволюции фреймворка.", "Evidence boundary": "Граница доказательств", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Причинная трасса показывает записанные факты и не выводит отсутствующее согласование или наблюдаемый эффект.", "Episodes": "Эпизоды", "Declared-fitness closures": "Закрытия по заявленной пригодности", "Counterfactual / mutation matrix": "Контрфактическая матрица / мутации", "Each row preserves the driver, decision, registry delta, and verification tier.": "Каждая строка сохраняет триггер, решение, изменение реестра и уровень проверки.", "Trigger": "Триггер", "Evidence tier": "Уровень доказательств", "Episode timeline": "Хронология эпизодов", "Rebuilt from existing decision and observation records.": "Восстановлена из существующих записей решений и наблюдений.", "Durable trace feed": "Поток долговечных трасс", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Отклонённые решения и решения без действия остаются видимыми, когда установлен их приёмник трасс.", "Lifecycle": "Жизненный цикл", "Pipeline evidence over time": "Свидетельства конвейера во времени", "One point per recorded change in framework state, oldest first.": "Одна точка на каждое зафиксированное изменение состояния фреймворка, старшие слева.", "Samples": "Выборки", "Net change": "Итоговое изменение"} + zh: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **尚未记录任何效果判定**,因此没有可度量的奖励信号。上面的比率有意留空而非显示 0%。只有当需求声明了预期效果才可能验证,而目前只有世界模型撰写的需求带有预期效果。", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **回归:已闭合的缺口再次复发。** 一次看起来成功的演进并未站住。这是本看板上唯一需要立即处理的发现。", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **仅快照。** 目前尚无可重建的因果历史,因此时间线是「缺席」而非「空白」。原因由管道贯通度中的 `策略决策` 一行说明;实时快照与贯通度表本身不受影响。", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **部分插件因内部缺陷被冻结。** 冻结的插件仍报告 `DRAFT`,而信任维度只做「打分」,因此若未同时注销,它仍可被选中——请查看 `可被选中` 列。", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **验证层级:L2(声明式适配)。** 观测被退役,只意味着某个候选**声明**自己提供该能力,并不意味着该能力被观测到确实生效。效果验证(L3)尚未接线,因此本看板上的任何闭合都不应被读作「已证实」。", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> 需要至少完成一个观测周期才会有内容。若持续为空,请检查调度器是否启用、`framework-evolution` watch 是否已 armed 且未静音。", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> 当一次环境观测导向一次能力决策时,才会写下一条剧集。目前尚无记录——这既可能是系统本就安静,也可能是管道更早就断了:**管道**页签会指出它断在哪一段,以及什么能解除阻塞。", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> 目前没有任何机制自动回收它们。每一个都占着一个工具名、出现在能力列表里,却不可被选中——注册表朝着没有任何需求能用的方向增长。", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> 这些提议未进入任何管道,因此不会出现在任何决策记录或观测中。是否准入是一项配置选择。", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "比值低于 1.0 表示采样循环未能维持其声明的节奏。", "Abstained": "弃权", "Acquisition authority": "获取授权", "Acquisition lifecycle": "获取生命周期", "Action": "动作", "After": "变更后", "An unverified declaration has its writable channels demoted to read-only.": "未核验的声明,其可写通道会被降级为只读。", "Approval": "审批", "Autonomous governance": "自主治理", "Autonomy": "自主级别", "Before": "变更前", "CANDIDATE": "候选级", "Calibrated at": "校准时间", "Calibration health": "校准健康度", "Calls": "调用次数", "Calls (decisions)": "观点(决策)", "Candlestick": "K 线", "Capability": "能力", "Capability adaptation": "能力适配", "Capability observations": "能力观测", "Capability ownership": "能力归属", "Capability topology": "能力拓扑", "Change": "变化", "Channel": "通道", "Channels": "通道数", "Channels that have never been calibrated or whose calibration has expired are shown first.": "从未校准或校准已过期的通道排在最前。", "Command": "命令", "Commanded versus observed, best tracking first": "命令值与实测值对比,跟随最好者在前", "Composition": "组成", "Concerns (open questions)": "关切(待答问题)", "Confidence": "置信度", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "统计所有绘制通道。“接近”指处于声明边界的 5% 以内。", "Cycles run": "已运行周期", "DRAFT": "草稿级", "Days since": "距今天数", "Decision": "决策", "Decisions read as calls; action items as the execution checklist.": "决策即观点,行动项即执行清单。", "Declared Hz": "声明频率 (Hz)", "Desk brief": "交易台简报", "Device": "设备", "Dropped samples": "丢弃的样本", "Each row names one blocked segment and the change that would unblock it.": "每一行指出一个受阻环节,以及能解除阻塞的那项变更。", "Effect verification (L3)": "效果验证(L3)", "Effects declared": "已声明效果", "Entities as references, and recommended next prompts to advance the work.": "实体作为参考,并给出推进工作的后续追问。", "Entities in play and the open risks still to resolve.": "涉及的实体,以及尚未解决的敞口风险。", "Envelope, rate, staleness and quality observations · newest first": "包络、速率、失联与质量观测 · 最新在前", "Environment": "环境", "Environment to framework": "环境 → 框架", "Environment, selected plugin tools, and orchestration order.": "环境、已选插件工具及编排顺序。", "Error rate": "错误率", "Events paced out": "被配速抑制的事件", "Ever used": "是否用过", "Evidence": "证据", "Evidence admission": "证据准入", "Evolution": "演进", "Evolution timeline": "演进时间线", "Executable": "可执行", "Execution checklist": "执行清单", "Extracted from this session's tool/file output (not model-generated).": "数据来自本次会话的工具/文件产物(非模型生成)。", "Failures": "失败次数", "Fiber": "Fiber 状态", "Fiber state changes since the previous cycle, including load retries.": "自上一周期以来的 Fiber 状态变化,含加载重试。", "Finance lens": "金融视图", "Follow-ups": "后续事项", "Framework change": "框架变更", "Framework changes as they happened, from runtime probes.": "来自运行时探针的框架变更实况。", "Framework evolution": "框架演进", "Framework size and how much of the evolution pipeline shows runtime evidence.": "框架规模,以及演进管道中有多少环节呈现运行时证据。", "From": "从", "Frozen plugins": "已冻结插件", "Gap closure": "缺口闭合", "Halt": "可急停", "How closures are verified": "闭合是如何验证的", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "效果信号中有多少可真正用作反馈。这决定了是否值得构建学习策略。", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "框架中有多少是它自己长出来的,以及演进管道中有多少环节呈现运行时证据。", "How often each window sat inside, near, or outside its declared limits": "各窗口处于声明限值内、接近边界或越界的频次", "Inquiry brief": "研究简报", "Insights carded as evidence, capped for fast review.": "洞察以证据卡呈现,数量受限以便快速浏览。", "Instruments & counterparties": "标的与交易对手", "Kept": "保留", "Latest capability decision": "最新能力决策", "Lifecycle records": "生命周期记录", "Lifecycle timeline": "生命周期时间线", "Lifecycle transitions": "生命周期迁移", "Line of inquiry": "研究主线", "Live activity": "实时动态", "Location": "位置", "Loop phase": "循环阶段", "Mean of each downsample window. Declared limits are listed per channel below.": "每个降采样窗口的均值。各通道的声明限值见下方。", "Model's reasoning": "模型的推理", "Mutation": "变更", "Narrative": "叙事", "Narrative pulse": "叙事脉搏", "Needs attention": "需要关注", "Next recal due": "下次校准期限", "Next step": "下一步", "No causal history yet": "尚无因果历史", "Normalized error": "归一化误差", "Normalized error is the residual as a share of the channel's declared span.": "归一化误差是残差占该通道声明量程的比例。", "Not yet observed": "尚未观测", "Nothing has driven a framework change, so there is no episode to narrate.": "尚无任何事驱动过框架变更,因此没有可讲述的剧集。", "OHLC extracted from captured session market data.": "OHLC 提取自本次会话捕获的行情数据。", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "观测待办、提案状态、策略决策与生命周期结果。", "Observations": "观测数", "Observed Hz": "实测频率 (Hz)", "Observed rate against declared rate": "实测速率与声明速率对比", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "单一全局命名空间,先注册者胜。挑战者会被记录,绝不静默丢弃。", "Open": "已连接", "Open risks": "敞口风险", "Open/high/low/close from captured tool output.": "开/高/低/收,来自捕获的工具输出。", "Origin": "来源", "Outcome": "结果", "PRODUCTION": "生产级", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "逐条剧集:触发源、决策、变更,以及缺口是否闭合。", "Per-channel calibration state, freshness, and residual correction": "各通道的校准状态、时效性与残差校正", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "逐段运行时证据。模块存在并不等于有任何代码调用它。", "Pipeline": "管道", "Pipeline evidence": "管道证据", "Pipeline reachability": "管道贯通度", "Plan": "计划", "Plan steps": "计划步骤", "Plugin": "插件", "Plugin roster and maturity": "插件名册与成熟度", "Plugins": "插件数", "Plugins by origin": "按来源分布的插件", "Plugins by maturity": "按成熟度分布的插件", "Policy": "策略", "Policy decisions": "策略决策", "Positions & actions": "持仓与操作", "Posture": "态势", "Price action": "价格行为", "Proposal": "提案", "Proposal status": "提案状态", "Proposed, not admitted": "已提议,未准入", "Pulse": "脉搏", "Quarantine feed": "隔离进料", "Ratio": "比值", "Read live from the registry and maturity ledger every cycle.": "每个周期从注册表与成熟度账本实时读取。", "Recent episodes": "近期剧集", "Reclaim candidates": "可回收候选", "Reclaimable": "可回收", "References & follow-ups": "参考与后续", "References (entities)": "参考(实体)", "Registry": "注册表", "Registry delta": "注册表变化", "Registry version": "注册表版本", "Regressions": "回归", "Rejected": "被拒", "Representative observations, capped for quick scanning.": "代表性观察,数量受限以便快速浏览。", "Requirements": "能力需求", "Research lens": "研究视图", "Residual": "残差", "Reward signal bandwidth": "奖励信号带宽", "Runtime evidence": "运行时证据", "Sampled history per channel, newest on the right": "按通道的采样历史,最新在右侧", "Segment": "管道段", "Segments by status": "按状态分布的管道段", "Selectable": "可被选中", "Selection delta": "选择变化", "Self-acquired": "自获取", "Self-acquired plugins that are registered but unselectable or never once used.": "已注册但不可被选中、或从未被使用过的自获取插件。", "Sentiment lens": "情绪视图", "Series": "序列", "Session analysis": "会话分析", "Signal strength": "信号强度", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "表明某处长错了、或被扣下未放行的信号。无论打开哪个页签都会显示。", "Skipped slots": "跳过的采样点", "State": "状态", "Storyline and signal strength before drilling into positions and actions.": "先看叙事与信号强度,再深入持仓与操作。", "Streaming": "采样中", "Suggested next steps": "建议的下一步", "The line of investigation and where the open questions concentrate.": "研究主线,以及待答问题的集中之处。", "The narrative arc and how strongly themes are trending.": "叙事走向,以及主题的趋势强度。", "The world model asked for these capabilities and nothing took them up.": "世界模型请求了这些能力,但无人受理。", "Theme intensity": "主题强度", "Themes": "主题", "This board reports how the framework changes itself. Nothing has been recorded yet.": "本看板报告框架如何改变自身。目前尚无任何记录。", "To": "到", "Tool": "工具", "Tool-name conflicts": "工具名冲突", "Tools": "工具数", "Transport": "传输方式", "Transport, provenance and channel counts": "传输方式、来源与通道数量", "Maturity": "成熟度", "Maturity accrual": "成熟度累积", "Maturity class": "成熟度", "Unselectable reclamation": "不可选回收", "Usable": "可用", "VERIFIED": "已验证级", "Verdicts": "判定数", "Verdicts by reason": "按原因分布的判定", "Verified": "已核验", "Verified by": "验证依据", "Voices & concerns": "声音与关切", "Watchlist": "关注列表", "What changed in the environment, and what the framework did about it.": "环境发生了什么变化,框架又为此做了什么。", "Which plugin owns which tool, and which capability that tool provides.": "哪个插件拥有哪个工具,以及该工具提供什么能力。", "Who/what is in the conversation, and the concerns still open.": "谁/什么在被讨论,以及尚未解决的关切。", "Why": "原因", "Why not admitted": "未准入原因", "Why this page is empty": "这个页面为何是空的", "World-model driver": "世界模型驱动器", "Writable": "可写", "aborted": "已中断", "accruing": "正在累积", "active": "运行中", "appeared": "新出现", "armed": "已就绪", "assess_compatibility": "评估兼容性", "built_in": "内置", "capability_expand": "扩展能力", "committed": "已定论", "conformance": "合规", "declared_fitness": "声明式适配", "disable": "停用", "disposed": "已释放", "effect_observed": "效果已观测", "environment_probe": "环境探测", "execution_failed": "执行失败", "expected_effect_absent": "预期效果未出现", "failed": "已失败", "frozen": "已冻结", "gone": "已消失", "idle": "空闲无变化", "install": "安装", "loading": "加载中", "manual": "人工", "moved": "已迁移", "new_unproven": "新,未验证", "no": "否", "no_evidence": "无证据", "no_expected_effect_declared": "未声明预期效果", "no_outcome_observed": "未观测到结果", "none": "无", "not_admitted": "未准入", "not_applicable": "不适用", "observe_only": "仅观察", "observed_effect": "观测效果", "open": "进行中", "pending": "待启", "reload": "重载", "remove": "移除", "reopened": "已复发", "resolved": "已闭合", "rollback": "回滚", "runtime": "运行时", "self_acquired": "自获取", "still_open": "仍未闭合", "tool_reported_no_effect": "工具未报告效果", "trusted": "已信任", "unknown": "未知", "unknown_tool": "未知工具", "unloading": "卸载中", "unscheduled": "未调度", "unverifiable": "无法核实", "unverified": "未验证", "waiting": "等待首个周期", "watching": "监视中", "wired": "已贯通", "world_model": "世界模型", "yes": "是", "Causal trace": "因果追踪", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "单个框架演进快照的只读环境到治理证据。", "Evidence boundary": "证据边界", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "因果追踪展示已记录的事实;不推断缺失的审批或已观测效果。", "Episodes": "剧集", "Declared-fitness closures": "声明式适配闭合", "Counterfactual / mutation matrix": "反事实 / 变更矩阵", "Each row preserves the driver, decision, registry delta, and verification tier.": "每一行保留驱动因素、决策、注册表变化和验证层级。", "Trigger": "触发源", "Evidence tier": "证据层级", "Episode timeline": "剧集时间线", "Rebuilt from existing decision and observation records.": "从现有决策和观测记录重建。", "Durable trace feed": "持久追踪流", "Rejected and no-op decisions remain visible when their trace sink is installed.": "安装追踪接收器后,被拒绝和无操作决策仍保持可见。", "Lifecycle": "生命周期", "Pipeline evidence over time": "管道证据随时间变化", "One point per recorded change in framework state, oldest first.": "每一个点对应一次已记录的框架状态变化,最旧在左。", "Samples": "样本数", "Net change": "净变化"}, + fr: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aucun verdict d'effet n'a encore été enregistré**, il n'y a donc aucun signal de récompense à mesurer. Les taux ci-dessus sont volontairement vides plutôt que nuls. Un effet ne peut être vérifié que si l'exigence en a déclaré un, et seules les exigences rédigées par le modèle du monde en portent aujourd'hui.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Régression : un écart comblé s'est reproduit.** Une évolution qui semblait réussie n'a pas tenu. C'est le seul constat de ce tableau qui exige une attention immédiate.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Instantané seulement.** Aucun historique causal à reconstruire pour l'instant : la chronologie est absente, non vide. La raison est indiquée par la ligne `Décisions de politique` sous la couverture du pipeline ; l'instantané et le tableau de couverture ne sont pas affectés.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Certains plugins sont gelés par un défaut interne.** Un plugin gelé signale toujours `DRAFT`, et la dimension de confiance ne fait que *noter*, donc il reste sélectionnable tant qu'il n'est pas également désenregistré — voir la colonne `Sélectionnable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Niveau de vérification : L2 (aptitude déclarée).** Une observation retirée signifie qu'un candidat a *déclaré* fournir la capacité, non que la capacité a été observée en fonctionnement. La vérification d'effet (L3) n'est pas câblée, donc aucune clôture de ce tableau ne doit être lue comme prouvée.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Un cycle d'observation doit s'achever avant qu'il y ait quoi que ce soit à montrer. Si cela persiste, vérifiez que le planificateur est actif et que la surveillance `framework-evolution` est armée et non silencée.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un épisode est écrit lorsqu'une observation de l'environnement conduit à une décision de capacité. Aucun n'a été enregistré : soit le système est calme, soit le pipeline s'arrête plus tôt — l'onglet **Pipeline** nomme le segment où il s'arrête et ce qui le débloquerait.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Rien ne les récupère automatiquement. Chacun occupe un nom d'outil et figure dans la liste des capacités sans être sélectionnable : le registre grandit dans une direction qu'aucune exigence ne peut utiliser.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Ces propositions n'ont intégré aucun pipeline : elles n'apparaissent donc dans aucun enregistrement de décision ni observation. Les admettre est un choix de configuration.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Un ratio inférieur à 1,0 signifie que la boucle d’échantillonnage ne tient pas sa cadence déclarée.", "Abstained": "Abstention", "Acquisition authority": "Autorité d'acquisition", "Acquisition lifecycle": "Cycle de vie d'acquisition", "Action": "Action", "After": "Après", "An unverified declaration has its writable channels demoted to read-only.": "Une déclaration non vérifiée voit ses canaux inscriptibles rétrogradés en lecture seule.", "Approval": "Approbation", "Autonomous governance": "Gouvernance autonome", "Autonomy": "Autonomie", "Before": "Avant", "CANDIDATE": "Candidat", "Calibrated at": "Calibré le", "Calibration health": "État de calibration", "Calls": "Appels", "Calls (decisions)": "Recommandations (décisions)", "Candlestick": "Chandeliers", "Capability": "Capacité", "Capability adaptation": "Adaptation des capacités", "Capability observations": "Observations de capacités", "Capability ownership": "Propriété des capacités", "Capability topology": "Topologie des capacités", "Change": "Changement", "Channel": "Canal", "Channels": "Canaux", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Les canaux jamais calibrés ou dont la calibration a expiré apparaissent en premier.", "Command": "Commande", "Commanded versus observed, best tracking first": "Commandé contre observé, meilleur suivi d’abord", "Composition": "Composition", "Concerns (open questions)": "Préoccupations (questions ouvertes)", "Confidence": "Confiance", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Compté sur tous les canaux tracés. « près » signifie à moins de 5 % d’une borne déclarée.", "Cycles run": "Cycles exécutés", "DRAFT": "Brouillon", "Days since": "Jours écoulés", "Decision": "Décision", "Decisions read as calls; action items as the execution checklist.": "Les décisions se lisent comme des recommandations ; les actions comme la liste d’exécution.", "Declared Hz": "Hz déclarés", "Desk brief": "Note de desk", "Device": "Appareil", "Dropped samples": "Échantillons perdus", "Each row names one blocked segment and the change that would unblock it.": "Chaque ligne nomme un segment bloqué et le changement qui le débloquerait.", "Effect verification (L3)": "Vérification d'effet (L3)", "Effects declared": "Effets déclarés", "Entities as references, and recommended next prompts to advance the work.": "Entités comme références, et invites suivantes recommandées pour avancer.", "Entities in play and the open risks still to resolve.": "Entités concernées et risques ouverts à résoudre.", "Envelope, rate, staleness and quality observations · newest first": "Observations d’enveloppe, de débit, d’obsolescence et de qualité · les plus récentes d’abord", "Environment": "Environnement", "Environment to framework": "De l'environnement au framework", "Environment, selected plugin tools, and orchestration order.": "Environnement, outils de plugin sélectionnés et ordre d’orchestration.", "Error rate": "Taux d'erreur", "Events paced out": "Événements limités", "Ever used": "Déjà utilisé", "Evidence": "Preuve", "Evidence admission": "Admission des preuves", "Evolution": "Évolution", "Evolution timeline": "Chronologie de l'évolution", "Executable": "Exécutable", "Execution checklist": "Liste d’exécution", "Extracted from this session's tool/file output (not model-generated).": "Extrait des sorties d’outils/fichiers de cette session (non généré par le modèle).", "Failures": "Échecs", "Fiber": "Fibre", "Fiber state changes since the previous cycle, including load retries.": "Changements d'état de fiber depuis le cycle précédent, y compris les tentatives de chargement.", "Finance lens": "Vue finance", "Follow-ups": "Suivis", "Framework change": "Changement du framework", "Framework changes as they happened, from runtime probes.": "Changements du framework en temps réel, via les sondes d'exécution.", "Framework evolution": "Évolution du framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Taille du framework et part du pipeline d'évolution qui présente des preuves d'exécution.", "From": "De", "Frozen plugins": "Plugins gelés", "Gap closure": "Clôture de l'écart", "Halt": "Arrêt", "How closures are verified": "Comment les clôtures sont vérifiées", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Quelle part du signal d'effet est exploitable comme rétroaction. C'est ce qui détermine s'il vaut la peine de construire une politique d'apprentissage.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Quelle part du framework il a fait croître lui-même, et quelle part du pipeline présente des preuves d'exécution.", "How often each window sat inside, near, or outside its declared limits": "Fréquence à laquelle chaque fenêtre était dans, près de, ou hors de ses limites déclarées", "Inquiry brief": "Note d’enquête", "Insights carded as evidence, capped for fast review.": "Analyses présentées comme preuves, limitées pour une revue rapide.", "Instruments & counterparties": "Instruments et contreparties", "Kept": "Conservé", "Latest capability decision": "Dernière décision de capacité", "Lifecycle records": "Enregistrements de cycle de vie", "Lifecycle timeline": "Chronologie du cycle de vie", "Lifecycle transitions": "Transitions de cycle de vie", "Line of inquiry": "Ligne d’enquête", "Live activity": "Activité en direct", "Location": "Emplacement", "Loop phase": "Phase de boucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Moyenne de chaque fenêtre de sous-échantillonnage. Les limites déclarées figurent par canal ci-dessous.", "Model's reasoning": "Raisonnement du modèle", "Mutation": "Mutation", "Narrative": "Récit", "Narrative pulse": "Pouls narratif", "Needs attention": "Requiert attention", "Next recal due": "Prochaine recalibration", "Next step": "Étape suivante", "No causal history yet": "Pas encore d'historique causal", "Normalized error": "Erreur normalisée", "Normalized error is the residual as a share of the channel's declared span.": "L’erreur normalisée est le résidu en proportion de l’étendue déclarée du canal.", "Not yet observed": "Pas encore observé", "Nothing has driven a framework change, so there is no episode to narrate.": "Rien n'a encore déclenché de changement du framework : il n'y a donc aucun épisode à raconter.", "OHLC extracted from captured session market data.": "OHLC extrait des données de marché capturées durant la session.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "File d’observations, état des propositions, décisions de politique et résultats du cycle de vie.", "Observations": "Observations", "Observed Hz": "Hz observés", "Observed rate against declared rate": "Débit observé par rapport au débit déclaré", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un espace de noms global unique, arbitré au premier arrivé. Le concurrent est enregistré, jamais supprimé en silence.", "Open": "Ouvert", "Open risks": "Risques ouverts", "Open/high/low/close from captured tool output.": "Ouverture/haut/bas/clôture issus des sorties d’outils capturées.", "Origin": "Origine", "Outcome": "Résultat", "PRODUCTION": "Production", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Par épisode : le déclencheur, la décision, le changement, et si l'écart a été comblé.", "Per-channel calibration state, freshness, and residual correction": "État de calibration, fraîcheur et correction résiduelle par canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Preuves d'exécution par segment. L'existence d'un module ne prouve pas qu'il soit appelé.", "Pipeline": "Pipeline", "Pipeline evidence": "Preuves du pipeline", "Pipeline reachability": "Accessibilité du pipeline", "Plan": "Plan", "Plan steps": "Étapes du plan", "Plugin": "Plugin", "Plugin roster and maturity": "Registre des plugins et maturité", "Plugins": "Plugins", "Plugins by origin": "Plugins par origine", "Plugins by maturity": "Plugins par maturité", "Policy": "Politique", "Policy decisions": "Décisions de politique", "Positions & actions": "Positions et actions", "Posture": "Posture", "Price action": "Action des prix", "Proposal": "Proposition", "Proposal status": "Statut de la proposition", "Proposed, not admitted": "Proposé, non admis", "Pulse": "Pouls", "Quarantine feed": "Flux de quarantaine", "Ratio": "Ratio", "Read live from the registry and maturity ledger every cycle.": "Lu en direct depuis le registre et le registre de maturité à chaque cycle.", "Recent episodes": "Épisodes récents", "Reclaim candidates": "Candidats à la récupération", "Reclaimable": "Récupérable", "References & follow-ups": "Références et suivis", "References (entities)": "Références (entités)", "Registry": "Registre", "Registry delta": "Delta du registre", "Registry version": "Version du registre", "Regressions": "Régressions", "Rejected": "Rejeté", "Representative observations, capped for quick scanning.": "Observations représentatives, limitées pour une lecture rapide.", "Requirements": "Exigences", "Research lens": "Vue recherche", "Residual": "Résidu", "Reward signal bandwidth": "Bande passante du signal de récompense", "Runtime evidence": "Preuve d'exécution", "Sampled history per channel, newest on the right": "Historique échantillonné par canal, le plus récent à droite", "Segment": "Segment", "Segments by status": "Segments par statut", "Selectable": "Sélectionnable", "Selection delta": "Delta de sélection", "Self-acquired": "Auto-acquis", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins auto-acquis qui sont enregistrés mais non sélectionnables, ou jamais utilisés une seule fois.", "Sentiment lens": "Vue sentiment", "Series": "Série", "Session analysis": "Analyse de session", "Signal strength": "Force du signal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Signaux indiquant qu'une évolution a mal tourné ou a été retenue. Affichés quel que soit l'onglet ouvert.", "Skipped slots": "Créneaux manqués", "State": "État", "Storyline and signal strength before drilling into positions and actions.": "Récit et force du signal avant d’examiner positions et actions.", "Streaming": "Diffusion", "Suggested next steps": "Prochaines étapes suggérées", "The line of investigation and where the open questions concentrate.": "La ligne d’investigation et où se concentrent les questions ouvertes.", "The narrative arc and how strongly themes are trending.": "L’arc narratif et l’intensité des tendances thématiques.", "The world model asked for these capabilities and nothing took them up.": "Le modèle du monde a demandé ces capacités et personne ne les a prises en charge.", "Theme intensity": "Intensité des thèmes", "Themes": "Thèmes", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Ce tableau rend compte de la façon dont le framework se modifie lui-même. Rien n'a encore été enregistré.", "To": "Vers", "Tool": "Outil", "Tool-name conflicts": "Conflits de noms d'outils", "Tools": "Outils", "Transport": "Transport", "Transport, provenance and channel counts": "Transport, provenance et nombre de canaux", "Maturity": "Maturité", "Maturity accrual": "Accumulation de maturité", "Maturity class": "Classe de maturité", "Unselectable reclamation": "Récupération non sélectionnable", "Usable": "Exploitable", "VERIFIED": "Vérifié", "Verdicts": "Verdicts", "Verdicts by reason": "Verdicts par motif", "Verified": "Vérifié", "Verified by": "Vérifié par", "Voices & concerns": "Voix et préoccupations", "Watchlist": "Liste de suivi", "What changed in the environment, and what the framework did about it.": "Ce qui a changé dans l'environnement, et ce que le framework a fait en réponse.", "Which plugin owns which tool, and which capability that tool provides.": "Quel plugin possède quel outil, et quelle capacité cet outil fournit.", "Who/what is in the conversation, and the concerns still open.": "Qui/quoi est dans la conversation, et les préoccupations encore ouvertes.", "Why": "Pourquoi", "Why not admitted": "Motif de non-admission", "Why this page is empty": "Pourquoi cette page est vide", "World-model driver": "Pilote du modèle du monde", "Writable": "Inscriptible", "aborted": "Abandonné", "accruing": "En accumulation", "active": "Actif", "appeared": "Apparu", "armed": "Armé", "assess_compatibility": "Évaluer la compatibilité", "built_in": "Intégré", "capability_expand": "Étendre les capacités", "committed": "Conclu", "conformance": "Conformité", "declared_fitness": "Aptitude déclarée", "disable": "Désactiver", "disposed": "Libéré", "effect_observed": "Effet observé", "environment_probe": "Sonde d'environnement", "execution_failed": "Échec d'exécution", "expected_effect_absent": "Effet attendu absent", "failed": "Échoué", "frozen": "Gelé", "gone": "Disparu", "idle": "Au repos", "install": "Installer", "loading": "Chargement", "manual": "Manuel", "moved": "Déplacé", "new_unproven": "Nouveau, non éprouvé", "no": "Non", "no_evidence": "Aucune preuve", "no_expected_effect_declared": "Aucun effet attendu déclaré", "no_outcome_observed": "Aucun résultat observé", "none": "Aucun", "not_admitted": "Non admis", "not_applicable": "Sans objet", "observe_only": "Observer seulement", "observed_effect": "Effet observé", "open": "Ouvert", "pending": "En attente", "reload": "Recharger", "remove": "Supprimer", "reopened": "Réouvert", "resolved": "Résolu", "rollback": "Annuler", "runtime": "Exécution", "self_acquired": "Auto-acquis", "still_open": "Toujours ouvert", "tool_reported_no_effect": "L'outil n'a signalé aucun effet", "trusted": "De confiance", "unknown": "Inconnu", "unknown_tool": "Outil inconnu", "unloading": "Déchargement", "unscheduled": "Non planifié", "unverifiable": "Invérifiable", "unverified": "Non vérifié", "waiting": "En attente", "watching": "En surveillance", "wired": "Câblé", "world_model": "Modèle du monde", "yes": "Oui", "Causal trace": "Trace causale", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Preuves en lecture seule reliant l’environnement à la gouvernance pour un instantané d’évolution du framework.", "Evidence boundary": "Limite des preuves", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Une trace causale montre les faits enregistrés ; elle n’infère ni approbation manquante ni effet observé.", "Episodes": "Épisodes", "Declared-fitness closures": "Clôtures par aptitude déclarée", "Counterfactual / mutation matrix": "Matrice contrefactuelle / mutations", "Each row preserves the driver, decision, registry delta, and verification tier.": "Chaque ligne conserve le déclencheur, la décision, le delta du registre et le niveau de vérification.", "Trigger": "Déclencheur", "Evidence tier": "Niveau de preuve", "Episode timeline": "Chronologie des épisodes", "Rebuilt from existing decision and observation records.": "Reconstruite à partir des enregistrements existants de décision et d’observation.", "Durable trace feed": "Flux de traces durables", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Les décisions rejetées et sans action restent visibles lorsque leur récepteur de traces est installé.", "Lifecycle": "Cycle de vie", "Pipeline evidence over time": "Évolution des preuves du convéoyeur", "One point per recorded change in framework state, oldest first.": "Un point par changement enregistré de l’état du framework, du plus ancien au plus récent.", "Samples": "Échantillons", "Net change": "Variation nette"}, + es: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Aún no se ha registrado ningún veredicto de efecto**, por lo que no hay señal de recompensa que medir. Las tasas anteriores están en blanco a propósito, no en cero. Un efecto solo puede verificarse si el requisito declaró uno, y hoy solo los requisitos redactados por el modelo del mundo lo llevan.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Regresión: una brecha cerrada ha vuelto a aparecer.** Una evolución que parecía exitosa no se sostuvo. Es el único hallazgo de este panel que exige atención inmediata.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Solo instantánea.** Todavía no hay historia causal que reconstruir, por lo que la cronología está ausente, no vacía. El motivo lo indica la fila `Decisiones de política` bajo la cobertura del pipeline; la instantánea y la tabla de cobertura no se ven afectadas.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Algunos plugins están congelados por un defecto interno.** Un plugin congelado sigue informando `DRAFT`, y la dimensión de confianza solo *puntúa*, por lo que permanece seleccionable a menos que también se desregistre — consulte la columna `Seleccionable`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Nivel de verificación: L2 (aptitud declarada).** Una observación retirada significa que un candidato *declaró* que proporciona la capacidad, no que se observara funcionando. La verificación de efecto (L3) no está conectada, así que ningún cierre de este panel debe leerse como probado.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Debe completarse un ciclo de observación antes de que haya algo que mostrar. Si persiste, compruebe que el planificador está activo y que la vigilancia `framework-evolution` está armada y no silenciada.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Un episodio se escribe cuando una observación del entorno conduce a una decisión de capacidad. No se ha registrado ninguno: o el sistema está tranquilo o el pipeline se detiene antes — la pestaña **Pipeline** nombra el segmento donde se detiene y qué lo desbloquearía.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Nada los recupera automáticamente. Cada uno ocupa un nombre de herramienta y aparece en la lista de capacidades sin ser seleccionable: el registro crece en una dirección que ningún requisito puede usar.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Estas propuestas no entraron en ningún pipeline, por lo que no aparecen en ningún registro de decisión ni observación. Admitirlas es una elección de configuración.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Una relación inferior a 1,0 significa que el bucle de muestreo no mantiene su cadencia declarada.", "Abstained": "Abstenido", "Acquisition authority": "Autoridad de adquisición", "Acquisition lifecycle": "Ciclo de vida de adquisición", "Action": "Acción", "After": "Después", "An unverified declaration has its writable channels demoted to read-only.": "Una declaración no verificada degrada sus canales escribibles a solo lectura.", "Approval": "Aprobación", "Autonomous governance": "Gobernanza autónoma", "Autonomy": "Autonomía", "Before": "Antes", "CANDIDATE": "Candidato", "Calibrated at": "Calibrado el", "Calibration health": "Estado de calibración", "Calls": "Llamadas", "Calls (decisions)": "Recomendaciones (decisiones)", "Candlestick": "Velas", "Capability": "Capacidad", "Capability adaptation": "Adaptación de capacidades", "Capability observations": "Observaciones de capacidad", "Capability ownership": "Propiedad de capacidades", "Capability topology": "Topología de capacidades", "Change": "Cambio", "Channel": "Canal", "Channels": "Canales", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Los canales nunca calibrados o con calibración vencida se muestran primero.", "Command": "Comando", "Commanded versus observed, best tracking first": "Comandado frente a observado, mejor seguimiento primero", "Composition": "Composición", "Concerns (open questions)": "Inquietudes (preguntas abiertas)", "Confidence": "Confianza", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Contado en todos los canales graficados. «cerca» significa dentro del 5 % de un límite declarado.", "Cycles run": "Ciclos ejecutados", "DRAFT": "Borrador", "Days since": "Días desde", "Decision": "Decisión", "Decisions read as calls; action items as the execution checklist.": "Las decisiones se leen como recomendaciones; las acciones como la lista de ejecución.", "Declared Hz": "Hz declarados", "Desk brief": "Informe de mesa", "Device": "Dispositivo", "Dropped samples": "Muestras descartadas", "Each row names one blocked segment and the change that would unblock it.": "Cada fila nombra un segmento bloqueado y el cambio que lo desbloquearía.", "Effect verification (L3)": "Verificación de efecto (L3)", "Effects declared": "Efectos declarados", "Entities as references, and recommended next prompts to advance the work.": "Entidades como referencias y siguientes preguntas recomendadas para avanzar.", "Entities in play and the open risks still to resolve.": "Entidades implicadas y riesgos abiertos por resolver.", "Envelope, rate, staleness and quality observations · newest first": "Observaciones de envolvente, tasa, obsolescencia y calidad · las más recientes primero", "Environment": "Entorno", "Environment to framework": "Del entorno al framework", "Environment, selected plugin tools, and orchestration order.": "Entorno, herramientas de plugin seleccionadas y orden de orquestación.", "Error rate": "Tasa de error", "Events paced out": "Eventos limitados", "Ever used": "Alguna vez usado", "Evidence": "Evidencia", "Evidence admission": "Admisión de evidencia", "Evolution": "Evolución", "Evolution timeline": "Cronología de la evolución", "Executable": "Ejecutable", "Execution checklist": "Lista de ejecución", "Extracted from this session's tool/file output (not model-generated).": "Extraído de la salida de herramientas/archivos de esta sesión (no generado por el modelo).", "Failures": "Fallos", "Fiber": "Fibra", "Fiber state changes since the previous cycle, including load retries.": "Cambios de estado de fiber desde el ciclo anterior, incluidos los reintentos de carga.", "Finance lens": "Vista financiera", "Follow-ups": "Seguimientos", "Framework change": "Cambio del framework", "Framework changes as they happened, from runtime probes.": "Cambios del framework en tiempo real, desde sondas de ejecución.", "Framework evolution": "Evolución del framework", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Tamaño del framework y qué parte del pipeline de evolución muestra evidencia en ejecución.", "From": "Desde", "Frozen plugins": "Plugins congelados", "Gap closure": "Cierre de la brecha", "Halt": "Parada", "How closures are verified": "Cómo se verifican los cierres", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Cuánto de la señal de efecto es utilizable como retroalimentación. Esto decide si vale la pena construir una política de aprendizaje.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Cuánto del framework hizo crecer por sí mismo y cuánto del pipeline muestra evidencia de ejecución.", "How often each window sat inside, near, or outside its declared limits": "Con qué frecuencia cada ventana estuvo dentro, cerca o fuera de sus límites declarados", "Inquiry brief": "Informe de indagación", "Insights carded as evidence, capped for fast review.": "Hallazgos presentados como evidencia, limitados para revisión rápida.", "Instruments & counterparties": "Instrumentos y contrapartes", "Kept": "Conservado", "Latest capability decision": "Última decisión de capacidad", "Lifecycle records": "Registros de ciclo de vida", "Lifecycle timeline": "Cronología del ciclo de vida", "Lifecycle transitions": "Transiciones de ciclo de vida", "Line of inquiry": "Línea de indagación", "Live activity": "Actividad en vivo", "Location": "Ubicación", "Loop phase": "Fase del bucle", "Mean of each downsample window. Declared limits are listed per channel below.": "Media de cada ventana de submuestreo. Los límites declarados se listan por canal abajo.", "Model's reasoning": "Razonamiento del modelo", "Mutation": "Mutación", "Narrative": "Narrativa", "Narrative pulse": "Pulso narrativo", "Needs attention": "Requiere atención", "Next recal due": "Próxima recalibración", "Next step": "Siguiente paso", "No causal history yet": "Aún no hay historia causal", "Normalized error": "Error normalizado", "Normalized error is the residual as a share of the channel's declared span.": "El error normalizado es el residuo como fracción del rango declarado del canal.", "Not yet observed": "Aún no observado", "Nothing has driven a framework change, so there is no episode to narrate.": "Nada ha impulsado todavía un cambio del framework, por lo que no hay ningún episodio que narrar.", "OHLC extracted from captured session market data.": "OHLC extraído de los datos de mercado capturados en la sesión.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Cola de observaciones, estado de propuestas, decisiones de política y resultados del ciclo de vida.", "Observations": "Observaciones", "Observed Hz": "Hz observados", "Observed rate against declared rate": "Tasa observada frente a la tasa declarada", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Un único espacio de nombres global, arbitrado por orden de llegada. El aspirante queda registrado, nunca se descarta en silencio.", "Open": "Abierto", "Open risks": "Riesgos abiertos", "Open/high/low/close from captured tool output.": "Apertura/máximo/mínimo/cierre desde la salida de herramientas capturada.", "Origin": "Origen", "Outcome": "Resultado", "PRODUCTION": "Producción", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "Por episodio: el desencadenante, la decisión, el cambio y si la brecha se cerró.", "Per-channel calibration state, freshness, and residual correction": "Estado de calibración, vigencia y corrección residual por canal", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Evidencia en ejecución por segmento. Que un módulo exista no prueba que algo lo invoque.", "Pipeline": "Pipeline", "Pipeline evidence": "Evidencia del pipeline", "Pipeline reachability": "Alcanzabilidad del pipeline", "Plan": "Plan", "Plan steps": "Pasos del plan", "Plugin": "Plugin", "Plugin roster and maturity": "Registro de plugins y madurez", "Plugins": "Plugins", "Plugins by origin": "Plugins por origen", "Plugins by maturity": "Plugins por madurez", "Policy": "Política", "Policy decisions": "Decisiones de política", "Positions & actions": "Posiciones y acciones", "Posture": "Postura", "Price action": "Acción del precio", "Proposal": "Propuesta", "Proposal status": "Estado de la propuesta", "Proposed, not admitted": "Propuesto, no admitido", "Pulse": "Pulso", "Quarantine feed": "Entrada de cuarentena", "Ratio": "Relación", "Read live from the registry and maturity ledger every cycle.": "Leído en vivo del registro y del libro de madurez en cada ciclo.", "Recent episodes": "Episodios recientes", "Reclaim candidates": "Candidatos a recuperación", "Reclaimable": "Recuperable", "References & follow-ups": "Referencias y seguimientos", "References (entities)": "Referencias (entidades)", "Registry": "Registro", "Registry delta": "Delta del registro", "Registry version": "Versión del registro", "Regressions": "Regresiones", "Rejected": "Rechazado", "Representative observations, capped for quick scanning.": "Observaciones representativas, limitadas para lectura rápida.", "Requirements": "Requisitos", "Research lens": "Vista de investigación", "Residual": "Residuo", "Reward signal bandwidth": "Ancho de banda de la señal de recompensa", "Runtime evidence": "Evidencia en ejecución", "Sampled history per channel, newest on the right": "Historial muestreado por canal, el más reciente a la derecha", "Segment": "Segmento", "Segments by status": "Segmentos por estado", "Selectable": "Seleccionable", "Selection delta": "Delta de selección", "Self-acquired": "Autoadquirido", "Self-acquired plugins that are registered but unselectable or never once used.": "Plugins autoadquiridos que están registrados pero no son seleccionables, o nunca se han usado.", "Sentiment lens": "Vista de sentimiento", "Series": "Serie", "Session analysis": "Análisis de sesión", "Signal strength": "Fuerza de la señal", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Señales de que algo creció mal o fue retenido. Se muestran independientemente de la pestaña abierta.", "Skipped slots": "Ranuras omitidas", "State": "Estado", "Storyline and signal strength before drilling into positions and actions.": "Narrativa y fuerza de la señal antes de entrar en posiciones y acciones.", "Streaming": "Transmisión", "Suggested next steps": "Próximos pasos sugeridos", "The line of investigation and where the open questions concentrate.": "La línea de investigación y dónde se concentran las preguntas abiertas.", "The narrative arc and how strongly themes are trending.": "El arco narrativo y con qué fuerza se mueven los temas.", "The world model asked for these capabilities and nothing took them up.": "El modelo del mundo pidió estas capacidades y nada las asumió.", "Theme intensity": "Intensidad temática", "Themes": "Temas", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Este panel informa de cómo el framework se modifica a sí mismo. Todavía no se ha registrado nada.", "To": "Hasta", "Tool": "Herramienta", "Tool-name conflicts": "Conflictos de nombres de herramientas", "Tools": "Herramientas", "Transport": "Transporte", "Transport, provenance and channel counts": "Transporte, procedencia y número de canales", "Maturity": "Madurez", "Maturity accrual": "Acumulación de madurez", "Maturity class": "Clase de madurez", "Unselectable reclamation": "Recuperación no seleccionable", "Usable": "Utilizable", "VERIFIED": "Verificado", "Verdicts": "Veredictos", "Verdicts by reason": "Veredictos por motivo", "Verified": "Verificado", "Verified by": "Verificado por", "Voices & concerns": "Voces e inquietudes", "Watchlist": "Lista de seguimiento", "What changed in the environment, and what the framework did about it.": "Qué cambió en el entorno y qué hizo el framework al respecto.", "Which plugin owns which tool, and which capability that tool provides.": "Qué plugin posee qué herramienta y qué capacidad proporciona esa herramienta.", "Who/what is in the conversation, and the concerns still open.": "Quién/qué está en la conversación y las inquietudes aún abiertas.", "Why": "Por qué", "Why not admitted": "Motivo de no admisión", "Why this page is empty": "Por qué esta página está vacía", "World-model driver": "Controlador del modelo del mundo", "Writable": "Escribible", "aborted": "Abortado", "accruing": "Acumulando", "active": "Activo", "appeared": "Apareció", "armed": "Armado", "assess_compatibility": "Evaluar compatibilidad", "built_in": "Integrado", "capability_expand": "Ampliar capacidad", "committed": "Concluido", "conformance": "Conformidad", "declared_fitness": "Aptitud declarada", "disable": "Desactivar", "disposed": "Liberado", "effect_observed": "Efecto observado", "environment_probe": "Sonda de entorno", "execution_failed": "Ejecución fallida", "expected_effect_absent": "Efecto esperado ausente", "failed": "Fallido", "frozen": "Congelado", "gone": "Desapareció", "idle": "Inactivo", "install": "Instalar", "loading": "Cargando", "manual": "Manual", "moved": "Se movió", "new_unproven": "Nuevo, no probado", "no": "No", "no_evidence": "Sin evidencia", "no_expected_effect_declared": "Sin efecto esperado declarado", "no_outcome_observed": "Sin resultado observado", "none": "Ninguno", "not_admitted": "No admitido", "not_applicable": "No aplicable", "observe_only": "Solo observar", "observed_effect": "Efecto observado", "open": "Abierto", "pending": "Pendiente", "reload": "Recargar", "remove": "Eliminar", "reopened": "Reabierto", "resolved": "Resuelto", "rollback": "Revertir", "runtime": "Tiempo de ejecución", "self_acquired": "Autoadquirido", "still_open": "Aún abierto", "tool_reported_no_effect": "La herramienta no informó efecto", "trusted": "De confianza", "unknown": "Desconocido", "unknown_tool": "Herramienta desconocida", "unloading": "Descargando", "unscheduled": "No planificado", "unverifiable": "No verificable", "unverified": "No verificado", "waiting": "En espera", "watching": "Vigilando", "wired": "Conectado", "world_model": "Modelo del mundo", "yes": "Sí", "Causal trace": "Traza causal", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Evidencia de solo lectura del entorno a la gobernanza para una instantánea de evolución del framework.", "Evidence boundary": "Límite de evidencia", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Una traza causal muestra hechos registrados; no infiere aprobación ausente ni efecto observado.", "Episodes": "Episodios", "Declared-fitness closures": "Cierres por aptitud declarada", "Counterfactual / mutation matrix": "Matriz contrafactual / de mutaciones", "Each row preserves the driver, decision, registry delta, and verification tier.": "Cada fila conserva el desencadenante, la decisión, el delta del registro y el nivel de verificación.", "Trigger": "Desencadenante", "Evidence tier": "Nivel de evidencia", "Episode timeline": "Cronología de episodios", "Rebuilt from existing decision and observation records.": "Reconstruida a partir de registros existentes de decisión y observación.", "Durable trace feed": "Flujo de trazas durables", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Las decisiones rechazadas y sin acción permanecen visibles cuando se instala su receptor de trazas.", "Lifecycle": "Ciclo de vida", "Pipeline evidence over time": "Evidencia del canal a lo largo del tiempo", "One point per recorded change in framework state, oldest first.": "Un punto por cada cambio registrado del estado del framework, del más antiguo al más reciente.", "Samples": "Muestras", "Net change": "Cambio neto"}, + ar: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **لم يُسجَّل أي حكم على الأثر بعد**، لذا لا توجد إشارة مكافأة لقياسها. النسب أعلاه فارغة عن قصد وليست صفرًا. لا يمكن التحقق من الأثر إلا إذا أعلنه المطلب، واليوم لا تحمل الأثر المتوقع سوى المطالب التي كتبها نموذج العالم.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **انحدار: فجوة أُغلقت عادت للظهور.** تطوّر بدا ناجحًا لم يصمد. هذا هو الاكتشاف الوحيد في هذه اللوحة الذي يستدعي انتباهًا فوريًا.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **لقطة فقط.** لا يوجد بعد تاريخ سببي لإعادة بنائه، لذا فالخط الزمني غائب وليس فارغًا. السبب مبيَّن في صف `قرارات السياسة` تحت تغطية المسار؛ اللقطة الحيّة وجدول التغطية غير متأثرين.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **بعض الإضافات مُجمَّدة بسبب خلل داخلي.** الإضافة المُجمَّدة لا تزال تُبلِّغ `DRAFT`، وبُعد الثقة يقوم بالتقييم فقط، لذا تبقى قابلة للاختيار إلا إذا أُلغي تسجيلها أيضًا — راجع عمود `قابل للاختيار`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **مستوى التحقق: L2 (الملاءمة المُعلنة).** سحب الرصد يعني أن مرشّحًا *أعلن* أنه يوفّر القدرة، لا أن القدرة رُصدت وهي تعمل. التحقق من الأثر (L3) غير موصول، لذا لا ينبغي قراءة أي إغلاق في هذه اللوحة كأمر مُثبَت.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> يجب أن تكتمل دورة مراقبة واحدة قبل ظهور أي محتوى. إذا استمر ذلك، تحقّق من تمكين المُجدول وأن مراقبة `framework-evolution` مُسلّحة وغير مكتومة.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> تُكتب الحلقة عندما يؤدي رصد للبيئة إلى قرار بشأن قدرة. لم يُسجَّل أي منها، وهذا يعني إمّا نظامًا هادئًا أو مسارًا يتوقف قبل ذلك — تبويب **المسار** يحدّد الجزء الذي يتوقف عنده وما الذي يزيل التعطيل.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> لا شيء يستعيدها تلقائيًا. كل واحدة تحتجز اسم أداة وتظهر في قائمة القدرات دون أن تكون قابلة للاختيار، فينمو السجل في اتجاه لا يمكن لأي مطلب استخدامه.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> لم تدخل هذه المقترحات أي مسار، لذا لا تظهر في أي سجل قرار أو رصد. قبولها خيار في الإعدادات.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "نسبة أقل من 1.0 تعني أن حلقة أخذ العينات لا تحافظ على وتيرتها المعلنة.", "Abstained": "امتناع", "Acquisition authority": "سلطة الاكتساب", "Acquisition lifecycle": "دورة حياة الاكتساب", "Action": "الإجراء", "After": "بعد", "An unverified declaration has its writable channels demoted to read-only.": "الإعلان غير المُتحقَّق منه تُخفَّض قنواته القابلة للكتابة إلى القراءة فقط.", "Approval": "الموافقة", "Autonomous governance": "الحكم الذاتي", "Autonomy": "الاستقلالية", "Before": "قبل", "CANDIDATE": "مرشّح", "Calibrated at": "تاريخ المعايرة", "Calibration health": "سلامة المعايرة", "Calls": "الاستدعاءات", "Calls (decisions)": "التوصيات (القرارات)", "Candlestick": "الشموع", "Capability": "القدرة", "Capability adaptation": "تكييف القدرات", "Capability observations": "رصد القدرات", "Capability ownership": "ملكية القدرات", "Capability topology": "طوبولوجيا القدرات", "Change": "التغيير", "Channel": "القناة", "Channels": "القنوات", "Channels that have never been calibrated or whose calibration has expired are shown first.": "تظهر أولاً القنوات التي لم تُعاير قط أو التي انتهت صلاحية معايرتها.", "Command": "الأمر", "Commanded versus observed, best tracking first": "المأمور مقابل المرصود، الأفضل تتبعاً أولاً", "Composition": "التركيب", "Concerns (open questions)": "المخاوف (أسئلة مفتوحة)", "Confidence": "الثقة", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "محسوب على كل قناة مرسومة. \"قريب\" تعني داخل 5% من حد معلن.", "Cycles run": "الدورات المنفَّذة", "DRAFT": "مسوّدة", "Days since": "الأيام المنقضية", "Decision": "القرار", "Decisions read as calls; action items as the execution checklist.": "القرارات تُقرأ كتوصيات؛ والإجراءات كقائمة تنفيذ.", "Declared Hz": "الهرتز المعلن", "Desk brief": "موجز المكتب", "Device": "الجهاز", "Dropped samples": "العينات المفقودة", "Each row names one blocked segment and the change that would unblock it.": "كل صف يحدّد جزءًا معطَّلًا والتغيير الذي يزيل التعطيل.", "Effect verification (L3)": "التحقق من الأثر (L3)", "Effects declared": "الآثار المُعلنة", "Entities as references, and recommended next prompts to advance the work.": "الكيانات كمراجع، والمطالبات التالية الموصى بها لدفع العمل.", "Entities in play and the open risks still to resolve.": "الكيانات المعنية والمخاطر المفتوحة التي لم تُحل.", "Envelope, rate, staleness and quality observations · newest first": "رصدات المغلف والمعدل والتقادم والجودة · الأحدث أولاً", "Environment": "البيئة", "Environment to framework": "من البيئة إلى الإطار", "Environment, selected plugin tools, and orchestration order.": "البيئة والأدوات المختارة وترتيب التنسيق.", "Error rate": "معدل الأخطاء", "Events paced out": "الأحداث المُقيَّدة", "Ever used": "استُخدم سابقًا", "Evidence": "الدليل", "Evidence admission": "قبول الأدلة", "Evolution": "التطور", "Evolution timeline": "الخط الزمني للتطور", "Executable": "قابل للتنفيذ", "Execution checklist": "قائمة التنفيذ", "Extracted from this session's tool/file output (not model-generated).": "مستخرج من مخرجات الأدوات/الملفات في هذه الجلسة (ليس من إنشاء النموذج).", "Failures": "الأعطال", "Fiber": "الخيط", "Fiber state changes since the previous cycle, including load retries.": "تغييرات حالة الـ fiber منذ الدورة السابقة، بما في ذلك محاولات التحميل.", "Finance lens": "منظور مالي", "Follow-ups": "المتابعات", "Framework change": "تغيير الإطار", "Framework changes as they happened, from runtime probes.": "تغييرات الإطار لحظة حدوثها، من مجسّات وقت التشغيل.", "Framework evolution": "تطور الإطار", "Framework size and how much of the evolution pipeline shows runtime evidence.": "حجم الإطار ومقدار ما يُظهره مسار التطور من أدلة وقت التشغيل.", "From": "من", "Frozen plugins": "الإضافات المُجمَّدة", "Gap closure": "إغلاق الفجوة", "Halt": "إيقاف", "How closures are verified": "كيف يُتحقَّق من الإغلاقات", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "ما مقدار إشارة الأثر القابل للاستخدام كتغذية راجعة. هذا يحدّد ما إذا كان بناء سياسة تعلّم يستحق العناء.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "ما مقدار ما نمّاه الإطار بنفسه، وما مقدار المسار الذي يُظهر أدلة وقت التشغيل.", "How often each window sat inside, near, or outside its declared limits": "عدد المرات التي كانت فيها كل نافذة داخل حدودها المعلنة أو قريبة منها أو خارجها", "Inquiry brief": "موجز الاستقصاء", "Insights carded as evidence, capped for fast review.": "الرؤى معروضة كأدلة، ومحدودة العدد للمراجعة السريعة.", "Instruments & counterparties": "الأدوات والأطراف المقابلة", "Kept": "المحتفظ به", "Latest capability decision": "أحدث قرار للقدرات", "Lifecycle records": "سجلات دورة الحياة", "Lifecycle timeline": "الخط الزمني لدورة الحياة", "Lifecycle transitions": "انتقالات دورة الحياة", "Line of inquiry": "خط الاستقصاء", "Live activity": "النشاط المباشر", "Location": "الموقع", "Loop phase": "مرحلة الحلقة", "Mean of each downsample window. Declared limits are listed per channel below.": "متوسط كل نافذة تخفيض للعينات. الحدود المعلنة مدرجة لكل قناة أدناه.", "Model's reasoning": "استدلال النموذج", "Mutation": "التغيير", "Narrative": "السرد", "Narrative pulse": "نبض السرد", "Needs attention": "يستدعي الانتباه", "Next recal due": "موعد إعادة المعايرة", "Next step": "الخطوة التالية", "No causal history yet": "لا يوجد تاريخ سببي بعد", "Normalized error": "الخطأ المعياري", "Normalized error is the residual as a share of the channel's declared span.": "الخطأ المعياري هو المتبقي كنسبة من المدى المعلن للقناة.", "Not yet observed": "لم يُرصد بعد", "Nothing has driven a framework change, so there is no episode to narrate.": "لم يدفع أي شيء بعد إلى تغيير في الإطار، لذا لا توجد حلقة لسردها.", "OHLC extracted from captured session market data.": "OHLC مستخرج من بيانات السوق المسجلة في الجلسة.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "قائمة الرصد وحالة المقترحات وقرارات السياسة ونتائج دورة الحياة.", "Observations": "الرصدات", "Observed Hz": "الهرتز المرصود", "Observed rate against declared rate": "المعدل المرصود مقابل المعدل المعلن", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "مساحة أسماء عالمية واحدة، تُحكَّم بأسبقية التسجيل. يُسجَّل المتنافس ولا يُهمَل بصمت.", "Open": "مفتوح", "Open risks": "المخاطر المفتوحة", "Open/high/low/close from captured tool output.": "الافتتاح/الأعلى/الأدنى/الإغلاق من مخرجات الأدوات المسجلة.", "Origin": "المصدر", "Outcome": "النتيجة", "PRODUCTION": "إنتاج", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "لكل حلقة: المُحفِّز والقرار والتغيير وما إذا أُغلقت الفجوة.", "Per-channel calibration state, freshness, and residual correction": "حالة المعايرة وحداثتها وتصحيح المتبقي لكل قناة", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "أدلة وقت التشغيل لكل مقطع. وجود وحدة لا يعني أن شيئًا يستدعيها.", "Pipeline": "المسار", "Pipeline evidence": "أدلة المسار", "Pipeline reachability": "إمكانية الوصول إلى المسار", "Plan": "الخطة", "Plan steps": "خطوات الخطة", "Plugin": "الملحق", "Plugin roster and maturity": "قائمة الملحقات والنضج", "Plugins": "الملحقات", "Plugins by origin": "الإضافات حسب المصدر", "Plugins by maturity": "الإضافات حسب النضج", "Policy": "السياسة", "Policy decisions": "قرارات السياسة", "Positions & actions": "المراكز والإجراءات", "Posture": "الوضع", "Price action": "حركة السعر", "Proposal": "المقترح", "Proposal status": "حالة المقترح", "Proposed, not admitted": "مُقترح وغير مقبول", "Pulse": "النبض", "Quarantine feed": "تغذية الحجر", "Ratio": "النسبة", "Read live from the registry and maturity ledger every cycle.": "يُقرأ مباشرة من السجل ودفتر النضج في كل دورة.", "Recent episodes": "الحلقات الأخيرة", "Reclaim candidates": "مرشّحو الاسترجاع", "Reclaimable": "قابل للاسترجاع", "References & follow-ups": "المراجع والمتابعات", "References (entities)": "المراجع (الكيانات)", "Registry": "السجل", "Registry delta": "فرق السجل", "Registry version": "إصدار السجل", "Regressions": "الانحدارات", "Rejected": "المرفوض", "Representative observations, capped for quick scanning.": "رصدات تمثيلية، محدودة العدد للقراءة السريعة.", "Requirements": "المتطلبات", "Research lens": "منظور بحثي", "Residual": "المتبقي", "Reward signal bandwidth": "نطاق إشارة المكافأة", "Runtime evidence": "دليل وقت التشغيل", "Sampled history per channel, newest on the right": "سجل العينات لكل قناة، الأحدث على اليمين", "Segment": "المقطع", "Segments by status": "الأجزاء حسب الحالة", "Selectable": "قابل للاختيار", "Selection delta": "فرق الاختيار", "Self-acquired": "مُكتسَب ذاتيًا", "Self-acquired plugins that are registered but unselectable or never once used.": "إضافات مُكتسَبة ذاتيًا مُسجَّلة لكنها غير قابلة للاختيار أو لم تُستخدم قطّ.", "Sentiment lens": "منظور المشاعر", "Series": "السلسلة", "Session analysis": "تحليل الجلسة", "Signal strength": "قوة الإشارة", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "إشارات على أن شيئًا نما بشكل خاطئ أو تم حجبه. تظهر أيًا كان التبويب المفتوح.", "Skipped slots": "الفتحات المتخطاة", "State": "الحالة", "Storyline and signal strength before drilling into positions and actions.": "السرد وقوة الإشارة قبل التوسع في المراكز والإجراءات.", "Streaming": "بث", "Suggested next steps": "الخطوات التالية المقترحة", "The line of investigation and where the open questions concentrate.": "خط البحث وأين تتركز الأسئلة المفتوحة.", "The narrative arc and how strongly themes are trending.": "قوس السرد ومدى قوة اتجاه الموضوعات.", "The world model asked for these capabilities and nothing took them up.": "طلب نموذج العالم هذه القدرات ولم يتبنّها شيء.", "Theme intensity": "شدة الموضوعات", "Themes": "الموضوعات", "This board reports how the framework changes itself. Nothing has been recorded yet.": "تُبلِّغ هذه اللوحة عن كيفية تغيير الإطار لنفسه. لم يُسجَّل أي شيء بعد.", "To": "إلى", "Tool": "الأداة", "Tool-name conflicts": "تعارضات أسماء الأدوات", "Tools": "الأدوات", "Transport": "النقل", "Transport, provenance and channel counts": "النقل والمنشأ وعدد القنوات", "Maturity": "النضج", "Maturity accrual": "تراكم النضج", "Maturity class": "فئة النضج", "Unselectable reclamation": "استرجاع غير القابل للاختيار", "Usable": "قابل للاستخدام", "VERIFIED": "مُتحقَّق", "Verdicts": "الأحكام", "Verdicts by reason": "الأحكام حسب السبب", "Verified": "مُتحقَّق", "Verified by": "تم التحقق بواسطة", "Voices & concerns": "الأصوات والمخاوف", "Watchlist": "قائمة المتابعة", "What changed in the environment, and what the framework did about it.": "ما تغيّر في البيئة، وما فعله الإطار حيال ذلك.", "Which plugin owns which tool, and which capability that tool provides.": "أي ملحق يملك أي أداة، وأي قدرة توفرها تلك الأداة.", "Who/what is in the conversation, and the concerns still open.": "من/ما هو في المحادثة، والمخاوف التي لا تزال مفتوحة.", "Why": "السبب", "Why not admitted": "سبب عدم القبول", "Why this page is empty": "لماذا هذه الصفحة فارغة", "World-model driver": "مُشغِّل نموذج العالم", "Writable": "قابل للكتابة", "aborted": "مُلغى", "accruing": "قيد التراكم", "active": "نشط", "appeared": "ظهر", "armed": "مُسلّح", "assess_compatibility": "تقييم التوافق", "built_in": "مدمج", "capability_expand": "توسيع القدرة", "committed": "مُنجَز", "conformance": "المطابقة", "declared_fitness": "الملاءمة المُعلنة", "disable": "تعطيل", "disposed": "تم التخلص منه", "effect_observed": "تم رصد الأثر", "environment_probe": "مِجَس البيئة", "execution_failed": "فشل التنفيذ", "expected_effect_absent": "الأثر المتوقع غائب", "failed": "فشل", "frozen": "مُجمَّد", "gone": "اختفى", "idle": "خامل", "install": "تثبيت", "loading": "قيد التحميل", "manual": "يدوي", "moved": "انتقل", "new_unproven": "جديد وغير مُثبَت", "no": "لا", "no_evidence": "لا يوجد دليل", "no_expected_effect_declared": "لم يُعلَن أثر متوقع", "no_outcome_observed": "لم يُرصد أي ناتج", "none": "لا شيء", "not_admitted": "غير مقبول", "not_applicable": "غير منطبق", "observe_only": "المراقبة فقط", "observed_effect": "الأثر المرصود", "open": "مفتوح", "pending": "معلّق", "reload": "إعادة تحميل", "remove": "إزالة", "reopened": "أُعيد فتحه", "resolved": "تم الحل", "rollback": "تراجع", "runtime": "وقت التشغيل", "self_acquired": "مُكتسَب ذاتيًا", "still_open": "لا يزال مفتوحًا", "tool_reported_no_effect": "الأداة لم تُبلِّغ عن أثر", "trusted": "موثوق", "unknown": "غير معروف", "unknown_tool": "أداة غير معروفة", "unloading": "قيد الإلغاء", "unscheduled": "غير مُجدول", "unverifiable": "غير قابل للتحقق", "unverified": "غير مُتحقَّق", "waiting": "في الانتظار", "watching": "يراقب", "wired": "موصول", "world_model": "نموذج العالم", "yes": "نعم", "Causal trace": "الأثر السببي", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "دليل للقراءة فقط يربط البيئة بالحوكمة للّقطة واحدة من تطور الإطار.", "Evidence boundary": "حدود الدليل", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "يعرض الأثر السببي الحقائق المسجلة ولا يستنتج موافقة مفقودة أو أثرًا مرصودًا.", "Episodes": "الحلقات", "Declared-fitness closures": "إغلاقات الملاءمة المعلنة", "Counterfactual / mutation matrix": "مصفوفة الافتراضات المضادة / التغييرات", "Each row preserves the driver, decision, registry delta, and verification tier.": "يحفظ كل صف المحفز والقرار وفرق السجل ومستوى التحقق.", "Trigger": "المحفز", "Evidence tier": "طبقة الدليل", "Episode timeline": "الخط الزمني للحلقات", "Rebuilt from existing decision and observation records.": "أُعيد بناؤه من سجلات القرار والرصد الموجودة.", "Durable trace feed": "تدفق آثار دائم", "Rejected and no-op decisions remain visible when their trace sink is installed.": "تبقى القرارات المرفوضة والتي بلا إجراء مرئية عند تثبيت مستقبل آثارها.", "Lifecycle": "دورة الحياة", "Pipeline evidence over time": "أدلة المسار عبر الزمن", "One point per recorded change in framework state, oldest first.": "نقطة واحدة لكل تغيير مسجّل في حالة الإطار، الأقدم أولًا.", "Samples": "العينات", "Net change": "التغير الصافي"}, + ru: {"> **No effect verdict has been recorded yet**, so there is no reward signal to measure. The rates above are blank rather than zero on purpose. An effect can only be verified when the requirement declared one, and only world-model-authored requirements carry an expected effect today.": "> **Ни одного заключения об эффекте пока не записано**, поэтому измерять нечего. Показатели выше намеренно пусты, а не равны нулю. Эффект можно проверить только если требование его заявило, а сегодня заявленный эффект несут лишь требования, составленные моделью мира.", "> **Regression: a closed gap has recurred.** An evolution that looked successful did not hold. This is the one finding on this board that warrants immediate attention.": "> **Регрессия: закрытый пробел возобновился.** Эволюция, казавшаяся успешной, не удержалась. Это единственный вывод на этой панели, требующий немедленного внимания.", "> **Snapshot only.** There is no causal history to rebuild yet, so the timeline is absent rather than empty. Why is stated by the `Policy decisions` row under pipeline reachability; the live snapshot and the reachability table itself are unaffected.": "> **Только снимок.** Причинной истории для восстановления пока нет, поэтому хронология отсутствует, а не пуста. Причина указана в строке `Решения политики` под покрытием конвейера; снимок и таблица покрытия не затронуты.", "> **Some plugins are frozen by an internal defect.** A frozen plugin still reports `DRAFT`, and the trust dimension only *scores*, so it stays selectable unless it is also unregistered — check the `Selectable` column.": "> **Некоторые плагины заморожены из-за внутреннего дефекта.** Замороженный плагин по-прежнему сообщает `DRAFT`, а измерение доверия только *оценивает*, поэтому он остаётся выбираемым, пока не будет также снят с регистрации — см. столбец `Выбираемо`.", "> **Verification tier: L2 (declared fitness).** A retired observation means a candidate *declared* it provides the capability, not that the capability was observed to work. Effect verification (L3) is not wired yet, so no closure on this board should be read as proven.": "> **Уровень проверки: L2 (заявленная пригодность).** Снятое наблюдение означает, что кандидат *заявил* о предоставлении возможности, а не что возможность наблюдалась в работе. Проверка эффекта (L3) не подключена, поэтому ни одно закрытие на этой панели не следует считать доказанным.", "> A watch has to complete one cycle before there is anything to show. If this persists, check that the scheduler is enabled and that the `framework-evolution` watch is armed and not muted.": "> Прежде чем появятся данные, должен завершиться хотя бы один цикл наблюдения. Если это сохраняется, проверьте, включён ли планировщик и что наблюдение `framework-evolution` активно и не отключено.", "> An episode is written when an environment observation leads to a capability decision. None has been recorded, which is either a quiet system or a pipeline that stops earlier — the **Pipeline** tab names the segment where it stops, and what would unblock it.": "> Эпизод записывается, когда наблюдение окружения приводит к решению о возможности. Ни одного не зафиксировано: либо система спокойна, либо конвейер останавливается раньше — вкладка **Конвейер** называет сегмент остановки и то, что его разблокирует.", "> Nothing reclaims these automatically. Each holds a tool name and appears in the capability list without being selectable, so the registry grows in a direction no requirement can use.": "> Ничто не утилизирует их автоматически. Каждый занимает имя инструмента и присутствует в списке возможностей, не будучи выбираемым: реестр растёт в направлении, непригодном ни для одного требования.", "> These proposals entered no pipeline, so they appear in no decision record and no observation. Admitting them is a configuration choice.": "> Эти предложения не вошли ни в один конвейер, поэтому не отражены ни в одной записи решения или наблюдения. Их приём — вопрос конфигурации.", "A ratio below 1.0 means the sampling loop is not keeping its declared cadence.": "Отношение ниже 1,0 означает, что цикл выборки не выдерживает объявленный ритм.", "Abstained": "Воздержалось", "Acquisition authority": "Право на получение", "Acquisition lifecycle": "Жизненный цикл получения", "Action": "Действие", "After": "После", "An unverified declaration has its writable channels demoted to read-only.": "У непроверенного объявления записываемые каналы понижаются до только чтения.", "Approval": "Согласование", "Autonomous governance": "Автономное управление", "Autonomy": "Автономность", "Before": "До", "CANDIDATE": "Кандидат", "Calibrated at": "Калиброван", "Calibration health": "Состояние калибровки", "Calls": "Вызовы", "Calls (decisions)": "Рекомендации (решения)", "Candlestick": "Свечи", "Capability": "Возможность", "Capability adaptation": "Адаптация возможностей", "Capability observations": "Наблюдения возможностей", "Capability ownership": "Владение возможностями", "Capability topology": "Топология возможностей", "Change": "Изменение", "Channel": "Канал", "Channels": "Каналы", "Channels that have never been calibrated or whose calibration has expired are shown first.": "Каналы, которые никогда не калибровались или чья калибровка истекла, показаны первыми.", "Command": "Команда", "Commanded versus observed, best tracking first": "Заданное против наблюдаемого, лучшее отслеживание первым", "Composition": "Состав", "Concerns (open questions)": "Опасения (открытые вопросы)", "Confidence": "Уверенность", "Counted across every charted channel. 'near' means within 5% of a declared bound.": "Подсчитано по всем отображаемым каналам. «У границы» — в пределах 5% от объявленного предела.", "Cycles run": "Выполнено циклов", "DRAFT": "Черновик", "Days since": "Дней с тех пор", "Decision": "Решение", "Decisions read as calls; action items as the execution checklist.": "Решения читаются как рекомендации; действия — как чек-лист исполнения.", "Declared Hz": "Объявл. Гц", "Desk brief": "Сводка деска", "Device": "Устройство", "Dropped samples": "Отброшенные образцы", "Each row names one blocked segment and the change that would unblock it.": "Каждая строка называет заблокированный сегмент и изменение, которое его разблокирует.", "Effect verification (L3)": "Проверка эффекта (L3)", "Effects declared": "Заявлено эффектов", "Entities as references, and recommended next prompts to advance the work.": "Сущности как ссылки и рекомендуемые следующие запросы.", "Entities in play and the open risks still to resolve.": "Задействованные сущности и нерешённые риски.", "Envelope, rate, staleness and quality observations · newest first": "Наблюдения по огибающей, частоте, устареванию и качеству · сначала новые", "Environment": "Окружение", "Environment to framework": "От окружения к фреймворку", "Environment, selected plugin tools, and orchestration order.": "Окружение, выбранные инструменты плагинов и порядок оркестрации.", "Error rate": "Частота ошибок", "Events paced out": "Событий подавлено", "Ever used": "Использовался", "Evidence": "Обоснование", "Evidence admission": "Приём данных", "Evolution": "Эволюция", "Evolution timeline": "Хронология эволюции", "Executable": "Исполнимо", "Execution checklist": "Чек-лист исполнения", "Extracted from this session's tool/file output (not model-generated).": "Извлечено из вывода инструментов/файлов этой сессии (не сгенерировано моделью).", "Failures": "Сбои", "Fiber": "Файбер", "Fiber state changes since the previous cycle, including load retries.": "Изменения состояния fiber с предыдущего цикла, включая повторные загрузки.", "Finance lens": "Финансовый ракурс", "Follow-ups": "Продолжения", "Framework change": "Изменение фреймворка", "Framework changes as they happened, from runtime probes.": "Изменения фреймворка в момент их появления, от рантайм-зондов.", "Framework evolution": "Эволюция фреймворка", "Framework size and how much of the evolution pipeline shows runtime evidence.": "Размер фреймворка и какая часть конвейера эволюции показывает свидетельства времени выполнения.", "From": "Из", "Frozen plugins": "Замороженные плагины", "Gap closure": "Закрытие пробела", "Halt": "Останов", "How closures are verified": "Как проверяются закрытия", "How much of the effect signal is usable as feedback. This decides whether a learning policy is worth building.": "Какая часть сигнала об эффекте пригодна как обратная связь. Это определяет, стоит ли строить обучающую политику.", "How much of the framework it grew itself, and how much of the pipeline shows runtime evidence.": "Какую часть фреймворка он вырастил сам и какая часть конвейера показывает данные времени выполнения.", "How often each window sat inside, near, or outside its declared limits": "Как часто каждое окно было внутри, у границы или вне объявленных пределов", "Inquiry brief": "Сводка исследования", "Insights carded as evidence, capped for fast review.": "Инсайты как карточки-обоснования, ограничены для быстрого просмотра.", "Instruments & counterparties": "Инструменты и контрагенты", "Kept": "Оставлен", "Latest capability decision": "Последнее решение о возможностях", "Lifecycle records": "Записи жизненного цикла", "Lifecycle timeline": "Хронология жизненного цикла", "Lifecycle transitions": "Переходы жизненного цикла", "Line of inquiry": "Линия исследования", "Live activity": "Текущая активность", "Location": "Расположение", "Loop phase": "Фаза цикла", "Mean of each downsample window. Declared limits are listed per channel below.": "Среднее по каждому окну прореживания. Объявленные пределы указаны по каналам ниже.", "Model's reasoning": "Обоснование модели", "Mutation": "Изменение", "Narrative": "Сюжет", "Narrative pulse": "Нарративный пульс", "Needs attention": "Требует внимания", "Next recal due": "Следующая рекалибровка", "Next step": "Следующий шаг", "No causal history yet": "Причинной истории пока нет", "Normalized error": "Нормированная ошибка", "Normalized error is the residual as a share of the channel's declared span.": "Нормированная ошибка — остаток как доля объявленного диапазона канала.", "Not yet observed": "Ещё не наблюдалось", "Nothing has driven a framework change, so there is no episode to narrate.": "Ничто пока не вызвало изменения фреймворка, поэтому рассказывать не о чем.", "OHLC extracted from captured session market data.": "OHLC извлечён из рыночных данных, записанных в сессии.", "Observation backlog, proposal state, policy decisions, and lifecycle outcomes.": "Очередь наблюдений, состояние предложений, решения политики и итоги жизненного цикла.", "Observations": "Наблюдения", "Observed Hz": "Наблюд. Гц", "Observed rate against declared rate": "Наблюдаемая частота против объявленной", "One global namespace, arbitrated first-wins. The challenger is recorded, never silently dropped.": "Единое глобальное пространство имён, арбитраж по первому пришедшему. Претендент записывается, а не отбрасывается молча.", "Open": "Открыт", "Open risks": "Открытые риски", "Open/high/low/close from captured tool output.": "Открытие/максимум/минимум/закрытие из записанного вывода инструментов.", "Origin": "Источник", "Outcome": "Результат", "PRODUCTION": "Продакшн", "Per episode: the trigger, the decision, the change, and whether the gap closed.": "По эпизодам: триггер, решение, изменение и закрылся ли пробел.", "Per-channel calibration state, freshness, and residual correction": "Состояние калибровки, актуальность и остаточная поправка по каналам", "Per-segment runtime evidence. A module existing is not evidence that anything calls it.": "Свидетельства времени выполнения по сегментам. Наличие модуля не доказывает, что его кто-то вызывает.", "Pipeline": "Конвейер", "Pipeline evidence": "Свидетельства конвейера", "Pipeline reachability": "Достижимость конвейера", "Plan": "План", "Plan steps": "Шаги плана", "Plugin": "Плагин", "Plugin roster and maturity": "Реестр плагинов и зрелость", "Plugins": "Плагины", "Plugins by origin": "Плагины по происхождению", "Plugins by maturity": "Плагины по зрелости", "Policy": "Политика", "Policy decisions": "Решения политики", "Positions & actions": "Позиции и действия", "Posture": "Состояние", "Price action": "Ценовое движение", "Proposal": "Предложение", "Proposal status": "Статус предложения", "Proposed, not admitted": "Предложено, не принято", "Pulse": "Пульс", "Quarantine feed": "Поток карантина", "Ratio": "Отношение", "Read live from the registry and maturity ledger every cycle.": "Читается напрямую из реестра и журнала зрелости каждый цикл.", "Recent episodes": "Недавние эпизоды", "Reclaim candidates": "Кандидаты на утилизацию", "Reclaimable": "Утилизируемо", "References & follow-ups": "Ссылки и продолжения", "References (entities)": "Ссылки (сущности)", "Registry": "Реестр", "Registry delta": "Изменение реестра", "Registry version": "Версия реестра", "Regressions": "Регрессии", "Rejected": "Отклонён", "Representative observations, capped for quick scanning.": "Показательные наблюдения, ограничены для быстрого просмотра.", "Requirements": "Требования", "Research lens": "Исследовательский ракурс", "Residual": "Остаток", "Reward signal bandwidth": "Пропускная способность сигнала вознаграждения", "Runtime evidence": "Свидетельство времени выполнения", "Sampled history per channel, newest on the right": "История выборок по каналам, самое новое справа", "Segment": "Сегмент", "Segments by status": "Сегменты по статусу", "Selectable": "Выбираемый", "Selection delta": "Изменение выбора", "Self-acquired": "Самостоятельно получено", "Self-acquired plugins that are registered but unselectable or never once used.": "Самостоятельно полученные плагины, которые зарегистрированы, но невыбираемы или ни разу не использовались.", "Sentiment lens": "Ракурс тональности", "Series": "Серия", "Session analysis": "Анализ сессии", "Signal strength": "Сила сигнала", "Signals that something grew wrong, or was withheld. Shown regardless of the open tab.": "Признаки того, что что-то выросло неверно или было задержано. Показываются независимо от открытой вкладки.", "Skipped slots": "Пропущенные слоты", "State": "Состояние", "Storyline and signal strength before drilling into positions and actions.": "Сюжет и сила сигнала до перехода к позициям и действиям.", "Streaming": "Потоковая передача", "Suggested next steps": "Рекомендуемые следующие шаги", "The line of investigation and where the open questions concentrate.": "Линия исследования и где сосредоточены открытые вопросы.", "The narrative arc and how strongly themes are trending.": "Нарративная дуга и насколько сильно растут темы.", "The world model asked for these capabilities and nothing took them up.": "Модель мира запросила эти возможности, и никто их не принял.", "Theme intensity": "Интенсивность тем", "Themes": "Темы", "This board reports how the framework changes itself. Nothing has been recorded yet.": "Эта панель сообщает, как фреймворк изменяет сам себя. Пока ничего не записано.", "To": "В", "Tool": "Инструмент", "Tool-name conflicts": "Конфликты имён инструментов", "Tools": "Инструменты", "Transport": "Транспорт", "Transport, provenance and channel counts": "Транспорт, происхождение и число каналов", "Maturity": "Зрелость", "Maturity accrual": "Накопление зрелости", "Maturity class": "Класс зрелости", "Unselectable reclamation": "Утилизация невыбираемого", "Usable": "Пригодно", "VERIFIED": "Проверено", "Verdicts": "Заключений", "Verdicts by reason": "Заключения по причине", "Verified": "Проверено", "Verified by": "Подтверждено", "Voices & concerns": "Голоса и опасения", "Watchlist": "Список наблюдения", "What changed in the environment, and what the framework did about it.": "Что изменилось в окружении и что фреймворк с этим сделал.", "Which plugin owns which tool, and which capability that tool provides.": "Какой плагин владеет каким инструментом и какую возможность этот инструмент предоставляет.", "Who/what is in the conversation, and the concerns still open.": "Кто/что в разговоре и какие опасения остаются.", "Why": "Почему", "Why not admitted": "Причина отклонения", "Why this page is empty": "Почему эта страница пуста", "World-model driver": "Драйвер модели мира", "Writable": "Записываемый", "aborted": "Прервано", "accruing": "Накапливается", "active": "Активно", "appeared": "Появился", "armed": "Активно", "assess_compatibility": "Оценка совместимости", "built_in": "Встроенный", "capability_expand": "Расширение возможностей", "committed": "Завершено", "conformance": "Соответствие", "declared_fitness": "Заявленная пригодность", "disable": "Отключение", "disposed": "Освобождено", "effect_observed": "Эффект наблюдался", "environment_probe": "Зонд окружения", "execution_failed": "Сбой выполнения", "expected_effect_absent": "Ожидаемый эффект отсутствует", "failed": "Сбой", "frozen": "Заморожено", "gone": "Исчез", "idle": "Простой", "install": "Установка", "loading": "Загрузка", "manual": "Вручную", "moved": "Перешёл", "new_unproven": "Новое, непроверенное", "no": "Нет", "no_evidence": "Нет данных", "no_expected_effect_declared": "Ожидаемый эффект не заявлен", "no_outcome_observed": "Результат не наблюдался", "none": "Нет", "not_admitted": "Не принято", "not_applicable": "Неприменимо", "observe_only": "Только наблюдение", "observed_effect": "Наблюдаемый эффект", "open": "Открыто", "pending": "Ожидает", "reload": "Перезагрузка", "remove": "Удаление", "reopened": "Возобновлено", "resolved": "Закрыто", "rollback": "Откат", "runtime": "Среда выполнения", "self_acquired": "Самостоятельно получено", "still_open": "Всё ещё открыто", "tool_reported_no_effect": "Инструмент не сообщил об эффекте", "trusted": "Доверенное", "unknown": "Неизвестно", "unknown_tool": "Неизвестный инструмент", "unloading": "Выгрузка", "unscheduled": "Не запланировано", "unverifiable": "Не проверяемо", "unverified": "Непроверенное", "waiting": "Ожидание", "watching": "Наблюдает", "wired": "Подключено", "world_model": "Модель мира", "yes": "Да", "Causal trace": "Причинная трасса", "Read-only environment-to-governance evidence for one framework-evolution snapshot.": "Доказательства только для чтения от окружения к управлению для одного снимка эволюции фреймворка.", "Evidence boundary": "Граница доказательств", "A causal trace shows recorded facts; it does not infer missing approval or observed effect.": "Причинная трасса показывает записанные факты и не выводит отсутствующее согласование или наблюдаемый эффект.", "Episodes": "Эпизоды", "Declared-fitness closures": "Закрытия по заявленной пригодности", "Counterfactual / mutation matrix": "Контрфактическая матрица / мутации", "Each row preserves the driver, decision, registry delta, and verification tier.": "Каждая строка сохраняет триггер, решение, изменение реестра и уровень проверки.", "Trigger": "Триггер", "Evidence tier": "Уровень доказательств", "Episode timeline": "Хронология эпизодов", "Rebuilt from existing decision and observation records.": "Восстановлена из существующих записей решений и наблюдений.", "Durable trace feed": "Поток долговечных трасс", "Rejected and no-op decisions remain visible when their trace sink is installed.": "Отклонённые решения и решения без действия остаются видимыми, когда установлен их приёмник трасс.", "Lifecycle": "Жизненный цикл", "Pipeline evidence over time": "Свидетельства конвейера во времени", "One point per recorded change in framework state, oldest first.": "Одна точка на каждое зафиксированное изменение состояния фреймворка, старшие слева.", "Samples": "Выборки", "Net change": "Итоговое изменение"} }; // Page-chrome freshness strings. A table of their own because the provenance bar // is not a lens: it renders above every board, so keying it off any one lens's diff --git a/src/leapflow/dashboard/static/styles.css b/src/leapflow/dashboard/static/styles.css index 9d4869b4..521ebc43 100644 --- a/src/leapflow/dashboard/static/styles.css +++ b/src/leapflow/dashboard/static/styles.css @@ -161,8 +161,9 @@ body { .figcaption .fignum { color: var(--accent); font-weight: 700; margin-inline-end: 5px; } /* ── Bars / sparkline / pie (flat, single-hue accents) ───────────────────── */ -.bar-row { display: grid; grid-template-columns: 74px 1fr 30px; align-items: center; gap: 8px; margin: 7px 0; } +.bar-row { display: grid; grid-template-columns: max-content 1fr 36px; align-items: center; gap: 8px; margin: 7px 0; } .bar-label, .bar-value { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; } +.bar-label { white-space: nowrap; } .bar-track { height: 8px; background: var(--track); border-radius: 0; overflow: hidden; } .bar-fill { display: block; height: 100%; border-radius: 0; background: var(--info); } .bar-fill.sev-alert { background: var(--alert); } diff --git a/src/leapflow/dashboard/templates/capability.yaml b/src/leapflow/dashboard/templates/capability.yaml index 67edbbb7..fe75fb3c 100644 --- a/src/leapflow/dashboard/templates/capability.yaml +++ b/src/leapflow/dashboard/templates/capability.yaml @@ -117,7 +117,7 @@ layout: - key: plugin_id label: "Plugin" - key: trust_level - label: "Trust" + label: "Maturity" - key: failure_streak label: "Failures" bind: capability_plan.governance_results diff --git a/src/leapflow/dashboard/templates/evolution.yaml b/src/leapflow/dashboard/templates/evolution.yaml index 43ee3a92..01763868 100644 --- a/src/leapflow/dashboard/templates/evolution.yaml +++ b/src/leapflow/dashboard/templates/evolution.yaml @@ -445,8 +445,8 @@ layout: - type: Section when: evolution.roster props: - title: "Plugin roster and trust" - subtitle: "Read live from the registry and trust ledger every cycle." + title: "Plugin roster and maturity" + subtitle: "Read live from the registry and maturity ledger every cycle." children: - type: BarChart when: evolution.provenance_mix @@ -456,7 +456,7 @@ layout: - type: BarChart when: evolution.trust_mix props: - title: "Plugins by trust class" + title: "Plugins by maturity" bind: evolution.trust_mix # Deliberately no live counters here. This finding dedups on a # content fingerprint, so a rendered metric that changes every tick @@ -473,7 +473,7 @@ layout: - key: fiber_state label: "Fiber" - key: trust_level - label: "Trust" + label: "Maturity" - key: selectable label: "Selectable" - key: ever_used @@ -503,7 +503,7 @@ layout: - key: plugin_id label: "Plugin" - key: trust_level - label: "Trust" + label: "Maturity" - key: selectable label: "Selectable" - key: ever_used diff --git a/src/leapflow/domain/event_types.py b/src/leapflow/domain/event_types.py index 3a3f4669..7b1d55e1 100644 --- a/src/leapflow/domain/event_types.py +++ b/src/leapflow/domain/event_types.py @@ -103,6 +103,7 @@ class EvolutionEventType: PLUGIN_PROBATION_STARTED = "plugin.probation_started" PLUGIN_VERIFIED = "plugin.verified" PLUGIN_QUARANTINED = "plugin.quarantined" + PLUGIN_UNQUARANTINED = "plugin.unquarantined" PLUGIN_ROLLED_BACK = "plugin.rolled_back" FRAMEWORK_TRACE_RECORDED = "framework.trace_recorded" PLUGIN_OUTCOME_RECORDED = "plugin.outcome_recorded" diff --git a/src/leapflow/engine/session_factory.py b/src/leapflow/engine/session_factory.py index e6cedb08..16877e84 100644 --- a/src/leapflow/engine/session_factory.py +++ b/src/leapflow/engine/session_factory.py @@ -77,8 +77,17 @@ def record_failure(self, plugin_id: str, *, hard: bool = False) -> None: self._flush() self._trace_transition(plugin_id, before, after, hard=hard) + def unfreeze(self, plugin_id: str) -> bool: + before = self.level(plugin_id) + result = super().unfreeze(plugin_id) + if result: + after = self.level(plugin_id) + self._flush() + self._trace_transition(plugin_id, before, after, hard=False, trigger="unfreeze") + return result + def _trace_transition( - self, plugin_id: str, before: Any, after: Any, *, hard: bool + self, plugin_id: str, before: Any, after: Any, *, hard: bool, trigger: str = "" ) -> None: """Emit the trust transition, which nothing else records durably. @@ -93,6 +102,29 @@ def _trace_transition( PRODUCTION or a freeze on an internal defect cannot be reconstructed after the fact from the trust state alone. """ + # ── DuckDB trust transition history (cold-path, best-effort) ── + try: + store = self._store + if store is not None: + before_int = int(before) if hasattr(before, '__int__') else int(before) + after_int = int(after) if hasattr(after, '__int__') else int(after) + if trigger: + pass # Caller-supplied trigger (e.g. "unfreeze") + elif hard: + trigger = "hard_failure" + elif after_int > before_int: + trigger = "success" + else: + trigger = "failure" + ok_count = self._consecutive_ok.get(plugin_id, 0) + fail_count = self._consecutive_fail.get(plugin_id, 0) + store.record_trust_transition( + plugin_id, before_int, after_int, trigger, ok_count, fail_count + ) + except Exception: # noqa: BLE001 - trust history is best-effort, never fail a turn + pass + + # ── EvolutionTap telemetry ── try: from leapflow.domain.evolution_trace import EvolutionStage from leapflow.telemetry.evolution_tap import emit_trace, is_enabled diff --git a/src/leapflow/evolution/sweep.py b/src/leapflow/evolution/sweep.py index 1f58ea36..43ea0f55 100644 --- a/src/leapflow/evolution/sweep.py +++ b/src/leapflow/evolution/sweep.py @@ -32,6 +32,7 @@ from __future__ import annotations import logging +import time from dataclasses import dataclass, field from typing import Any, Mapping, Sequence @@ -63,6 +64,8 @@ class SweepOutcome: verdicts: tuple[EffectVerdict, ...] = () quarantined: tuple[Mapping[str, Any], ...] = () reclamation: tuple[ReclamationCandidate, ...] = () + expired: int = 0 + superseded: int = 0 @property def verified(self) -> int: @@ -83,12 +86,14 @@ def to_dict(self) -> dict[str, Any]: "effect_unverifiable": self.unverifiable, "quarantined": len(self.quarantined), "reclamation_candidates": [c.plugin_id for c in self.reclamation], + "expired": self.expired, + "superseded": self.superseded, } @dataclass class CoevolutionSweep: - """Runs effect verification, quarantine governance and reclamation. + """Runs effect verification, quarantine governance, proposal expiry and reclamation. All collaborators are optional: a sweep with nothing wired emits the corresponding no-op traces and returns an empty outcome, which is what keeps @@ -100,6 +105,8 @@ class CoevolutionSweep: verifier: CapabilityEffectVerifier = field(default_factory=CapabilityEffectVerifier) reaper: UnselectableArtifactReaper = field(default_factory=UnselectableArtifactReaper) proposal_ids: Mapping[str, str] = field(default_factory=dict) + orchestrator: Any = None # ProposalOrchestrator, optional + proposal_store: Any = None # EvolutionCapabilityProposalStore, optional async def run( self, @@ -117,8 +124,12 @@ async def run( """ verdicts = await self._verify(verifications) quarantined = await self._drain() + expired, superseded = self._sweep_proposal_expiry() reclamation = self._reclaim(acquired_plugin_ids, resolutions) - return SweepOutcome(verdicts, quarantined, reclamation) + return SweepOutcome( + verdicts, quarantined, reclamation, + expired=expired, superseded=superseded, + ) # ── effect verification (L3 closure) ────────────────────────────────── @@ -295,6 +306,98 @@ def _reclaim( ) return found + # ── proposal TTL and supersession ───────────────────────────────────── + + def _sweep_proposal_expiry(self) -> tuple[int, int]: + """Expire stale proposals and supersede outdated ones.""" + if self.orchestrator is None or self.proposal_store is None: + self._emit( + EvolutionStage.LEARN, "proposal_expiry", + summary="proposal store or orchestrator not available", + detail={"expired": 0, "superseded": 0, "no_op": True}, + ) + return 0, 0 + try: + now = time.time() + active = self.proposal_store.active(limit=0) + except Exception: # noqa: BLE001 + logger.debug("sweep: could not read active proposals", exc_info=True) + return 0, 0 + + expired_count = superseded_count = 0 + for item in active: + try: + # 1) TTL expiry + if item.expires_at is not None and now >= item.expires_at: + self.orchestrator.expire(item.proposal_id, reason="ttl_exceeded") + expired_count += 1 + self._emit( + EvolutionStage.LEARN, "proposal_expiry", + correlation={"proposal_id": item.proposal_id}, + summary=f"{item.proposal_id}: ttl_exceeded", + detail={"proposal_id": item.proposal_id, "reason": "ttl_exceeded"}, + ) + continue + # 2) Supersession: same requirements hash, newer proposal exists + if self._has_newer_proposal(item, active): + self.orchestrator.supersede( + item.proposal_id, + replacement_id=self._newest_for_requirements(item, active), + reason="newer_proposal_exists", + ) + superseded_count += 1 + self._emit( + EvolutionStage.LEARN, "proposal_expiry", + correlation={"proposal_id": item.proposal_id}, + summary=f"{item.proposal_id}: superseded by newer proposal", + detail={"proposal_id": item.proposal_id, "reason": "newer_proposal_exists"}, + ) + except Exception: # noqa: BLE001 - one bad proposal must not stop the sweep + logger.debug("sweep: proposal expiry failed for %s", item.proposal_id, exc_info=True) + + if not expired_count and not superseded_count: + self._emit( + EvolutionStage.LEARN, "proposal_expiry", + summary="no proposal expired or superseded", + detail={"expired": 0, "superseded": 0, "no_op": True}, + ) + return expired_count, superseded_count + + @staticmethod + def _requirements_hash(item: Any) -> str: + """Stable content hash of a proposal's requirement set.""" + from leapflow.domain.evolution_event import content_hash + + reqs = [dict(r) for r in (item.requirements or ())] + return content_hash(reqs) + + @classmethod + def _has_newer_proposal(cls, candidate: Any, active: Sequence[Any]) -> bool: + """Return True if a newer active proposal exists for the same requirements.""" + candidate_hash = cls._requirements_hash(candidate) + for other in active: + if other.proposal_id == candidate.proposal_id: + continue + if cls._requirements_hash(other) == candidate_hash: + if (other.created_at or 0.0) > (candidate.created_at or 0.0): + return True + return False + + @classmethod + def _newest_for_requirements(cls, candidate: Any, active: Sequence[Any]) -> str: + """Return the proposal_id of the newest active proposal with the same requirements.""" + candidate_hash = cls._requirements_hash(candidate) + newest_id = candidate.proposal_id + newest_at = candidate.created_at or 0.0 + for other in active: + if other.proposal_id == candidate.proposal_id: + continue + if cls._requirements_hash(other) == candidate_hash: + if (other.created_at or 0.0) > newest_at: + newest_id = other.proposal_id + newest_at = other.created_at or 0.0 + return newest_id + @staticmethod def _emit(stage: EvolutionStage, kind: str, **kwargs: Any) -> None: """Record one sweep fact. Observability must never affect the observed.""" diff --git a/src/leapflow/learning/plugin_stats_store.py b/src/leapflow/learning/plugin_stats_store.py index eae796a7..36e0c50d 100644 --- a/src/leapflow/learning/plugin_stats_store.py +++ b/src/leapflow/learning/plugin_stats_store.py @@ -27,6 +27,7 @@ def __init__(self, db_path: Optional[Path] = None) -> None: self._db_path = db_path self._table_created = False self._usage_table_created = False + self._transitions_table_created = False def _connect(self): """Get a DuckDB connection using the centralized factory.""" @@ -65,6 +66,54 @@ def _ensure_usage_table(self, conn) -> None: """) self._usage_table_created = True + def _ensure_transitions_table(self, conn) -> None: + """Create the trust transitions time-series table if it does not exist.""" + if self._transitions_table_created: + return + conn.execute(""" + CREATE SEQUENCE IF NOT EXISTS seq_trust_transition_id START 1 + """) + conn.execute(""" + CREATE TABLE IF NOT EXISTS plugin_trust_transitions ( + id INTEGER PRIMARY KEY DEFAULT nextval('seq_trust_transition_id'), + plugin_id TEXT NOT NULL, + from_level INTEGER NOT NULL, + to_level INTEGER NOT NULL, + trigger TEXT NOT NULL, + consecutive_ok INTEGER, + consecutive_fail INTEGER, + transitioned_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP + ) + """) + self._transitions_table_created = True + + def record_trust_transition( + self, + plugin_id: str, + from_level: int, + to_level: int, + trigger: str, + consecutive_ok: int | None = None, + consecutive_fail: int | None = None, + ) -> bool: + """Record a trust level transition. Best-effort, never fails a turn.""" + conn = self._connect() + if conn is None: + return False + try: + self._ensure_transitions_table(conn) + conn.execute( + "INSERT INTO plugin_trust_transitions " + "(plugin_id, from_level, to_level, trigger, consecutive_ok, consecutive_fail) " + "VALUES (?, ?, ?, ?, ?, ?)", + [plugin_id, from_level, to_level, trigger, consecutive_ok, consecutive_fail], + ) + return True + except Exception: # noqa: BLE001 - trust history is best-effort + return False + finally: + conn.close() + def save_trust_state(self, state: Dict[str, Any]) -> bool: """Persist trust ledger state. Returns True on success.""" conn = self._connect() diff --git a/src/leapflow/learning/plugin_trust.py b/src/leapflow/learning/plugin_trust.py index f7082de6..c3e53b89 100644 --- a/src/leapflow/learning/plugin_trust.py +++ b/src/leapflow/learning/plugin_trust.py @@ -19,8 +19,14 @@ """ from __future__ import annotations +import logging +from dataclasses import dataclass +from datetime import datetime from enum import IntEnum -from typing import Any, Dict +from pathlib import Path +from typing import Any, Dict, List + +logger = logging.getLogger(__name__) class PluginTrustLevel(IntEnum): @@ -100,6 +106,17 @@ def record_failure(self, plugin_id: str, *, hard: bool = False) -> None: if self._consecutive_fail[plugin_id] >= self._demote_after: self._demote(plugin_id) + def unfreeze(self, plugin_id: str) -> bool: + """Remove plugin from frozen set and reset counters for re-probation.""" + if plugin_id not in self._frozen: + return False + self._frozen.discard(plugin_id) + self._consecutive_ok.pop(plugin_id, None) + self._consecutive_fail.pop(plugin_id, None) + # Reset to DRAFT — must re-earn trust + self._levels[plugin_id] = PluginTrustLevel.DRAFT + return True + # ── Internal promotion / demotion ── def _maybe_promote(self, plugin_id: str) -> None: @@ -157,3 +174,83 @@ def load_state(cls, state: Dict[str, Any]) -> "PluginTrustLedger": } ledger._frozen = {str(k) for k in (state.get("frozen") or [])} return ledger + + +@dataclass(frozen=True) +class TrustTransitionRecord: + """A single trust level transition persisted in DuckDB.""" + + plugin_id: str + from_level: int + to_level: int + trigger: str + consecutive_ok: int | None + consecutive_fail: int | None + transitioned_at: datetime + + +def trust_history( + db_path: Path | str, + plugin_id: str | None = None, + since: datetime | None = None, +) -> List[TrustTransitionRecord]: + """Query trust transition history from DuckDB. + + Returns records ordered by ``transitioned_at ASC``. Handles a missing + table gracefully (returns an empty list). ``db_path`` is the path to + the ``plugin_stats.duckdb`` file used by ``PluginStatsStore``. + """ + try: + from leapflow.storage.duckdb_connect import connect + except ImportError: + return [] + + try: + conn = connect(Path(db_path)) + except (RuntimeError, OSError): + return [] + + try: + # Check table existence — the table may not have been created yet. + tables = [ + row[0] + for row in conn.execute( + "SELECT table_name FROM information_schema.tables " + "WHERE table_name = 'plugin_trust_transitions'" + ).fetchall() + ] + if not tables: + return [] + + clauses: list[str] = [] + params: list[Any] = [] + if plugin_id is not None: + clauses.append("plugin_id = ?") + params.append(plugin_id) + if since is not None: + clauses.append("transitioned_at >= ?") + params.append(since) + + sql = "SELECT plugin_id, from_level, to_level, trigger, consecutive_ok, consecutive_fail, transitioned_at FROM plugin_trust_transitions" + if clauses: + sql += " WHERE " + " AND ".join(clauses) + sql += " ORDER BY transitioned_at ASC" + + rows = conn.execute(sql, params).fetchall() + return [ + TrustTransitionRecord( + plugin_id=r[0], + from_level=r[1], + to_level=r[2], + trigger=r[3], + consecutive_ok=r[4], + consecutive_fail=r[5], + transitioned_at=r[6], + ) + for r in rows + ] + except Exception: # noqa: BLE001 - query is best-effort + logger.debug("trust_history query failed", exc_info=True) + return [] + finally: + conn.close() diff --git a/src/leapflow/plugins/proposal_orchestrator.py b/src/leapflow/plugins/proposal_orchestrator.py index a8e893c2..2eb664d9 100644 --- a/src/leapflow/plugins/proposal_orchestrator.py +++ b/src/leapflow/plugins/proposal_orchestrator.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass +from datetime import datetime, timezone from typing import Any, Mapping, Protocol, runtime_checkable from leapflow.evolution.artifact_store import ContentAddressedArtifactStore @@ -239,28 +240,38 @@ def record_installed( metadata={"terminal_reason": reason} if target == "FAILED" else {}, ) - def supersede(self, proposal_id: str, *, replacement_id: str, reason: str) -> CapabilityProposalItem: + def supersede(self, proposal_id: str, *, replacement_id: str, reason: str = "") -> CapabilityProposalItem: """Close an uninstalled proposal in favor of a newer durable proposal.""" return self._queue.transition( proposal_id, "SUPERSEDED", - metadata={"terminal_reason": reason, "replacement_proposal_id": replacement_id}, + metadata={ + "terminal_reason": reason, + "replacement_proposal_id": replacement_id, + "swept_at": datetime.now(timezone.utc).isoformat(), + }, ) - def expire(self, proposal_id: str, *, reason: str) -> CapabilityProposalItem: + def expire(self, proposal_id: str, *, reason: str = "") -> CapabilityProposalItem: """Close an uninstalled proposal whose review window has elapsed.""" return self._queue.transition( proposal_id, "EXPIRED", - metadata={"terminal_reason": reason}, + metadata={ + "terminal_reason": reason, + "swept_at": datetime.now(timezone.utc).isoformat(), + }, ) - def record_noop(self, proposal_id: str, *, reason: str) -> CapabilityProposalItem: + def record_noop(self, proposal_id: str, *, reason: str = "") -> CapabilityProposalItem: """Close a proposal resolved without acquiring a new capability.""" return self._queue.transition( proposal_id, "NO_OP", - metadata={"terminal_reason": reason}, + metadata={ + "terminal_reason": reason, + "swept_at": datetime.now(timezone.utc).isoformat(), + }, ) def _reject( diff --git a/src/leapflow/plugins/tool_plugins/self_management.py b/src/leapflow/plugins/tool_plugins/self_management.py index 005a35bf..0e9990b0 100644 --- a/src/leapflow/plugins/tool_plugins/self_management.py +++ b/src/leapflow/plugins/tool_plugins/self_management.py @@ -1,7 +1,7 @@ # Copyright (c) Alibaba, Inc. and its affiliates. """Self-Management plugin — lets the Agent introspect and manage its own plugin composition. -This is the Phase 2.4 Self-Modification MVP. It exposes twelve tools: +This is the Phase 2.4 Self-Modification MVP. It exposes thirteen tools: Read-only governance (no approval needed): - plugin_list : list all registered plugins across Tool/Gateway/LLM subsystems @@ -1477,9 +1477,11 @@ async def _install_from_dsh_source( if not result.get("ok"): return result try: - version_info = self._version_store().record_source( + version_store = self._version_store() + version_info = version_store.record_bundle( prepared.plugin_id, prepared.wrapper_path, + prepared.final_root, version=version_label, metadata={ "source": "dsh_source", @@ -2051,14 +2053,9 @@ async def _plugin_rollback_handler( except (ImportError, ValueError): is_dsh = False if is_dsh: - return { - "ok": False, - "error": ( - "DSH bundle rollback is not supported in P0; reinstall the desired " - "source bundle after removing the current plugin" - ), - "failure_code": "dsh_rollback_unsupported", - } + return await self._plugin_rollback_dsh( + plugin_id, version, **kwargs + ) approved, denial = await self._check_approval("rollback", plugin_id) if not approved: return {"ok": False, "error": denial, "requires_approval": True} @@ -2114,6 +2111,70 @@ async def _plugin_rollback_handler( response["rollback_error"] = restoration_error return response + async def _plugin_rollback_dsh( + self, plugin_id: str, version: str, **kwargs: Any + ) -> Dict[str, Any]: + """Rollback a DSH bundle plugin to a recorded directory-level snapshot.""" + approved, denial = await self._check_approval("rollback", plugin_id) + if not approved: + return {"ok": False, "error": denial, "requires_approval": True} + + from leapflow.plugins import reload_plugin + + version_store = self._version_store() + wrapper_target = self._resolve_install_dir() / f"{plugin_id}.py" + bundle_target = self._resolve_dsh_install_dir() / plugin_id + metadata_snapshot = version_store.snapshot_state(plugin_id) + wrapper_snapshot = wrapper_target.read_bytes() if wrapper_target.exists() else None + try: + _result = version_store.rollback_bundle( + plugin_id, version, wrapper_target, bundle_target + ) + fiber = reload_plugin(plugin_id) + response: Dict[str, Any] = { + "ok": True, + "action": "rollback", + "plugin_id": plugin_id, + "version": version, + "bundle": True, + "state": fiber.state.value, + "new_generation": fiber.generation, + } + from leapflow.domain.event_types import EvolutionEventType + + persisted = await self._emit_plugin_event( + EvolutionEventType.PLUGIN_ROLLED_BACK, + plugin_id=plugin_id, + version_id=version, + payload=response, + dedup_suffix=f"{version}:{fiber.generation}", + ) + if not persisted: + response["audit_incomplete"] = True + return response + except (KeyError, RuntimeError, OSError, AttributeError, FileNotFoundError) as exc: + restoration_error = "" + try: + version_store.restore_source(wrapper_target, wrapper_snapshot) + version_store.restore_state(plugin_id, metadata_snapshot) + reload_plugin(plugin_id) + except (KeyError, RuntimeError, OSError, AttributeError) as restore_exc: + restoration_error = str(restore_exc) + logger.error( + "DSH bundle rollback could not restore the previous runtime: %s", + restore_exc, + exc_info=True, + ) + logger.warning("DSH bundle rollback failed: %s", exc, exc_info=True) + response = { + "ok": False, + "error": f"DSH bundle rollback failed: {exc}", + "rolled_back": restoration_error == "", + } + if restoration_error: + response["rollback_error"] = restoration_error + return response + async def _plugin_enable_handler(self, plugin_id: str, **kwargs: Any) -> Dict[str, Any]: """Re-enable a previously disabled plugin. REQUIRES approval. @@ -2278,6 +2339,108 @@ async def _plugin_reload_handler( except RuntimeError as exc: return {"ok": False, "error": f"Reload failed: {exc}"} + async def _plugin_unquarantine_handler(self, plugin_id: str, **kwargs: Any) -> Dict[str, Any]: + """Restore a quarantined plugin to probation for re-evaluation.""" + if plugin_id == "self_management": + return {"ok": False, "error": "Cannot unquarantine self_management (not quarantined)"} + + # Approval gate — forces HIGH risk via platform="plugin_management" + approved, denial = await self._check_approval( + "unquarantine", plugin_id, + metadata={"platform": "plugin_management"}, + ) + if not approved: + return {"ok": False, "error": denial, "requires_approval": True} + + # Confirm the plugin is actually in QUARANTINED status via proposal store + lifecycle_store = self._capability_lifecycle_store + proposal = None + quarantine_reason = "" + if lifecycle_store is not None: + try: + for item in lifecycle_store.list_items(status="QUARANTINED", limit=0): + pid = str(item.metadata.get("plugin_id") or "") + if pid == plugin_id: + proposal = item + quarantine_reason = str(item.metadata.get("terminal_reason") or "") + break + except (AttributeError, RuntimeError) as exc: + logger.warning("unquarantine: proposal lookup failed: %s", exc) + + if proposal is None: + return { + "ok": False, + "error": f"Plugin '{plugin_id}' is not in QUARANTINED status", + } + + # Unfreeze the trust ledger — resets to DRAFT + unfrozen = False + try: + from leapflow.learning.plugin_advisor import get_default_advisor + + advisor = get_default_advisor() + if advisor is not None: + unfrozen = advisor._trust_ledger.unfreeze(plugin_id) + except (ImportError, AttributeError, RuntimeError) as exc: + logger.warning("unquarantine: trust unfreeze failed: %s", exc) + + # Transition proposal: QUARANTINED -> PROBATION + try: + lifecycle_store.transition( + proposal.proposal_id, + "PROBATION", + metadata={"unquarantine_reason": "manual_recovery"}, + ) + except (ValueError, KeyError, RuntimeError) as exc: + return { + "ok": False, + "error": f"Proposal transition failed: {exc}", + "trust_unfrozen": unfrozen, + } + + # Reload the plugin fiber + reload_ok = False + reload_error = "" + try: + from leapflow.plugins import reload_plugin + + reload_plugin(plugin_id) + reload_ok = True + except (KeyError, RuntimeError, ImportError) as exc: + reload_error = str(exc) + logger.warning("unquarantine: reload failed: %s", exc) + + # Emit PLUGIN_UNQUARANTINED event + try: + from leapflow.domain.event_types import EvolutionEventType + + await self._emit_plugin_event( + EvolutionEventType.PLUGIN_UNQUARANTINED, + plugin_id=plugin_id, + proposal_id=proposal.proposal_id, + payload={ + "plugin_id": plugin_id, + "original_quarantine_reason": quarantine_reason, + "trust_unfrozen": unfrozen, + "reload_ok": reload_ok, + }, + dedup_suffix=f"{proposal.proposal_id}:unquarantine", + ) + except Exception: # noqa: BLE001 + logger.debug("unquarantine event emission failed", exc_info=True) + + response: Dict[str, Any] = { + "ok": True, + "plugin_id": plugin_id, + "status": "PROBATION", + "trust": "DRAFT", + "trust_unfrozen": unfrozen, + "reload_ok": reload_ok, + } + if reload_error: + response["reload_error"] = reload_error + return response + async def _plugin_disable_handler(self, plugin_id: str, **kwargs: Any) -> Dict[str, Any]: """Disable a plugin by disposing its fiber. REQUIRES approval. @@ -2778,6 +2941,37 @@ def tools(self) -> list[ToolMetadata]: provides_capabilities=("plugin.remove",), requires_platform_capabilities=("file.ops",), ), + ToolMetadata( + name="plugin_unquarantine", + description=( + "Restore a quarantined plugin to probation status for re-evaluation. " + "Unfreezes the trust ledger, transitions the proposal back to PROBATION, " + "and reloads the plugin. REQUIRES APPROVAL." + ), + parameters_schema={ + "type": "object", + "properties": { + "plugin_id": { + "type": "string", + "description": "The plugin identifier to unquarantine.", + }, + }, + "required": ["plugin_id"], + }, + handler=self._plugin_unquarantine_handler, + x_leapflow={ + "category": "plugin_management", + "risk_level": "high", + "schema_cost": "medium", + "requires_approval": True, + "effect_scope": "local", + "idempotency_scope": "session", + "summary": "restore a quarantined plugin to probation (approval required)", + }, + mutates_state=True, + provides_capabilities=("plugin.unquarantine",), + requires_platform_capabilities=("file.ops",), + ), ToolMetadata( name="plugin_enable", description=( diff --git a/src/leapflow/storage/capability_proposal_queue.py b/src/leapflow/storage/capability_proposal_queue.py index b4947d7b..c26e382d 100644 --- a/src/leapflow/storage/capability_proposal_queue.py +++ b/src/leapflow/storage/capability_proposal_queue.py @@ -43,7 +43,7 @@ "INSTALLED": frozenset({"PROBATION", "QUARANTINED", "FAILED"}), "PROBATION": frozenset({"VERIFIED", "QUARANTINED", "FAILED"}), "VERIFIED": frozenset({"PROBATION", "QUARANTINED", "FAILED"}), - "QUARANTINED": frozenset({"FAILED"}), + "QUARANTINED": frozenset({"FAILED", "PROBATION"}), "REJECTED": frozenset(), "FAILED": frozenset(), "SUPERSEDED": frozenset(), @@ -72,6 +72,7 @@ class CapabilityProposalItem: trust_state: Mapping[str, Any] = field(default_factory=dict) created_at: float = 0.0 updated_at: float = 0.0 + expires_at: float | None = None metadata: Mapping[str, Any] = field(default_factory=dict) def to_dict(self) -> dict[str, Any]: @@ -92,6 +93,7 @@ def to_dict(self) -> dict[str, Any]: "trust_state": dict(self.trust_state), "created_at": self.created_at, "updated_at": self.updated_at, + "expires_at": self.expires_at, "metadata": dict(self.metadata), } @@ -118,6 +120,7 @@ def from_dict(cls, data: Mapping[str, Any]) -> "CapabilityProposalItem": trust_state=dict(data.get("trust_state") or {}), created_at=float(data.get("created_at") or 0.0), updated_at=float(data.get("updated_at") or 0.0), + expires_at=_coerce_optional_float(data.get("expires_at")), metadata=dict(data.get("metadata") or {}), ) @@ -141,9 +144,16 @@ def from_dict(cls, data: Mapping[str, Any]) -> "CapabilityProposalItem": class EvolutionCapabilityProposalStore: """Event-sourced capability proposal lifecycle used by production runtime.""" - def __init__(self, event_store: Any, *, profile_id: str) -> None: + def __init__( + self, + event_store: Any, + *, + profile_id: str, + proposal_ttl_hours: int = 72, + ) -> None: self._event_store = event_store self._profile_id = str(profile_id) + self._proposal_ttl_hours = max(0, int(proposal_ttl_hours)) self._lock = threading.RLock() def enqueue( @@ -194,6 +204,11 @@ def prepare_enqueue( if existing is not None: return existing, None now = time.time() if occurred_at is None else float(occurred_at) + expires_at = ( + now + self._proposal_ttl_hours * 3600.0 + if self._proposal_ttl_hours > 0 + else None + ) item = CapabilityProposalItem( proposal_id=proposal_id, status="PENDING", @@ -204,6 +219,7 @@ def prepare_enqueue( observation_ids=tuple(str(item) for item in observation_ids), created_at=now, updated_at=now, + expires_at=expires_at, metadata=dict(metadata or {}), ) return item, self._state_event(item, previous_status="") @@ -285,6 +301,7 @@ def update( ), created_at=item.created_at, updated_at=time.time(), + expires_at=item.expires_at, metadata={**dict(item.metadata), **dict(metadata or {})}, ) return self._append_state(updated, previous_status=item.status) @@ -429,6 +446,15 @@ def _proposal_identity( return "prop-" + content_hash(material)[:16] +def _coerce_optional_float(value: Any) -> float | None: + if value is None: + return None + try: + return float(value) + except (TypeError, ValueError): + return None + + def _coerce_status(value: Any) -> ProposalStatus: raw = str(value or "PENDING").upper() allowed = ProposalStatus.__args__ # type: ignore[attr-defined] diff --git a/src/leapflow/storage/plugin_version_store.py b/src/leapflow/storage/plugin_version_store.py index 595e7362..60677be5 100644 --- a/src/leapflow/storage/plugin_version_store.py +++ b/src/leapflow/storage/plugin_version_store.py @@ -3,8 +3,11 @@ from __future__ import annotations import hashlib +import io import json import os +import shutil +import tarfile import time from pathlib import Path from typing import Any @@ -105,6 +108,144 @@ def rollback(self, plugin_id: str, version: str, target_path: Path) -> dict[str, entry = self.record_source(plugin_id, target, version=version, metadata={"rollback": True}) return entry + # ── bundle (directory-level) snapshots ──────────────────────────── + + def record_bundle( + self, + plugin_id: str, + wrapper_path: Path, + bundle_dir: Path, + *, + version: str = "", + metadata: dict[str, Any] | None = None, + ) -> dict[str, Any]: + """Create a tar.gz archive of *wrapper_path* and *bundle_dir* and record it.""" + wrapper = Path(wrapper_path) + bundle = Path(bundle_dir) + if not wrapper.is_file(): + raise FileNotFoundError(f"Wrapper not found: {wrapper}") + if not bundle.is_dir(): + raise NotADirectoryError(f"Bundle directory not found: {bundle}") + + # Derive version from combined content hash when unspecified. + sha_hasher = hashlib.sha256() + sha_hasher.update(wrapper.read_bytes()) + for p in sorted(bundle.rglob("*")): + if p.is_file(): + sha_hasher.update(p.read_bytes()) + bundle_sha256 = sha_hasher.hexdigest() + version_id = str(version or f"sha-{bundle_sha256[:12]}") + + plugin_dir = self._plugin_dir(plugin_id) + versions_dir = plugin_dir / "versions" + versions_dir.mkdir(parents=True, exist_ok=True) + archive_path = versions_dir / f"{version_id}_bundle.tar.gz" + + # Build archive in memory then write atomically. + buf = io.BytesIO() + with tarfile.open(fileobj=buf, mode="w:gz") as tar: + tar.add(str(wrapper), arcname=f"wrapper/{wrapper.name}") + tar.add(str(bundle), arcname="bundle") + archive_bytes = buf.getvalue() + self._write_bytes(archive_path, archive_bytes) + + entry: dict[str, Any] = { + "plugin_id": plugin_id, + "version": version_id, + "source_path": str(wrapper), + "snapshot_path": str(archive_path), + "sha256": hashlib.sha256(wrapper.read_bytes()).hexdigest(), + "bundle_sha256": bundle_sha256, + "is_bundle": True, + "created_at": time.time(), + "metadata": dict(metadata or {}), + } + index = [ + item for item in self._read_index(plugin_id) + if item.get("version") != version_id + ] + index.append(entry) + self._write_json(plugin_dir / "versions.json", index) + self._write_json(plugin_dir / "active.json", entry) + return entry + + def rollback_bundle( + self, + plugin_id: str, + version: str, + wrapper_target: Path, + bundle_target_dir: Path, + ) -> dict[str, Any]: + """Restore a bundle snapshot previously recorded with *record_bundle*.""" + entry: dict[str, Any] | None = None + for item in self._read_index(plugin_id): + if str(item.get("version")) == str(version) and item.get("is_bundle"): + entry = item + break + if entry is None: + raise KeyError(f"Bundle version not found: {plugin_id}@{version}") + archive_path = Path(str(entry["snapshot_path"])) + if not archive_path.exists(): + raise FileNotFoundError(f"Bundle archive missing: {archive_path}") + + expected_sha = str(entry.get("bundle_sha256", "")) + wrapper_dest = Path(wrapper_target) + bundle_dest = Path(bundle_target_dir) + + # Extract into a temporary staging directory, then promote. + staging = bundle_dest.parent / f".rollback_staging_{plugin_id}_{os.getpid()}" + try: + if staging.exists(): + shutil.rmtree(staging) + staging.mkdir(parents=True, exist_ok=True) + with tarfile.open(archive_path, "r:gz") as tar: + tar.extractall(staging, filter="data") + + # Locate extracted artefacts. + extracted_wrapper_dir = staging / "wrapper" + extracted_bundle_dir = staging / "bundle" + if not extracted_bundle_dir.is_dir(): + raise RuntimeError("Archive does not contain a bundle directory") + wrapper_files = list(extracted_wrapper_dir.iterdir()) if extracted_wrapper_dir.is_dir() else [] + if not wrapper_files: + raise RuntimeError("Archive does not contain a wrapper file") + extracted_wrapper = wrapper_files[0] + + # Verify SHA-256 integrity. + sha_hasher = hashlib.sha256() + sha_hasher.update(extracted_wrapper.read_bytes()) + for p in sorted(extracted_bundle_dir.rglob("*")): + if p.is_file(): + sha_hasher.update(p.read_bytes()) + actual_sha = sha_hasher.hexdigest() + if expected_sha and actual_sha != expected_sha: + raise RuntimeError( + f"Bundle integrity check failed: expected {expected_sha[:16]}…, " + f"got {actual_sha[:16]}…" + ) + + # Promote: replace wrapper and bundle directory atomically-ish. + wrapper_dest.parent.mkdir(parents=True, exist_ok=True) + self._write_bytes(wrapper_dest, extracted_wrapper.read_bytes()) + if bundle_dest.exists(): + shutil.rmtree(bundle_dest) + shutil.copytree(extracted_bundle_dir, bundle_dest) + + # Update version index to mark this version active. + result_entry = dict(entry) + result_entry["metadata"] = {**result_entry.get("metadata", {}), "rollback": True} + idx = [ + item for item in self._read_index(plugin_id) + if item.get("version") != version + ] + idx.append(result_entry) + plugin_dir = self._plugin_dir(plugin_id) + self._write_json(plugin_dir / "versions.json", idx) + self._write_json(plugin_dir / "active.json", result_entry) + return {"ok": True, "plugin_id": plugin_id, "version": version, "bundle": True} + finally: + shutil.rmtree(staging, ignore_errors=True) + def _plugin_dir(self, plugin_id: str) -> Path: return self._root / str(plugin_id) diff --git a/src/leapflow/storage/schema.py b/src/leapflow/storage/schema.py index 9c3c524f..5b227d6d 100644 --- a/src/leapflow/storage/schema.py +++ b/src/leapflow/storage/schema.py @@ -5,6 +5,16 @@ schema here rather than running ad-hoc CREATE TABLE in its own __init__. Migration is version-tracked via a ``_schema_version`` table. + +**Every migration must be idempotent.** The version integer records how far a +database has been advanced, but it cannot guarantee that a migration's *contents* +match the physical objects present -- an intermediate build may have created an +object under a different version, and a crash between a DDL statement and the +version bump can leave a migration half-applied. So every statement uses +``CREATE ... IF NOT EXISTS`` / ``DROP ... IF EXISTS`` / ``ADD COLUMN IF NOT EXISTS`` +and re-running it against a database that already holds the object is a safe no-op. +A non-idempotent ``CREATE`` here is a latent startup crash: it aborts the whole +bootstrap transaction the first time a pre-existing object is met. """ from __future__ import annotations @@ -375,7 +385,7 @@ def _apply_evolution_tables(conn: duckdb.DuckDBPyConnection) -> None: """Create the append-only event stream and durable cold-path work queues.""" statements = ( """ - CREATE TABLE evolution_events ( + CREATE TABLE IF NOT EXISTS evolution_events ( sequence BIGINT NOT NULL, event_id VARCHAR PRIMARY KEY, event_type VARCHAR NOT NULL, @@ -407,7 +417,7 @@ def _apply_evolution_tables(conn: duckdb.DuckDBPyConnection) -> None: ) """, """ - CREATE TABLE evolution_teacher_jobs ( + CREATE TABLE IF NOT EXISTS evolution_teacher_jobs ( job_id VARCHAR PRIMARY KEY, profile_id VARCHAR NOT NULL, workspace_id VARCHAR NOT NULL DEFAULT '', @@ -433,10 +443,10 @@ def _apply_evolution_tables(conn: duckdb.DuckDBPyConnection) -> None: UNIQUE(profile_id, episode_id) ) """, - "CREATE INDEX idx_evo_event_session ON evolution_events(profile_id, session_id, sequence)", - "CREATE INDEX idx_evo_event_correlation ON evolution_events(profile_id, correlation_id, sequence)", - "CREATE INDEX idx_evo_event_type ON evolution_events(profile_id, event_type, sequence)", - "CREATE INDEX idx_evo_teacher_status ON evolution_teacher_jobs(profile_id, status, next_attempt_at)", + "CREATE INDEX IF NOT EXISTS idx_evo_event_session ON evolution_events(profile_id, session_id, sequence)", + "CREATE INDEX IF NOT EXISTS idx_evo_event_correlation ON evolution_events(profile_id, correlation_id, sequence)", + "CREATE INDEX IF NOT EXISTS idx_evo_event_type ON evolution_events(profile_id, event_type, sequence)", + "CREATE INDEX IF NOT EXISTS idx_evo_teacher_status ON evolution_teacher_jobs(profile_id, status, next_attempt_at)", ) for statement in statements: conn.execute(statement) @@ -445,11 +455,11 @@ def _apply_evolution_tables(conn: duckdb.DuckDBPyConnection) -> None: def _apply_evolution_sequence(conn: duckdb.DuckDBPyConnection) -> None: """Create a database-global cursor after any pre-sequence event rows.""" conn.execute( - "CREATE UNIQUE INDEX idx_evo_event_sequence ON evolution_events(sequence)" + "CREATE UNIQUE INDEX IF NOT EXISTS idx_evo_event_sequence ON evolution_events(sequence)" ) row = conn.execute("SELECT COALESCE(MAX(sequence), 0) + 1 FROM evolution_events").fetchone() start = max(1, int(row[0] if row else 1)) - conn.execute(f"CREATE SEQUENCE evolution_event_sequence START {start}") + conn.execute(f"CREATE SEQUENCE IF NOT EXISTS evolution_event_sequence START {start}") def _apply_teacher_job_context(conn: duckdb.DuckDBPyConnection) -> None: @@ -473,7 +483,7 @@ def _apply_evolution_projection(conn: duckdb.DuckDBPyConnection) -> None: """Create checkpointed read models derived exclusively from the event stream.""" conn.execute( """ - CREATE TABLE evolution_projections ( + CREATE TABLE IF NOT EXISTS evolution_projections ( projection_name VARCHAR NOT NULL, profile_id VARCHAR NOT NULL, scope_key VARCHAR NOT NULL, @@ -490,7 +500,7 @@ def _apply_proposal_event_index(conn: duckdb.DuckDBPyConnection) -> None: """Retire the unused work table and index event-sourced proposal replay.""" conn.execute("DROP TABLE IF EXISTS evolution_proposal_work") conn.execute( - "CREATE INDEX idx_evo_event_proposal " + "CREATE INDEX IF NOT EXISTS idx_evo_event_proposal " "ON evolution_events(profile_id, proposal_id, sequence)" ) diff --git a/tests/test_coevolution_sweep_wiring.py b/tests/test_coevolution_sweep_wiring.py index b2e94f04..a099589e 100644 --- a/tests/test_coevolution_sweep_wiring.py +++ b/tests/test_coevolution_sweep_wiring.py @@ -15,6 +15,8 @@ from __future__ import annotations import asyncio +import time +from pathlib import Path from leapflow.domain.capability_requirement import CapabilityRequirement from leapflow.domain.evolution_trace import EvolutionStage, EvolutionTrace @@ -75,8 +77,8 @@ def test_empty_sweep_still_records_its_no_op_branches(): try: outcome = asyncio.run(CoevolutionSweep().run()) assert outcome == SweepOutcome() - # All three segments reported, each flagged as a no-op. - assert sink.kinds() == {"effect_verification", "quarantine_drain", "reclamation"} + # All four segments reported, each flagged as a no-op. + assert sink.kinds() == {"effect_verification", "quarantine_drain", "proposal_expiry", "reclamation"} assert all(t.detail.get("no_op") for t in sink.traces) finally: _teardown() @@ -292,8 +294,8 @@ def test_production_sweep_hook_builds_and_runs_a_real_sweep(): assert outcome.refuted == 1 # WM-6 wired assert len(outcome.quarantined) == 1 # A-4 wired assert [c.plugin_id for c in outcome.reclamation] == ["gen_overrisk"] # LF-10 wired - # All three dashboard segments now have observed output. - assert sink.kinds() == {"effect_verification", "quarantine_drain", "reclamation"} + # All four dashboard segments now have observed output. + assert sink.kinds() == {"effect_verification", "quarantine_drain", "proposal_expiry", "reclamation"} assert outcome.to_dict()["quarantined"] == 1 # Verifications were drained, so a second sweep cannot double-govern them. assert buf.drain_verifications() == () @@ -413,3 +415,155 @@ def test_gap_gate_excludes_unauthorised_origins(tmp_path): # And with nothing authorised, the gate is empty rather than permissive. assert loop.unmet_requirements([shipped], _env(), authorising_origins=("world_model",)) == () + + +# ── proposal expiry sweep tests ─────────────────────────────────────────────── + + +def _proposal_queue(tmp_path: Path, *, ttl_hours: int = 72): + from leapflow.storage.capability_proposal_queue import EvolutionCapabilityProposalStore + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + + events = DuckDBEvolutionEventStore(tmp_path / "events.duckdb") + return EvolutionCapabilityProposalStore(events, profile_id="sweep-p", proposal_ttl_hours=ttl_hours) + + +def _orchestrator(queue): + from leapflow.evolution.artifact_store import ContentAddressedArtifactStore + from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy + from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator + import tempfile + + return ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(Path(tempfile.mkdtemp()) / "artifacts"), + approval_gate=None, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + + +def test_sweep_expires_stale_proposals(tmp_path: Path): + """A proposal with expires_at in the past is swept to EXPIRED.""" + queue = _proposal_queue(tmp_path / "expire", ttl_hours=0) + # Create with an explicit past expires_at via low-level update + item = queue.enqueue( + requirements=(CapabilityRequirement.create("chat.reply", "world_model", requirement_id="req-exp"),), + ) + # Manually set expires_at in the past by re-creating with occurred_at far back + # Since ttl_hours=0 means expires_at=None, we need a different approach. + # Use a queue with ttl_hours=1, but create with occurred_at far in the past. + queue2 = _proposal_queue(tmp_path / "expire2", ttl_hours=1) + item2 = queue2.enqueue( + requirements=(CapabilityRequirement.create("chat.stale", "world_model", requirement_id="req-stale"),), + ) + # The item was created "now" with expires_at = now + 3600. Force expiry by + # creating a proposal with occurred_at far in the past. + queue3 = _proposal_queue(tmp_path / "expire3", ttl_hours=1) + past_item, ev = queue3.prepare_enqueue( + requirements=(CapabilityRequirement.create("chat.old", "world_model", requirement_id="req-old"),), + occurred_at=1.0, # epoch second 1 = way in the past + ) + assert ev is not None + queue3._event_store.append(ev) + assert past_item.expires_at is not None + assert past_item.expires_at < time.time() # Definitely expired + + orch = _orchestrator(queue3) + sink = _sink() + try: + outcome = asyncio.run( + CoevolutionSweep( + orchestrator=orch, proposal_store=queue3, + ).run() + ) + assert outcome.expired == 1 + refreshed = queue3.get(past_item.proposal_id) + assert refreshed is not None + assert refreshed.status == "EXPIRED" + assert refreshed.metadata["terminal_reason"] == "ttl_exceeded" + finally: + _teardown() + + +def test_sweep_supersedes_outdated_proposal(tmp_path: Path): + """Two proposals with same requirements: the older is SUPERSEDED.""" + queue = _proposal_queue(tmp_path / "supersede", ttl_hours=0) # no TTL expiry + older, ev_old = queue.prepare_enqueue( + requirements=(CapabilityRequirement.create("chat.reply", "world_model", requirement_id="req-a"),), + occurred_at=100.0, + ) + assert ev_old is not None + queue._event_store.append(ev_old) + + newer, ev_new = queue.prepare_enqueue( + requirements=(CapabilityRequirement.create("chat.reply", "world_model", requirement_id="req-a"),), + environment={"fingerprint_id": "different"}, # different env => different proposal_id + occurred_at=200.0, + ) + assert ev_new is not None + queue._event_store.append(ev_new) + assert older.proposal_id != newer.proposal_id + + orch = _orchestrator(queue) + sink = _sink() + try: + outcome = asyncio.run( + CoevolutionSweep( + orchestrator=orch, proposal_store=queue, + ).run() + ) + assert outcome.superseded == 1 + old_item = queue.get(older.proposal_id) + assert old_item is not None + assert old_item.status == "SUPERSEDED" + new_item = queue.get(newer.proposal_id) + assert new_item is not None + assert new_item.status == "PENDING" # newer remains active + finally: + _teardown() + + +def test_proposal_without_ttl_not_expired(tmp_path: Path): + """A proposal with expires_at=None is not touched by TTL sweep.""" + queue = _proposal_queue(tmp_path / "no_ttl", ttl_hours=0) # expires_at=None + item = queue.enqueue( + requirements=(CapabilityRequirement.create("chat.reply", "world_model", requirement_id="req-no-ttl"),), + ) + assert item.expires_at is None + + orch = _orchestrator(queue) + sink = _sink() + try: + outcome = asyncio.run( + CoevolutionSweep( + orchestrator=orch, proposal_store=queue, + ).run() + ) + assert outcome.expired == 0 + assert outcome.superseded == 0 + refreshed = queue.get(item.proposal_id) + assert refreshed is not None + assert refreshed.status == "PENDING" # unchanged + finally: + _teardown() + + +def test_sweep_proposal_expiry_cold_path(): + """Proposal expiry lives only in CoevolutionSweep.run(), never per-turn.""" + import ast + import inspect + import textwrap + from leapflow.evolution.sweep import CoevolutionSweep + + source = textwrap.dedent(inspect.getsource(CoevolutionSweep.run)) + tree = ast.parse(source) + calls = [ + node.func.attr + for node in ast.walk(tree) + if isinstance(node, ast.Call) + and isinstance(node.func, ast.Attribute) + and "expir" in getattr(node.func, "attr", "").lower() + ] + assert "_sweep_proposal_expiry" in calls, ( + "proposal_expiry must be called inside CoevolutionSweep.run()" + ) diff --git a/tests/test_dsh_bundle_rollback.py b/tests/test_dsh_bundle_rollback.py new file mode 100644 index 00000000..f71e31c4 --- /dev/null +++ b/tests/test_dsh_bundle_rollback.py @@ -0,0 +1,156 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Tests for DSH directory-level bundle snapshot and rollback.""" +from __future__ import annotations + +import hashlib +import tarfile +from pathlib import Path + +import pytest + +from leapflow.storage.plugin_version_store import PluginVersionStore + + +# ── helpers ─────────────────────────────────────────────────────── + +def _make_bundle(tmp_path: Path, plugin_id: str = "my_dsh") -> tuple[Path, Path]: + """Create a wrapper .py file and a bundle directory with several files.""" + wrapper = tmp_path / "plugins" / f"{plugin_id}.py" + wrapper.parent.mkdir(parents=True, exist_ok=True) + wrapper.write_text("# wrapper v1\nimport json\n", encoding="utf-8") + + bundle = tmp_path / "dsh" / plugin_id + bundle.mkdir(parents=True, exist_ok=True) + (bundle / "index.js").write_text("module.exports = {};", encoding="utf-8") + (bundle / "package.json").write_text('{"name":"test"}', encoding="utf-8") + sub = bundle / "lib" + sub.mkdir() + (sub / "helper.js").write_text("exports.help = true;", encoding="utf-8") + return wrapper, bundle + + +def _content_sha256(wrapper: Path, bundle: Path) -> str: + """Reproduce the combined SHA-256 used by record_bundle.""" + h = hashlib.sha256() + h.update(wrapper.read_bytes()) + for p in sorted(bundle.rglob("*")): + if p.is_file(): + h.update(p.read_bytes()) + return h.hexdigest() + + +# ── tests ───────────────────────────────────────────────────────── + +def test_bundle_snapshot_and_restore_roundtrip(tmp_path: Path) -> None: + """record_bundle → delete originals → rollback_bundle restores everything.""" + wrapper, bundle = _make_bundle(tmp_path) + store = PluginVersionStore(tmp_path / "versions") + + entry = store.record_bundle("my_dsh", wrapper, bundle, version="v1") + + assert entry["version"] == "v1" + assert entry["is_bundle"] is True + assert entry["bundle_sha256"] + assert Path(entry["snapshot_path"]).exists() + + # Capture original content for later comparison. + orig_wrapper = wrapper.read_text(encoding="utf-8") + orig_index = (bundle / "index.js").read_text(encoding="utf-8") + orig_helper = (bundle / "lib" / "helper.js").read_text(encoding="utf-8") + + # Delete originals. + wrapper.unlink() + import shutil + shutil.rmtree(bundle) + assert not wrapper.exists() + assert not bundle.exists() + + # Rollback. + result = store.rollback_bundle("my_dsh", "v1", wrapper, bundle) + assert result["ok"] is True + assert result["bundle"] is True + + # Verify everything is restored. + assert wrapper.read_text(encoding="utf-8") == orig_wrapper + assert (bundle / "index.js").read_text(encoding="utf-8") == orig_index + assert (bundle / "lib" / "helper.js").read_text(encoding="utf-8") == orig_helper + + +def test_rollback_bundle_restores_both_wrapper_and_dir(tmp_path: Path) -> None: + """Modify both wrapper and bundle after recording, rollback restores original.""" + wrapper, bundle = _make_bundle(tmp_path) + store = PluginVersionStore(tmp_path / "versions") + + store.record_bundle("my_dsh", wrapper, bundle, version="v1") + + # Modify both wrapper and bundle content. + wrapper.write_text("# modified wrapper\n", encoding="utf-8") + (bundle / "index.js").write_text("MODIFIED", encoding="utf-8") + (bundle / "lib" / "helper.js").write_text("MODIFIED HELPER", encoding="utf-8") + (bundle / "new_file.txt").write_text("should disappear", encoding="utf-8") + + result = store.rollback_bundle("my_dsh", "v1", wrapper, bundle) + assert result["ok"] is True + + assert wrapper.read_text(encoding="utf-8") == "# wrapper v1\nimport json\n" + assert (bundle / "index.js").read_text(encoding="utf-8") == "module.exports = {};" + assert (bundle / "lib" / "helper.js").read_text(encoding="utf-8") == "exports.help = true;" + # The extra file added after recording should be gone (dir was replaced). + assert not (bundle / "new_file.txt").exists() + + +def test_rollback_bundle_with_sha256_mismatch_fails(tmp_path: Path) -> None: + """Tampering with the stored archive triggers an integrity error.""" + wrapper, bundle = _make_bundle(tmp_path) + store = PluginVersionStore(tmp_path / "versions") + + entry = store.record_bundle("my_dsh", wrapper, bundle, version="v1") + archive_path = Path(entry["snapshot_path"]) + + # Tamper: rewrite the archive with different content. + tampered_wrapper = tmp_path / "tampered.py" + tampered_wrapper.write_text("# TAMPERED\n", encoding="utf-8") + tampered_bundle = tmp_path / "tampered_bundle" + tampered_bundle.mkdir() + (tampered_bundle / "bad.js").write_text("BAD", encoding="utf-8") + import io + buf = io.BytesIO() + with tarfile.open(fileobj=buf, mode="w:gz") as tar: + tar.add(str(tampered_wrapper), arcname=f"wrapper/{tampered_wrapper.name}") + tar.add(str(tampered_bundle), arcname="bundle") + archive_path.write_bytes(buf.getvalue()) + + with pytest.raises(RuntimeError, match="integrity check failed"): + store.rollback_bundle("my_dsh", "v1", wrapper, bundle) + + +def test_rollback_bundle_missing_version_raises_key_error(tmp_path: Path) -> None: + """Attempting to rollback to a non-existent bundle version raises KeyError.""" + store = PluginVersionStore(tmp_path / "versions") + wrapper = tmp_path / "w.py" + bundle = tmp_path / "b" + + with pytest.raises(KeyError, match="Bundle version not found"): + store.rollback_bundle("ghost", "v99", wrapper, bundle) + + +def test_record_bundle_updates_active_and_index(tmp_path: Path) -> None: + """Recording two bundle versions tracks both and points active to the latest.""" + wrapper, bundle = _make_bundle(tmp_path) + store = PluginVersionStore(tmp_path / "versions") + + store.record_bundle("my_dsh", wrapper, bundle, version="v1") + # Modify and record v2. + (bundle / "index.js").write_text("v2 content", encoding="utf-8") + wrapper.write_text("# wrapper v2\n", encoding="utf-8") + store.record_bundle("my_dsh", wrapper, bundle, version="v2") + + versions = store.versions("my_dsh") + version_ids = [v["version"] for v in versions] + assert "v1" in version_ids + assert "v2" in version_ids + + active = store.active("my_dsh") + assert active is not None + assert active["version"] == "v2" + assert active["is_bundle"] is True diff --git a/tests/test_evolution_event_store.py b/tests/test_evolution_event_store.py index 73a9ceb8..738f0302 100644 --- a/tests/test_evolution_event_store.py +++ b/tests/test_evolution_event_store.py @@ -279,6 +279,58 @@ def test_schema_upgrades_a_v1_database_in_order(tmp_path: Path) -> None: connection.close() +def test_schema_heals_an_intermediate_build_with_preexisting_objects(tmp_path: Path) -> None: + """An intermediate build recorded version 2 but already created a later + migration's object (``idx_evo_event_sequence``). Non-idempotent DDL then aborts + startup with 'Index ... already exists'. Every migration must be idempotent so + such a database self-heals in place, and re-running is a no-op. + """ + from leapflow.storage import schema as schema_mod + + connection = duckdb.connect(str(tmp_path / "intermediate.duckdb")) + for table_def in schema_mod.TABLES: + connection.execute(table_def.ddl) + for idx_sql in table_def.indexes: + connection.execute(idx_sql) + # Real migration-2 objects, plus the sequence index a later build created under v2. + schema_mod._apply_evolution_tables(connection) + connection.execute( + "CREATE UNIQUE INDEX idx_evo_event_sequence ON evolution_events(sequence)" + ) + # A real database that reached v2 recorded the base version first, then v2. + connection.execute("INSERT INTO _schema_version VALUES (1, 0.0)") + connection.execute("INSERT INTO _schema_version VALUES (2, 0.0)") + + assert ensure_schema(connection) == CURRENT_SCHEMA_VERSION + assert ensure_schema(connection) == CURRENT_SCHEMA_VERSION, "re-run must be a no-op" + assert [ + row[0] + for row in connection.execute( + "SELECT version FROM _schema_version ORDER BY version" + ).fetchall() + ] == list(range(1, CURRENT_SCHEMA_VERSION + 1)) + # The healed database is functional: the global sequence exists and advances. + assert connection.execute("SELECT nextval('evolution_event_sequence')").fetchone()[0] >= 1 + connection.close() + + +def test_every_evolution_migration_is_idempotent(tmp_path: Path) -> None: + """Applying each migration twice against the same connection must not raise. + + Guards the class of defect directly: a non-idempotent ``CREATE`` in any migration + is a latent startup crash the first time it meets a pre-existing object. + """ + from leapflow.storage import schema as schema_mod + + connection = duckdb.connect(str(tmp_path / "idem.duckdb")) + for table_def in schema_mod.TABLES: + connection.execute(table_def.ddl) + for migration in schema_mod.MIGRATIONS: + migration.apply(connection) + migration.apply(connection) # second application must be a safe no-op + connection.close() + + def test_event_payload_is_deeply_immutable_and_hash_checked() -> None: source = {"nested": {"items": [1, 2]}} event = EvolutionEvent.create( diff --git a/tests/test_evolution_lifecycle_e2e.py b/tests/test_evolution_lifecycle_e2e.py new file mode 100644 index 00000000..cc456ea3 --- /dev/null +++ b/tests/test_evolution_lifecycle_e2e.py @@ -0,0 +1,578 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""End-to-end evolution lifecycle: environment trigger through sweep. + +Single-process integration test covering the full governed pipeline +introduced across Phases 1-4: + + Phase A — Environment trigger → AdaptationVerdict → EvolutionIntent + Phase B — Capability gap detection → proposal enqueue + Phase C — Generate, validate, register (good + INCOMPATIBLE path) + Phase D — Dual approval → install → fiber ACTIVE → tool invocable + Phase E — Trust accrual (DRAFT→CANDIDATE), quarantine, unfreeze (Phase 2) + Phase F — Proposal TTL sweep (Phase 1) + Phase G — Event chain verification (causation/correlation) + +Modelled after ``test_llm_coevolution_e2e`` for the single-process setup +but exercising every Phase 1-4 feature through their real APIs. +""" +from __future__ import annotations + +import sys +import time +from pathlib import Path +from typing import Any, Mapping + +import pytest + +# --------------------------------------------------------------------------- +# Valid echo plugin code -- returned by the fake LLM +# --------------------------------------------------------------------------- +ECHO_PLUGIN_CODE = ''' +"""Auto-generated echo plugin for lifecycle E2E test.""" +from typing import Any +from leapflow.plugins.protocol import ToolMetadata + + +class EchoLifecyclePlugin: + """Echo plugin for the full lifecycle journey.""" + + @property + def plugin_id(self) -> str: + return "echo_lifecycle" + + @property + def category(self) -> str: + return "custom" + + @property + def dependencies(self) -> list: + return [] + + def bind_runtime(self, **deps: Any) -> None: + pass + + @property + def tools(self) -> list: + return [ToolMetadata( + name="echo_lifecycle_test", + description="Echo tool for lifecycle E2E test", + parameters_schema={ + "type": "object", + "properties": { + "message": {"type": "string"}, + }, + "required": ["message"], + }, + handler=self._echo_handler, + x_leapflow={"category": "custom", "risk_level": "read_only"}, + provides_capabilities=("echo.lifecycle",), + )] + + async def _echo_handler(self, message: str = "", **kwargs: Any) -> dict: + return { + "ok": True, + "echoed": message, + "source": "lifecycle_generated", + "observed_effect": "echoed the input message", + } + + +plugin = EchoLifecyclePlugin() +''' + +PLUGIN_ID = "echo_lifecycle" +TOOL_NAME = "echo_lifecycle_test" +PROFILE_ID = "test-lifecycle" + + +# --------------------------------------------------------------------------- +# Helpers / fakes +# --------------------------------------------------------------------------- +class _FakeLLM: + """Canned LLM returning the echo plugin code.""" + + async def achat(self, messages: Any) -> str: + return f"```python\n{ECHO_PLUGIN_CODE}\n```" + + +class _ApprovedResult: + approved = True + denial_message = "" + + +class _ApprovingGate: + """Always-approve gate for both content and mutation approval.""" + + async def evaluate(self, descriptor: Any) -> _ApprovedResult: + return _ApprovedResult() + + +# --------------------------------------------------------------------------- +# Fixtures +# --------------------------------------------------------------------------- +@pytest.fixture +def evolution_dirs(tmp_path: Path) -> dict[str, Path]: + """Create all scratch directories for the lifecycle test.""" + dirs = { + "plugins": tmp_path / "plugins", + "artifacts": tmp_path / "artifacts", + "events_db": tmp_path / "events.duckdb", + "stats_db": tmp_path / "plugin_stats.duckdb", + } + dirs["plugins"].mkdir(parents=True, exist_ok=True) + dirs["artifacts"].mkdir(parents=True, exist_ok=True) + return dirs + + +@pytest.fixture +def event_store(evolution_dirs: dict[str, Path]) -> Any: + """A real DuckDB-backed evolution event store.""" + from leapflow.storage.evolution_event_store import DuckDBEvolutionEventStore + + return DuckDBEvolutionEventStore(evolution_dirs["events_db"]) + + +@pytest.fixture +def proposal_store(event_store: Any) -> Any: + """A real proposal store wired to the event store.""" + from leapflow.storage.capability_proposal_queue import ( + EvolutionCapabilityProposalStore, + ) + + return EvolutionCapabilityProposalStore( + event_store, profile_id=PROFILE_ID, proposal_ttl_hours=72, + ) + + +@pytest.fixture +def artifact_store(evolution_dirs: dict[str, Path]) -> Any: + """A real CAS artifact store.""" + from leapflow.evolution.artifact_store import ContentAddressedArtifactStore + + return ContentAddressedArtifactStore(evolution_dirs["artifacts"]) + + +@pytest.fixture +def policy() -> Any: + """An evolution policy at generate_only autonomy (permits generation).""" + from leapflow.plugins.adaptive_policy import AdaptiveEvolutionPolicy + + return AdaptiveEvolutionPolicy(autonomy_level="generate_only") + + +@pytest.fixture +def orchestrator(proposal_store: Any, artifact_store: Any, policy: Any) -> Any: + """A real ProposalOrchestrator wired to stores and approval.""" + from leapflow.plugins.proposal_orchestrator import ProposalOrchestrator + + return ProposalOrchestrator( + queue=proposal_store, + artifact_store=artifact_store, + approval_gate=_ApprovingGate(), + policy=policy, + ) + + +@pytest.fixture +def trust_ledger() -> Any: + """A trust ledger with short thresholds for fast promotion.""" + from leapflow.learning.plugin_trust import PluginTrustLedger + + return PluginTrustLedger( + candidate_at=5, verified_at=20, production_at=50, demote_after=3, + ) + + +@pytest.fixture +def stats_store(evolution_dirs: dict[str, Path]) -> Any: + """A real DuckDB-backed plugin stats store.""" + from leapflow.learning.plugin_stats_store import PluginStatsStore + + return PluginStatsStore(db_path=evolution_dirs["stats_db"]) + + +@pytest.fixture +def cleanup_plugin(): + """Tear down registry / sys.modules state after the test.""" + yield + sys.modules.pop(PLUGIN_ID, None) + try: + from leapflow.plugins import get_registry, get_scoped_registry + + reg = get_registry() + scoped = get_scoped_registry() + if PLUGIN_ID in reg.plugins: + reg.unregister_plugin(PLUGIN_ID) + if PLUGIN_ID in scoped._fibers: + fiber = scoped._fibers.pop(PLUGIN_ID) + try: + fiber.dispose() + except Exception: + pass + except Exception: + pass + + +# =================================================================== +# THE TEST +# =================================================================== +@pytest.mark.asyncio +async def test_full_evolution_lifecycle( + evolution_dirs: dict[str, Path], + event_store: Any, + proposal_store: Any, + artifact_store: Any, + policy: Any, + orchestrator: Any, + trust_ledger: Any, + stats_store: Any, + cleanup_plugin: None, +) -> None: + """Complete governed evolution pipeline, single-process.""" + + # ── Phase A — Environment Trigger and Intent ────────────────── + from leapflow.domain.adaptation_verdict import AdaptationVerdict + + verdict = AdaptationVerdict.create( + action="acquire", + capability="echo.lifecycle", + knowledge="The runtime lacks an echo capability for lifecycle testing.", + rationale="No existing plugin provides echo.lifecycle.", + confidence=0.9, + max_risk_level="read_only", + evidence_ids=("obs-001", "obs-002"), + ) + intent = verdict.to_intent() + assert intent is not None, "acquire verdict must produce an intent" + assert intent.capability == "echo.lifecycle" + assert intent.evidence_ids == ("obs-001", "obs-002") + assert intent.max_risk_level == "read_only" + # Identity is derived from the verdict, not minted fresh + assert verdict.verdict_id.removeprefix("adv-") in intent.intent_id + + # ── Phase B — Capability Gap to Proposal ────────────────────── + from leapflow.domain.capability_requirement import CapabilityRequirement + from leapflow.learning.capability_gap_detector import CapabilityGapDetector + + detector = CapabilityGapDetector() + plugin_proposal = detector.proposal_from_evolution_intent(intent) + assert plugin_proposal.plugin_id # non-empty, derived from capability slug + assert plugin_proposal.risk_level == "read_only" + + # Enqueue to the durable store + requirement = intent.to_requirement() + assert isinstance(requirement, CapabilityRequirement) + item = proposal_store.enqueue( + requirements=[requirement], + environment={"fingerprint_id": "test-fp", "workspace_id": "ws-lifecycle"}, + risk={"risk_level": "read_only"}, + source="world_model", + observation_ids=list(intent.evidence_ids), + metadata={"plugin_id": PLUGIN_ID}, + ) + assert item.status == "PENDING" + proposal_id = item.proposal_id + + # Re-enqueue is idempotent + item2 = proposal_store.enqueue( + requirements=[requirement], + environment={"fingerprint_id": "test-fp", "workspace_id": "ws-lifecycle"}, + ) + assert item2.proposal_id == proposal_id, "re-enqueue must be idempotent" + + # ── Phase C — Generate and Validate ─────────────────────────── + from leapflow.learning.plugin_generator import ( + PluginGenerationRequest, + PluginGenerator, + ) + + generator = PluginGenerator(llm_provider=_FakeLLM()) + gen_result = await generator.generate_and_validate( + PluginGenerationRequest( + plugin_id=PLUGIN_ID, + description="Echo tool for lifecycle testing", + provides_capabilities=("echo.lifecycle",), + ), + ) + assert gen_result["ok"], f"Generation failed: {gen_result.get('error')}" + assert TOOL_NAME in gen_result["exposed_tools"] + generated_code = gen_result["code"] + + # Register through the orchestrator (PENDING → GENERATED) + registered = orchestrator.register_generated( + proposal_id, + generated_code, + validation={"ok": True, "compatibility_ok": True, "exposed_tools": [TOOL_NAME]}, + ) + assert registered.status == "GENERATED" + + # ── Phase C (INCOMPATIBLE path) ─────────────────────────────── + # Create a second proposal that will fail validation + bad_req = CapabilityRequirement.create( + "bad.tool", "world_model", evidence="should fail", + requirement_id="req-bad-tool", + ) + bad_item = proposal_store.enqueue( + requirements=[bad_req], + environment={"fingerprint_id": "test-fp-bad"}, + risk={"risk_level": "read_only"}, + source="world_model", + ) + assert bad_item.status == "PENDING" + bad_proposal_id = bad_item.proposal_id + + bad_registered = orchestrator.register_generated( + bad_proposal_id, + "invalid code", + validation={"ok": False, "compatibility_ok": False, "error": "syntax"}, + ) + assert bad_registered.status == "FAILED", "INCOMPATIBLE code must not reach CAS" + + # ── Phase D — Approval and Install ──────────────────────────── + # Content approval (GENERATED → APPROVED) + content_approval = await orchestrator.approve_content(proposal_id) + assert content_approval.approved is True + stored = proposal_store.get(proposal_id) + assert stored is not None and stored.status == "APPROVED" + + # Mutation approval + mutation_approval = await orchestrator.authorize_mutation(proposal_id) + assert mutation_approval.approved is True + + # Actual install via self_management + from leapflow.plugins import get_registry + + reg = get_registry() + reg.assemble() + self_mgmt = reg.get_plugin("self_management") + self_mgmt._plugin_approval_gate = _ApprovingGate() + self_mgmt.bind_runtime(plugin_install_dir=str(evolution_dirs["plugins"])) + + try: + install_result = await self_mgmt._plugin_install_handler( + plugin_id=PLUGIN_ID, + code=generated_code, + ) + assert install_result["ok"], f"Install failed: {install_result.get('error')}" + assert TOOL_NAME in install_result["installed_tools"] + + # Plugin file written + assert (evolution_dirs["plugins"] / f"{PLUGIN_ID}.py").exists() + + # Fiber ACTIVE + tool in registry + assert PLUGIN_ID in reg.plugins + assert TOOL_NAME in reg.tool_handlers + + # Invoke the tool + handler = reg.tool_handlers[TOOL_NAME] + invoke_result = await handler(message="lifecycle hello") + assert invoke_result["ok"] is True + assert invoke_result["echoed"] == "lifecycle hello" + + # Record install in orchestrator lifecycle + orchestrator.record_installed(proposal_id, install_result) + stored = proposal_store.get(proposal_id) + assert stored is not None and stored.status == "INSTALLED" + + finally: + self_mgmt._plugin_approval_gate = None + self_mgmt._plugin_install_dir = None + + # ── Phase E — Trust Accrual and Governance ──────────────────── + from leapflow.learning.plugin_trust import PluginTrustLevel + + # Start at DRAFT + assert trust_ledger.level(PLUGIN_ID) == PluginTrustLevel.DRAFT + + # Record 5 consecutive successes → CANDIDATE + for _ in range(5): + trust_ledger.record_success(PLUGIN_ID) + assert trust_ledger.level(PLUGIN_ID) == PluginTrustLevel.CANDIDATE + + # Record trust transition in DuckDB (Phase 4 feature) + stats_store.record_trust_transition( + plugin_id=PLUGIN_ID, + from_level=PluginTrustLevel.DRAFT.value, + to_level=PluginTrustLevel.CANDIDATE.value, + trigger="consecutive_success", + consecutive_ok=5, + consecutive_fail=0, + ) + + # Verify trust_history (Phase 4 feature) + from leapflow.learning.plugin_trust import trust_history + + history = trust_history(evolution_dirs["stats_db"], plugin_id=PLUGIN_ID) + assert len(history) >= 1 + rec = history[0] + assert rec.plugin_id == PLUGIN_ID + assert rec.from_level == PluginTrustLevel.DRAFT.value + assert rec.to_level == PluginTrustLevel.CANDIDATE.value + assert rec.trigger == "consecutive_success" + + # Record 3 consecutive failures → demotion (CANDIDATE → DRAFT) + for _ in range(3): + trust_ledger.record_failure(PLUGIN_ID) + assert trust_ledger.level(PLUGIN_ID) == PluginTrustLevel.DRAFT + + # Hard failure → freeze + trust_ledger.record_success(PLUGIN_ID) # Reset from demotion + trust_ledger.record_failure(PLUGIN_ID, hard=True) + assert trust_ledger.is_frozen(PLUGIN_ID) + assert trust_ledger.level(PLUGIN_ID) == PluginTrustLevel.DRAFT + + # Transition proposal to QUARANTINED (Phase 2: quarantine recovery) + proposal_store.transition(proposal_id, "QUARANTINED") + stored = proposal_store.get(proposal_id) + assert stored is not None and stored.status == "QUARANTINED" + + # Phase 2: unfreeze + QUARANTINED → PROBATION + unfrozen = trust_ledger.unfreeze(PLUGIN_ID) + assert unfrozen is True + assert not trust_ledger.is_frozen(PLUGIN_ID) + assert trust_ledger.level(PLUGIN_ID) == PluginTrustLevel.DRAFT + + proposal_store.transition(proposal_id, "PROBATION") + stored = proposal_store.get(proposal_id) + assert stored is not None and stored.status == "PROBATION" + + # Record the unquarantine trust transition + stats_store.record_trust_transition( + plugin_id=PLUGIN_ID, + from_level=PluginTrustLevel.DRAFT.value, # frozen→unfrozen at DRAFT + to_level=PluginTrustLevel.DRAFT.value, + trigger="unfreeze", + consecutive_ok=0, + consecutive_fail=0, + ) + + # ── Phase F — Proposal Sweep (Phase 1: TTL expiry) ──────────── + from leapflow.evolution.sweep import CoevolutionSweep, SweepOutcome + + # Create a stale proposal with expires_at in the past + stale_req = CapabilityRequirement.create( + "stale.tool", "world_model", evidence="stale evidence", + requirement_id="req-stale-tool", + ) + # Build a store with 0 TTL so proposals expire immediately + from leapflow.storage.capability_proposal_queue import ( + EvolutionCapabilityProposalStore, + ) + + sweep_store = EvolutionCapabilityProposalStore( + event_store, profile_id=PROFILE_ID, proposal_ttl_hours=0, + ) + # TTL=0 means no expiry timestamp is set, so create with explicit past expiry + stale_item, stale_event = sweep_store.prepare_enqueue( + requirements=[stale_req], + environment={"fingerprint_id": "test-fp-stale"}, + risk={"risk_level": "read_only"}, + source="sweep_test", + occurred_at=time.time() - 7200, # 2 hours ago + ) + if stale_event is not None: + event_store.append(stale_event) + stale_id = stale_item.proposal_id + + # Manually set expires_at to the past by updating it with a past timestamp + # Since TTL=0 means expires_at=None, we use the main store (TTL=72h) + # and create a proposal with occurred_at far in the past + from leapflow.storage.capability_proposal_queue import CapabilityProposalItem + + # Use the main proposal_store (TTL=72h) and create an already-expired proposal + expired_req = CapabilityRequirement.create( + "expired.tool", "world_model", evidence="expired evidence", + requirement_id="req-expired-tool", + ) + # Enqueue with the main store so expires_at is set + expired_item, expired_event = proposal_store.prepare_enqueue( + requirements=[expired_req], + environment={"fingerprint_id": "test-fp-expired"}, + risk={"risk_level": "read_only"}, + source="sweep_test", + occurred_at=time.time() - 72 * 3600 - 1, # Beyond TTL + ) + if expired_event is not None: + event_store.append(expired_event) + expired_id = expired_item.proposal_id + + # Verify the expired_at is in the past + stored_expired = proposal_store.get(expired_id) + assert stored_expired is not None + assert stored_expired.expires_at is not None + assert stored_expired.expires_at < time.time(), "proposal must be past its TTL" + + sweep = CoevolutionSweep( + orchestrator=orchestrator, + proposal_store=proposal_store, + ) + expired_count, superseded_count = sweep._sweep_proposal_expiry() + assert expired_count >= 1, f"expected at least 1 expired, got {expired_count}" + + # Verify the proposal is now EXPIRED + stored_expired = proposal_store.get(expired_id) + assert stored_expired is not None and stored_expired.status == "EXPIRED" + + # ── Phase G — Event Chain Verification ──────────────────────── + from leapflow.domain.event_types import EvolutionEventType + + # Read all events for the main proposal + records = event_store.read( + profile_id=PROFILE_ID, + correlation_id=proposal_id, + limit=500, + ) + event_types = [r.event.event_type for r in records] + + # Key lifecycle events must be present + assert EvolutionEventType.PROPOSAL_CREATED in event_types, ( + f"PROPOSAL_CREATED missing; got: {event_types}" + ) + assert EvolutionEventType.PROPOSAL_GENERATED in event_types, ( + f"PROPOSAL_GENERATED missing; got: {event_types}" + ) + assert EvolutionEventType.PROPOSAL_APPROVED in event_types, ( + f"PROPOSAL_APPROVED missing; got: {event_types}" + ) + assert EvolutionEventType.PLUGIN_INSTALLED in event_types, ( + f"PLUGIN_INSTALLED missing; got: {event_types}" + ) + assert EvolutionEventType.PLUGIN_QUARANTINED in event_types, ( + f"PLUGIN_QUARANTINED missing; got: {event_types}" + ) + assert EvolutionEventType.PLUGIN_PROBATION_STARTED in event_types, ( + f"PLUGIN_PROBATION_STARTED missing; got: {event_types}" + ) + + # All events in the chain share the same correlation_id (the proposal_id) + for record in records: + assert record.event.context.correlation_id == proposal_id, ( + f"event {record.event.event_type} has wrong correlation_id: " + f"{record.event.context.correlation_id}" + ) + + # The expired proposal's events also exist + expired_records = event_store.read( + profile_id=PROFILE_ID, + correlation_id=expired_id, + limit=100, + ) + expired_event_types = [r.event.event_type for r in expired_records] + assert EvolutionEventType.PROPOSAL_CREATED in expired_event_types + assert EvolutionEventType.PROPOSAL_EXPIRED in expired_event_types + + # The failed proposal's events exist + failed_records = event_store.read( + profile_id=PROFILE_ID, + correlation_id=bad_proposal_id, + limit=100, + ) + failed_event_types = [r.event.event_type for r in failed_records] + assert EvolutionEventType.PROPOSAL_CREATED in failed_event_types + assert EvolutionEventType.PROPOSAL_FAILED in failed_event_types + + print( + f"[lifecycle E2E] All 7 phases passed. " + f"Events: {len(records)} main, {len(expired_records)} expired, " + f"{len(failed_records)} failed." + ) diff --git a/tests/test_plugin_stats_persistence.py b/tests/test_plugin_stats_persistence.py index 1d4448ff..a5922988 100644 --- a/tests/test_plugin_stats_persistence.py +++ b/tests/test_plugin_stats_persistence.py @@ -26,7 +26,7 @@ from leapflow.engine.turn_usage import TurnUsageTracker from leapflow.learning.plugin_stats import PluginUsageTracker from leapflow.learning.plugin_stats_store import PluginStatsStore -from leapflow.learning.plugin_trust import PluginTrustLedger, PluginTrustLevel +from leapflow.learning.plugin_trust import PluginTrustLedger, PluginTrustLevel, trust_history def _db(tmp_path: Path) -> Path: @@ -401,3 +401,59 @@ def test_corrupt_usage_state_degrades_to_empty_tracker( advisor = pa.get_default_advisor() assert advisor is not None assert advisor._usage_tracker._samples == {} + + +class TestTrustTransitionHistory: + """Trust transition time-series persistence and query.""" + + def test_trust_transition_persisted_to_history_table(self, tmp_path: Path) -> None: + """A promotion writes a row to plugin_trust_transitions with correct levels.""" + store = PluginStatsStore(_db(tmp_path)) + ledger = _PersistingTrustLedger(candidate_at=5, store=store) + for _ in range(5): + ledger.record_success("alpha") + assert ledger.level("alpha") is PluginTrustLevel.CANDIDATE + + records = trust_history(_db(tmp_path)) + assert len(records) == 1 + rec = records[0] + assert rec.plugin_id == "alpha" + assert rec.from_level == PluginTrustLevel.DRAFT + assert rec.to_level == PluginTrustLevel.CANDIDATE + assert rec.trigger == "success" + assert rec.consecutive_ok == 5 + assert rec.consecutive_fail == 0 + assert rec.transitioned_at is not None + + def test_trust_history_query_by_plugin_id(self, tmp_path: Path) -> None: + """Querying by plugin_id returns only matching records.""" + store = PluginStatsStore(_db(tmp_path)) + ledger = _PersistingTrustLedger(candidate_at=2, store=store) + # Drive two plugins to CANDIDATE. + for _ in range(2): + ledger.record_success("plug_a") + for _ in range(2): + ledger.record_success("plug_b") + assert ledger.level("plug_a") is PluginTrustLevel.CANDIDATE + assert ledger.level("plug_b") is PluginTrustLevel.CANDIDATE + + all_records = trust_history(_db(tmp_path)) + assert len(all_records) == 2 + + a_records = trust_history(_db(tmp_path), plugin_id="plug_a") + assert len(a_records) == 1 + assert a_records[0].plugin_id == "plug_a" + + b_records = trust_history(_db(tmp_path), plugin_id="plug_b") + assert len(b_records) == 1 + assert b_records[0].plugin_id == "plug_b" + + def test_trust_history_cold_path_only(self, tmp_path: Path) -> None: + """A single success (no promotion) writes NO row to trust_transitions.""" + store = PluginStatsStore(_db(tmp_path)) + ledger = _PersistingTrustLedger(candidate_at=5, store=store) + ledger.record_success("beta") # streak 1, no level change + assert ledger.level("beta") is PluginTrustLevel.DRAFT + + records = trust_history(_db(tmp_path)) + assert records == [] diff --git a/tests/test_proposal_orchestrator.py b/tests/test_proposal_orchestrator.py index 70c58bab..cb10b2d1 100644 --- a/tests/test_proposal_orchestrator.py +++ b/tests/test_proposal_orchestrator.py @@ -301,3 +301,52 @@ def test_queue_rejects_lifecycle_shortcuts(tmp_path: Path) -> None: with pytest.raises(ValueError, match="PENDING -> INSTALLED"): queue.transition(proposal_id, "INSTALLED") + + +def test_expire_records_reason_in_metadata(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=None, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + + item = orchestrator.expire(proposal_id, reason="ttl_exceeded") + + assert item.status == "EXPIRED" + assert item.metadata["terminal_reason"] == "ttl_exceeded" + assert "swept_at" in item.metadata + + +def test_supersede_records_reason_in_metadata(tmp_path: Path) -> None: + queue, proposal_id = _queue(tmp_path) + orchestrator = ProposalOrchestrator( + queue=queue, + artifact_store=ContentAddressedArtifactStore(tmp_path / "artifacts"), + approval_gate=None, + policy=AdaptiveEvolutionPolicy(autonomy_level="generate_only"), + ) + + item = orchestrator.supersede(proposal_id, replacement_id="prop-new", reason="newer_proposal_exists") + + assert item.status == "SUPERSEDED" + assert item.metadata["terminal_reason"] == "newer_proposal_exists" + assert item.metadata["replacement_proposal_id"] == "prop-new" + assert "swept_at" in item.metadata + + +def test_quarantine_to_probation_transition_allowed(tmp_path: Path) -> None: + """QUARANTINED proposals can be transitioned back to PROBATION for re-trial.""" + queue, proposal_id = _queue(tmp_path) + # Walk the proposal through PENDING -> GENERATED -> APPROVED -> INSTALLED -> QUARANTINED + queue.transition(proposal_id, "GENERATED") + queue.transition(proposal_id, "APPROVED") + queue.transition(proposal_id, "INSTALLED") + queue.transition(proposal_id, "QUARANTINED") + item = queue.get(proposal_id) + assert item.status == "QUARANTINED" + + # Now transition QUARANTINED -> PROBATION + recovered = queue.transition(proposal_id, "PROBATION") + assert recovered.status == "PROBATION" diff --git a/tests/test_quarantine_recovery.py b/tests/test_quarantine_recovery.py new file mode 100644 index 00000000..15bdd064 --- /dev/null +++ b/tests/test_quarantine_recovery.py @@ -0,0 +1,65 @@ +# Copyright (c) Alibaba, Inc. and its affiliates. +"""Phase 2 quarantine recovery path tests.""" +from __future__ import annotations + +import pytest + +from leapflow.learning.plugin_trust import PluginTrustLedger, PluginTrustLevel + + +class TestUnfreeze: + """PluginTrustLedger.unfreeze() resets a frozen plugin for re-probation.""" + + def test_unfreeze_resets_trust_to_draft(self) -> None: + ledger = PluginTrustLedger(candidate_at=2, demote_after=1) + pid = "quarantined_plugin" + + # Earn some trust first, then hard-freeze + for _ in range(3): + ledger.record_success(pid) + assert ledger.level(pid) == PluginTrustLevel.CANDIDATE + + ledger.record_failure(pid, hard=True) + assert ledger.is_frozen(pid) + assert ledger.level(pid) == PluginTrustLevel.DRAFT + + # Unfreeze + result = ledger.unfreeze(pid) + assert result is True + assert not ledger.is_frozen(pid) + assert ledger.level(pid) == PluginTrustLevel.DRAFT + # Counters are zeroed — verify by recording success and checking promotion + assert ledger._consecutive_ok.get(pid, 0) == 0 + assert ledger._consecutive_fail.get(pid, 0) == 0 + + # Verify record_success works again after unfreeze + ledger.record_success(pid) + assert ledger._consecutive_ok[pid] == 1 + + def test_unfreeze_nonexistent_returns_false(self) -> None: + ledger = PluginTrustLedger() + assert ledger.unfreeze("never_frozen") is False + + def test_unfreeze_nonfrozen_plugin_returns_false(self) -> None: + ledger = PluginTrustLedger() + pid = "normal_plugin" + ledger.record_success(pid) + assert ledger.unfreeze(pid) is False + + +class TestUnquarantineToolMetadata: + """Verify plugin_unquarantine tool metadata meets governance requirements.""" + + def test_unquarantine_requires_approval(self) -> None: + from leapflow.plugins.tool_plugins.self_management import SelfManagementPlugin + + plugin = SelfManagementPlugin() + tool = None + for t in plugin.tools: + if t.name == "plugin_unquarantine": + tool = t + break + assert tool is not None, "plugin_unquarantine tool not found" + assert tool.x_leapflow["risk_level"] == "high" + assert tool.x_leapflow["category"] == "plugin_management" + assert tool.mutates_state is True From 524b231ed31e5557c021611e730c59c7ef52ce67 Mon Sep 17 00:00:00 2001 From: Cheney Zhang Date: Sat, 19 Sep 2026 16:45:51 +0800 Subject: [PATCH 06/10] chore: remove auto-generated .learnings/ and gitignore it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .learnings/ directory was created by an external AI skill (self-improving-agent), not part of the LeapFlow project structure. Its content is already captured in the Memory system (common_pitfalls_experience) and git history. Signed-off-by: 班扬 --- .gitignore | 1 + .learnings/ERRORS.md | 98 -------------------------------------------- 2 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 .learnings/ERRORS.md diff --git a/.gitignore b/.gitignore index 2b41683c..d5e4d30b 100644 --- a/.gitignore +++ b/.gitignore @@ -221,6 +221,7 @@ __marimo__/ *.duckdb *.duckdb.wal .leapflow/ +.learnings/ .idea/ # Swift / Xcode diff --git a/.learnings/ERRORS.md b/.learnings/ERRORS.md deleted file mode 100644 index 1fc00387..00000000 --- a/.learnings/ERRORS.md +++ /dev/null @@ -1,98 +0,0 @@ -# Errors - -## [ERR-20260918-P2S] sandbox-resource-default - -**Logged**: 2026-09-18T13:52:25Z -**Priority**: high -**Status**: resolved -**Area**: backend - -### Summary -A default RLIMIT_AS ceiling caused Python sandbox workers to exit before responding on macOS. - -### Error -``` -Sandbox smoke test failed: worker did not respond -``` - -### Context -- The plugin sandbox applied a 512 MiB address-space limit before importing runtime modules. -- macOS virtual address-space accounting exceeded the limit during normal worker startup. - -### Suggested Fix -Keep memory limits configurable but disabled by default unless validated for the deployment platform. - -### Metadata -- Reproducible: yes -- Related Files: src/leapflow/plugins/sandbox/worker.py, src/leapflow/config.py - -### Resolution -- **Resolved**: 2026-09-18T13:52:25Z -- **Notes**: Default memory limit changed to zero; explicit configured limits remain enforced. - ---- - -## [ERR-20260918-LNT] repository-wide-ruff-baseline - -**Logged**: 2026-09-18T13:52:25Z -**Priority**: medium -**Status**: resolved -**Area**: tests - -### Summary -Repository-wide Ruff validation reports pre-existing unused imports outside the evolution implementation surface. - -### Error -``` -ruff check src tests: 33 F401/F811 findings -``` - -### Context -- Targeted Ruff checks for all files changed by the evolution plan pass. -- The remaining findings are in unrelated perception, platform, marketplace, and older test modules. - -### Suggested Fix -Run a dedicated repository-wide lint cleanup and verify affected modules with their focused tests. - -### Metadata -- Reproducible: yes -- Related Files: src/leapflow/perception/signal_source.py, src/leapflow/platform/event_bus.py, tests/test_signal_source.py - -### Resolution -- **Resolved**: 2026-09-18T13:52:25Z -- **Notes**: Applied safe Ruff fixes and replaced the remaining assigned lambdas with local functions; repository-wide Ruff now passes. - ---- - -## [ERR-20260918-EVP] event-projection-migration-regressions - -**Logged**: 2026-09-18T14:30:00Z -**Priority**: medium -**Status**: resolved -**Area**: tests - -### Summary -Targeted tests exposed stale constructor and lazy JSON-store assumptions during the event-derived knowledge migration. - -### Error -``` -3 failed: proposal_sink constructor argument, lazy JSON knowledge binding, missing injected event knowledge store -``` - -### Context -- DurableTeacherWorker now requires an event-backed proposal queue and live resolver. -- AgentEngine no longer creates a JSON knowledge store on the hot path. -- A production-wiring unit fixture did not inject the new event-derived knowledge projection. - -### Suggested Fix -Update tests and fixtures to use the event store, inject the knowledge projection explicitly, and assert fail-closed acquisition resolution. - -### Metadata -- Reproducible: yes -- Related Files: tests/test_durable_teacher.py, tests/test_distilled_knowledge.py, tests/test_degradation_feedback_loop.py - -### Resolution -- **Resolved**: 2026-09-19T00:30:00Z -- **Notes**: Updated worker tests for atomic proposal preparation, replaced lazy JSON binding with explicit event-projection injection, and fixed production governor fixtures. Full suite passes. - ---- From ce64702adc53da531c2d89830bff321488c39fbf Mon Sep 17 00:00:00 2001 From: Cheney Zhang Date: Sat, 19 Sep 2026 17:03:32 +0800 Subject: [PATCH 07/10] docs: enrich harness evolution architecture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 班扬 --- assets/harness_evolution_architecture.png | Bin 0 -> 506701 bytes docs/world_model_plugin_harness_evolution.md | 116 +++++++------------ 2 files changed, 43 insertions(+), 73 deletions(-) create mode 100644 assets/harness_evolution_architecture.png diff --git a/assets/harness_evolution_architecture.png b/assets/harness_evolution_architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..cbf127c0493ca47f911b0ec8270f7c2f79849596 GIT binary patch literal 506701 zcmeFZWmHvP+cmxw0WknUK#){IS{e=|Qqt1W-Q5iW3eqKABHi8HB_JLe>CQtRns@!~ zG4AJn?(zTl|L}f!$JnBt!(M0ay{@&cdCfVm6ZBD5{OKd2M-T)(mG~f{06`D4AqaKo z;eGH*3*Ocz@Yg*D1@ZUyru!Luz<)4oKd3oC(94p4{@e@IayW+|a!5i%NXd0(ch1BW zS9Jnf%(RxOpsF8iMruQFkJ1dP?~z|3wOcKnV`M5Cr%&b_D`+1mkVoEs@UVGWx9zhX zqIt05FC~GK+VRZ`5A0}5k*5L20@p9J<_IJ9{}KlAIE-ZHEAxNGe*ci-%YS}|QB%jr z^s2o3uNSe2M&Hi+|L2$f`4@YIUK9HNJ`?-BsbQxp)_)K8yD#97^nVQx&di8&-<-9UWYA#^m2lZo4QRfQou?l`tMPFvFov0!_`@@%_~-G5y6PDwqDp zKKX&Y zUTi~grbR;P;W0jZtCp6o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(AA5uU4Q;HT$MG*;Hk~im4wm+gnBRbV7gW?Z zom`oTWVBri{TE>)Nc(nxag>7Vb~VwdJd&-ebDYH4@zS(={t}=H^nE9{t6F_4i7yB~ z+`dR=UF8-K%zS-4)3k;-JDv!mxu$|hu@QYHjfDxD;W^Ray$N#q=llO9K?%QRjmYvb z#8SK=QEJLejD5TPVc=iy7hTBz>-ymQEb_4S^74N$p?^kDyZ<+9=HH{e-uS<9z0W-) z|KmM^a~?NB{u9xGW5T((-M_gDe-9Au^q+*spHHL&{?{E){lifD*FOyZzkK<+>%R+s+<0~p1ib*R4LT-?f(H@U7Pa& literal 0 HcmV?d00001 diff --git a/docs/world_model_plugin_harness_evolution.md b/docs/world_model_plugin_harness_evolution.md index dc71404f..416b5812 100644 --- a/docs/world_model_plugin_harness_evolution.md +++ b/docs/world_model_plugin_harness_evolution.md @@ -27,37 +27,21 @@ The term *Harness self-evolution* is used in this restricted sense: the Harness The architecture follows the principle that a capability should be composed rather than built into the core runtime. Tools, platform adapters, signal sources, and other extensions are specified through runtime-checkable protocols and managed by common discovery and lifecycle machinery. The Harness owns the rules of composition; plugins own concrete capability implementations. -```text - Environment and execution evidence - │ - ▼ - Observe / filter / persist - │ - ├───────────────┐ - ▼ │ - World-model teacher │ - grade trajectory + infer verdict│ - │ │ - ▼ │ - distilled knowledge / preference│ - │ │ - ▼ │ - student execution loop ◄──┘ - │ - unmet requirement only - ▼ - proposal → validation → approval → sandbox - │ - ▼ - governed plugin lifecycle - │ - ▼ - outcome, trust, quarantine, rollback - │ - ┌────────┴────────┐ - ▼ ▼ - LeapSpace signals LeapBoard presentation -``` +![Figure 1. LeapFlow system architecture and governed capability-evolution pipeline.](../assets/harness_evolution_architecture.png) + +*Figure 1. From real-world signals to explainable, reversible capability evolution. The figure depicts LeapSpace as an evidence-producing environment and focuses on the LeapFlow execution and evolution paths. LeapBoard, the read-only presentation surface, is introduced in [Section 8](#8-leapspaceleapflowleapboard-causal-plane).* + +### 2.1 Reading the Architecture + +Figure 1 is read from left to right and then from the hot path into the cold path: + +1. **Signals enter the acting loop.** LeapSpace and live interaction provide observable environmental and execution evidence to the OODA-oriented hot path. +2. **The teacher interprets completed evidence.** The world model operates on a retrospective trajectory and returns action grades plus a four-valued adaptation verdict; it does not directly install code. +3. **The default response changes knowledge, not capability.** `absorb` and `rebind` flow through the always-on channel, distilling environmental knowledge and provider preferences into the next-turn context. +4. **Only an unmet `acquire` verdict reaches the mutation boundary.** This opt-in channel crosses proposal, validation, approval, sandbox, and trust gates before a capability can become active. +5. **Every consequential outcome becomes evidence.** Trust transitions, rejection, failure, quarantine, and rollback are retained as causal records that inform subsequent analysis and operator inspection. + +The storyline therefore progresses from **observation**, to **interpretation**, to the **least invasive valid response**, and only then—when existing knowledge and installed capability are insufficient—to governed acquisition. This ordering is the central safety and efficiency claim of the architecture. This organization makes two distinctions explicit. @@ -147,48 +131,39 @@ The ordering is intentional: `absorb` and `rebind` are cheaper and safer than `a This design counters a common failure mode in agentic systems: interpreting a changed environment as proof that the incumbent implementation is defective. An incumbent can be correct for a previous application version while an alternate adapter is now more appropriate. The verdict asks what action is supported by evidence, not which component is to blame. -### 4.3 Event-Sourced Knowledge and Selection +### 4.3 Event-Sourced Knowledge, Resolution, and Selection Evolution evidence is persisted through an append-only event store. Read models, including distilled knowledge and rebind preferences, are projections over that evidence rather than independent sources of truth. A preference extracted from a `rebind` verdict can influence selection, but it is intentionally weaker than structural constraints such as declared capability fit and environment affordances. -The capability resolver operationalizes this distinction. It scores live candidates from declared matching, environmental compatibility, risk cost, trust, reliability, and—when present—distilled preference. A teacher recommendation cannot make an incompatible capability eligible; it is evidence that informs a deterministic resolution process, not a hidden control channel. - -## 5. From Evidence to Plugin Acquisition +Before generating new code, LeapFlow resolves a typed requirement against the live catalog. A satisfiable requirement becomes an explicit no-op or rebind result rather than a duplicate proposal. This **resolution-before-acquisition** rule operationalizes the least-invasive-response principle shown in Figure 1. -### 5.1 Resolution Before Acquisition +The capability resolver scores live candidates using declared matching, environmental compatibility, risk cost, trust, reliability, and—when present—distilled preference. A teacher recommendation cannot make an incompatible candidate eligible; it is evidence that informs a deterministic resolution process, not a hidden control channel. -Before generating new code, LeapFlow resolves the requirement against the live catalog. An already satisfiable requirement becomes an explicit no-op or rebind result rather than a duplicate proposal. This avoids capability proliferation and ensures that new code is the exception rather than the default response to change. +The user-visible `evolution.enabled` setting, disabled by default, governs the only branch that may introduce a new capability: whether an `acquire` verdict may enter the proposal path. It does not disable world-model grading, knowledge distillation, or read-only selection guidance. The system can therefore learn from an environment while capability mutation remains disabled. -The acquisition branch is gated by the user-visible `evolution.enabled` setting, which is disabled by default. The setting controls whether an `acquire` verdict may enter the capability-proposal path. It does not disable world-model grading, knowledge distillation, or read-only selection guidance. Consequently, the system can learn from an environment even while capability mutation remains disabled. +## 5. Governed Plugin Acquisition -### 5.2 Governed Acquisition Pipeline +### 5.1 Gate Sequence -An eligible acquisition follows a staged path: +Only an eligible, unresolved `acquire` requirement traverses the following sequence: -```text -classified evidence - → typed capability requirement - → live-catalog resolution - → proposal - → generation - → syntax / structure / protocol validation - → compatibility assessment - → approval - → artifact write - → sandbox smoke test - → register at DRAFT - → behavior tests and probation - → trust accrual, verification, or quarantine -``` +| Stage | Required result before the next stage | +|---|---| +| Evidence and resolution | A typed, task-relevant requirement remains unsatisfied by the live catalog. | +| Proposal and generation | A candidate artifact is associated with its causal evidence and declared capability. | +| Validation and compatibility | Syntax, structure, import/protocol conformance, and compatibility assessment succeed. | +| Approval and sandboxing | The operator gate permits the mutation and the artifact passes bounded sandbox smoke checks. | +| Registration and probation | The plugin enters at `DRAFT`, then accumulates behavior-test and outcome evidence. | +| Trust or containment | Observed outcomes support advancement, demotion, quarantine, disablement, or rollback. | -The pipeline is intentionally more restrictive than “LLM writes a file and imports it.” It provides an accountable answer to four questions that an unconstrained script cannot answer reliably: +The sequence is intentionally more restrictive than “LLM writes a file and imports it.” It preserves the answer to four accountability questions: 1. **Why was this capability needed?** The requirement is linked to source evidence and resolution results. -2. **Why is this implementation admissible?** Validation, compatibility assessment, and approval must precede activation. +2. **Why is this implementation admissible?** Validation, compatibility assessment, and approval precede activation. 3. **What happens if it fails?** Outcomes drive demotion, quarantine, disablement, or rollback. 4. **Can the decision be reconstructed?** Causal records include no-op, rejected, and failed branches, not only successful installation. -### 5.3 Progressive Trust and Reversibility +### 5.2 Progressive Trust and Reversibility New plugins start with limited trust. Trust can advance through observed success and can be reduced by consecutive failures; an internal defect can permanently freeze a capability. Plugins can also be isolated in a subprocess, invoked over bounded JSON-RPC, and removed from service through lifecycle governance. @@ -229,23 +204,17 @@ A practical decision rule follows: ## 8. LeapSpace–LeapFlow–LeapBoard Causal Plane -The three systems form complementary surfaces rather than a monolithic control loop. +Figure 1 details the LeapSpace-to-LeapFlow execution and evolution pipeline. LeapBoard is deliberately not a control node in that figure; it completes the architecture as the human-observable presentation surface. The three systems therefore form complementary surfaces rather than a monolithic control loop. -```text -LeapSpace LeapFlow LeapBoard -───────── ──────── ───────── -application state typed observation causal views -reference actions ─────► signal filtering watch updates -LeapSignal records world-model verdicts ─────► evolution lens -sandboxed experiments capability resolution operator inspection - plugin governance notifications -``` +| Surface | Primary responsibility | Causal output | +|---|---|---| +| **LeapSpace** | Controlled application environments, `LeapSignal` records, and task outcomes | Typed environmental and task-outcome observations | +| **LeapFlow** | Filtering, world-model reasoning, capability resolution, and lifecycle governance | Read-only evolution, lifecycle, and provenance events | +| **LeapBoard** | Causal views, watch updates, evolution lens, and operator inspection | Human-observable operational state | -1. **LeapSpace observes and stages:** it makes environmental conditions and outcomes available through controlled application environments, signals, and an environment-source adapter. -2. **LeapFlow reasons and governs:** it converts admissible observations into knowledge, resolutions, and—only where justified—governed proposals and lifecycle transitions. -3. **LeapBoard exposes and explains:** it presents state and causal outcomes to the operator without bypassing the policy and approval chain. +**Causal path:** **LeapSpace** → *typed observations* → **LeapFlow** → *causal events* → **LeapBoard**. -This decomposition preserves a critical separation of powers. LeapSpace does not directly register production capabilities; LeapBoard does not approve or execute mutations; the world model does not directly install code. Each component contributes evidence, reasoning, governance, or visibility within its own boundary. +This decomposition preserves a separation of powers: LeapSpace produces and stages evidence; LeapFlow reasons over admissible evidence and governs capability change; LeapBoard exposes causal state without bypassing policy or approval. LeapSpace does not register production capabilities, LeapBoard does not approve or execute mutations, and the world model does not install code directly. ## 9. Safety and Scientific Integrity Properties @@ -269,7 +238,7 @@ The agent may improve its knowledge and selection policy without the authority t ### 9.5 Cold-Path Governance -Retrospective grading, proposal processing, telemetry, and broad co-evolution sweeps should remain off the ordinary turn-critical path. Learning must not impose material latency or fragility on normal task execution. +Retrospective grading, proposal processing, telemetry, and broad co-evolution sweeps are designed as cold-path work and should not execute synchronously inside the ordinary turn-critical loop. This reduces direct coupling to response latency; it does not prove that background workers consume no daemon scheduling or compute resources. Operational evaluation must therefore measure their effect on ordinary execution as well as their adaptation benefit. ## 10. Limitations and Non-Claims @@ -322,3 +291,4 @@ The resulting system favors the least invasive valid response. It learns first, | LeapBoard templates | [`src/leapflow/dashboard/templates.py`](../src/leapflow/dashboard/templates.py) | | Configuration and evolution gate | [`src/leapflow/config.py`](../src/leapflow/config.py) | | Engineering constraints | [`AGENTS.md`](../AGENTS.md) | +| Architecture figure asset | [`assets/harness_evolution_architecture.png`](../assets/harness_evolution_architecture.png) | From 8338bbcaac1b2bf59e00022675acc704baaba729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Sun, 20 Sep 2026 00:58:27 +0800 Subject: [PATCH 08/10] fix leapboard layout --- src/leapflow/dashboard/static/app.js | 4 ++- src/leapflow/dashboard/static/index.html | 4 +-- src/leapflow/dashboard/static/styles.css | 44 +++++++++++++++++++++--- tests/test_dashboard_frontend_static.py | 29 ++++++++++++++++ 4 files changed, 74 insertions(+), 7 deletions(-) diff --git a/src/leapflow/dashboard/static/app.js b/src/leapflow/dashboard/static/app.js index 60a53dee..eb69507e 100644 --- a/src/leapflow/dashboard/static/app.js +++ b/src/leapflow/dashboard/static/app.js @@ -1104,7 +1104,9 @@ const max = Math.max(1, ...rows.map((r) => r.value)); rows.forEach((row) => { const line = el("div", "bar-row"); - line.appendChild(el("span", "bar-label", esc(tx(row.label)))); + const label = el("span", "bar-label", esc(tx(row.label))); + label.title = tx(row.label); + line.appendChild(label); const track = el("span", "bar-track"); const fill = el("span", "bar-fill" + (severity ? " sev-" + row.key : "")); fill.style.width = Math.round((row.value / max) * 100) + "%"; track.appendChild(fill); line.appendChild(track); line.appendChild(el("span", "bar-value", esc(row.value))); d.appendChild(line); diff --git a/src/leapflow/dashboard/static/index.html b/src/leapflow/dashboard/static/index.html index de06d2a7..4c5f7016 100644 --- a/src/leapflow/dashboard/static/index.html +++ b/src/leapflow/dashboard/static/index.html @@ -7,7 +7,7 @@ - +

    @@ -30,6 +30,6 @@
    Loading…
    - + diff --git a/src/leapflow/dashboard/static/styles.css b/src/leapflow/dashboard/static/styles.css index 521ebc43..c6fdfdfe 100644 --- a/src/leapflow/dashboard/static/styles.css +++ b/src/leapflow/dashboard/static/styles.css @@ -155,17 +155,53 @@ body { .insight-list, .dl, .citations, .summary, .prose, .md, .chips button { font-size: 0.9rem; } /* ── Figures + captions (academic numbering set by the renderer) ─────────── */ -.chart { min-height: 120px; } +.chart { min-height: 120px; min-width: 0; container-type: inline-size; } .chart-placeholder { color: var(--muted); border: 1px dashed var(--line); border-radius: 0; padding: 30px 14px; text-align: center; } .figcaption { color: var(--muted); font-size: 0.81rem; margin-top: 7px; padding-top: 5px; border-top: 1px solid var(--line); } .figcaption .fignum { color: var(--accent); font-weight: 700; margin-inline-end: 5px; } /* ── Bars / sparkline / pie (flat, single-hue accents) ───────────────────── */ -.bar-row { display: grid; grid-template-columns: max-content 1fr 36px; align-items: center; gap: 8px; margin: 7px 0; } +.bar-row { + display: grid; + grid-template-columns: fit-content(13rem) minmax(4rem, 1fr) max-content; + align-items: center; + column-gap: 0.65rem; + row-gap: 4px; + margin: 7px 0; +} .bar-label, .bar-value { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; } -.bar-label { white-space: nowrap; } -.bar-track { height: 8px; background: var(--track); border-radius: 0; overflow: hidden; } +.bar-label { min-width: 0; white-space: normal; overflow-wrap: anywhere; } +.bar-track { min-width: 0; width: 100%; height: 8px; background: var(--track); border-radius: 0; overflow: hidden; } +.bar-value { min-width: 2ch; justify-self: end; white-space: nowrap; text-align: end; } .bar-fill { display: block; height: 100%; border-radius: 0; background: var(--info); } + +/* A chart may be narrow because of its grid cell even on a wide viewport. At + that point, preserve every label and value by placing the track on its own + row instead of allowing any grid item to overlap another. */ +@container (max-width: 18rem) { + .bar-row { + grid-template-columns: minmax(0, 1fr) max-content; + grid-template-areas: + "label value" + "track track"; + } + .bar-label { grid-area: label; } + .bar-track { grid-area: track; } + .bar-value { grid-area: value; } +} + +/* Viewport fallback for browsers without container-query support. */ +@media (max-width: 440px) { + .bar-row { + grid-template-columns: minmax(0, 1fr) max-content; + grid-template-areas: + "label value" + "track track"; + } + .bar-label { grid-area: label; } + .bar-track { grid-area: track; } + .bar-value { grid-area: value; } +} .bar-fill.sev-alert { background: var(--alert); } .bar-fill.sev-notable { background: var(--notable); } .bar-fill.sev-info { background: var(--info); } diff --git a/tests/test_dashboard_frontend_static.py b/tests/test_dashboard_frontend_static.py index 8f40ac25..cf4b49f8 100644 --- a/tests/test_dashboard_frontend_static.py +++ b/tests/test_dashboard_frontend_static.py @@ -198,3 +198,32 @@ def test_static_assets_are_cache_busted_together() -> None: assert versions[0] != "status-i18n-20260808", ( "the version predates the markdown and provenance changes" ) + + +# ════════════════════════════════════════════════════════════════ +# Bar charts: long labels overlapped their tracks in narrow cells +# ════════════════════════════════════════════════════════════════ + + +def test_bar_chart_labels_wrap_without_consuming_the_track() -> None: + """Long translated labels must never be allowed to overlap a value or bar. + + ``max-content`` paired with ``white-space: nowrap`` made the maturity label + ``new_unproven`` paint over its track. The base grid reserves a bounded label + column, and a narrow chart promotes the track to a dedicated second row. + """ + css = _STYLES.read_text(encoding="utf-8") + assert ".chart { min-height: 120px; min-width: 0; container-type: inline-size; }" in css + assert "grid-template-columns: fit-content(13rem) minmax(4rem, 1fr) max-content;" in css + assert "column-gap: 0.65rem;" in css + assert ".bar-label { min-width: 0; white-space: normal; overflow-wrap: anywhere; }" in css + assert ".bar-track { min-width: 0; width: 100%;" in css + assert "@container (max-width: 18rem)" in css + assert '"label value"\n "track track"' in css + + +def test_bar_chart_labels_preserve_full_text_for_accessibility() -> None: + """Wrapping is visible; the title retains the complete translated label.""" + src = _app() + assert 'const label = el("span", "bar-label", esc(tx(row.label)));' in src + assert "label.title = tx(row.label);" in src From 3cf32859345be7edcdb3571c1e23e88d0d3acf0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Sun, 20 Sep 2026 02:07:27 +0800 Subject: [PATCH 09/10] fix(approval): pause tool deadline for human decisions --- src/leapflow/daemon/approval_coordinator.py | 7 +- src/leapflow/domain/tool_pipeline.py | 85 +++++++++++++++++++-- src/leapflow/engine/engine.py | 12 ++- tests/test_tool_pipeline.py | 45 +++++++++++ tests/test_turn_admission_parking.py | 25 ++++++ 5 files changed, 160 insertions(+), 14 deletions(-) diff --git a/src/leapflow/daemon/approval_coordinator.py b/src/leapflow/daemon/approval_coordinator.py index 2d032e85..daaf7402 100644 --- a/src/leapflow/daemon/approval_coordinator.py +++ b/src/leapflow/daemon/approval_coordinator.py @@ -294,7 +294,12 @@ async def request_approval(self, request: Any, route: "tuple[asyncio.Queue[Strea )) try: async with parked_for_human_decision(): - result = await future + from leapflow.domain.tool_pipeline import ( + pause_tool_execution_timeout_for_human_decision, + ) + + async with pause_tool_execution_timeout_for_human_decision(): + result = await future return str(result.get("decision") or "deny") finally: self._approval_pending.pop(pending_id, None) diff --git a/src/leapflow/domain/tool_pipeline.py b/src/leapflow/domain/tool_pipeline.py index b7a15c53..d872cc4c 100644 --- a/src/leapflow/domain/tool_pipeline.py +++ b/src/leapflow/domain/tool_pipeline.py @@ -17,12 +17,84 @@ import asyncio import logging import time +from contextlib import asynccontextmanager +from contextvars import ContextVar from dataclasses import dataclass, field -from typing import Any, Awaitable, Callable, Dict, List, Optional, Protocol, runtime_checkable +from typing import Any, AsyncIterator, Awaitable, Callable, Dict, List, Optional, Protocol, runtime_checkable logger = logging.getLogger(__name__) +class _ToolExecutionDeadline: + """Pauses one tool deadline while the tool awaits a human decision.""" + + def __init__(self, loop: asyncio.AbstractEventLoop, timeout_s: float) -> None: + self._loop = loop + self._remaining_s = timeout_s + self._scope: asyncio.Timeout | None = None + self._pause_depth = 0 + + def bind(self, scope: asyncio.Timeout) -> None: + """Bind the active ``asyncio.timeout`` scope to this deadline.""" + self._scope = scope + + def pause(self) -> None: + """Suspend deadline accounting until the matching resume call.""" + if self._pause_depth == 0: + scope = self._scope + if scope is None: + return + deadline = scope.when() + self._remaining_s = max(0.0, (deadline or self._loop.time()) - self._loop.time()) + scope.reschedule(None) + self._pause_depth += 1 + + def resume(self) -> None: + """Resume deadline accounting after the outermost human wait finishes.""" + if self._pause_depth == 0: + return + self._pause_depth -= 1 + if self._pause_depth == 0 and self._scope is not None: + self._scope.reschedule(self._loop.time() + self._remaining_s) + + +_current_tool_execution_deadline: ContextVar[_ToolExecutionDeadline | None] = ContextVar( + "leapflow_tool_execution_deadline", default=None, +) + + +@asynccontextmanager +async def pause_tool_execution_timeout_for_human_decision() -> AsyncIterator[None]: + """Exclude human approval time from the active tool execution timeout. + + Outside an engine-managed tool invocation this is intentionally a no-op, so + approval surfaces can use it without coupling themselves to a caller. + """ + deadline = _current_tool_execution_deadline.get() + if deadline is None: + yield + return + deadline.pause() + try: + yield + finally: + deadline.resume() + + +async def run_tool_with_timeout( + awaitable: Awaitable[Dict[str, Any]], timeout_s: float, +) -> Dict[str, Any]: + """Run a tool with a deadline that pauses only for human decisions.""" + controller = _ToolExecutionDeadline(asyncio.get_running_loop(), timeout_s) + token = _current_tool_execution_deadline.set(controller) + try: + async with asyncio.timeout(timeout_s) as scope: + controller.bind(scope) + return await awaitable + finally: + _current_tool_execution_deadline.reset(token) + + @dataclass class ToolCallContext: """Context passed through the waterfall pipeline. @@ -126,16 +198,17 @@ async def execute( The final result dict (possibly transformed by after hooks). Timeout: when ``context.annotations['timeout']`` is set (the engine - passes the per-tool timeout there), the handler invocation is wrapped - in ``asyncio.wait_for``. A timeout raises ``asyncio.TimeoutError`` so - the caller's existing timeout handling stays authoritative. When no - timeout is annotated the handler is called directly (no wrapping). + passes the per-tool timeout there), the handler invocation receives an + execution deadline. Human approval waits explicitly pause that deadline; + a timeout still raises ``asyncio.TimeoutError`` so the caller's existing + timeout handling stays authoritative. When no timeout is annotated the + handler is called directly (no wrapping). """ timeout = context.annotations.get("timeout") async def _run_handler() -> Dict[str, Any]: if timeout is not None: - return await asyncio.wait_for(handler(context), timeout=timeout) + return await run_tool_with_timeout(handler(context), timeout) return await handler(context) if not self._interceptors: diff --git a/src/leapflow/engine/engine.py b/src/leapflow/engine/engine.py index 821b7445..68d5f4bd 100644 --- a/src/leapflow/engine/engine.py +++ b/src/leapflow/engine/engine.py @@ -5589,16 +5589,14 @@ async def _execute_general_tool( try: handler = handlers.get(name) if handler is not None: - # The tool execution pipeline wraps only the handler call, - # enabling composable interceptors (audit, rate-limit, etc.) - # without touching the surrounding approval/semantic gates. - # Fast path: no interceptors registered = direct call, zero overhead. + # The execution deadline wraps each handler consistently, whether + # plugins install pipeline interceptors or the direct path is used. + from leapflow.domain.tool_pipeline import ToolCallContext, run_tool_with_timeout from leapflow.plugins import get_registry from leapflow.plugins.handler_invocation import invoke_tool_handler pipeline = get_registry().tool_pipeline if pipeline.interceptor_count > 0: - from leapflow.domain.tool_pipeline import ToolCallContext spec = _default_tool_registry().specs.get(name) tool_metadata: Dict[str, Any] = {} @@ -5622,8 +5620,8 @@ async def _invoke_handler(ctx: ToolCallContext) -> Dict[str, Any]: result = await pipeline.execute(call_ctx, _invoke_handler) else: - result = await asyncio.wait_for( - invoke_tool_handler(handler, args), timeout=timeout + result = await run_tool_with_timeout( + invoke_tool_handler(handler, args), timeout ) else: # No handler — tool is truly unknown diff --git a/tests/test_tool_pipeline.py b/tests/test_tool_pipeline.py index 5bbd4f87..6f7b2c31 100644 --- a/tests/test_tool_pipeline.py +++ b/tests/test_tool_pipeline.py @@ -15,6 +15,8 @@ ToolCallContext, ToolExecutionPipeline, ToolInterceptor, + pause_tool_execution_timeout_for_human_decision, + run_tool_with_timeout, ) @@ -438,6 +440,49 @@ async def test_timeout_uses_metadata_override(self) -> None: await pipeline.execute(ctx, echo_handler) assert ctx.annotations["_timeout"] == 5.0 + @pytest.mark.asyncio + async def test_human_decision_pause_excludes_wait_from_execution_timeout(self) -> None: + waiting = asyncio.Event() + answered = asyncio.Event() + context = ToolCallContext(tool_name="write_file", arguments={}) + + async def handler(_: ToolCallContext) -> Dict[str, Any]: + async with pause_tool_execution_timeout_for_human_decision(): + waiting.set() + await answered.wait() + await asyncio.sleep(0.005) + return {"completed": True} + + task = asyncio.create_task(run_tool_with_timeout(handler(context), 0.02)) + await asyncio.wait_for(waiting.wait(), timeout=1.0) + await asyncio.sleep(0.05) + assert not task.done(), "human decision time must not consume the tool deadline" + + answered.set() + assert await asyncio.wait_for(task, timeout=1.0) == {"completed": True} + + @pytest.mark.asyncio + async def test_execution_still_times_out_after_human_decision_pause(self) -> None: + waiting = asyncio.Event() + answered = asyncio.Event() + context = ToolCallContext(tool_name="write_file", arguments={}) + + async def handler(_: ToolCallContext) -> Dict[str, Any]: + async with pause_tool_execution_timeout_for_human_decision(): + waiting.set() + await answered.wait() + await asyncio.sleep(0.05) + return {"completed": True} + + task = asyncio.create_task(run_tool_with_timeout(handler(context), 0.02)) + await asyncio.wait_for(waiting.wait(), timeout=1.0) + await asyncio.sleep(0.05) + assert not task.done(), "approval wait must remain unbounded" + + answered.set() + with pytest.raises(asyncio.TimeoutError): + await asyncio.wait_for(task, timeout=1.0) + @pytest.mark.asyncio async def test_timeout_wrapper_times_out(self) -> None: ctx = ToolCallContext(tool_name="slow", arguments={"delay": 10.0}) diff --git a/tests/test_turn_admission_parking.py b/tests/test_turn_admission_parking.py index e423b1fb..4b06fafd 100644 --- a/tests/test_turn_admission_parking.py +++ b/tests/test_turn_admission_parking.py @@ -219,3 +219,28 @@ async def turn() -> None: assert decision == ["allow_once"] assert adm.snapshot()["available"] == 1 assert adm.snapshot()["parked"] == 0 + + +@pytest.mark.asyncio +async def test_coordinator_pauses_the_tool_deadline_for_a_pending_approval() -> None: + """An unanswered daemon prompt must not consume its tool's execution budget.""" + from leapflow.daemon.approval_coordinator import ApprovalCoordinator + from leapflow.daemon.protocol import StreamChunk + from leapflow.domain.tool_pipeline import run_tool_with_timeout + from leapflow.security.approval import ApprovalRequest + + coordinator = ApprovalCoordinator() + queue: asyncio.Queue[StreamChunk] = asyncio.Queue() + request = ApprovalRequest(category="file.write", detail="write delayed-output.py") + + task = asyncio.create_task(run_tool_with_timeout( + coordinator.request_approval(request, (queue, "req-1")), 0.02, + )) + chunk = await asyncio.wait_for(queue.get(), timeout=1.0) + pending_id = chunk.metadata["approval"]["pending_id"] + + await asyncio.sleep(0.05) + assert not task.done(), "a pending approval must not expire with the tool deadline" + + await coordinator.resolve(pending_id, "allow_once") + assert await asyncio.wait_for(task, timeout=1.0) == "allow_once" From 200c63207adf1f51154d0a2950b37e678aee12d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=AD=E6=89=AC?= Date: Sun, 20 Sep 2026 12:51:25 +0800 Subject: [PATCH 10/10] fix(approval): make session bypass unconditional --- src/leapflow/security/approval.py | 36 ++---- src/leapflow/security/orchestrator.py | 13 +-- src/leapflow/security/policy.py | 5 +- src/leapflow/security/risk.py | 94 ++++++++++++++-- src/leapflow/tools/execution_context.py | 35 +----- src/leapflow/tools/shell_tools.py | 3 +- tests/test_approval_layer.py | 140 +++++++++--------------- tests/test_path_sensitivity.py | 12 ++ tests/test_workspace_escape_approval.py | 45 +------- 9 files changed, 175 insertions(+), 208 deletions(-) diff --git a/src/leapflow/security/approval.py b/src/leapflow/security/approval.py index f1474061..88ecb157 100644 --- a/src/leapflow/security/approval.py +++ b/src/leapflow/security/approval.py @@ -15,7 +15,7 @@ from typing import Any, Protocol, runtime_checkable from leapflow.security.actions import ActionDescriptor -from leapflow.security.risk import RiskAssessment, RiskLevel +from leapflow.security.risk import RiskAssessment logger = logging.getLogger(__name__) @@ -133,28 +133,14 @@ async def check(self, command: str) -> bool: async def request_approval( self, request: ApprovalRequest, ) -> ApprovalDecision: - # Session-wide bypass: auto-approve without prompting, EXCEPT - # high/critical-risk actions whose risk classifier set - # allow_permanent=False. Those actions require per-invocation - # consent; letting a low-risk approval silently extend to them - # would let plugin installs, external sends, and credential - # reads bypass the gate they are specifically designed to hit. + # Session-wide bypass is explicit user consent for every action that + # reaches this gate. Hardline actions are denied by ApprovalPolicyEngine + # before a request is built, so this branch never weakens that boundary. + # ``allow_permanent`` controls profile persistence only; it must not turn + # a session-wide bypass into a misleading partial bypass. if self._bypass_all: - risk = request.risk - if ( - risk is not None - and not risk.allow_permanent - and risk.level in {RiskLevel.HIGH, RiskLevel.CRITICAL} - ): - logger.info( - "bypass_all.fallthrough category=%s level=%s " - "allow_permanent=False", - request.category, - risk.level.value, - ) - else: - self._log_decision(request, ApprovalDecision.ALLOW, auto=True) - return ApprovalDecision.ALLOW + self._log_decision(request, ApprovalDecision.ALLOW, auto=True) + return ApprovalDecision.ALLOW grant_key = request.grant_key if grant_key in self._approved_categories: @@ -164,10 +150,8 @@ async def request_approval( decision = await self._delegate.request_approval(request) # Validate that the delegate's decision is within the declared - # choices. A delegate returning a choice the orchestrator - # withheld (e.g. allow_all_session when allow_permanent=False) - # is either a UI defect or a spoofed response; fail-closed to - # the request's default (deny) rather than honouring it. + # choices. A choice outside the request contract is either a UI defect + # or a spoofed response, so fail closed to the request default. if request.choices and decision.value not in request.choices: logger.warning( "approval.decision_out_of_choices category=%s " diff --git a/src/leapflow/security/orchestrator.py b/src/leapflow/security/orchestrator.py index 62e5ce15..2c5f357c 100644 --- a/src/leapflow/security/orchestrator.py +++ b/src/leapflow/security/orchestrator.py @@ -217,15 +217,12 @@ def _denied( @staticmethod def _choices(allow_permanent: bool) -> tuple[str, ...]: - base = ["allow_once", "allow_session"] + # Session bypass is explicit consent for every action that can reach an + # approval prompt. ``allow_permanent`` governs only persistence beyond + # the current session, never the meaning of “Allow ALL for this session”. + base = ["allow_once", "allow_session", "allow_all_session"] if allow_permanent: - # Session-wide and profile-wide grants are only offered when - # the risk classifier explicitly permits reuse. Actions - # whose ``allow_permanent`` is False (plugin management, - # external sends, credential reads, etc.) must never be - # auto-approved by a session bypass earned from a lower-risk - # approval. - base.extend(["allow_all_session", "allow_always"]) + base.append("allow_always") base.extend(["deny", "deny_always", "show_details"]) return tuple(base) diff --git a/src/leapflow/security/policy.py b/src/leapflow/security/policy.py index f34337b5..bb993c66 100644 --- a/src/leapflow/security/policy.py +++ b/src/leapflow/security/policy.py @@ -42,14 +42,15 @@ def __init__(self, rules: list[ApprovalPolicyRule] | None = None, *, bypass: boo self._bypass = bypass def evaluate(self, action: ActionDescriptor, risk: RiskAssessment) -> PolicyDecision: - # Hardline/CRITICAL always denied regardless of bypass + # Hardline/CRITICAL actions are not approvable and therefore never reach + # either config-level or session-level bypass handling. if risk.hardline or risk.level == RiskLevel.CRITICAL: return PolicyDecision( verdict=PolicyVerdict.DENY, reason="; ".join(risk.reasons) or "hardline_block", allow_permanent=False, ) - # Bypass mode: auto-allow everything below CRITICAL + # Config bypass auto-allows every action that remains approvable. if self._bypass: return PolicyDecision(verdict=PolicyVerdict.ALLOW, reason="bypass_mode") # Normal rule-based evaluation diff --git a/src/leapflow/security/risk.py b/src/leapflow/security/risk.py index 0f5c519e..58dc36c1 100644 --- a/src/leapflow/security/risk.py +++ b/src/leapflow/security/risk.py @@ -3,6 +3,7 @@ from __future__ import annotations import re +import shlex from dataclasses import asdict, dataclass, field from enum import Enum from pathlib import Path @@ -511,18 +512,89 @@ def _assess_mcp_tool(self, action: ActionDescriptor) -> RiskAssessment: def _matched_reasons(command: str, rules: tuple[tuple[re.Pattern[str], str], ...]) -> list[str]: return [reason for pattern, reason in rules if pattern.search(command)] - @staticmethod - def _mentions_sensitive_config(command: str) -> bool: - lowered = command.lower().replace("\\", "/") - configured_roots = tuple( - str(root).lower().replace("\\", "/").rstrip("/") - for root in configured_path_sensitivity_roots() + _SHELL_CONTROL_OPERATORS = frozenset({"&&", "||", ";", "|", "&"}) + _SHELL_REDIRECTION_OPERATORS = frozenset({">", ">>", "<", "<<", "<<<"}) + _SHELL_FILE_ACCESS_COMMANDS = frozenset({ + ".", "awk", "cat", "chmod", "chown", "cp", "cut", "diff", "find", "grep", "head", + "less", "ln", "ls", "more", "mv", "rg", "ripgrep", "rm", "sed", "sort", "source", + "stat", "tail", "tee", "test", "touch", "uniq", "vim", + }) + _SHELL_PATTERN_ARGUMENT_COMMANDS = frozenset({"awk", "grep", "rg", "ripgrep", "sed"}) + _SENSITIVE_CONFIG_SUFFIXES = ( + "/.leapflow/config.yaml", "/.leapflow/workspace.yaml", "/config/user.yaml", + "/mcp_servers.json", "/workspace.yaml", "/tui_history", + ) + + @classmethod + def _mentions_sensitive_config(cls, command: str) -> bool: + """Return whether a shell command addresses a sensitive path operand. + + Commands are tokenized before inspecting path operands so text such as + ``echo config.yaml`` is not confused with file access. Shell parsing + failures retain the command's other risk matches but do not promote an + arbitrary substring to a sensitive-config operation. + """ + try: + tokens = shlex.split(command, posix=True, comments=False) + except ValueError: + return False + + segment: list[str] = [] + for token in [*tokens, ";"]: + if token in cls._SHELL_CONTROL_OPERATORS: + if cls._segment_mentions_sensitive_config(segment): + return True + segment = [] + else: + segment.append(token) + return False + + @classmethod + def _segment_mentions_sensitive_config(cls, segment: list[str]) -> bool: + if not segment: + return False + + for index, token in enumerate(segment): + if token in cls._SHELL_REDIRECTION_OPERATORS: + if index + 1 < len(segment) and cls._is_sensitive_shell_path(segment[index + 1]): + return True + continue + match = re.match(r"^(?:\\d*(?:>>?|< bool: + candidate = token.split("=", 1)[-1].strip().replace("\\", "/") + if not candidate or candidate.startswith(("http://", "https://")): + return False + expanded = str(Path(candidate).expanduser()).replace("\\", "/") + lowered = expanded.lower().rstrip("/") + if Path(expanded).name.lower() in cls._SENSITIVE_NAMES: + return True + if any(part in lowered for part in cls._SENSITIVE_PARTS): + return True + if lowered.endswith(cls._SENSITIVE_CONFIG_SUFFIXES): + return True return any( - token in lowered - for token in ( - ".env", "vault.json", "vault.key", "secrets.yaml", "config/user.yaml", - "mcp_servers.json", "workspace.yaml", ".leapflow/config.yaml", "tui_history", - "profiles/", "config.yaml", *configured_roots, + lowered == root or lowered.startswith(root + "/") + for root in ( + str(path).lower().replace("\\", "/").rstrip("/") + for path in configured_path_sensitivity_roots() ) ) diff --git a/src/leapflow/tools/execution_context.py b/src/leapflow/tools/execution_context.py index b7ba3e9b..76ca0091 100644 --- a/src/leapflow/tools/execution_context.py +++ b/src/leapflow/tools/execution_context.py @@ -184,33 +184,6 @@ def _active_orchestrator() -> Any: return None -def is_approval_bypass_active() -> bool: - """Return whether approval prompts are bypassed for this turn. - - The single predicate every gate consults, so a bypass cannot mean "approved" - at one gate and "still ask" at the next. It covers both the config/env level - (``approval_bypass``) and the session level (the user picked "Allow ALL for - this session", which arms ``SessionAwareGate._bypass_all``). - - The session flag is reached through ``_delegate`` as well as ``_gate``: the - in-process CLI installs a wrapper gate, and looking only at ``_gate`` would - miss the bypass in exactly that mode. - """ - ctx = current_tool_context() - if ctx is None: - return False - if getattr(ctx, "approval_bypass", False): - return True - orchestrator = _active_orchestrator() - if orchestrator is None: - return False - gate = getattr(orchestrator, "_gate", None) - if gate is None: - delegate = getattr(orchestrator, "_delegate", None) - if delegate is not None: - gate = getattr(delegate, "_gate", None) - return bool(gate is not None and getattr(gate, "_bypass_all", False)) - async def require_workspace_access( path: Path, @@ -222,9 +195,9 @@ async def require_workspace_access( ) -> dict[str, Any] | None: """Gate access to *path*. Returns None when permitted, else a refusal dict. - The whole sequence lives here — boundary check, bypass, human approval, - refusal — because it used to be spelled out per call site and only the shell - path ever got it right. The other eleven returned the refusal directly, so + The whole sequence lives here — boundary check, policy, approval, refusal — + because it used to be spelled out per call site and only the shell path ever + got it right. The other eleven returned the refusal directly, so ``file_list``/``code_search`` refused in 39ms with a message claiming approval was required, and ignored a session-wide "Allow ALL" that the shell honoured. @@ -237,8 +210,6 @@ async def require_workspace_access( refusal = workspace_scope_refusal(path, operation=operation) if refusal is None: return None - if is_approval_bypass_active(): - return None orchestrator = _active_orchestrator() evaluate = getattr(orchestrator, "evaluate", None) diff --git a/src/leapflow/tools/shell_tools.py b/src/leapflow/tools/shell_tools.py index 6d563dd1..377b86d6 100644 --- a/src/leapflow/tools/shell_tools.py +++ b/src/leapflow/tools/shell_tools.py @@ -21,7 +21,6 @@ from leapflow.tools.execution_context import ( current_tool_context, - is_approval_bypass_active, is_within_allowed_roots, require_workspace_access, resolve_workspace_path, @@ -273,7 +272,7 @@ async def shell_run(params: Dict[str, Any]) -> Dict[str, Any]: if scope_error: return scope_error - if _is_dangerous(command) and not is_approval_bypass_active(): + if _is_dangerous(command): approved, message = await _approve_command(command, cwd) if not approved: return {"ok": False, "error": message} diff --git a/tests/test_approval_layer.py b/tests/test_approval_layer.py index 7dc99c6f..298a3661 100644 --- a/tests/test_approval_layer.py +++ b/tests/test_approval_layer.py @@ -369,7 +369,7 @@ async def check(self, *_args, **_kwargs) -> bool: # ════════════════════════════════════════════════════════════════ -# _bypass_all session bypass: security hardening (issue #30) +# _bypass_all session bypass semantics # ════════════════════════════════════════════════════════════════ @@ -406,31 +406,42 @@ def _high_risk_permanent() -> RiskAssessment: @pytest.mark.asyncio -async def test_bypass_all_does_not_auto_approve_high_no_permanent() -> None: - """_bypass_all must not auto-approve HIGH+allow_permanent=False actions. - - This is the core of the _bypass_all privilege-escalation fix: a session - bypass earned from a low-risk approval must not silently extend to - plugin installs, external sends, or other actions the risk classifier - marked as non-reusable. - """ - delegate = _Gate(ApprovalDecision.ALLOW_ONCE) +async def test_bypass_all_auto_approves_high_no_permanent() -> None: + """Session bypass covers every action that can reach an approval prompt.""" + delegate = _Gate(ApprovalDecision.DENY) gate = SessionAwareGate(delegate) - # Arm the bypass. gate._bypass_all = True request = ApprovalRequest( category="platform.action", detail="plugin install", risk=_high_risk_no_permanent(), - choices=("allow_once", "allow_session", "deny"), + choices=("allow_once", "allow_session", "allow_all_session", "deny"), default_choice="deny", ) decision = await gate.request_approval(request) - # The delegate must have been consulted -- bypass did not fire. + assert delegate.requests == [] + assert decision == ApprovalDecision.ALLOW + + +@pytest.mark.asyncio +async def test_high_risk_request_can_arm_and_reuse_session_bypass() -> None: + """The bypass choice remains valid even when persistent grants are forbidden.""" + delegate = _Gate(ApprovalDecision.ALLOW_ALL_SESSION) + gate = SessionAwareGate(delegate) + request = ApprovalRequest( + category="platform.action", + detail="plugin install", + risk=_high_risk_no_permanent(), + choices=ApprovalOrchestrator._choices(allow_permanent=False), + default_choice="deny", + ) + + assert await gate.request_approval(request) == ApprovalDecision.ALLOW + assert gate._bypass_all is True + assert await gate.request_approval(request) == ApprovalDecision.ALLOW assert len(delegate.requests) == 1 - assert decision == ApprovalDecision.ALLOW_ONCE @pytest.mark.asyncio @@ -456,12 +467,7 @@ async def test_bypass_all_still_auto_approves_low_and_medium_risk() -> None: @pytest.mark.asyncio async def test_bypass_all_auto_approves_high_with_allow_permanent() -> None: - """HIGH + allow_permanent=True (e.g. hardware) is still bypassed. - - The fix gates only on the *combination* of high risk and non-reusable - consent, so hardware writes that declare allow_permanent=True are - unaffected. - """ + """The bypass also covers high-risk actions eligible for persistence.""" delegate = _Gate(ApprovalDecision.DENY) gate = SessionAwareGate(delegate) gate._bypass_all = True @@ -479,17 +485,15 @@ async def test_bypass_all_auto_approves_high_with_allow_permanent() -> None: assert delegate.requests == [] -@pytest.mark.asyncio -async def test_choices_exclude_allow_all_session_when_not_permanent() -> None: - """allow_all_session must not be offered for non-reusable actions.""" +def test_choices_offer_session_bypass_without_offering_persistent_grant() -> None: + """Session bypass is universal while profile persistence stays risk-bound.""" choices_restricted = ApprovalOrchestrator._choices(allow_permanent=False) choices_full = ApprovalOrchestrator._choices(allow_permanent=True) - assert "allow_all_session" not in choices_restricted + assert "allow_all_session" in choices_restricted assert "allow_always" not in choices_restricted assert "allow_all_session" in choices_full assert "allow_always" in choices_full - # Core choices are always present. assert "allow_once" in choices_restricted assert "allow_session" in choices_restricted assert "deny" in choices_restricted @@ -523,13 +527,9 @@ async def test_delegate_decision_outside_choices_falls_back_to_deny() -> None: @pytest.mark.asyncio -async def test_bypass_all_and_choices_validation_combined() -> None: - """Full chain: bypass armed → HIGH non-reusable → fallthrough → delegate - returns out-of-choices → denied. - - Exercises all three fixes together as defence-in-depth. - """ - delegate = _Gate(ApprovalDecision.ALLOW_ALL_SESSION) +async def test_bypass_all_skips_delegate_for_high_external_action() -> None: + """A high-risk external action is auto-approved once bypass is armed.""" + delegate = _Gate(ApprovalDecision.DENY) gate = SessionAwareGate(delegate) gate._bypass_all = True @@ -543,26 +543,17 @@ async def test_bypass_all_and_choices_validation_combined() -> None: explanation="external platform send", allow_permanent=False, ), - choices=("allow_once", "allow_session", "deny", "deny_always"), + choices=ApprovalOrchestrator._choices(allow_permanent=False), default_choice="deny", ) - decision = await gate.request_approval(request) - # Fix 1: bypass fell through (HIGH + !allow_permanent). - # Fix 3: delegate returned ALLOW_ALL_SESSION not in choices → deny. - assert decision == ApprovalDecision.DENY - assert len(delegate.requests) == 1 - assert gate._bypass_all is True # not disarmed, still set from before + assert await gate.request_approval(request) == ApprovalDecision.ALLOW + assert delegate.requests == [] @pytest.mark.asyncio -async def test_orchestrator_high_no_permanent_through_full_chain() -> None: - """End-to-end: orchestrator + SessionAwareGate for a plugin_management action. - - Verifies the orchestrator builds the right choices and the gate enforces - them when a delegate tries to escalate. - """ - # Delegate always tries ALLOW_ALL_SESSION -- a realistic UI misconfig. +async def test_orchestrator_high_no_permanent_can_arm_bypass() -> None: + """A high-risk prompt may explicitly arm the session-wide bypass.""" delegate = _Gate(ApprovalDecision.ALLOW_ALL_SESSION) gate = SessionAwareGate(delegate) orchestrator = ApprovalOrchestrator(gate) @@ -576,16 +567,14 @@ async def test_orchestrator_high_no_permanent_through_full_chain() -> None: result = await orchestrator.evaluate(action) - # The risk classifier forces HIGH + allow_permanent=False. assert result.risk.level == RiskLevel.HIGH assert result.risk.allow_permanent is False - # The delegate returned ALLOW_ALL_SESSION which was not in choices → deny. - assert result.approved is False - assert gate._bypass_all is False + assert result.approved is True + assert gate._bypass_all is True # ════════════════════════════════════════════════════════════════ -# Irreversible / external-output physical writes under bypass (issue #34) +# Irreversible / external-output physical writes under bypass # ════════════════════════════════════════════════════════════════ @@ -617,17 +606,9 @@ def _critical_no_permanent() -> RiskAssessment: @pytest.mark.asyncio -async def test_bypass_all_does_not_auto_approve_irreversible_hardware_write() -> None: - """An irreversible physical write must fall through, not be blanket-approved. - - Before #34, ``_tier_for`` marked in-envelope physical writes - allow_permanent=True, so an irreversible DISPENSE reached the gate as - HIGH+allow_permanent=True and was silently authorised by a session-wide - bypass earned from a lower-risk approval. With the tightening it arrives - as HIGH+allow_permanent=False, so the bypass must fall through to the - delegate for per-invocation consent. - """ - delegate = _Gate(ApprovalDecision.ALLOW_ONCE) +async def test_bypass_all_auto_approves_irreversible_hardware_write() -> None: + """Explicit session bypass covers irreversible but approvable actions.""" + delegate = _Gate(ApprovalDecision.DENY) gate = SessionAwareGate(delegate) gate._bypass_all = True @@ -635,36 +616,21 @@ async def test_bypass_all_does_not_auto_approve_irreversible_hardware_write() -> category="device.dispense", detail="aspirate 10 uL", risk=_irreversible_hardware_write(), - choices=("allow_once", "allow_session", "deny"), + choices=ApprovalOrchestrator._choices(allow_permanent=False), default_choice="deny", ) - decision = await gate.request_approval(request) - - # The delegate was consulted -- the bypass did not fire. - assert len(delegate.requests) == 1 - assert decision == ApprovalDecision.ALLOW_ONCE + assert await gate.request_approval(request) == ApprovalDecision.ALLOW + assert delegate.requests == [] -@pytest.mark.asyncio -async def test_bypass_all_does_not_auto_approve_critical_no_permanent() -> None: - """CRITICAL + allow_permanent=False must fall through under a session bypass. - The fallthrough covers both HIGH and CRITICAL; this guards the CRITICAL - arm so a session-wide bypass cannot blanket-approve, for example, a write - that could only be classified as an unresolvable/hardline command. - """ - delegate = _Gate(ApprovalDecision.ALLOW_ONCE) - gate = SessionAwareGate(delegate) - gate._bypass_all = True +def test_policy_blocks_critical_action_before_session_bypass() -> None: + """Critical actions are denied before any session bypass can be consulted.""" + from leapflow.security.policy import ApprovalPolicyEngine, PolicyVerdict - request = ApprovalRequest( - category="device.actuate", - detail="unresolvable device command", - risk=_critical_no_permanent(), - choices=("allow_once", "allow_session", "deny"), - default_choice="deny", + decision = ApprovalPolicyEngine().evaluate( + ActionDescriptor.shell("unresolvable device command"), + _critical_no_permanent(), ) - decision = await gate.request_approval(request) - assert len(delegate.requests) == 1 - assert decision == ApprovalDecision.ALLOW_ONCE + assert decision.verdict is PolicyVerdict.DENY diff --git a/tests/test_path_sensitivity.py b/tests/test_path_sensitivity.py index 08df91cc..899dd665 100644 --- a/tests/test_path_sensitivity.py +++ b/tests/test_path_sensitivity.py @@ -42,6 +42,18 @@ def test_risk_classifier_uses_configured_layout_root_for_shell_config_mentions(t configure_path_sensitivity_roots((Path("~/.leapflow").expanduser(),)) +def test_shell_sensitive_config_detection_inspects_path_operands_not_text() -> None: + classifier = DefaultRiskClassifier() + + assert classifier.assess(ActionDescriptor.shell("cat .env")).level == RiskLevel.HIGH + assert classifier.assess(ActionDescriptor.shell("printf secret > .env")).level == RiskLevel.HIGH + assert classifier.assess(ActionDescriptor.shell('echo "config.yaml"')).level == RiskLevel.LOW + assert classifier.assess(ActionDescriptor.shell("grep config.yaml README.md")).level == RiskLevel.LOW + assert classifier.assess( + ActionDescriptor.shell("awk '{print $1}' ~/.leapflow/config/user.yaml") + ).level == RiskLevel.HIGH + + def test_path_sensitivity_classifies_new_layout_categories(tmp_path) -> None: data_root = tmp_path / "custom-leap-home" configure_path_sensitivity_roots((data_root,)) diff --git a/tests/test_workspace_escape_approval.py b/tests/test_workspace_escape_approval.py index 4ae4b95b..d5828e50 100644 --- a/tests/test_workspace_escape_approval.py +++ b/tests/test_workspace_escape_approval.py @@ -9,7 +9,7 @@ These tests pin the three properties that were broken: 1. every entry point routes through the approval gate, - 2. every entry point honours the one bypass predicate, + 2. every entry point keeps the approval chain observable under bypass, 3. the escape is risk-classified so the policy engine always asks. """ from __future__ import annotations @@ -23,7 +23,6 @@ from leapflow.security.risk import DefaultRiskClassifier, RiskLevel from leapflow.tools.execution_context import ( ToolExecutionContext, - is_approval_bypass_active, require_workspace_access, reset_tool_context, set_tool_context, @@ -140,27 +139,22 @@ async def test_entry_point_asks_before_leaving_the_workspace( _ENTRY_POINTS, ids=[f"{m}.{a}" for m, a, _, _ in _ENTRY_POINTS], ) -async def test_entry_point_honours_the_bypass( +async def test_entry_point_uses_unified_approval_chain_under_bypass( tmp_path, module_name, attr, build_params, expected_effect, ) -> None: - """A session-wide bypass must not stop at the shell. - - The file tools used to ignore it entirely, so a user who had granted - "Allow ALL for this session" still got refused by ``file_list`` while - ``shell_run`` ran freely — the worst possible split. - """ + """Bypass is decided by the orchestrator rather than a tool-local shortcut.""" outside = tmp_path / "outside" outside.mkdir() (outside / "a.txt").write_text("a", encoding="utf-8") - gate = RecordingOrchestrator(approved=False) + gate = RecordingOrchestrator(approved=True) token = set_tool_context(_context(tmp_path, gate, bypass=True)) try: result = await _handler(module_name, attr)(build_params(outside)) finally: reset_tool_context(token) - assert gate.actions == [], f"{attr} prompted despite an active bypass" + assert len(gate.actions) == 1, f"{attr} bypassed the unified approval chain" assert result.get("error_type") != "outside_workspace" @@ -235,35 +229,6 @@ async def test_paths_inside_the_workspace_are_not_gated(tmp_path) -> None: assert gate.actions == [] -# ── one bypass predicate ───────────────────────────────────────────────────── - -def test_bypass_predicate_penetrates_a_wrapper_gate(tmp_path) -> None: - """The in-process CLI wraps the gate; looking only at ``_gate`` misses it.""" - - class SessionGate: - _bypass_all = True - - class Orchestrator: - _gate = SessionGate() - - class WrapperGate: - def __init__(self, delegate: Any) -> None: - self._delegate = delegate - - token = set_tool_context(_context(tmp_path, WrapperGate(Orchestrator()))) - try: - assert is_approval_bypass_active() is True - finally: - reset_tool_context(token) - - -def test_bypass_predicate_is_false_without_a_grant(tmp_path) -> None: - token = set_tool_context(_context(tmp_path, RecordingOrchestrator(approved=True))) - try: - assert is_approval_bypass_active() is False - finally: - reset_tool_context(token) - # ── the escape is always risk-classified above the auto-allow floor ──────────