feat: honor the CPA workbook export contract#29
Conversation
There was a problem hiding this comment.
Pull request overview
This PR rebuilds the CPA workbook export to match the canonical ledger-core workbook contract and introduces a code-first MCP contract module that generates/validates the published 7-tool ledgerr_* surface (schemas + docs + demo script).
Changes:
- Rework
export_cpa_workbookto materialize allledger_core::workbook::REQUIRED_SHEETSand populate key sheets (META.config,ACCT.registry, schedule/flags,TX.*,AUDIT.log). - Collapse the advertised MCP surface to 7 top-level
ledgerr_*tools with requiredaction, backed by a newcontract.rsthat generates schemas/docs/examples and adds drift tests. - Update e2e/tests/docs/scripts to use the reduced tool catalog and assert representative workbook contents (not just sheet presence).
Reviewed changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
xtask/src/main.rs |
Adds generate-mcp-artifacts command to write generated docs/scripts from Rust contract code. |
xtask/Cargo.toml |
Depends on ledgerr-mcp so xtask can call the contract generators. |
scripts/mcp_e2e.sh |
Points e2e script at ledgerr-mcp test target. |
scripts/mcp_cli_demo.sh |
Updates runnable MCP demo to the ledgerr_* + action contract. |
docs/mcp-capability-contract.md |
Replaced with generated capability contract doc for the reduced 7-tool surface. |
docs/claude-cowork-plugin-marketplace.md |
Updates references/commands for ledgerr-mcp server naming. |
docs/agent-mcp-runbook.md |
Replaced with generated runbook aligned to the reduced MCP surface. |
crates/ledgerr-mcp/tests/tax_assist_mcp_e2e.rs |
Adjusts tools/list expectations to ledgerr_tax. |
crates/ledgerr-mcp/tests/reconciliation_mcp_e2e.rs |
Adjusts tools/list expectations to ledgerr_reconciliation. |
crates/ledgerr-mcp/tests/plugin_info_mcp_e2e.rs |
Moves plugin info under ledgerr_workflow + schema assertions. |
crates/ledgerr-mcp/tests/phase5_cpa_outputs.rs |
Strengthens workbook export tests to check required sheets + representative contents. |
crates/ledgerr-mcp/tests/ontology_mcp_e2e.rs |
Adjusts tools/list expectations to ledgerr_ontology. |
crates/ledgerr-mcp/tests/mcp_stdio_e2e.rs |
Updates transport e2e to call ledgerr_documents with action. |
crates/ledgerr-mcp/tests/mcp_adapter_contract.rs |
Updates contract assertions to the reduced 7-tool catalog. |
crates/ledgerr-mcp/tests/hsm_mcp_e2e.rs |
Adjusts tools/list expectations to ledgerr_workflow. |
crates/ledgerr-mcp/tests/events_mcp_e2e.rs |
Adjusts tools/list expectations to ledgerr_audit. |
crates/ledgerr-mcp/tests/contract_codegen.rs |
New tests enforcing doc/script generation drift checks and compatibility parsing behaviors. |
crates/ledgerr-mcp/src/mcp_adapter.rs |
Refactors tool dispatch to parse action-tagged args via contract.rs and expose only the 7 tools. |
crates/ledgerr-mcp/src/lib.rs |
Implements canonical workbook export sheet set + content population and reuses schedule-summary logic. |
crates/ledgerr-mcp/src/contract.rs |
New canonical MCP contract module with schemars-based schemas + generated docs/scripts. |
crates/ledgerr-mcp/src/bin/mcp-outcome-test.rs |
Updates outcome flow to new tool names + action-based calls. |
crates/ledgerr-mcp/src/bin/ledgerr-mcp-server.rs |
Routes tools/call to the new 7-tool dispatch; keeps legacy aliases as compatibility paths. |
crates/ledgerr-mcp/Cargo.toml |
Adds schemars dependency for schema generation. |
README.md |
Updates README statements to match reduced 7-tool MCP surface. |
Cargo.lock |
Locks new schemars (and transitive) dependencies. |
AGENTS.md |
Documents the “7-tool surface + action” rule and generated artifact workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
| pub struct PluginInfoSubcommand(pub String); | ||
|
|
||
| impl JsonSchema for PluginInfoSubcommand { | ||
| fn schema_name() -> String { | ||
| "PluginInfoSubcommand".to_string() | ||
| } | ||
|
|
||
| fn json_schema(_gen: &mut schemars::gen::SchemaGenerator) -> Schema { | ||
| Schema::Object(SchemaObject { | ||
| instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::String))), | ||
| enum_values: Some(vec![json!("check"), json!("upgrade"), json!("cleanup")]), | ||
| metadata: Some(Box::new(Metadata { | ||
| description: Some("Recognized values are check, upgrade, and cleanup. Unknown strings intentionally fall through to the default check behavior.".to_string()), | ||
| ..Metadata::default() | ||
| })), | ||
| ..SchemaObject::default() | ||
| }) |
There was a problem hiding this comment.
PluginInfoSubcommand's JSON Schema declares an enum of only check|upgrade|cleanup, but the contract/tests explicitly rely on accepting unknown strings (Postel boundary) and treating them as default behavior. As-is, schema-driven clients/validators may reject unknown subcommands even though the parser accepts them. Consider removing enum_values (keep type: string + description), or using a oneOf that allows any string while documenting the known values.
| @@ -1180,19 +1213,17 @@ impl TurboLedgerTools for TurboLedgerService { | |||
|
|
|||
There was a problem hiding this comment.
export_cpa_workbook holds classification_state's mutex for the entire workbook build and disk write. Writing XLSX files can be relatively slow, so this can unnecessarily block concurrent calls (e.g., classification/audit queries) and makes latency spikes more likely. Consider cloning the specific data needed for export (tx_rows, classifications, audit_log, etc.) while the lock is held, then dropping the lock before generating/saving the workbook.
| - Plugin manifest: [plugin.json](/home/brianh/promptexecution/mbse/l3dg3rr/plugins/l3dg3rr-plugin-create/.claude-plugin/plugin.json) | ||
| - Plugin skill: [SKILL.md](/home/brianh/promptexecution/mbse/l3dg3rr/plugins/l3dg3rr-plugin-create/skills/plugin-create-for-l3dg3rr/SKILL.md) | ||
| - MCP server entrypoint: [turbo-mcp-server.rs](/home/brianh/promptexecution/mbse/l3dg3rr/crates/turbo-mcp/src/bin/turbo-mcp-server.rs) | ||
| - MCP server entrypoint: [ledgerr-mcp-server.rs](/mnt/c/users/wendy/l3dg3rr/crates/ledgerr-mcp/src/bin/ledgerr-mcp-server.rs) |
There was a problem hiding this comment.
This link is a machine-specific absolute path (/mnt/c/users/...) which won't resolve for other contributors or in GitHub rendering. Prefer a repo-relative link (e.g. crates/ledgerr-mcp/src/bin/ledgerr-mcp-server.rs) to keep the documentation portable.
… read generated artifacts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/PromptExecution/l3dg3rr/sessions/76fb51c3-ff13-4b63-b92c-cb66416ad797 Co-authored-by: elasticdotventures <35611074+elasticdotventures@users.noreply.github.com>
Applied all three changes in commit 290dcb1:
All 73 tests pass. |
Closes #21
Summary
ledger-coreMETA.config,ACCT.registry, schedule sheets, flags, transaction sheets, andAUDIT.logValidation
cargo test -p ledgerr-mcpjust test