meguro-mcp 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +63 -25
- package/RELEASING.md +10 -5
- package/package.json +1 -1
- package/src/admin-versions.generated.mjs +32 -0
- package/src/docs.mjs +641 -11
- package/src/protocol.mjs +37 -0
- package/src/server.mjs +25 -8
- package/src/tools.mjs +729 -89
package/src/docs.mjs
CHANGED
|
@@ -1,15 +1,49 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import {
|
|
3
|
+
ADMIN_API_DEFAULT_VERSION,
|
|
4
|
+
ADMIN_API_SUPPORTED_VERSIONS,
|
|
5
|
+
ADMIN_API_VERSION_REGISTRY,
|
|
6
|
+
} from './admin-versions.generated.mjs';
|
|
2
7
|
|
|
3
8
|
const RECEIPT_GUIDE_VERSION = 1;
|
|
4
|
-
const
|
|
9
|
+
const RECEIPT_GUIDE_V2_VERSION = 2;
|
|
10
|
+
const RECEIPT_GUIDE_V3_VERSION = 3;
|
|
11
|
+
const RECEIPT_GUIDE_V4_VERSION = 4;
|
|
12
|
+
const RECEIPT_GUIDE_LATEST_VERSION = 5;
|
|
13
|
+
const RECEIPT_GUIDE_V6_VERSION = 6;
|
|
14
|
+
const RECEIPT_GUIDE_V7_VERSION = 7;
|
|
5
15
|
const GATE_POLICY_VERSION = 1;
|
|
16
|
+
const GATE_POLICY_V2_VERSION = 2;
|
|
6
17
|
const GETTING_STARTED_VERSION = 1;
|
|
18
|
+
const GETTING_STARTED_V2_VERSION = 2;
|
|
19
|
+
const GETTING_STARTED_LATEST_VERSION = 3;
|
|
20
|
+
const GETTING_STARTED_V4_VERSION = 4;
|
|
21
|
+
const GETTING_STARTED_V5_VERSION = 5;
|
|
22
|
+
const GETTING_STARTED_V6_VERSION = 6;
|
|
23
|
+
const PRODUCT_GUIDE_VERSION = 1;
|
|
24
|
+
const PRODUCT_GUIDE_V2_VERSION = 2;
|
|
25
|
+
const PRODUCT_GUIDE_V3_VERSION = 3;
|
|
7
26
|
const RECEIPT_GUIDE_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_VERSION}`;
|
|
27
|
+
const RECEIPT_GUIDE_V2_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_V2_VERSION}`;
|
|
28
|
+
const RECEIPT_GUIDE_V3_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_V3_VERSION}`;
|
|
29
|
+
const RECEIPT_GUIDE_V4_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_V4_VERSION}`;
|
|
8
30
|
const RECEIPT_GUIDE_LATEST_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_LATEST_VERSION}`;
|
|
31
|
+
const RECEIPT_GUIDE_V6_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_V6_VERSION}`;
|
|
32
|
+
const RECEIPT_GUIDE_V7_URI = `meguro://docs/receipt-guide/v${RECEIPT_GUIDE_V7_VERSION}`;
|
|
9
33
|
const GATE_POLICY_URI = `meguro://docs/gate-policy/v${GATE_POLICY_VERSION}`;
|
|
34
|
+
const GATE_POLICY_V2_URI = `meguro://docs/gate-policy/v${GATE_POLICY_V2_VERSION}`;
|
|
10
35
|
const GETTING_STARTED_URI = `meguro://docs/getting-started/v${GETTING_STARTED_VERSION}`;
|
|
11
|
-
|
|
12
|
-
|
|
36
|
+
const GETTING_STARTED_V2_URI = `meguro://docs/getting-started/v${GETTING_STARTED_V2_VERSION}`;
|
|
37
|
+
const GETTING_STARTED_LATEST_URI = `meguro://docs/getting-started/v${GETTING_STARTED_LATEST_VERSION}`;
|
|
38
|
+
const GETTING_STARTED_V4_URI = `meguro://docs/getting-started/v${GETTING_STARTED_V4_VERSION}`;
|
|
39
|
+
const GETTING_STARTED_V5_URI = `meguro://docs/getting-started/v${GETTING_STARTED_V5_VERSION}`;
|
|
40
|
+
const GETTING_STARTED_V6_URI = `meguro://docs/getting-started/v${GETTING_STARTED_V6_VERSION}`;
|
|
41
|
+
const PRODUCT_GUIDE_URI = `meguro://docs/product-guide/v${PRODUCT_GUIDE_VERSION}`;
|
|
42
|
+
const PRODUCT_GUIDE_V2_URI = `meguro://docs/product-guide/v${PRODUCT_GUIDE_V2_VERSION}`;
|
|
43
|
+
const PRODUCT_GUIDE_V3_URI = `meguro://docs/product-guide/v${PRODUCT_GUIDE_V3_VERSION}`;
|
|
44
|
+
|
|
45
|
+
export const MCP_INITIALIZE_INSTRUCTIONS = `Start with \`${GETTING_STARTED_V6_URI}\` or call \`docs_read({ topic: "getting-started", version: 6 })\`; for general Meguro questions, read \`${PRODUCT_GUIDE_V3_URI}\` or call \`docs_read({ topic: "product-guide", version: 3 })\`.`;
|
|
46
|
+
export const PRODUCT_GUIDE_SHA256 = 'e5450c1b4181cec4d6ed0a498dbff1cb25d2e223ff2228928aecbbce9674f074';
|
|
13
47
|
|
|
14
48
|
function deepFreeze(value) {
|
|
15
49
|
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
|
|
@@ -535,6 +569,79 @@ const RECEIPT_FIELDS = deepFreeze({
|
|
|
535
569
|
]),
|
|
536
570
|
});
|
|
537
571
|
|
|
572
|
+
const RECEIPT_FIELDS_V3 = deepFreeze({
|
|
573
|
+
...RECEIPT_FIELDS,
|
|
574
|
+
'meguro.shared-receipt.v2': stableFields([
|
|
575
|
+
...RECEIPT_FIELDS['meguro.shared-receipt.v2'],
|
|
576
|
+
'rejectionAttribution.acceptedCalls',
|
|
577
|
+
'rejectionAttribution.allCallsRejected',
|
|
578
|
+
'rejectionAttribution.classification',
|
|
579
|
+
'rejectionAttribution.evidenceSource',
|
|
580
|
+
'rejectionAttribution.explanation',
|
|
581
|
+
'rejectionAttribution.field',
|
|
582
|
+
'rejectionAttribution.gateStatus',
|
|
583
|
+
'rejectionAttribution.headline',
|
|
584
|
+
'rejectionAttribution.operation',
|
|
585
|
+
'rejectionAttribution.reasonCode',
|
|
586
|
+
'rejectionAttribution.rejectedCalls',
|
|
587
|
+
'rejectionAttribution.requiresReview',
|
|
588
|
+
'rejectionAttribution.responsibleLayer',
|
|
589
|
+
'rejectionAttribution.schemaVersion',
|
|
590
|
+
'rejectionAttribution.targetValidity',
|
|
591
|
+
]),
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
const FINANCIAL_SOURCE_FIELDS = [
|
|
595
|
+
'revenueCents',
|
|
596
|
+
'refundedCents',
|
|
597
|
+
'netRevenueCents',
|
|
598
|
+
'cogsCents',
|
|
599
|
+
'costLedgerCents',
|
|
600
|
+
'wrongfulDeclinePenaltyCents',
|
|
601
|
+
'storeCreditNetCostCents',
|
|
602
|
+
'freeShippingSubsidyCents',
|
|
603
|
+
'orderRiskCostCents',
|
|
604
|
+
'inventoryTransferCostCents',
|
|
605
|
+
'catalogQualityImprovementCostCents',
|
|
606
|
+
'loyaltyExpectedRedemptionCostCents',
|
|
607
|
+
'winbackOfferCostCents',
|
|
608
|
+
'cartRecoveryCostCents',
|
|
609
|
+
'fulfillmentCostCents',
|
|
610
|
+
'netContributionCents',
|
|
611
|
+
];
|
|
612
|
+
|
|
613
|
+
const RECEIPT_FIELDS_V5 = deepFreeze({
|
|
614
|
+
...RECEIPT_FIELDS_V3,
|
|
615
|
+
'meguro.hosted-impact-report.v1': stableFields([
|
|
616
|
+
...RECEIPT_FIELDS_V3['meguro.hosted-impact-report.v1'],
|
|
617
|
+
'effectLines[].sourceField',
|
|
618
|
+
...FINANCIAL_SOURCE_FIELDS.flatMap((field) => [
|
|
619
|
+
`financialSourceTotals.baseline.${field}`,
|
|
620
|
+
`financialSourceTotals.treated.${field}`,
|
|
621
|
+
]),
|
|
622
|
+
]),
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
const RECEIPT_FIELDS_LATEST = deepFreeze({
|
|
626
|
+
...RECEIPT_FIELDS_V5,
|
|
627
|
+
'meguro.tiktok-practice-receipt.v1': stableFields([
|
|
628
|
+
...RECEIPT_FIELDS_V5['meguro.tiktok-practice-receipt.v1']
|
|
629
|
+
.filter((field) => field !== 'rehearsalDigest' && field !== 'software.rehearsalProjectionVersion'),
|
|
630
|
+
'simulationDigest',
|
|
631
|
+
'software.simulationProjectionVersion',
|
|
632
|
+
]),
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
const RECEIPT_FIELDS_V7 = deepFreeze({
|
|
636
|
+
...RECEIPT_FIELDS_LATEST,
|
|
637
|
+
'meguro.hosted-impact-report.v1': stableFields([
|
|
638
|
+
...RECEIPT_FIELDS_LATEST['meguro.hosted-impact-report.v1'],
|
|
639
|
+
'dailyMetricBasis.units',
|
|
640
|
+
'dailyMetricBasis.orders.customer_depth_model',
|
|
641
|
+
'dailyMetricBasis.orders.sold_units_proxy',
|
|
642
|
+
]),
|
|
643
|
+
});
|
|
644
|
+
|
|
538
645
|
const FIELD_MEANINGS = Object.freeze({
|
|
539
646
|
schemaVersion: 'Selects the immutable wire contract used to interpret the remaining fields.',
|
|
540
647
|
evidenceContext: 'Carries the declared subject, attempt history, and world provenance without verifying a customer-declared build identity.',
|
|
@@ -581,8 +688,8 @@ function fieldMeaning(schema, path) {
|
|
|
581
688
|
return `Recorded ${words(leaf)} in ${schema}; interpret it with that schema's basis and adjacent evidence fields.`;
|
|
582
689
|
}
|
|
583
690
|
|
|
584
|
-
function renderFieldInventory() {
|
|
585
|
-
return Object.entries(
|
|
691
|
+
function renderFieldInventory(fields = RECEIPT_FIELDS) {
|
|
692
|
+
return Object.entries(fields).map(([schema, paths]) => [
|
|
586
693
|
`### \`${schema}\``,
|
|
587
694
|
'',
|
|
588
695
|
...paths.map((path) => `- \`${path}\` — ${fieldMeaning(schema, path)}`),
|
|
@@ -673,9 +780,75 @@ retention policy.`;
|
|
|
673
780
|
// the MEG-622 account-deletion interpretation without mutating any previously citable resource.
|
|
674
781
|
const RECEIPT_GUIDE_V2_TEXT = RECEIPT_GUIDE_TEXT
|
|
675
782
|
.replace('# Meguro receipt guide v1', '# Meguro receipt guide v2')
|
|
676
|
-
.replace(`Published URI: \`${RECEIPT_GUIDE_URI}\``, `Published URI: \`${
|
|
783
|
+
.replace(`Published URI: \`${RECEIPT_GUIDE_URI}\``, `Published URI: \`${RECEIPT_GUIDE_V2_URI}\``)
|
|
677
784
|
.replace('## Field inventory', `${ACCOUNT_DELETION_GUIDE_TEXT}\n\n## Field inventory`);
|
|
678
785
|
|
|
786
|
+
const RECEIPT_GUIDE_V3_TEXT = RECEIPT_GUIDE_V2_TEXT
|
|
787
|
+
.replace('# Meguro receipt guide v2', '# Meguro receipt guide v3')
|
|
788
|
+
.replace(`Published URI: \`${RECEIPT_GUIDE_V2_URI}\``, `Published URI: \`${RECEIPT_GUIDE_V3_URI}\``)
|
|
789
|
+
.replace(renderFieldInventory(RECEIPT_FIELDS), renderFieldInventory(RECEIPT_FIELDS_V3));
|
|
790
|
+
|
|
791
|
+
const IMPACT_RECOMPUTATION_GUIDE_TEXT = `## Recomputing impact money figures
|
|
792
|
+
|
|
793
|
+
Every comparable \`meguro.hosted-impact-report.v1\` money effect line carries \`sourceField\`.
|
|
794
|
+
Recompute its \`amountCents\` as
|
|
795
|
+
\`financialSourceTotals.treated[sourceField] - financialSourceTotals.baseline[sourceField]\`.
|
|
796
|
+
The refund effect links to \`refundedCents\`; net revenue links to \`netRevenueCents\`; net
|
|
797
|
+
contribution links to \`netContributionCents\`.
|
|
798
|
+
|
|
799
|
+
For either arm, \`netRevenueCents = revenueCents - refundedCents\`. Net contribution is that net
|
|
800
|
+
revenue minus the same arm's COGS and every listed operating-cost component: \`costLedgerCents\`,
|
|
801
|
+
\`wrongfulDeclinePenaltyCents\`, \`storeCreditNetCostCents\`, \`freeShippingSubsidyCents\`,
|
|
802
|
+
\`orderRiskCostCents\`, \`inventoryTransferCostCents\`, \`catalogQualityImprovementCostCents\`,
|
|
803
|
+
\`loyaltyExpectedRedemptionCostCents\`, \`winbackOfferCostCents\`, \`cartRecoveryCostCents\`, and
|
|
804
|
+
\`fulfillmentCostCents\`. These are the source totals used by the verdict, not a second calculation.
|
|
805
|
+
|
|
806
|
+
When \`metricSource\` is \`sold_units_proxy\`, the count line is labeled as a net-units effect used
|
|
807
|
+
as a one-order-per-unit proxy. It is not an observed order count.`;
|
|
808
|
+
|
|
809
|
+
const RECEIPT_GUIDE_V4_TEXT = RECEIPT_GUIDE_V3_TEXT
|
|
810
|
+
.replace('# Meguro receipt guide v3', '# Meguro receipt guide v4')
|
|
811
|
+
.replace(`Published URI: \`${RECEIPT_GUIDE_V3_URI}\``, `Published URI: \`${RECEIPT_GUIDE_V4_URI}\``)
|
|
812
|
+
.replace('## Field inventory', `${IMPACT_RECOMPUTATION_GUIDE_TEXT}\n\n## Field inventory`)
|
|
813
|
+
.replace(renderFieldInventory(RECEIPT_FIELDS_V3), renderFieldInventory(RECEIPT_FIELDS_V5));
|
|
814
|
+
|
|
815
|
+
const PUBLIC_RECEIPT_DELIVERY_GUIDE_TEXT = `## Public receipt delivery
|
|
816
|
+
|
|
817
|
+
For every newly returned \`meguro.public-receipt-reference.v1\`, \`canonicalPath\` is the complete
|
|
818
|
+
environment-qualified HTTPS URL of the immutable artifact. Fetch that URL as-is without credentials;
|
|
819
|
+
do not join it to the MCP origin, Console origin, or another guessed host. The same rule applies to
|
|
820
|
+
the run reference in \`publicReceipt\` and the impact reference in \`impactPublicReceipt\`.
|
|
821
|
+
|
|
822
|
+
\`\`\`sh
|
|
823
|
+
curl --fail --silent --show-error "$CANONICAL_URL" --output receipt.json
|
|
824
|
+
printf '%s %s\\n' "$EXPECTED_SHA256" receipt.json | shasum -a 256 --check
|
|
825
|
+
\`\`\`
|
|
826
|
+
|
|
827
|
+
Unknown, malformed, foreign, expired, purged, and never-issued public ids return the same
|
|
828
|
+
\`receipt-unavailable\` response. Fetchability ends at the receipt-availability window stated by the
|
|
829
|
+
live product response; retain the exact bytes in your own evidence store when longer custody is
|
|
830
|
+
required.`;
|
|
831
|
+
|
|
832
|
+
// Published documentation is append-only. V1-V4 retain their original bytes and digests; V5 binds
|
|
833
|
+
// the canonical receipt reference to the selected environment's public API without an undefined
|
|
834
|
+
// out-of-band MEGURO_ORIGIN variable.
|
|
835
|
+
const RECEIPT_GUIDE_V5_TEXT = RECEIPT_GUIDE_V4_TEXT
|
|
836
|
+
.replace('# Meguro receipt guide v4', '# Meguro receipt guide v5')
|
|
837
|
+
.replace(`Published URI: \`${RECEIPT_GUIDE_V4_URI}\``, `Published URI: \`${RECEIPT_GUIDE_LATEST_URI}\``)
|
|
838
|
+
.replace('## Independent exact-byte verification', `${PUBLIC_RECEIPT_DELIVERY_GUIDE_TEXT}\n\n## Independent exact-byte verification`)
|
|
839
|
+
.replace(
|
|
840
|
+
'`publicReceipt.canonicalPath` without credentials, preserve the exact response bytes, compute',
|
|
841
|
+
'`publicReceipt.canonicalPath` as a complete URL without credentials, preserve the exact response bytes, compute',
|
|
842
|
+
)
|
|
843
|
+
.replace(
|
|
844
|
+
'curl --fail --silent --show-error "$MEGURO_ORIGIN$CANONICAL_PATH" --output receipt.json',
|
|
845
|
+
'curl --fail --silent --show-error "$CANONICAL_URL" --output receipt.json',
|
|
846
|
+
)
|
|
847
|
+
.replace(
|
|
848
|
+
'The unauthenticated path from which an independent reader fetches the exact issued bytes.',
|
|
849
|
+
'The complete environment-qualified HTTPS URL from which an independent reader fetches the exact issued bytes without credentials.',
|
|
850
|
+
);
|
|
851
|
+
|
|
679
852
|
export const GATE_POLICY_V1_CHECKS = deepFreeze([
|
|
680
853
|
{
|
|
681
854
|
name: 'blocked-write and error evidence',
|
|
@@ -810,8 +983,278 @@ All published documentation resources are immutable. Cite the exact URI, version
|
|
|
810
983
|
digest returned by Meguro.
|
|
811
984
|
`;
|
|
812
985
|
|
|
986
|
+
const GETTING_STARTED_V2_TEXT = GETTING_STARTED_TEXT
|
|
987
|
+
.replace('# Getting started with Meguro v1', '# Getting started with Meguro v2')
|
|
988
|
+
.replace(`Published URI: \`${GETTING_STARTED_URI}\``, `Published URI: \`${GETTING_STARTED_V2_URI}\``)
|
|
989
|
+
.replace(
|
|
990
|
+
' account-scoped `MEGURO_API_TOKEN` and cannot control other stores or account resources.',
|
|
991
|
+
` account-scoped \`MEGURO_API_TOKEN\` and cannot control other stores or account resources.
|
|
992
|
+
|
|
993
|
+
This practice store emulates Shopify Admin GraphQL \`2026-04\`. If your agent targets a newer
|
|
994
|
+
Shopify release, call \`admin_schema\` to inspect the modeled contract before issuing the first
|
|
995
|
+
Admin call; newer-release behavior is not established by a \`2026-04\` practice result.
|
|
996
|
+
`,
|
|
997
|
+
);
|
|
998
|
+
|
|
999
|
+
const GETTING_STARTED_V3_TEXT = GETTING_STARTED_V2_TEXT
|
|
1000
|
+
.replace('# Getting started with Meguro v2', '# Getting started with Meguro v3')
|
|
1001
|
+
.replace(`Published URI: \`${GETTING_STARTED_V2_URI}\``, `Published URI: \`${GETTING_STARTED_LATEST_URI}\``)
|
|
1002
|
+
.replace(
|
|
1003
|
+
` This practice store emulates Shopify Admin GraphQL \`2026-04\`. If your agent targets a newer
|
|
1004
|
+
Shopify release, call \`admin_schema\` to inspect the modeled contract before issuing the first
|
|
1005
|
+
Admin call; newer-release behavior is not established by a \`2026-04\` practice result.
|
|
1006
|
+
`,
|
|
1007
|
+
` The supported Shopify Admin GraphQL versions are ${ADMIN_API_SUPPORTED_VERSIONS.map((version) => `\`${version}\``).join(' and ')}; the
|
|
1008
|
+
default is \`${ADMIN_API_DEFAULT_VERSION}\`. Read \`adminApiVersion\` for the default,
|
|
1009
|
+
\`adminApiVersions\` for the supported set, and \`adminVersions\` for the exact versioned Admin URLs.
|
|
1010
|
+
Use the URL whose version segment matches your agent. Call \`admin_schema\` with that version before
|
|
1011
|
+
issuing the first Admin call; valid Shopify additions outside Meguro's modeled subset return an
|
|
1012
|
+
explicit teaching refusal rather than approximate behavior.
|
|
1013
|
+
`,
|
|
1014
|
+
);
|
|
1015
|
+
|
|
1016
|
+
const PRODUCT_GUIDE_TEXT = `# Meguro product guide v1
|
|
1017
|
+
|
|
1018
|
+
Published URI: \`${PRODUCT_GUIDE_URI}\`
|
|
1019
|
+
|
|
1020
|
+
## What Meguro is—and is not
|
|
1021
|
+
|
|
1022
|
+
Meguro is a technical evaluation environment for commerce agents. Its core product primitives are
|
|
1023
|
+
practice stores, deterministic Store time, recorded API behavior, immutable receipts, and Gate
|
|
1024
|
+
evidence.
|
|
1025
|
+
|
|
1026
|
+
Practice results do not prove live-market demand, future revenue, production performance, or live
|
|
1027
|
+
Shopify acceptance. Live-platform claims are established only by the relevant real-platform or
|
|
1028
|
+
Shopify Exam evidence; never infer them from practice compatibility or modeled outcomes.
|
|
1029
|
+
|
|
1030
|
+
## Core nouns
|
|
1031
|
+
|
|
1032
|
+
- **Template:** a supported, versioned starting scenario used to create a practice store.
|
|
1033
|
+
- **Practice store / \`storeId\`:** an owned synthetic commerce environment and its canonical public
|
|
1034
|
+
identifier. It is not a merchant's production store.
|
|
1035
|
+
- **Store time:** the deterministic scenario clock advanced through the run lifecycle. It is distinct
|
|
1036
|
+
from wall-clock request time.
|
|
1037
|
+
- **Run / \`attemptId\`:** one bounded evaluation window and the identifier used by its lifecycle,
|
|
1038
|
+
status, and evidence tools.
|
|
1039
|
+
- **Receipt:** the immutable record of what the agent called, what was accepted or rejected, and what
|
|
1040
|
+
the declared evidence establishes. For field-level interpretation, read
|
|
1041
|
+
\`meguro://docs/receipt-guide/v1\` or \`meguro://docs/receipt-guide/v2\`.
|
|
1042
|
+
- **Modeled outcome / Impact context:** scenario-derived context that compares recorded behavior with
|
|
1043
|
+
a declared model. It is not a merchant forecast, causal claim, or production result.
|
|
1044
|
+
- **Gate:** a release signal computed from named receipt facts, thresholds, and precedence. For the
|
|
1045
|
+
exact policy, read \`meguro://docs/gate-policy/v1\`.
|
|
1046
|
+
- **Shopify Exam:** a captured API-shape fidelity exam against an eligible Shopify development store.
|
|
1047
|
+
Its evidence establishes only the bounded live-platform facts recorded by that exam, not blanket
|
|
1048
|
+
Shopify acceptance or merchant outcomes.
|
|
1049
|
+
|
|
1050
|
+
## Product surfaces and boundaries
|
|
1051
|
+
|
|
1052
|
+
- **Console** provides visual setup, receipt inspection, account administration, client revocation,
|
|
1053
|
+
plans, billing, and payment actions.
|
|
1054
|
+
- **Hosted OAuth MCP** is the recommended control plane for interactive agents.
|
|
1055
|
+
- **Public STDIO MCP** is the local and CI fallback.
|
|
1056
|
+
- **Practice-store Admin endpoint** is the Shopify-shaped data plane used by the commerce agent under
|
|
1057
|
+
evaluation; it is separate from the MCP control plane.
|
|
1058
|
+
- **MCP does not perform money actions:** it does not check out, buy or change a subscription, manage
|
|
1059
|
+
payment methods, or make another payment.
|
|
1060
|
+
|
|
1061
|
+
## Question-to-source routing
|
|
1062
|
+
|
|
1063
|
+
| User asks | Agent must do |
|
|
1064
|
+
|---|---|
|
|
1065
|
+
| What is Meguro or what does it prove? | Answer from this product guide and preserve its evidence boundary. |
|
|
1066
|
+
| How do I start an evaluation? | Read \`meguro://docs/getting-started/v1\`. |
|
|
1067
|
+
| What does this receipt or verdict mean? | Read the appropriate receipt guide and \`meguro://docs/gate-policy/v1\`. |
|
|
1068
|
+
| What stores exist? | Call \`stores_list\`. |
|
|
1069
|
+
| What runs exist or what happened? | Call \`runs_list\` and the relevant status, report, or impact tool. |
|
|
1070
|
+
| What workspaces exist? | Call \`workspaces_list\`. |
|
|
1071
|
+
| What is my current usage or cap? | Call \`usage_read\`; do not answer from static values. |
|
|
1072
|
+
| Which templates are available? | Call \`templates_list\`. |
|
|
1073
|
+
| How much does a plan cost, or how do I subscribe or change plans? | Direct the user to Console → Plans & Billing. Do not quote immutable pricing or attempt payment through MCP. |
|
|
1074
|
+
| How do I manage or revoke an MCP connection? | Direct the user to Console → Connection → MCP authorizations. |
|
|
1075
|
+
| How do I delete my account? | Direct the user to the Console-only account-deletion flow and [Meguro Help](https://meguro.io/help.html). |
|
|
1076
|
+
| Where can I learn more or get support? | Use [Meguro Help](https://meguro.io/help.html) or [hello@meguro.io](mailto:hello@meguro.io); do not invent another location. |
|
|
1077
|
+
|
|
1078
|
+
## Answering discipline
|
|
1079
|
+
|
|
1080
|
+
- Use live MCP tools for user-, workspace-, store-, run-, usage-, and template-specific facts.
|
|
1081
|
+
- Use immutable guides for stable concepts and evidence interpretation.
|
|
1082
|
+
- Use Console for money actions and explicitly Console-only account actions.
|
|
1083
|
+
- Never infer an undocumented capability, price, limit, legal conclusion, Shopify acceptance, or
|
|
1084
|
+
merchant outcome.
|
|
1085
|
+
- If neither an in-band document nor a tool result establishes the answer, say that it is not
|
|
1086
|
+
established and direct the user to Meguro Help or support.
|
|
1087
|
+
|
|
1088
|
+
## Stable concepts versus changing facts
|
|
1089
|
+
|
|
1090
|
+
Do not hardcode plan prices, current tier allowances, trial length, supported-country lists, current
|
|
1091
|
+
account state, or current fleet state. Read changing values from the appropriate live tool or the
|
|
1092
|
+
canonical Console surface.
|
|
1093
|
+
|
|
1094
|
+
Do not reproduce or interpret legal terms. Link to the canonical [Terms](https://meguro.io/terms) and
|
|
1095
|
+
[Privacy Notice](https://meguro.io/privacy).
|
|
1096
|
+
`;
|
|
1097
|
+
|
|
1098
|
+
function simulationVocabularyText(source) {
|
|
1099
|
+
const replacements = [
|
|
1100
|
+
['returns-rehearsal', 'returns-simulation'],
|
|
1101
|
+
['runConclusionReceipt', 'simulationRunReceipt'],
|
|
1102
|
+
['runConclusionClock', 'simulationRunClock'],
|
|
1103
|
+
['meguro.run-conclusion-receipt.v1', 'meguro.simulation-run-receipt.v1'],
|
|
1104
|
+
['meguro.run-conclusion-clock.v1', 'meguro.simulation-run-clock.v1'],
|
|
1105
|
+
['consumedCredits', 'consumedSimulationRuns'],
|
|
1106
|
+
['billableRuns', 'billableSimulationRuns'],
|
|
1107
|
+
['remainingCredits', 'remainingSimulationRuns'],
|
|
1108
|
+
['monthlyRunCredits', 'monthlySimulationRuns'],
|
|
1109
|
+
['run credits', 'simulation runs'],
|
|
1110
|
+
['run credit', 'simulation run'],
|
|
1111
|
+
['Run credits', 'Simulation runs'],
|
|
1112
|
+
['Run credit', 'Simulation run'],
|
|
1113
|
+
['Conclusions', 'Simulation runs'],
|
|
1114
|
+
['conclusions', 'simulation runs'],
|
|
1115
|
+
['Conclusion', 'Result'],
|
|
1116
|
+
['conclusion', 'result'],
|
|
1117
|
+
['Rehearsals', 'Simulations'],
|
|
1118
|
+
['rehearsals', 'simulations'],
|
|
1119
|
+
['Rehearsal', 'Simulation'],
|
|
1120
|
+
['rehearsal', 'simulation'],
|
|
1121
|
+
];
|
|
1122
|
+
let text = String(source);
|
|
1123
|
+
for (const [before, after] of replacements) text = text.split(before).join(after);
|
|
1124
|
+
return text;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
const GETTING_STARTED_V4_TEXT = simulationVocabularyText(
|
|
1128
|
+
GETTING_STARTED_V3_TEXT
|
|
1129
|
+
.replace('# Getting started with Meguro v3', '# Getting started with Meguro v4')
|
|
1130
|
+
.replace(`Published URI: \`${GETTING_STARTED_LATEST_URI}\``, `Published URI: \`${GETTING_STARTED_V4_URI}\``),
|
|
1131
|
+
);
|
|
1132
|
+
const ADMIN_VERSION_POLICY_GUIDE_TEXT = [
|
|
1133
|
+
'## Shopify Admin version policy',
|
|
1134
|
+
'',
|
|
1135
|
+
"Meguro checks Shopify's official version schedule weekly and opens a migration ticket when a new",
|
|
1136
|
+
"stable Admin release appears. Meguro mirrors Shopify's published accessible-until window; it does",
|
|
1137
|
+
'not make an independent support-window promise.',
|
|
1138
|
+
'',
|
|
1139
|
+
...ADMIN_API_VERSION_REGISTRY.map((entry) => {
|
|
1140
|
+
const released = `${entry.releaseDate.slice(0, 10)} ${entry.releaseDate.slice(11, 16)} UTC`;
|
|
1141
|
+
const supportedUntil = `${entry.supportedUntil.slice(0, 10)} ${entry.supportedUntil.slice(11, 16)} UTC`;
|
|
1142
|
+
return `- \`${entry.apiVersion}\`: released ${released}; accessible until ${supportedUntil}.`;
|
|
1143
|
+
}),
|
|
1144
|
+
'',
|
|
1145
|
+
`Source: [Shopify API versioning](${ADMIN_API_VERSION_REGISTRY[0]?.supportSourceUrl}).`,
|
|
1146
|
+
].join('\n');
|
|
1147
|
+
const GETTING_STARTED_V5_TEXT = GETTING_STARTED_V4_TEXT
|
|
1148
|
+
.replace('# Getting started with Meguro v4', '# Getting started with Meguro v5')
|
|
1149
|
+
.replace(`Published URI: \`${GETTING_STARTED_V4_URI}\``, `Published URI: \`${GETTING_STARTED_V5_URI}\``)
|
|
1150
|
+
.replace('## Control and data planes', `${ADMIN_VERSION_POLICY_GUIDE_TEXT}\n\n## Control and data planes`);
|
|
1151
|
+
const PRODUCT_GUIDE_V2_TEXT = simulationVocabularyText(
|
|
1152
|
+
PRODUCT_GUIDE_TEXT
|
|
1153
|
+
.replace('# Meguro product guide v1', '# Meguro product guide v2')
|
|
1154
|
+
.replace(`Published URI: \`${PRODUCT_GUIDE_URI}\``, `Published URI: \`${PRODUCT_GUIDE_V2_URI}\``),
|
|
1155
|
+
);
|
|
1156
|
+
const GETTING_STARTED_V6_TEXT = GETTING_STARTED_V5_TEXT
|
|
1157
|
+
.replace('# Getting started with Meguro v5', '# Getting started with Meguro v6')
|
|
1158
|
+
.replace(`Published URI: \`${GETTING_STARTED_V5_URI}\``, `Published URI: \`${GETTING_STARTED_V6_URI}\``)
|
|
1159
|
+
.replace(
|
|
1160
|
+
/## What Meguro is\n\n[\s\S]*?\n\n## Identities/u,
|
|
1161
|
+
`## Begin with the world
|
|
1162
|
+
|
|
1163
|
+
Meguro gives your agent a practice store with a year of modeled commerce history already behind it.
|
|
1164
|
+
When a run drives or schedules Store time, the store moves through Store days; between runs, its
|
|
1165
|
+
Store time stays frozen. The receipt is the store's memory of that run: the calls it heard, the
|
|
1166
|
+
changes it accepted or rejected, and the bounded evidence those events established.
|
|
1167
|
+
|
|
1168
|
+
This is a deterministic practice world, not a merchant forecast or blanket certification of live
|
|
1169
|
+
platform behavior. Preserve every stated evidence boundary when you carry a receipt into a release
|
|
1170
|
+
decision.
|
|
1171
|
+
|
|
1172
|
+
## Identities`,
|
|
1173
|
+
)
|
|
1174
|
+
.replace(
|
|
1175
|
+
'## Canonical discovery-first sequence',
|
|
1176
|
+
`## What requires your human
|
|
1177
|
+
|
|
1178
|
+
Your human owns the Meguro account, chooses or changes the plan, and grants the agent access by
|
|
1179
|
+
completing hosted OAuth or by creating and supplying a workspace API key. The agent must never buy
|
|
1180
|
+
or change a plan, consent on the human's behalf, or invent or recover a credential. After that grant,
|
|
1181
|
+
the agent can discover templates and stores, run the world, and retrieve its receipt through MCP.
|
|
1182
|
+
|
|
1183
|
+
## Canonical discovery-first sequence`,
|
|
1184
|
+
);
|
|
1185
|
+
const PRODUCT_GUIDE_V3_TEXT = PRODUCT_GUIDE_V2_TEXT
|
|
1186
|
+
.replace('# Meguro product guide v2', '# Meguro product guide v3')
|
|
1187
|
+
.replace(`Published URI: \`${PRODUCT_GUIDE_V2_URI}\``, `Published URI: \`${PRODUCT_GUIDE_V3_URI}\``)
|
|
1188
|
+
.replace(
|
|
1189
|
+
/## What Meguro is—and is not\n\n[\s\S]*?\n\n## Core nouns/u,
|
|
1190
|
+
`## Begin with the world
|
|
1191
|
+
|
|
1192
|
+
Meguro gives a commerce agent a practice store with a year of modeled commerce history already
|
|
1193
|
+
behind it. The store moves through Store days only while a run drives or schedules its clock, and it
|
|
1194
|
+
stays frozen between runs. The receipt is the store's memory of that run: recorded API behavior,
|
|
1195
|
+
accepted and rejected changes, and the bounded evidence earned inside the declared world.
|
|
1196
|
+
|
|
1197
|
+
Practice results do not prove live-market demand, future revenue, production performance, or live
|
|
1198
|
+
Shopify acceptance. Live-platform claims require the relevant real-platform or Shopify Exam evidence;
|
|
1199
|
+
never infer them from practice compatibility or modeled outcomes.
|
|
1200
|
+
|
|
1201
|
+
## Core nouns`,
|
|
1202
|
+
)
|
|
1203
|
+
.replace(
|
|
1204
|
+
'## Question-to-source routing',
|
|
1205
|
+
`## What requires your human
|
|
1206
|
+
|
|
1207
|
+
Your human creates and owns the account, chooses or changes its plan, and grants agent access by
|
|
1208
|
+
completing hosted OAuth or by creating and supplying a workspace API key. MCP does not buy or change
|
|
1209
|
+
a plan, consent for the human, or reveal a credential that the human has not granted.
|
|
1210
|
+
|
|
1211
|
+
## Question-to-source routing`,
|
|
1212
|
+
)
|
|
1213
|
+
.replace('Read \`meguro://docs/getting-started/v1\`.', `Read \`${GETTING_STARTED_V6_URI}\`.`);
|
|
1214
|
+
const RECEIPT_GUIDE_V6_TEXT = simulationVocabularyText(
|
|
1215
|
+
RECEIPT_GUIDE_V5_TEXT
|
|
1216
|
+
.replace('# Meguro receipt guide v5', '# Meguro receipt guide v6')
|
|
1217
|
+
.replace(`Published URI: \`${RECEIPT_GUIDE_LATEST_URI}\``, `Published URI: \`${RECEIPT_GUIDE_V6_URI}\``),
|
|
1218
|
+
);
|
|
1219
|
+
const DAILY_METRIC_BASIS_GUIDE_TEXT = [
|
|
1220
|
+
'## Daily signed net-unit basis',
|
|
1221
|
+
'',
|
|
1222
|
+
'Every `meguro.hosted-impact-report.v1` carries `dailyMetricBasis` beside `days`. Render or',
|
|
1223
|
+
'retain those exact strings when interpreting the daily columns.',
|
|
1224
|
+
'',
|
|
1225
|
+
'`days[].units` is signed net units in the simulation: sold units minus returned units. It may be',
|
|
1226
|
+
'negative when returns exceed sales. When `days[].orderMetricSource` is',
|
|
1227
|
+
'`sold_units_proxy`, `days[].orders` is that same signed net-unit value used as a',
|
|
1228
|
+
'one-order-per-net-unit proxy; it is not an observed order count and may also be negative. When the',
|
|
1229
|
+
'source is `customer_depth_model`, `days[].orders` is the separate modeled order count and is not',
|
|
1230
|
+
'netted against returns.',
|
|
1231
|
+
].join('\n');
|
|
1232
|
+
function replaceDerivedFieldInventory(source, fields) {
|
|
1233
|
+
const headingIndex = source.indexOf('## Field inventory');
|
|
1234
|
+
const firstSchemaIndex = source.indexOf('\n### `', headingIndex);
|
|
1235
|
+
if (headingIndex < 0 || firstSchemaIndex < 0) {
|
|
1236
|
+
throw new Error('Receipt guide field inventory is missing');
|
|
1237
|
+
}
|
|
1238
|
+
return `${source.slice(0, firstSchemaIndex + 1)}${simulationVocabularyText(renderFieldInventory(fields))}`;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
const RECEIPT_GUIDE_V7_WITH_BASIS = RECEIPT_GUIDE_V6_TEXT
|
|
1242
|
+
.replace('# Meguro receipt guide v6', '# Meguro receipt guide v7')
|
|
1243
|
+
.replace('Published URI: `' + RECEIPT_GUIDE_V6_URI + '`', 'Published URI: `' + RECEIPT_GUIDE_V7_URI + '`')
|
|
1244
|
+
.replace('## Field inventory', `${DAILY_METRIC_BASIS_GUIDE_TEXT}\n\n## Field inventory`);
|
|
1245
|
+
const RECEIPT_GUIDE_V7_TEXT = replaceDerivedFieldInventory(RECEIPT_GUIDE_V7_WITH_BASIS, RECEIPT_FIELDS_V7);
|
|
1246
|
+
const GATE_POLICY_V2_TEXT = simulationVocabularyText(
|
|
1247
|
+
GATE_POLICY_TEXT
|
|
1248
|
+
.replace('# Meguro Gate policy v1', '# Meguro Gate policy v2')
|
|
1249
|
+
.replace(`Published URI: \`${GATE_POLICY_URI}\``, `Published URI: \`${GATE_POLICY_V2_URI}\``),
|
|
1250
|
+
);
|
|
1251
|
+
|
|
813
1252
|
function entry(input) {
|
|
814
1253
|
const text = String(input.text);
|
|
1254
|
+
const digest = sha256(text);
|
|
1255
|
+
if (input.expectedSha256 && input.expectedSha256 !== digest) {
|
|
1256
|
+
throw new Error(`Documentation digest drift for ${input.uri}: expected ${input.expectedSha256}, received ${digest}`);
|
|
1257
|
+
}
|
|
815
1258
|
return deepFreeze({
|
|
816
1259
|
topic: input.topic,
|
|
817
1260
|
version: input.version,
|
|
@@ -821,7 +1264,7 @@ function entry(input) {
|
|
|
821
1264
|
description: input.description,
|
|
822
1265
|
mimeType: 'text/markdown',
|
|
823
1266
|
text,
|
|
824
|
-
sha256:
|
|
1267
|
+
sha256: digest,
|
|
825
1268
|
});
|
|
826
1269
|
}
|
|
827
1270
|
|
|
@@ -875,6 +1318,79 @@ const CATALOG = buildDocumentationCatalog([
|
|
|
875
1318
|
description: 'Discovery-first technical-evaluator sequence from template selection through an immutable practice receipt.',
|
|
876
1319
|
text: GETTING_STARTED_TEXT,
|
|
877
1320
|
},
|
|
1321
|
+
{
|
|
1322
|
+
topic: 'getting-started',
|
|
1323
|
+
version: GETTING_STARTED_V2_VERSION,
|
|
1324
|
+
uri: GETTING_STARTED_V2_URI,
|
|
1325
|
+
name: 'Getting started with Meguro v2',
|
|
1326
|
+
title: 'Getting started with Meguro v2',
|
|
1327
|
+
description: 'Discovery-first evaluator sequence with the explicit Shopify Admin GraphQL 2026-04 boundary.',
|
|
1328
|
+
text: GETTING_STARTED_V2_TEXT,
|
|
1329
|
+
},
|
|
1330
|
+
{
|
|
1331
|
+
topic: 'getting-started',
|
|
1332
|
+
version: GETTING_STARTED_LATEST_VERSION,
|
|
1333
|
+
uri: GETTING_STARTED_LATEST_URI,
|
|
1334
|
+
name: 'Getting started with Meguro v3',
|
|
1335
|
+
title: 'Getting started with Meguro v3',
|
|
1336
|
+
description: `Discovery-first evaluator sequence for Shopify Admin GraphQL ${ADMIN_API_SUPPORTED_VERSIONS.join(' and ')} with default ${ADMIN_API_DEFAULT_VERSION}.`,
|
|
1337
|
+
text: GETTING_STARTED_V3_TEXT,
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
topic: 'getting-started',
|
|
1341
|
+
version: GETTING_STARTED_V4_VERSION,
|
|
1342
|
+
uri: GETTING_STARTED_V4_URI,
|
|
1343
|
+
name: 'Getting started with Meguro v4',
|
|
1344
|
+
title: 'Getting started with Meguro v4',
|
|
1345
|
+
description: `Simulation-vocabulary evaluator sequence for Shopify Admin GraphQL ${ADMIN_API_SUPPORTED_VERSIONS.join(' and ')} with default ${ADMIN_API_DEFAULT_VERSION}.`,
|
|
1346
|
+
text: GETTING_STARTED_V4_TEXT,
|
|
1347
|
+
},
|
|
1348
|
+
{
|
|
1349
|
+
topic: 'getting-started',
|
|
1350
|
+
version: GETTING_STARTED_V5_VERSION,
|
|
1351
|
+
uri: GETTING_STARTED_V5_URI,
|
|
1352
|
+
name: 'Getting started with Meguro v5',
|
|
1353
|
+
title: 'Getting started with Meguro v5',
|
|
1354
|
+
description: `Version-policy evaluator sequence for Shopify Admin GraphQL ${ADMIN_API_SUPPORTED_VERSIONS.join(' and ')} with default ${ADMIN_API_DEFAULT_VERSION}.`,
|
|
1355
|
+
text: GETTING_STARTED_V5_TEXT,
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
topic: 'getting-started',
|
|
1359
|
+
version: GETTING_STARTED_V6_VERSION,
|
|
1360
|
+
uri: GETTING_STARTED_V6_URI,
|
|
1361
|
+
name: 'Getting started with Meguro v6',
|
|
1362
|
+
title: 'Getting started with Meguro v6',
|
|
1363
|
+
description: `World-first discovery sequence for Shopify Admin GraphQL ${ADMIN_API_SUPPORTED_VERSIONS.join(' and ')} with default ${ADMIN_API_DEFAULT_VERSION}.`,
|
|
1364
|
+
text: GETTING_STARTED_V6_TEXT,
|
|
1365
|
+
},
|
|
1366
|
+
{
|
|
1367
|
+
topic: 'product-guide',
|
|
1368
|
+
version: PRODUCT_GUIDE_VERSION,
|
|
1369
|
+
uri: PRODUCT_GUIDE_URI,
|
|
1370
|
+
name: 'Meguro product guide v1',
|
|
1371
|
+
title: 'Meguro product guide v1',
|
|
1372
|
+
description: 'Stable product concepts, evidence boundaries, surface responsibilities, and question-to-source routing.',
|
|
1373
|
+
text: PRODUCT_GUIDE_TEXT,
|
|
1374
|
+
expectedSha256: PRODUCT_GUIDE_SHA256,
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
topic: 'product-guide',
|
|
1378
|
+
version: PRODUCT_GUIDE_V2_VERSION,
|
|
1379
|
+
uri: PRODUCT_GUIDE_V2_URI,
|
|
1380
|
+
name: 'Meguro product guide v2',
|
|
1381
|
+
title: 'Meguro product guide v2',
|
|
1382
|
+
description: 'Stable product concepts, simulation vocabulary, evidence boundaries, surface responsibilities, and question-to-source routing.',
|
|
1383
|
+
text: PRODUCT_GUIDE_V2_TEXT,
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
topic: 'product-guide',
|
|
1387
|
+
version: PRODUCT_GUIDE_V3_VERSION,
|
|
1388
|
+
uri: PRODUCT_GUIDE_V3_URI,
|
|
1389
|
+
name: 'Meguro product guide v3',
|
|
1390
|
+
title: 'Meguro product guide v3',
|
|
1391
|
+
description: 'World-first product concepts, evidence boundaries, surface responsibilities, and question-to-source routing.',
|
|
1392
|
+
text: PRODUCT_GUIDE_V3_TEXT,
|
|
1393
|
+
},
|
|
878
1394
|
{
|
|
879
1395
|
topic: 'receipt-guide',
|
|
880
1396
|
version: RECEIPT_GUIDE_VERSION,
|
|
@@ -886,13 +1402,58 @@ const CATALOG = buildDocumentationCatalog([
|
|
|
886
1402
|
},
|
|
887
1403
|
{
|
|
888
1404
|
topic: 'receipt-guide',
|
|
889
|
-
version:
|
|
890
|
-
uri:
|
|
1405
|
+
version: RECEIPT_GUIDE_V2_VERSION,
|
|
1406
|
+
uri: RECEIPT_GUIDE_V2_URI,
|
|
891
1407
|
name: 'Meguro receipt guide v2',
|
|
892
1408
|
title: 'Meguro receipt guide v2',
|
|
893
1409
|
description: 'V1 receipt interpretation plus the Console-only account-deletion and public-id invalidation contract.',
|
|
894
1410
|
text: RECEIPT_GUIDE_V2_TEXT,
|
|
895
1411
|
},
|
|
1412
|
+
{
|
|
1413
|
+
topic: 'receipt-guide',
|
|
1414
|
+
version: RECEIPT_GUIDE_V3_VERSION,
|
|
1415
|
+
uri: RECEIPT_GUIDE_V3_URI,
|
|
1416
|
+
name: 'Meguro receipt guide v3',
|
|
1417
|
+
title: 'Meguro receipt guide v3',
|
|
1418
|
+
description: 'V2 receipt interpretation plus the complete shared-receipt rejection-attribution field inventory.',
|
|
1419
|
+
text: RECEIPT_GUIDE_V3_TEXT,
|
|
1420
|
+
},
|
|
1421
|
+
{
|
|
1422
|
+
topic: 'receipt-guide',
|
|
1423
|
+
version: RECEIPT_GUIDE_V4_VERSION,
|
|
1424
|
+
uri: RECEIPT_GUIDE_V4_URI,
|
|
1425
|
+
name: 'Meguro receipt guide v4',
|
|
1426
|
+
title: 'Meguro receipt guide v4',
|
|
1427
|
+
description: 'V3 receipt interpretation plus receipt-contained source totals for recomputing every impact money figure.',
|
|
1428
|
+
text: RECEIPT_GUIDE_V4_TEXT,
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
topic: 'receipt-guide',
|
|
1432
|
+
version: RECEIPT_GUIDE_LATEST_VERSION,
|
|
1433
|
+
uri: RECEIPT_GUIDE_LATEST_URI,
|
|
1434
|
+
name: 'Meguro receipt guide v5',
|
|
1435
|
+
title: 'Meguro receipt guide v5',
|
|
1436
|
+
description: 'V4 receipt interpretation plus environment-qualified public receipt delivery and exact-byte verification.',
|
|
1437
|
+
text: RECEIPT_GUIDE_V5_TEXT,
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
topic: 'receipt-guide',
|
|
1441
|
+
version: RECEIPT_GUIDE_V6_VERSION,
|
|
1442
|
+
uri: RECEIPT_GUIDE_V6_URI,
|
|
1443
|
+
name: 'Meguro receipt guide v6',
|
|
1444
|
+
title: 'Meguro receipt guide v6',
|
|
1445
|
+
description: 'V5 receipt interpretation republished with the simulation-run vocabulary and renamed lifecycle fields.',
|
|
1446
|
+
text: RECEIPT_GUIDE_V6_TEXT,
|
|
1447
|
+
},
|
|
1448
|
+
{
|
|
1449
|
+
topic: 'receipt-guide',
|
|
1450
|
+
version: RECEIPT_GUIDE_V7_VERSION,
|
|
1451
|
+
uri: RECEIPT_GUIDE_V7_URI,
|
|
1452
|
+
name: 'Meguro receipt guide v7',
|
|
1453
|
+
title: 'Meguro receipt guide v7',
|
|
1454
|
+
description: 'V6 receipt interpretation plus explicit signed net-unit semantics for daily impact rows.',
|
|
1455
|
+
text: RECEIPT_GUIDE_V7_TEXT,
|
|
1456
|
+
},
|
|
896
1457
|
{
|
|
897
1458
|
topic: 'gate-policy',
|
|
898
1459
|
version: GATE_POLICY_VERSION,
|
|
@@ -902,6 +1463,15 @@ const CATALOG = buildDocumentationCatalog([
|
|
|
902
1463
|
description: 'Immutable named checks, receipt facts, thresholds, precedence, flip conditions, and self-gating guidance.',
|
|
903
1464
|
text: GATE_POLICY_TEXT,
|
|
904
1465
|
},
|
|
1466
|
+
{
|
|
1467
|
+
topic: 'gate-policy',
|
|
1468
|
+
version: GATE_POLICY_V2_VERSION,
|
|
1469
|
+
uri: GATE_POLICY_V2_URI,
|
|
1470
|
+
name: 'Meguro Gate policy v2',
|
|
1471
|
+
title: 'Meguro Gate policy v2',
|
|
1472
|
+
description: 'Immutable named checks and flip conditions republished with the simulation-run vocabulary.',
|
|
1473
|
+
text: GATE_POLICY_V2_TEXT,
|
|
1474
|
+
},
|
|
905
1475
|
]);
|
|
906
1476
|
|
|
907
1477
|
export function documentationResources() {
|
|
@@ -916,13 +1486,73 @@ export function documentationByTopic(topic, version) {
|
|
|
916
1486
|
return CATALOG.readTopic(topic, version);
|
|
917
1487
|
}
|
|
918
1488
|
|
|
1489
|
+
function documentationList(values, conjunction = 'and') {
|
|
1490
|
+
if (values.length === 1) return String(values[0]);
|
|
1491
|
+
if (values.length === 2) return `${values[0]} ${conjunction} ${values[1]}`;
|
|
1492
|
+
return `${values.slice(0, -1).join(', ')}, ${conjunction} ${values.at(-1)}`;
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
export function deriveDocumentationToolContract(resources) {
|
|
1496
|
+
if (!Array.isArray(resources) || resources.length === 0) {
|
|
1497
|
+
throw new Error('Documentation tool contract requires at least one published resource');
|
|
1498
|
+
}
|
|
1499
|
+
const byTopic = new Map();
|
|
1500
|
+
const seen = new Set();
|
|
1501
|
+
for (const resource of resources) {
|
|
1502
|
+
const topic = String(resource?._meta?.['meguro/topic'] ?? '').trim();
|
|
1503
|
+
const version = Number(resource?._meta?.['meguro/version']);
|
|
1504
|
+
const description = String(resource?.description ?? '').trim();
|
|
1505
|
+
if (!/^[a-z][a-z0-9-]{0,63}$/u.test(topic)) {
|
|
1506
|
+
throw new Error(`Documentation resource has an invalid topic: ${topic || '(missing)'}`);
|
|
1507
|
+
}
|
|
1508
|
+
if (!Number.isSafeInteger(version) || version < 1) {
|
|
1509
|
+
throw new Error(`Documentation resource ${resource?.uri ?? '(unknown)'} has an invalid version`);
|
|
1510
|
+
}
|
|
1511
|
+
if (!description) {
|
|
1512
|
+
throw new Error(`Documentation resource ${resource?.uri ?? '(unknown)'} has no description`);
|
|
1513
|
+
}
|
|
1514
|
+
const key = `${topic}:v${version}`;
|
|
1515
|
+
if (seen.has(key)) throw new Error(`Duplicate documentation tool contract entry: ${key}`);
|
|
1516
|
+
seen.add(key);
|
|
1517
|
+
const rows = byTopic.get(topic) ?? [];
|
|
1518
|
+
rows.push({ version, description });
|
|
1519
|
+
byTopic.set(topic, rows);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
const topics = [...byTopic.keys()].sort(codepointCompare);
|
|
1523
|
+
const versions = [...new Set([...byTopic.values()].flatMap((rows) => rows.map((row) => row.version)))]
|
|
1524
|
+
.sort((left, right) => left - right);
|
|
1525
|
+
const announcements = topics.map((topic) => {
|
|
1526
|
+
const rows = byTopic.get(topic).sort((left, right) => left.version - right.version);
|
|
1527
|
+
const latest = rows.at(-1);
|
|
1528
|
+
return `${topic} versions [${rows.map((row) => row.version).join(', ')}] `
|
|
1529
|
+
+ `(latest v${latest.version}: ${latest.description.replace(/[.]+$/u, '')})`;
|
|
1530
|
+
});
|
|
1531
|
+
const topicList = documentationList(topics);
|
|
1532
|
+
const versionList = documentationList(versions);
|
|
1533
|
+
return deepFreeze({
|
|
1534
|
+
topics,
|
|
1535
|
+
versions,
|
|
1536
|
+
description: `Read immutable Meguro product and simulation evidence documentation in-band. `
|
|
1537
|
+
+ `Published registry: ${announcements.join('; ')}. Account deletion is deliberately not an MCP tool. `
|
|
1538
|
+
+ 'Pass the exact published topic and version so cited documentation never resolves to mutable latest content.',
|
|
1539
|
+
topicDescription: `Published Meguro simulation-documentation topic. Registry topics: ${topicList}.`,
|
|
1540
|
+
versionDescription: `Published immutable simulation-documentation version. Registry versions: ${versionList}.`,
|
|
1541
|
+
topicError: `topic must be ${documentationList(topics, 'or')}`,
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
export function documentationToolContract() {
|
|
1546
|
+
return deriveDocumentationToolContract(documentationResources());
|
|
1547
|
+
}
|
|
1548
|
+
|
|
919
1549
|
export function receiptGuideFieldManifest() {
|
|
920
1550
|
return deepFreeze({
|
|
921
1551
|
schemas() {
|
|
922
|
-
return Object.keys(
|
|
1552
|
+
return Object.keys(RECEIPT_FIELDS_V7).sort();
|
|
923
1553
|
},
|
|
924
1554
|
schemaFields(schema) {
|
|
925
|
-
const fields =
|
|
1555
|
+
const fields = RECEIPT_FIELDS_V7[schema];
|
|
926
1556
|
if (!fields) throw new Error(`Receipt schema not documented: ${schema}`);
|
|
927
1557
|
return [...fields];
|
|
928
1558
|
},
|