Analytics and Algorithm Delivery
The pain in this scenario
Selling an analytics model or algorithm script usually hits three walls:
- The customer will not hand over data and only accepts on-premise deployment;
- You will not hand over source code, otherwise one delivery becomes permanent distribution;
- Trial and production versions need separate handling, and renewals or upgrades need re-issuing.
MGC's two sealing modes map directly to those two commercial stages: free for the trial, p2p for the production license.
When to use it
- An independent analyst delivering forecasting, scoring, or cleaning models
- An algorithm vendor deploying on-premise, licensed per customer node
- A small team productizing an internal tool — trial first, production later
- Delivering scripts that must be "runnable, unreadable, non-resellable"
When it is not a fit
- The deliverable is pure data or a report → MGC encrypts scripts, not data
- The customer refuses to install a local runtime → MGC is required: builder 1.6.0+, runner 1.5.4+; cross-script calls need 1.5.2+
- You need online metering or billing → that is SaaS, not local delivery
Two delivery forms
| free trial package | p2p production license | |
|---|---|---|
| How to seal | omit ext04 |
ext04=customer node_pub |
| Who can run it | Any MGC 1.5.4+ node | Only that customer node |
| Commercial meaning | Anyone can try it, wider reach | One license per customer, non-resellable |
| Customer changes machine | Runs as-is | Must be re-sealed |
| Renewal / upgrade | Ship a new version | Ship a new version |
A free package cannot technically restrict who runs it; the trial boundary has to live in the script (for example, only return the first N periods, or add a watermark). To restrict per customer, use p2p.
The production delivery chain
| Stage | Who | Action |
|---|---|---|
| 1. Assemble | Deliverer | Prepare a flat script folder, document dependencies and usage |
| 2. Fetch key | Customer | mgc_get(info_type="__NODE_PUB__", info_owner="__NODE_PUB__") and send it to the deliverer |
| 3. Dry run | Deliverer | Run locally on sample data; confirm no hardcoded paths |
| 4. Seal | Deliverer | mgc_seal_package(..., ext04=customer_pub, output_dir=...) |
| 5. Deliver | Deliverer | Send .mgc_file, dependency list, usage notes, and sha256 |
| 6. Import | Customer | mgc_save_file(path="xxx.mgc_file", info_owner="...") |
| 7. Run | Customer | mgc_run(..., diff_3="run.py"), results written locally |
| 8. Renew | Both | Re-seal for upgrades or machine changes; retire the old package |
Four hard constraints
- Scripts go in, data does not. Customer data stays on the customer side; sample CSVs are not shipped in the package. Non-script files inside a sealed package are plaintext.
- Flat directory. Scripts saved into MGC must sit at the same
diff_2level. No subdirectories; cross-script calls require the samediff_2(DIFF2_MISMATCH). - Whole-folder seal, no file list. p2p / free
mgc_seal_packagehas nofilesparameter (filesonly exists inside chain-modeext04array elements); the whole folder is sealed automatically, anddiff_3is each file's relative path inside the package. - Output must be written explicitly. MGC does not create the parent directory of
--output; the script mustmkdir(parents=True)itself.
One compatibility note: the builder needs MGC 1.6.0+, the customer's runner needs 1.5.4+, and cross-script calls need 1.5.2+. If the customer node is older, import may succeed but cross-script calls will not route through sealed execution, and MGC returns a TARGET_NODE_MAY_NOT_SUPPORT_AUTO_WORKFLOW warning. Confirm the customer version before delivery.
Runnable minimal example
examples/ is a complete sales-forecast delivery package:
| File | Purpose |
|---|---|
prepare_sample_data.py |
Generates sample sales CSV (demo only, not shipped) |
model.py |
Forecast logic: moving average + growth rate, standard library only |
run.py |
Entry script, imports model at the same level, writes prediction JSON |
role_prompts.md |
Deliverer / customer briefs and licensing terms |
Local verification:
python examples/prepare_sample_data.py /tmp/delivery_demo/sales.csv
python examples/run.py --input /tmp/delivery_demo/sales.csv --output /tmp/delivery_demo/predictions.json
Sealed delivery:
# Deliverer: store as a workflow package
mgc_save_file(path="./examples", info_owner="sales_forecast")
# Trial package: free mode, runnable on any MGC 1.5.4+ node
mgc_seal_package(
info_owner="sales_forecast",
diff_2="examples",
output_dir="/tmp/delivery_demo/trial",
)
# Production package: p2p mode, bound to the customer node
mgc_seal_package(
info_owner="sales_forecast",
diff_2="examples",
output_dir="/tmp/delivery_demo/licensed",
ext04=customer_pub,
)
# Customer: import and run
mgc_save_file(path="/tmp/delivery_demo/licensed/examples_delivery/examples.mgc_file",
info_owner="sales_forecast")
mgc_run(info_type="script", info_owner="sales_forecast",
diff_2="examples", diff_3="run.py")
Import note: when importing a sealed package via
mgc_save_file, theinfo_owneryou pass applies to the package group only; every record inside keeps the owner recorded at seal time (theINFO_OWNER_NOT_APPLIEDwarning is advisory, not an error). After import, confirm withmgc_find(info_owner="<the package's own owner>")and use that value for all subsequentmgc_runcalls — the 5+1 cross-script check requires caller and target to share the exact sameinfo_owner, otherwise the call fails withOWNER_MISMATCH.
Delivery checklist
Every delivery should include at least:
- The
.mgc_filepackage sha256- Dependency list (packages outside the standard library, with versions)
- Input format (columns, types, required fields)
- Output format (field meanings, units)
- Version number and change notes
MGC tools quick reference
| Tool | Purpose |
|---|---|
mgc_get |
Fetch the customer node_pub (both info_type and info_owner must be __NODE_PUB__) / read licensing info |
mgc_save_file |
Store a workflow folder / import a .mgc_file |
mgc_seal_package |
Seal a workflow; omit ext04 for a free trial package |
mgc_run |
Black-box execution, diff_3 targets the entry script |
mgc_package |
Plaintext export within one trust domain (internal debugging) |
mgc_list / mgc_find |
Manage historical delivery versions |
mgc_delete |
Clean up expired packages |
mgc_skill |
Look up official parameters and artifact layout |
Common failures
| Symptom | Cause | Fix |
|---|---|---|
Import succeeds but UNSEAL_FAILED at run time |
The package was forwarded to a non-licensed node, or node_pub is malformed |
p2p packages are non-transferable; run on the licensed customer node and verify node_pub when re-sealing |
TARGET_NODE_MAY_NOT_SUPPORT_AUTO_WORKFLOW |
The customer's MGC is too old | Upgrade to ≥ 1.5.4 and re-import; cross-script calls need ≥ 1.5.2 |
DIFF2_MISMATCH |
diff_2 is not the directory name |
Confirm with mgc_find |
| Missing dependency on the customer side | An incomplete dependency list or a version mismatch | Ship requirements.txt with pinned versions |
| No output file produced | The --output parent directory does not exist |
mkdir(parents=True) inside the script |
Security boundary
- The deliverer gets: the customer's node_pub and the results the customer returns
- The deliverer does not get: the customer's raw data
- The customer gets: a runnable package and local output
- The customer does not get: source code or algorithm parameters
MGC protects content confidentiality; it does not provide online authentication or expiry. Licensing has limits: a p2p package is bound to a node, but it cannot stop a customer from observing inputs and outputs on that licensed machine. For stronger control, combine it with a contract and local audit logs. After unsealing, the script runs with the customer's permissions, and its reads, writes, and network behaviour are governed by the customer's environment.
