M6-S2 — The package contract: format, schemas and the dependency graph
Section titled “M6-S2 — The package contract: format, schemas and the dependency graph”| Module | M6 — Extension design |
| After this session you can | Read a package as the platform writes it, predict what its dependency graph pulls in, and choose how to produce a package for a need. |
| Time | 56 min with a facilitator · about 56 min on your own |
| Before you start | M2-S3 (definitions as a wire contract) and M6-S1. Larkspur Lab, Rami Aziz signed in; a terminal with unzip and jq. The chain you built on Work Orders in M4-S2 is still there. Keep the package contract card open. |
| Go deeper | The package format · The dependency graph · Generating a package · Package resource schemas |
◆ Orientation (1 min) — The file that carries a design
Section titled “◆ Orientation (1 min) — The file that carries a design”In ACE M8-S1 you packaged and promoted a suite through the wizard, and learned what travels and what does not. A master needs more: Larkspur will promote packages between environments for years, through scripts as well as screens, and every failed promotion is diagnosed from the file. In this session you open a real export of Asset Maintenance, read it file by file, and learn to predict from its dependency edges what the import will do. M6-S3 then drives the import itself, and M7-S4 ships your own capability this way.
▤ Concept (8 min) — Files, edges, paths
Section titled “▤ Concept (8 min) — Files, edges, paths”The archive
Section titled “The archive”A package is a ZIP with a fixed top level. Anything else at the top level fails the import at once.
| Entry | Required | What it holds |
|---|---|---|
manifest.json | yes | The format’s schemaVersion, when and where it was exported, how many resources of which types |
index.json | yes | Every resource in dependency order, and the name map from each resource id to its file name |
dependencies.json | yes, in practice | The dependency edges: what each resource points at, and where in its JSON |
resources/<Type>/<name>.json | the payload | One snapshot per resource, grouped by type |
entry-references.json | optional | Records the design points at (a step’s owner group, a user), with enough data to create them in the target |
store-references.json, file-references.json, files/ | optional | Shared stores the entities use; files such as templates, and their bytes |
config.json | written by every export | An echo of the export request; the importer ignores it |
field-mapping-hints.json, hashes.json, package-references.json, README.md | since 1.10, optional | Mapped-field hints; and, for a published package version, its hashes, cross-package references and readme |
The manifest’s schemaVersion is a compatibility gate. The exporter writes the lowest version that
describes the file: 1.1 for a plain export, 1.2 once it carries mapped-field hints, 1.3 and 1.4
for published versions. A 1.10 importer accepts 1.0 to 1.4; an importer older than 1.10 accepts only
1.0 and 1.1. So a module with mapped fields exported from a 1.10 environment cannot be imported
into an older one: it is refused as an incompatible schema before anything is read. That is a fact for
your promotion plan whenever environments are upgraded at different times.
The snapshot files are the stored definitions you met in M2-S3, minus what belongs to the source environment: database ids and audit stamps are removed, view execution plans are dropped and rebuilt in the target, and the items of a list backed by an entity are emptied, because records do not travel. Each resource keeps its own source id, which the importer uses as the key of its remapping table.
What is never a resource. Seventeen types can be exported: modules, entities, views, queries, relations, lists, reactions, pages, buttons, statistic queries, reports, Functions, counters, announcements, aggregates, and since 1.10 quick-filter groups and tag groups. Dashboards are records of a system entity, not resources. Users, groups, organization units and working hours exist in every environment, so they travel only as references to be matched or created in the target.
The edges
Section titled “The edges”The dependency service keeps a live graph of every resource and what it points at. At export time,
the exporter walks that graph from what you selected and writes the edges it walked into
dependencies.json. An edge looks like this:
{ "from": { "type": "DataView", "id": "5f0c…", "normalizedName": "open_work_orders" }, "to": { "type": "DataEntity", "id": "a91d…", "normalizedName": "work_orders" }, "kind": "MEMBERSHIP", "hard": true, "path": "dataEntity", "resolvedVia": "DIRECT_ID" }kindisMEMBERSHIP(the view belongs to the entity; this is what “with children” follows) orREFERENCE(a cross-reference to an independent resource).hardsays whether the source can function without the target. Only hard edges extend the export: a soft edge is recorded, but what it points at is not pulled in.pathis where, inside the source’s JSON, the target’s id sits, such asdataEntityorcolumns[0].entityId. It is what lets the importer rewrite ids precisely.
flowchart LR E["Edges in dependencies.json"] --> O["Order: sort with all edges;<br/>if a cycle, drop soft edges;<br/>a hard cycle is ordered as one block"] E --> R["Remap: at each edge's path, replace<br/>the source id with the target id"] E --> S["Skip: a skipped or failed resource<br/>skips every hard dependent"] R --> N["A soft edge whose target is missing:<br/>the value at its path becomes null"]
What to notice: the same edges decide three things. A wrong edge does not fail loudly; it orders, rewrites or skips wrongly.
At import, the edges drive three things. The order: the importer ignores the index’s order and
sorts again from the edges, so a resource is written after what it needs; a soft cycle is broken by
dropping soft edges, a hard cycle is ordered as one block and broken at write time by creating one member
as a stub. The remapping: every id is rewritten at its edge’s path, but only if the value there is
exactly the source id; anything else is left alone. And the skips: when a resource is skipped or
fails, every resource that depends on it through a hard edge is marked cascade skipped. A soft edge
whose target exists in neither the package nor the target is set to null.
Three ways to produce a package
Section titled “Three ways to produce a package”| Path | When | What it costs |
|---|---|---|
| Export, transform, re-import | You want a variant of something an environment already has | Every change you make to a payload must keep the edges true: change an id without its edge and it is never rewritten |
| Overrides on an import session | The same package, different values per environment (an address, a threshold) | Only content, never structure: the fields that say where a resource lives cannot be overridden (M6-S3) |
| Hand-authoring | Resources no environment ever contained | Unsupported: you reimplement the exporter, and the importer’s only safety net checks the container, not the consistency |
The rule that follows: start from an artifact the platform built, and parameterise it through the API built for that. M6-S3 shows the override API; the package contract card keeps the rules on one page.
▶ Guided demo (10 min) — An export, started and fetched
Section titled “▶ Guided demo (10 min) — An export, started and fetched”Starting state. Larkspur Lab as seeded, plus your M4-S2 chain on Work Orders.
- Open Packages › Build › Exports and start a new export. The Export resources page opens with the space’s resources on the left.
- Select the module Asset Maintenance with its children. The right panel lists the selection and External dependencies: resources outside the module that it needs, such as the entity Suppliers, which Spare Parts references.
- Do not add the dependencies. Select Export All. The status moves through Preparing… and Exporting… to Export ready.
- Select Download file and save it as
asset-maintenance.zip. - List it:
unzip -l asset-maintenance.zip | head -30. The top level holdsmanifest.json,index.json,dependencies.json,config.jsonandresources/. - Read the manifest:
unzip -p asset-maintenance.zip manifest.json | jq '{schemaVersion, resourceCount, resourceTypes, sourceSpaceId}'.
Screenshot pending The Export resources page with Asset Maintenance selected and the External dependencies panel listing Suppliers What to notice: the external dependencies are the soft and hard edges that leave your selection; what you do not add, the target must already have.
⛏ Lab (30 min) — Read Asset Maintenance as the importer will
Section titled “⛏ Lab (30 min) — Read Asset Maintenance as the importer will”Goal. From the export alone, answer six questions the importer will answer, and write down each prediction before you check it.
Before you start. asset-maintenance.zip from the demo, unzipped into a folder am/
(unzip -q asset-maintenance.zip -d am).
-
Count the resources by type:
jq '.orderedResources | group_by(.type) | map({type: .[0].type, n: length})' am/index.json. -
Compare with
resourceCountin the manifest. They are equal. -
Find the file of the entity Work Orders through the name map:
jq -r '.nameMap | to_entries[] | select(.value | test("work_orders"))' am/index.json, then openam/resources/DataEntity/<that name>.jsonand confirm it has anidbut no audit stamps. -
Count the edges, and how many are hard:
jq 'length, (map(select(.hard)) | length)' am/dependencies.json. -
List the edges that leave the package (their target is not in the index):
Terminal window jq --slurpfile idx am/index.json '($idx[0].orderedResources | map(.id)) as $ids| map(select((.to.id as $t | $ids | index($t)) | not))| map({from: .from.normalizedName, to: .to.normalizedName, type: .to.type, hard, path})' am/dependencies.json
Screenshot pending The jq output listing the edges that leave the Asset Maintenance package, with their target type, hardness and path What to notice: each line is a promise the target must keep; a hard one blocks the import until it is mapped.
- Predict: you import this file into a space that has no Suppliers entity, and you map nothing. What happens to Spare Parts and to everything that depends on it? Write it down.
- Check your prediction against the edge from Spare Parts to Suppliers in step 5: if it is hard, the import will refuse to run until you map it; if you chose to skip Spare Parts, its hard dependents would be cascade skipped.
- Find the reactions of your M4-S2 chain:
ls am/resources/DataReaction/. Open Tell the CMMS. - Find the edge whose
fromis Tell the CMMS and whosetois Mark asset under maintenance. Read itspath: that is where the watched reaction’s id sits, and what the importer will rewrite. - Read Tell the CMMS’s Call API options in its file. Note whether the
X-Api-Keyvalue travels in the package. - Read the reaction CMMS call failed. Predict: if you exported only Tell the CMMS without it, which edges would point outside, and which way?
- Open
am/resources/DataView/and pick a view. Confirm it has noexecutionPlan. - If
am/field-mapping-hints.jsonexists, check thatschemaVersionis1.2; otherwise1.1. - Decide the production path for three needs, with a reason each: (a) Larkspur Lab must point Tell the CMMS at the lab stub, production at the real CMMS; (b) a second plant wants Asset Maintenance with every name prefixed North; (c) a partner wants to generate five entities from their own catalogue that no environment has.
- Delete
am/when you finish, if step 10 found a key in it. - Fill in your notes table: question, prediction, evidence.
Check.
- The type counts match the manifest’s
resourceCount. - You found the Work Orders file through the name map, not by guessing its name.
- You listed the edges that leave the package, with their hardness.
- Your prediction for a missing Suppliers names the refusal for a hard unmapped dependency and the cascade skip.
- You recorded whether the API key travels.
- Each of the three needs has a production path and a reason.
Pass condition. Your notes give, for each of steps 6, 7, 9, 10, 11 and 14, a prediction or decision and the line of the package that settles it.
If something goes wrong
| What you see | What to do |
|---|---|
| Export failed | Open Show details; a resource installed from another package cannot be exported as a copy. Leave it out. |
| Step 5 lists nothing | You added the external dependencies in the demo; repeat the export without them. |
No DataReaction folder | Your chain was built in another space or deleted; export the module that holds Work Orders. |
jq complains about --slurpfile | Use jq 1.6 or later. |
Model answer
Steps 1 to 5. The index lists every resource once, so its counts match the manifest. The name map is the only reliable way to a file, because two resources with the same slug get suffixed names. The edges leaving the package include Spare Parts → Suppliers (a reference field, hard) and any page or widget that points outside.
Steps 6 and 7. A hard dependency that is in neither the package nor the target must be mapped before
the import will run. If instead you skip Spare Parts, everything that depends on it through a hard edge
is cascade skipped. A soft edge to a missing target would have been set to null instead.
Steps 8 to 11. The chained reaction points at the watched reaction by id, through an edge whose
path is in its event settings, so the importer rewrites it to the new id. The key travels (Redact in
history keeps it out of run history only), so the package carries a secret: you treat the file as sensitive and set the value per environment with an
override in M6-S3. Exported alone, Tell the CMMS would have an outgoing hard edge to the reaction it
watches; CMMS call failed would not be in the package at all, because nothing it watches points to it.
Step 14. (a) Overrides: one package, one value per environment. (b) Export, transform, re-import: renaming is a content change of an existing design, and names are not ids, so no edge is affected. (c) Hand-authoring, unsupported: better to build one specimen in an environment, export it and generate from that.
✓ Practice (6 min) — Check your understanding
Section titled “✓ Practice (6 min) — Check your understanding”A script transforms an exported package: it replaces a view’s source query id with the id of another
query in the same package, but leaves dependencies.json unchanged. What happens at import?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
Larkspur’s production runs a release older than 1.10; Larkspur Lab runs 1.10. An export of Quality
and Compliance from the lab carries field-mapping-hints.json. What happens when you import it into
production?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
You export Procurement with its children. Its Purchase Orders view points softly at a list in Supplier Management. Is that list in the package?
Check your answer
The correct answer is B. Open the explanation under each option to see why.
A generator names a resource file resources/DataEntity/Work Orders.json, with a space. What happens?
Check your answer
The correct answer is C. Open the explanation under each option to see why.
Why does the importer sort the resources itself instead of using the order in index.json?
Check your answer
The correct answer is A. Open the explanation under each option to see why.
↺ Recap (1 min) — Read before you ship
Section titled “↺ Recap (1 min) — Read before you ship”You can now open a package and read it as the importer will: the manifest’s version gate, the name map, the edges that decide order, rewriting and skips, and what never travels. You can choose a production path and name its cost. Next, M6-S3: drive the import yourself, from a script, through its session states, with an override and the typed failures.