feat: checkpoint device agent runtime milestones
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-07-06
|
||||
@@ -0,0 +1,65 @@
|
||||
## Context
|
||||
|
||||
This builds on the `apex-agent-mvp` change (currently proposed, not yet applied), which establishes the Device/Driver/Perception/Agent-Runtime/MCP layers for Apex Agent. That change already defines an MCP Tool Server (`api/mcp.py`) exposing device capabilities; this change adds a parallel `skills/` package and new MCP tools onto the same server, without touching the device/perception/runtime code.
|
||||
|
||||
The key external constraint: skill **authoring, versioning, and entitlement** live in a separate, already-planned **Subscription Platform** (a distinct information-management system, out of scope here). Apex Agent is a **consumer** of that platform's catalog, not the source of truth for skill content. We only control: how Apex Agent stores what it has synced, how it exposes that to the LLM via MCP, and the contract it expects the Subscription Platform to satisfy.
|
||||
|
||||
Two kinds of Skill must be supported, per product direction:
|
||||
- **Knowledge skill**: free-form structured instructional content (markdown/text + metadata) the LLM reads to decide how to act — e.g. "tips for searching effectively on Xiaohongshu." The LLM still plans/executes via the existing `agent-runtime`/`tools` layer.
|
||||
- **Flow-template skill**: a predefined, parameterized sequence of capability calls (tap/swipe/input steps with placeholders, e.g. `{query}`), which the LLM mostly fills in and triggers rather than re-planning from scratch.
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- Define a single `Skill` data model general enough to represent both knowledge and flow-template skills with shared metadata (id, name, description, version, tags, subscription/source id).
|
||||
- Expose skills to the LLM through MCP tools that are indistinguishable in style from the existing device tools (semantic, driver/platform-agnostic).
|
||||
- Define a clear, minimal contract for what Apex Agent needs from the Subscription Platform: a way to fetch "skills I'm entitled to" and a way to learn about changes (poll or push), without dictating that platform's internal design.
|
||||
- Enforce subscription-based visibility so `list_skills`/`search_skills`/`get_skill` only ever surface skills the current deployment (tenant/device/agent) is actually subscribed to.
|
||||
- Let a flow-template skill's steps execute through the *existing* `tools/` functions from `apex-agent-mvp` (no new execution primitives) — a flow template is just a data-driven script over the same capability calls the Executor already uses.
|
||||
|
||||
**Non-Goals:**
|
||||
- Designing or implementing the Subscription Platform itself (its UI, billing, authoring workflow, or storage).
|
||||
- Automatic skill generation/authoring by the LLM.
|
||||
- A full permission/RBAC system — subscription visibility is scoped to "is this skill in my entitled set," not fine-grained per-user roles.
|
||||
- Real-time push infrastructure (websockets/queues) as a hard requirement — push is supported as an *optional* transport; polling sync must work standalone.
|
||||
- Executing flow-template skills with a new engine — they are interpreted by the existing `runtime/executor.py`, not a separate workflow engine.
|
||||
|
||||
## Decisions
|
||||
|
||||
### D1: `Skill` is a single model with a `kind` discriminator (`knowledge` | `flow_template`), not two unrelated types
|
||||
Both kinds share `SkillMetadata` (id, name, description, version, tags, source/subscription id, updated_at). A `KnowledgeSkill` carries `content` (markdown/text). A `FlowTemplateSkill` carries `steps` (ordered list of `{tool, args_template}`, where `args_template` values may contain `{param}` placeholders) and a `parameters` schema (name, type, required, description) used to validate/prompt for inputs before execution.
|
||||
- **Alternative considered**: Two entirely separate catalogs/tables/tool sets for knowledge vs. flow skills. Rejected — `list_skills`/`search_skills` would need to be duplicated, and most metadata (id/name/description/version/tags) is identical; a discriminated union keeps one catalog and one set of list/search tools while `get_skill` returns kind-specific content.
|
||||
|
||||
### D2: Skill Catalog is a local, read-mostly cache; Subscription Platform is always the source of truth
|
||||
`skills/catalog.py` stores the last-synced copy of entitled skills locally (for offline availability and low-latency MCP responses) but never treats local edits as authoritative — there is no "create/update skill" MCP tool or API in this change. All content changes flow one direction: Subscription Platform → sync client → local catalog.
|
||||
- **Alternative considered**: Let Apex Agent locally override/edit synced skills. Rejected — breaks the "another system manages skills" requirement from the proposal and creates drift/merge-conflict problems with no clear owner.
|
||||
|
||||
### D3: Sync client supports pull (poll) as the required baseline, push (webhook) as an optional accelerator
|
||||
`skills/sync_client.py` defines a `fetch_entitled_skills(subscription_id, since_version)` contract against the Subscription Platform's assumed API, called on a configurable interval (baseline). If the platform can also deliver change notifications (webhook/callback), an optional receiver triggers an immediate out-of-cycle fetch instead of waiting for the next poll — but correctness never depends on push arriving.
|
||||
- **Alternative considered**: Push-only (webhook-driven) sync. Rejected — makes Apex Agent's catalog freshness dependent on network reachability of an inbound webhook, which is operationally harder (firewalls/NAT) than Apex Agent making outbound poll requests; poll-as-baseline is strictly more deployable.
|
||||
|
||||
### D4: Subscription-based visibility is enforced at the catalog query layer, not just at sync time
|
||||
Even though sync only ever pulls "entitled" skills, `skills/catalog.py`'s query functions (used by both MCP tools and any future internal caller) re-check that a skill's subscription id is still in the caller's active subscription set at query time, not just at last-sync time. This guards against a stale local cache still containing a skill whose entitlement was revoked but not yet re-synced.
|
||||
- **Alternative considered**: Trust the local cache fully between syncs (no re-check at query time). Rejected — entitlement revocation should not have to wait for the next poll interval to stop being visible if the revocation is already known locally (e.g. via a push notification that only carries "removed" without full content).
|
||||
|
||||
### D5: Flow-template skills execute via existing `tools/`/`runtime/executor.py`, with a resolution step in between
|
||||
`skills/mcp_tools.py` exposes `get_skill` (returns metadata + content/template) and a parameter-resolution helper; it does **not** expose a `run_skill` tool that silently executes on the LLM's behalf. The LLM fetches the flow template, fills placeholders itself (or asks the user for missing required parameters), and then issues the already-existing device-capability tool calls (`tap`, `input_text`, etc.) from `apex-agent-mvp` in the order/values the template specifies.
|
||||
- **Alternative considered**: Add a single `run_skill_flow(skill_id, params)` MCP tool that executes the whole sequence server-side. Rejected for this change — it would bypass the Agent Runtime's Observe→Think→Act loop and Executor retry/wait logic from `apex-agent-mvp`, silently skipping Scene verification between steps. Keeping execution inside the existing loop (LLM issues each tool call itself, informed by the template) preserves the "AI decides based on what it currently observes" principle the whole platform is built on. A batched execution helper can be revisited later as a design decision in its own change if needed.
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- **[Risk]** The Subscription Platform's actual API shape is unknown/assumed (`fetch_entitled_skills`, optional webhook) → **Mitigation**: keep `skills/sync_client.py` behind a small internal interface (similar to `Driver` in `apex-agent-mvp`) so the concrete HTTP client can be adjusted once the real Subscription Platform API is finalized, without touching `catalog.py` or `mcp_tools.py`.
|
||||
- **[Risk]** Stale cache could serve outdated skill content between polls → **Mitigation**: D4's query-time entitlement re-check plus a configurable poll interval; document the staleness window explicitly rather than promising real-time freshness.
|
||||
- **[Risk]** Flow-template skills reference tools/parameters that drift from the actual `tools/` function signatures in `apex-agent-mvp` (e.g. a template calls a tool that was renamed) → **Mitigation**: validate a flow template's `tool` names against the currently registered MCP/tool set at sync time (or at least at `get_skill` time) and surface a clear "skill unavailable/invalid" error rather than letting a bad call reach the device.
|
||||
- **[Trade-off]** No local skill authoring/editing keeps this change simple and avoids ownership ambiguity, but means Apex Agent is fully dependent on the Subscription Platform being reachable at least once to have any skills at all — acceptable since the platform is a required dependency by design, not an optional enhancement.
|
||||
- **[Trade-off]** Not providing a server-side `run_skill_flow` execution tool keeps flow templates consistent with the Observe-Think-Act loop, at the cost of the LLM needing a few more tool-call round trips per flow skill than a single batched call would take — acceptable given the platform's core principle of always re-observing between actions.
|
||||
|
||||
## Migration Plan
|
||||
|
||||
Additive only: new `skills/` package, new MCP tools, and new local storage tables/files. No existing `apex-agent-mvp` code paths are modified (only composed with, per D-decisions above). If `apex-agent-mvp` has already been applied, this change's MCP tools register onto its existing MCP server instance; if not yet applied, `skills/mcp_tools.py` can stand up its own MCP server instance for independent testing and be merged once `apex-agent-mvp` lands. Rollback is simply removing the `skills/` package and its MCP tool registrations; no data migration or schema changes to existing tables are required.
|
||||
|
||||
## Open Questions
|
||||
|
||||
- Exact Subscription Platform API contract (auth mechanism, request/response shapes, whether it supports `since_version` incremental sync or only full-catalog fetch) — to be confirmed with that platform's team/spec before `skills/sync_client.py` is finalized; this design assumes an interface shape that can absorb either.
|
||||
- Whether flow-template `args_template` placeholders need a richer expression language (e.g. simple conditionals) or plain `{param}` substitution is sufficient for the MVP — left open, default to plain substitution and revisit if a real skill needs more.
|
||||
- Where the local Skill Catalog lives relative to `apex-agent-mvp`'s existing SQLite task-metadata DB (same DB file, new tables, vs. a separate DB/file) — deferred to implementation time in `tasks.md`, doesn't affect the capability contracts defined here.
|
||||
@@ -0,0 +1,28 @@
|
||||
## Why
|
||||
|
||||
Apex Agent's MCP tool server (see change `apex-agent-mvp`) gives the LLM raw device capabilities (tap/swipe/screenshot/...), but it has no notion of reusable, task-specific know-how — e.g. "how to search on Xiaohongshu," or "the tap/swipe/input sequence to place an order on Taobao." Today that knowledge would have to live entirely inside the LLM's own reasoning or be re-derived from scratch on every task. We need a **Skill** concept the AI can discover and pull on demand via MCP, and — since skill content will be authored, versioned, and entitled to specific tenants/devices by a separate, already-planned **Subscription Platform** (统一订阅平台,另一套信息管理系统) — Apex Agent needs a defined contract for consuming that platform's catalog rather than owning skill authoring itself.
|
||||
|
||||
## What Changes
|
||||
|
||||
- Introduce a **Skill Catalog** capability: a local data model and store for Skills, where a Skill is either a **knowledge skill** (structured instructional/markdown content the AI reads to decide how to act, analogous to Claude Skills) or a **flow-template skill** (a parameterized, predefined sequence of capability calls — e.g. tap/swipe/input steps with placeholders — that the AI mostly fills in parameters for and triggers, rather than re-planning from scratch). Both kinds share common metadata (id, name, description, version, tags) so they can be listed/searched uniformly.
|
||||
- Introduce **Skill MCP tools** (`list_skills`, `search_skills`, `get_skill`, `run_skill_flow`-input-resolution helper) exposed through the same MCP surface established in `apex-agent-mvp`'s `mcp-tool-server`, so an LLM can discover which skills are available and fetch their content/flow template without knowing anything about the Subscription Platform underneath.
|
||||
- Introduce a **Skill Subscription Sync** capability: a client-side contract for talking to the external Subscription Platform, covering (a) pulling/receiving the catalog of skills a given deployment is entitled to, (b) keeping the local Skill Catalog in sync (create/update/remove on change), and (c) enforcing subscription-based visibility so only skills the current tenant/device/agent is subscribed to are listed or fetchable via the MCP tools.
|
||||
- Explicitly out of scope for this change: designing or building the Subscription Platform itself (authoring UI, billing, skill publishing workflow) — it is treated as an existing/external system; this change only defines the integration contract (API shape, sync semantics, auth) Apex Agent needs from it. Also out of scope: automatic skill-authoring/generation by the LLM, and a skill marketplace UI.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `skill-catalog`: Local Skill data model (knowledge-doc and flow-template variants), storage, and search/query functions used by both the MCP tools and the sync client.
|
||||
- `skill-mcp-tools`: MCP-facing tool surface for listing, searching, and fetching Skill content/flow templates, plus resolving flow-template parameters, without exposing any Subscription Platform or storage detail to the LLM.
|
||||
- `skill-subscription-sync`: Contract and client implementation for syncing the Skill Catalog from the external Subscription Platform (pull and/or push), and for enforcing subscription-based visibility/permission scoping per tenant/device/agent.
|
||||
|
||||
### Modified Capabilities
|
||||
(none — `mcp-tool-server` from the pending `apex-agent-mvp` change is composed with, not modified: this change adds new tools to the same MCP server process rather than changing that capability's existing requirements. If `apex-agent-mvp` has not yet been applied when this change is implemented, the Skill MCP tools should still be registrable on their own MCP server instance and merged in later.)
|
||||
|
||||
## Impact
|
||||
|
||||
- **New code**: `skills/` package — `skills/models.py` (Skill, KnowledgeSkill, FlowTemplateSkill, SkillMetadata), `skills/catalog.py` (local store + search/query), `skills/sync_client.py` (Subscription Platform client: pull/push, auth, visibility filtering), `skills/mcp_tools.py` (registers `list_skills`/`search_skills`/`get_skill`/flow-param-resolution as MCP tools).
|
||||
- **Dependencies**: depends on the `apex-agent-mvp` change for the MCP server process and `tools/`/`runtime/` capability layer that flow-template skills ultimately drive (a flow-template skill's steps still execute through existing `tools/` functions); does not depend on any new external dependency beyond an HTTP client for the sync API.
|
||||
- **External systems**: introduces a new external dependency — the Subscription Platform's API (assumed to expose an endpoint to fetch entitled skills and, optionally, a webhook/push channel for change notifications). Exact base URL/auth mechanism is a deployment-time configuration, not a code dependency.
|
||||
- **Storage**: adds a local Skill Catalog store (SQLite table(s) alongside the existing task-metadata DB from `apex-agent-mvp`, or an embedded file-based store — to be decided in design) plus a small sync-state table (last-synced version/timestamp per subscription).
|
||||
- **Follow-on work explicitly deferred**: Subscription Platform's own design/build, skill-authoring workflows, billing/entitlement logic beyond "is this skill visible to me," and any LLM-driven automatic skill generation.
|
||||
@@ -0,0 +1,53 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Unified Skill data model
|
||||
The system SHALL represent every Skill with shared metadata (id, name, description, version, tags, source/subscription id, updated_at) and a `kind` discriminator of either `knowledge` or `flow_template`, so both kinds can be listed and searched through one catalog.
|
||||
|
||||
#### Scenario: Knowledge skill has content
|
||||
- **WHEN** a Skill with `kind = knowledge` is stored
|
||||
- **THEN** it includes a `content` field (structured instructional text/markdown) in addition to the shared metadata
|
||||
|
||||
#### Scenario: Flow-template skill has steps and parameters
|
||||
- **WHEN** a Skill with `kind = flow_template` is stored
|
||||
- **THEN** it includes an ordered `steps` list (each referencing a tool name and an args template that may contain `{param}` placeholders) and a `parameters` schema (name, type, required, description) in addition to the shared metadata
|
||||
|
||||
### Requirement: Local skill storage
|
||||
The system SHALL persist the synced Skill Catalog locally so that skills can be listed and fetched without a live round-trip to the Subscription Platform for every query.
|
||||
|
||||
#### Scenario: Skill readable after sync
|
||||
- **WHEN** a skill has been synced from the Subscription Platform into the local catalog
|
||||
- **THEN** subsequent list/search/get operations return that skill without requiring a new network call to the Subscription Platform
|
||||
|
||||
#### Scenario: Local catalog is not independently authored
|
||||
- **WHEN** a caller attempts to create or edit a skill directly in the local catalog (outside of a sync operation)
|
||||
- **THEN** the system SHALL reject or ignore the write, since the Subscription Platform is the sole source of truth for skill content
|
||||
|
||||
### Requirement: Skill search and query
|
||||
The system SHALL provide functions to list all currently visible skills, search skills by name/tag/description text, and fetch a single skill by id.
|
||||
|
||||
#### Scenario: List returns only visible skills
|
||||
- **WHEN** the catalog is queried for the list of skills visible to the current caller
|
||||
- **THEN** it returns only skills whose subscription is currently active for that caller, sorted in a stable order (e.g. by name)
|
||||
|
||||
#### Scenario: Search matches on name, tags, or description
|
||||
- **WHEN** a search query string matches a skill's name, a tag, or its description
|
||||
- **THEN** that skill is included in the search results
|
||||
|
||||
#### Scenario: Get by id returns full content
|
||||
- **WHEN** a caller fetches a skill by its id
|
||||
- **THEN** the system returns the full skill record, including `content` for knowledge skills or `steps`/`parameters` for flow-template skills
|
||||
|
||||
#### Scenario: Get by id for unknown or invisible skill
|
||||
- **WHEN** a caller fetches a skill id that does not exist, or exists but is not currently visible to them (subscription inactive)
|
||||
- **THEN** the system returns a clear "not found" result rather than leaking the skill's existence or content
|
||||
|
||||
### Requirement: Flow-template tool reference validation
|
||||
The system SHALL validate that a flow-template skill's referenced tool names correspond to currently registered device-capability tools, and SHALL mark a flow-template skill as invalid/unavailable rather than allowing it to be fetched successfully if a referenced tool does not exist.
|
||||
|
||||
#### Scenario: Valid flow template
|
||||
- **WHEN** every step in a flow-template skill references a tool name that is currently registered
|
||||
- **THEN** the skill is fetchable and returned normally
|
||||
|
||||
#### Scenario: Flow template references an unknown tool
|
||||
- **WHEN** a flow-template skill's steps reference a tool name that is not currently registered (e.g. renamed or removed)
|
||||
- **THEN** fetching that skill returns a clear "skill unavailable/invalid" result instead of a step list containing a dangling tool reference
|
||||
@@ -0,0 +1,41 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: MCP tools for skill discovery and retrieval
|
||||
The system SHALL expose `list_skills`, `search_skills`, and `get_skill` as MCP tools on the same MCP server surface used for device capabilities, so an LLM client can discover and fetch Skill content using the same tool-calling mechanism it already uses for device actions.
|
||||
|
||||
#### Scenario: LLM lists available skills
|
||||
- **WHEN** an MCP client calls `list_skills`
|
||||
- **THEN** it receives the set of skills currently visible to it (per subscription visibility), each with id, name, description, kind, and tags, without any Subscription Platform-specific fields or identifiers
|
||||
|
||||
#### Scenario: LLM searches for a relevant skill
|
||||
- **WHEN** an MCP client calls `search_skills` with a query string
|
||||
- **THEN** it receives matching skills ranked/filtered by relevance to the query, using the same visibility rules as `list_skills`
|
||||
|
||||
#### Scenario: LLM fetches a specific skill's content
|
||||
- **WHEN** an MCP client calls `get_skill` with a skill id
|
||||
- **THEN** it receives the full skill content appropriate to its kind: `content` text for a `knowledge` skill, or `steps`/`parameters` for a `flow_template` skill
|
||||
|
||||
### Requirement: Flow-template parameter resolution helper
|
||||
The system SHALL provide an MCP-facing helper that, given a flow-template skill id and a set of proposed parameter values, validates the values against the skill's declared `parameters` schema and returns the fully resolved step sequence (placeholders substituted) for the LLM to then execute step-by-step via the existing device-capability tools.
|
||||
|
||||
#### Scenario: Valid parameters resolve the template
|
||||
- **WHEN** the LLM provides values for all required parameters of a flow-template skill
|
||||
- **THEN** the system returns the ordered steps with all `{param}` placeholders substituted by the provided values
|
||||
|
||||
#### Scenario: Missing required parameter
|
||||
- **WHEN** the LLM omits a required parameter when resolving a flow-template skill
|
||||
- **THEN** the system returns a clear validation error identifying the missing parameter(s) instead of returning a partially-substituted step list
|
||||
|
||||
### Requirement: No server-side flow execution tool
|
||||
The system SHALL NOT expose an MCP tool that executes a flow-template skill's full step sequence server-side on the LLM's behalf; the LLM SHALL issue each resulting device-capability tool call itself so every step remains subject to the existing Agent Runtime's Observe-Think-Act loop and Executor retry/wait handling.
|
||||
|
||||
#### Scenario: No batch-execute tool is available
|
||||
- **WHEN** the MCP tool list is inspected
|
||||
- **THEN** it contains skill discovery/retrieval/resolution tools but no tool that both resolves and executes a flow-template skill's steps in a single call
|
||||
|
||||
### Requirement: Skill MCP errors are semantic
|
||||
The system SHALL translate catalog-level errors (skill not found, skill not visible/entitled, invalid/unavailable flow template) into clear, semantic MCP tool error responses, consistent in style with the device-capability tool error handling.
|
||||
|
||||
#### Scenario: Requesting a non-visible skill
|
||||
- **WHEN** `get_skill` is called with a skill id that exists but is not visible to the caller's current subscriptions
|
||||
- **THEN** the tool returns a semantic "not found" error rather than a raw database or internal exception
|
||||
@@ -0,0 +1,61 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Pull-based sync from the Subscription Platform
|
||||
The system SHALL periodically fetch, from the external Subscription Platform, the set of skills the current deployment (tenant/device/agent) is entitled to, and SHALL apply creates/updates/removals to the local Skill Catalog to match that entitled set.
|
||||
|
||||
#### Scenario: New skill appears after sync
|
||||
- **WHEN** the Subscription Platform reports a new entitled skill that does not yet exist locally
|
||||
- **THEN** the next sync cycle creates it in the local Skill Catalog
|
||||
|
||||
#### Scenario: Updated skill content is refreshed
|
||||
- **WHEN** the Subscription Platform reports a newer version of a skill already present locally
|
||||
- **THEN** the next sync cycle updates the local copy to the newer version
|
||||
|
||||
#### Scenario: Revoked entitlement removes local visibility
|
||||
- **WHEN** the Subscription Platform no longer includes a previously-entitled skill in the current entitled set
|
||||
- **THEN** the next sync cycle removes or marks that skill as no longer visible in the local Skill Catalog
|
||||
|
||||
#### Scenario: Sync interval is configurable
|
||||
- **WHEN** the deployment is configured with a sync poll interval
|
||||
- **THEN** the system performs pull sync on approximately that interval without requiring a restart to take effect on the next cycle
|
||||
|
||||
### Requirement: Optional push-triggered sync
|
||||
The system MAY support receiving a change notification (e.g. webhook) from the Subscription Platform, and WHEN it does, SHALL trigger an immediate out-of-cycle pull sync rather than waiting for the next poll interval; correctness of the catalog SHALL NOT depend on push notifications being delivered.
|
||||
|
||||
#### Scenario: Push notification triggers immediate sync
|
||||
- **WHEN** a change notification is received from the Subscription Platform
|
||||
- **THEN** the system performs a pull sync immediately, independent of the regular poll schedule
|
||||
|
||||
#### Scenario: No push configured still stays eventually consistent
|
||||
- **WHEN** push notifications are not configured or not received
|
||||
- **THEN** the local Skill Catalog still reflects the Subscription Platform's entitled set within one poll interval via the baseline pull sync
|
||||
|
||||
### Requirement: Subscription-based visibility enforcement
|
||||
The system SHALL enforce, at both sync time and query time, that only skills belonging to the caller's currently active subscription(s) are stored as visible or returned by catalog queries.
|
||||
|
||||
#### Scenario: Query-time re-check catches stale entitlement
|
||||
- **WHEN** a skill's entitlement has been revoked but the local cache has not yet completed its next sync cycle
|
||||
- **AND** a catalog query for that skill is made using already-known revocation information
|
||||
- **THEN** the system does not return that skill as visible, even though its record may still exist locally pending cleanup
|
||||
|
||||
#### Scenario: Multiple subscriptions compose visibility
|
||||
- **WHEN** a deployment holds more than one active subscription, each entitling a different set of skills
|
||||
- **THEN** catalog queries return the union of skills entitled across all of that deployment's active subscriptions
|
||||
|
||||
### Requirement: Sync client contract is transport-replaceable
|
||||
The system SHALL define the Subscription Platform integration (fetch entitled skills, optional change notification receipt) behind a single internal interface, so the concrete HTTP client/auth mechanism can be adjusted to match the real Subscription Platform API without changes to the Skill Catalog or MCP tool layers.
|
||||
|
||||
#### Scenario: Sync client swap does not affect catalog/tools
|
||||
- **WHEN** the concrete Subscription Platform client implementation is replaced (e.g. different auth scheme or request/response shape)
|
||||
- **THEN** `skill-catalog` and `skill-mcp-tools` behavior and their own specs remain unaffected, as long as the new client still satisfies the sync interface
|
||||
|
||||
### Requirement: Sync failure handling
|
||||
The system SHALL treat a failed sync attempt (network error, auth failure, malformed response) as non-fatal to already-cached skills: the local catalog SHALL continue serving its last-known-good state, and the failure SHALL be recorded/observable rather than silently discarded.
|
||||
|
||||
#### Scenario: Sync failure preserves last-known catalog
|
||||
- **WHEN** a sync attempt fails due to a network or platform error
|
||||
- **THEN** the local Skill Catalog is left unchanged (not cleared or partially corrupted) and remains queryable using its last successfully synced state
|
||||
|
||||
#### Scenario: Sync failure is observable
|
||||
- **WHEN** a sync attempt fails
|
||||
- **THEN** the system records the failure (e.g. last-error timestamp/reason) so it can be surfaced to operators rather than failing silently forever
|
||||
@@ -0,0 +1,39 @@
|
||||
## 1. Package scaffolding & data model
|
||||
|
||||
- [ ] 1.1 Create `skills/` package (`__init__.py`) alongside existing `core/`, `tools/`, `vision/`, `runtime/`, `api/`, `storage/`
|
||||
- [ ] 1.2 Add `skills/models.py`: `SkillMetadata` (id, name, description, version, tags, source/subscription id, updated_at), `KnowledgeSkill` (content), `FlowTemplateSkill` (steps, parameters), and a `kind` discriminator uniting them
|
||||
- [ ] 1.3 Add dependencies if needed (HTTP client for sync, no new heavy deps expected) to `pyproject.toml`
|
||||
|
||||
## 2. Skill Catalog storage & query (capability: skill-catalog)
|
||||
|
||||
- [ ] 2.1 Implement `skills/catalog.py` local store (decide SQLite table(s) reusing the existing DB vs. separate file, per design's open question) with create/update/remove operations used only by the sync path
|
||||
- [ ] 2.2 Implement `list_skills(caller_context)` returning only skills visible under the caller's active subscriptions, stable-sorted
|
||||
- [ ] 2.3 Implement `search_skills(query, caller_context)` matching name/tags/description
|
||||
- [ ] 2.4 Implement `get_skill(skill_id, caller_context)` returning full content, or a clear "not found" for unknown/invisible ids
|
||||
- [ ] 2.5 Reject/ignore any direct create-or-edit call to the catalog that didn't come from the sync path (enforce "Subscription Platform is sole source of truth")
|
||||
- [ ] 2.6 Implement flow-template tool-reference validation: check each step's `tool` name against the currently registered device-capability tools; mark skill invalid/unavailable if any reference is dangling
|
||||
- [ ] 2.7 Write unit tests: list/search/get visibility filtering, not-found cases, and flow-template validation (valid and dangling-reference cases)
|
||||
|
||||
## 3. Subscription sync client (capability: skill-subscription-sync)
|
||||
|
||||
- [ ] 3.1 Define the internal sync interface (e.g. `SubscriptionClient.fetch_entitled_skills(subscription_id, since_version)` supporting full or incremental fetch) in `skills/sync_client.py`
|
||||
- [ ] 3.2 Implement a concrete HTTP-based `SubscriptionClient` against the assumed Subscription Platform API (configurable base URL/auth), isolated behind the interface from 3.1
|
||||
- [ ] 3.3 Implement the poll loop: fetch on a configurable interval, diff against local catalog, and apply create/update/remove to `skills/catalog.py`
|
||||
- [ ] 3.4 Implement optional push-triggered sync: a receiver (e.g. a small webhook endpoint) that, on notification, triggers an immediate out-of-cycle pull rather than being required for correctness
|
||||
- [ ] 3.5 Implement subscription-based visibility enforcement at query time (re-check active subscription set, not just last-sync membership) so revoked entitlements stop being visible without waiting for the next full sync
|
||||
- [ ] 3.6 Implement sync failure handling: on network/auth/malformed-response errors, leave the local catalog unchanged and record a last-error timestamp/reason for observability
|
||||
- [ ] 3.7 Write unit tests: create/update/remove sync scenarios, push-triggered immediate sync, query-time revocation re-check, and sync-failure-preserves-cache behavior (using a fake `SubscriptionClient`)
|
||||
|
||||
## 4. Skill MCP tools (capability: skill-mcp-tools)
|
||||
|
||||
- [ ] 4.1 Implement `skills/mcp_tools.py` registering `list_skills`, `search_skills`, `get_skill` as MCP tools on the existing MCP server surface from `apex-agent-mvp` (or a standalone MCP server instance if that change is not yet applied)
|
||||
- [ ] 4.2 Implement the flow-template parameter-resolution MCP tool: validate provided values against a skill's `parameters` schema and return the fully substituted step sequence, or a clear validation error listing missing/invalid parameters
|
||||
- [ ] 4.3 Add semantic error translation for skill MCP tools (not-found, not-visible/entitled, invalid/unavailable flow template) consistent in style with the device-capability tool error handling
|
||||
- [ ] 4.4 Confirm no MCP tool exists that both resolves and executes a flow-template skill's steps server-side (execution stays with the LLM issuing existing device-capability tool calls one at a time)
|
||||
- [ ] 4.5 Write tests: `list_skills`/`search_skills`/`get_skill` via MCP against a seeded catalog (mocked sync), parameter-resolution success/failure cases, and an explicit check that no batch-execute tool is registered
|
||||
|
||||
## 5. End-to-end validation
|
||||
|
||||
- [ ] 5.1 Seed a local catalog via a fake `SubscriptionClient` with one knowledge skill and one flow-template skill, and verify both are listable/searchable/fetchable via MCP tools
|
||||
- [ ] 5.2 Simulate an entitlement revocation (remove a skill from the fake client's entitled set) and confirm it disappears from `list_skills`/`get_skill` after both a sync cycle and, separately, via the query-time re-check before the next sync completes
|
||||
- [ ] 5.3 Resolve a flow-template skill's parameters via MCP, then manually drive the resulting step sequence through the existing `apex-agent-mvp` device-capability tools against a mocked device, confirming each step still goes through the normal Observe-Think-Act loop
|
||||
Reference in New Issue
Block a user