Skip to content

feat: honor the CPA workbook export contract#29

Merged
elasticdotventures merged 6 commits into
mainfrom
codex-issue-21-workbook-contract
Apr 17, 2026
Merged

feat: honor the CPA workbook export contract#29
elasticdotventures merged 6 commits into
mainfrom
codex-issue-21-workbook-contract

Conversation

@elasticdotventures
Copy link
Copy Markdown
Member

Closes #21

Summary

  • rebuild the CPA workbook export against the canonical workbook contract from ledger-core
  • populate META.config, ACCT.registry, schedule sheets, flags, transaction sheets, and AUDIT.log
  • strengthen workbook tests to assert representative exported contents instead of only sheet presence

Validation

  • cargo test -p ledgerr-mcp
  • just test

Comment thread crates/ledgerr-mcp/src/contract.rs Fixed
Comment thread crates/ledgerr-mcp/src/contract.rs Fixed
@elasticdotventures elasticdotventures marked this pull request as ready for review April 17, 2026 09:19
Copilot AI review requested due to automatic review settings April 17, 2026 09:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_workbook to materialize all ledger_core::workbook::REQUIRED_SHEETS and populate key sheets (META.config, ACCT.registry, schedule/flags, TX.*, AUDIT.log).
  • Collapse the advertised MCP surface to 7 top-level ledgerr_* tools with required action, backed by a new contract.rs that 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.

Comment on lines +149 to +166
#[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()
})
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread crates/ledgerr-mcp/src/lib.rs Outdated
Comment on lines 1209 to 1213
@@ -1180,19 +1213,17 @@ impl TurboLedgerTools for TurboLedgerService {

Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
- 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)
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
… read generated artifacts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elasticdotventures
Copy link
Copy Markdown
Member Author

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

@copilot apply changes based on the comments in this thread

Applied all three changes in commit 290dcb1:

  1. PluginInfoSubcommand schema (contract.rs:149-166): Removed the closed enum_values, keeping type: string with a description listing the known values (check, upgrade, cleanup). Schema-driven clients see the documented values while the parser still accepts any string.

  2. Mutex scope in export_cpa_workbook (lib.rs:1209-1213): Clones tx_rows, classifications, audit_log, and both flag snapshots while holding the lock, then drops the lock before building and saving the workbook. The slow XLSX write no longer blocks concurrent callers.

  3. Absolute path in docs (claude-cowork-plugin-marketplace.md:15): Replaced the machine-specific /mnt/c/users/wendy/... path with a repo-relative link (crates/ledgerr-mcp/src/bin/ledgerr-mcp-server.rs).

All 73 tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make CPA workbook export honor the canonical workbook contract

4 participants