fix(transport): bump bundle schemaVersion 1.2 -> 1.3 for the additive instance AreaPath (TRN-8 follow-up, decision A)
Minor bumps mark additive fields (1.1 sites/connections/instances, 1.2 #118 Derivation). TRN-8 added InstanceDto.AreaPath without a bump. Exporter now stamps 1.3; ManifestValidator still gates only on bundleFormatVersion, so 1.0-1.2 bundles import unchanged and older importers accept a 1.3 bundle (ignoring AreaPath, leaf-name fallback). Theory pins 1.0-1.4 validating Ok; version-pinning tests read the constant. Component-Transport.md + CLAUDE.md.
This commit is contained in:
@@ -150,7 +150,7 @@ spec for each is `docs/requirements/Component-<Name>.md`, and `README.md` carrie
|
|||||||
- Last-write-wins for concurrent template editing (no optimistic concurrency on templates).
|
- Last-write-wins for concurrent template editing (no optimistic concurrency on templates).
|
||||||
- Optimistic concurrency on deployment status records.
|
- Optimistic concurrency on deployment status records.
|
||||||
- Naming collisions in composed feature modules are design-time errors.
|
- Naming collisions in composed feature modules are design-time errors.
|
||||||
- Transport (#24, M8): bundles now move site/instance config (`Site`s, site-scoped `DataConnection`s, `Instance`s + override children + `Area` by name), not just central-only config — but still never touch site runtime nodes (imported instances land `NotDeployed`). A `BundleNameMap` name-mapping subsystem (Commons: `SiteMapping`/`ConnectionMapping`/`MappingAction`) reconciles environment-specific identifiers (sites by `SiteIdentifier`, connections by site-qualified `{SiteIdentifier}/{Name}`, instances by `UniqueName`): auto-match → operator override via the import-wizard Map step / CLI `--map-site`/`--map-connection`/`--create-missing-*` → blocker rows for the unresolved. D3 "carry full config (encrypted secrets)": Site addresses travel; `DataConnection` config rides the encrypted `SecretsBlock` (presence-only in diffs). Per-line Myers diff for code fields via the pure `LineDiffer` (`ArtifactDiff` embeds a size-capped structured `lineDiff`; input capped at `MaxInputLines`=4000 → summary-only, so a crafted bundle can't OOM the active node); `ImportResult.StaleInstanceIds` is real via the `IStaleInstanceProbe` seam (Commons; implemented in DeploymentManager). `schemaVersion` 1.0→1.1 (additive); `bundleFormatVersion` stays 1; no new EF tables/columns. **Arch-review 05 (plan 05):** template child fidelity completed (round-trip-guard-verified: `LockedInDerived`, native-alarm-sources, script cadence/timeout, real `AreaName`, ES retry config + methods-on-Add, notification recipients, folder parent edges); import runs the **script trust gate** (template/shared/ApiMethod bodies, template script + alarm Expression-trigger bodies, **and instance alarm-override trigger expressions** — R2-05) as a hard pre-runtime gate + a name-resolution severity split (template=advisory `ConflictKind.Warning`+`ImportResult.Warnings`, ApiMethod=hard error); `ArtifactDiff` resolves folder/base/composition names (unchanged structured templates classify Identical again); `MaxConcurrentImportSessions`=8 session cap (startup-validated `>0`, R2-05). **R2-05 also:** the post-commit `ScriptArtifactsChanged` publisher now covers `Add` resolutions (not just Overwrite/Rename), import warns on instance overrides targeting locked template members (advisory, rows still written), and the Expression-trigger syntax check is surface-keyed-cached + skipped on read-only staleness/comparison paths (`validateScriptCompilation:false`). Rename does NOT rewrite call sites (deploy gate on the target is the real check). Plan-06 handoff: `ScriptArtifactsChanged`/`IScriptArtifactChangeBus` seam + Host in-process bus + Transport post-commit publisher shipped (ApiMethod consumer = InboundAPI `ScriptArtifactChangeSubscriber`, wired in plan R2-06; SharedScript/Template publish with no consumer — nothing at central caches those kinds).
|
- Transport (#24, M8): bundles now move site/instance config (`Site`s, site-scoped `DataConnection`s, `Instance`s + override children + `Area` by name), not just central-only config — but still never touch site runtime nodes (imported instances land `NotDeployed`). A `BundleNameMap` name-mapping subsystem (Commons: `SiteMapping`/`ConnectionMapping`/`MappingAction`) reconciles environment-specific identifiers (sites by `SiteIdentifier`, connections by site-qualified `{SiteIdentifier}/{Name}`, instances by `UniqueName`): auto-match → operator override via the import-wizard Map step / CLI `--map-site`/`--map-connection`/`--create-missing-*` → blocker rows for the unresolved. D3 "carry full config (encrypted secrets)": Site addresses travel; `DataConnection` config rides the encrypted `SecretsBlock` (presence-only in diffs). Per-line Myers diff for code fields via the pure `LineDiffer` (`ArtifactDiff` embeds a size-capped structured `lineDiff`; input capped at `MaxInputLines`=4000 → summary-only, so a crafted bundle can't OOM the active node); `ImportResult.StaleInstanceIds` is real via the `IStaleInstanceProbe` seam (Commons; implemented in DeploymentManager). `schemaVersion` 1.0→1.1 (additive; since then 1.2 for #118 `Derivation`, 1.3 for TRN-8 instance `AreaPath`); `bundleFormatVersion` stays 1; no new EF tables/columns. **Arch-review 05 (plan 05):** template child fidelity completed (round-trip-guard-verified: `LockedInDerived`, native-alarm-sources, script cadence/timeout, real `AreaName`, ES retry config + methods-on-Add, notification recipients, folder parent edges); import runs the **script trust gate** (template/shared/ApiMethod bodies, template script + alarm Expression-trigger bodies, **and instance alarm-override trigger expressions** — R2-05) as a hard pre-runtime gate + a name-resolution severity split (template=advisory `ConflictKind.Warning`+`ImportResult.Warnings`, ApiMethod=hard error); `ArtifactDiff` resolves folder/base/composition names (unchanged structured templates classify Identical again); `MaxConcurrentImportSessions`=8 session cap (startup-validated `>0`, R2-05). **R2-05 also:** the post-commit `ScriptArtifactsChanged` publisher now covers `Add` resolutions (not just Overwrite/Rename), import warns on instance overrides targeting locked template members (advisory, rows still written), and the Expression-trigger syntax check is surface-keyed-cached + skipped on read-only staleness/comparison paths (`validateScriptCompilation:false`). Rename does NOT rewrite call sites (deploy gate on the target is the real check). Plan-06 handoff: `ScriptArtifactsChanged`/`IScriptArtifactChangeBus` seam + Host in-process bus + Transport post-commit publisher shipped (ApiMethod consumer = InboundAPI `ScriptArtifactChangeSubscriber`, wired in plan R2-06; SharedScript/Template publish with no consumer — nothing at central caches those kinds).
|
||||||
|
|
||||||
### Store-and-Forward
|
### Store-and-Forward
|
||||||
- Fixed retry interval, no max buffer size. Only transient failures buffered. The site sweep's due-message page is ranked **per lane** — lane = `(category, target)` — round-robin via `ROW_NUMBER`, so one dead target can no longer starve the others out of the 500-row page (review 2026-10-21 02/C2); the depth gauge is re-seeded every 6th sweep.
|
- Fixed retry interval, no max buffer size. Only transient failures buffered. The site sweep's due-message page is ranked **per lane** — lane = `(category, target)` — round-robin via `ROW_NUMBER`, so one dead target can no longer starve the others out of the 500-row page (review 2026-10-21 02/C2); the depth gauge is re-seeded every 6th sweep.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ zip-bomb guard, and the exporter never emits per-script files.
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"bundleFormatVersion": 1,
|
"bundleFormatVersion": 1,
|
||||||
"schemaVersion": "1.2",
|
"schemaVersion": "1.3",
|
||||||
"createdAtUtc": "2026-05-24T12:34:56Z",
|
"createdAtUtc": "2026-05-24T12:34:56Z",
|
||||||
"sourceEnvironment": "dev-cluster-a",
|
"sourceEnvironment": "dev-cluster-a",
|
||||||
"exportedBy": "alice@corp.example",
|
"exportedBy": "alice@corp.example",
|
||||||
@@ -107,6 +107,7 @@ The manifest is plaintext so the import wizard can preview bundle contents and s
|
|||||||
- `bundleFormatVersion` newer than what the importer supports produces a hard refusal at upload with a clear upgrade message.
|
- `bundleFormatVersion` newer than what the importer supports produces a hard refusal at upload with a clear upgrade message.
|
||||||
- `schemaVersion` minor increments are **additive-only**. T18 bumped it `1.0 → 1.1` (adding the `sites`/`dataConnections`/`instances` arrays). `bundleFormatVersion` stays `1`; `ManifestValidator` gates solely on `bundleFormatVersion`, so a pre-T18 importer still accepts a 1.1 bundle and simply lists the new site/instance/connection entries as "skipped — unsupported in this version".
|
- `schemaVersion` minor increments are **additive-only**. T18 bumped it `1.0 → 1.1` (adding the `sites`/`dataConnections`/`instances` arrays). `bundleFormatVersion` stays `1`; `ManifestValidator` gates solely on `bundleFormatVersion`, so a pre-T18 importer still accepts a 1.1 bundle and simply lists the new site/instance/connection entries as "skipped — unsupported in this version".
|
||||||
- ScadaBridge#118 bumped it `1.1 → 1.2`: a derived (composition-slot) template carries a `Derivation` object (see [Derived templates](#derived-composition-slot-templates-scadabridge118)). It is omitted on base templates (`WhenWritingNull`), so a base template's JSON is unchanged; an older importer ignores the unknown property and imports the slot the old (wrong) way; a 1.0/1.1 bundle has no derivation anywhere and imports exactly as before (pinned by `Fixtures/pre-118-derived-plaintext.scadabundle`). `bundleFormatVersion` stays `1`. The field lives in `content.json`/`content.enc`, whose SHA-256 is the manifest's `contentHash`, so a signed bundle's signature over `manifest.json` covers it (an edited derivation fails the hash check, or — with a recomputed hash — the signature).
|
- ScadaBridge#118 bumped it `1.1 → 1.2`: a derived (composition-slot) template carries a `Derivation` object (see [Derived templates](#derived-composition-slot-templates-scadabridge118)). It is omitted on base templates (`WhenWritingNull`), so a base template's JSON is unchanged; an older importer ignores the unknown property and imports the slot the old (wrong) way; a 1.0/1.1 bundle has no derivation anywhere and imports exactly as before (pinned by `Fixtures/pre-118-derived-plaintext.scadabundle`). `bundleFormatVersion` stays `1`. The field lives in `content.json`/`content.enc`, whose SHA-256 is the manifest's `contentHash`, so a signed bundle's signature over `manifest.json` covers it (an edited derivation fails the hash check, or — with a recomputed hash — the signature).
|
||||||
|
- TRN-8 (2026-12-03) bumped it `1.2 → 1.3`: an instance carries the additive `AreaPath` (root→leaf area names; see the instance bullet under Responsibilities). It is null on an area-less instance; an older importer ignores the unknown property and resolves the leaf `AreaName` as it always did; a 1.0–1.2 bundle has no path and imports through the leaf-name fallback (deterministic resolution + an `ImportResult.Warnings` entry when the leaf is ambiguous). `bundleFormatVersion` stays `1`, and `ManifestValidator` still gates solely on it, so every `1.x` minor — older or newer — validates.
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
@@ -494,7 +495,7 @@ The `manifest.json` file is always present in the ZIP root and is never encrypte
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"bundleFormatVersion": 1,
|
"bundleFormatVersion": 1,
|
||||||
"schemaVersion": "1.2",
|
"schemaVersion": "1.3",
|
||||||
"createdAtUtc": "2026-05-24T12:34:56Z",
|
"createdAtUtc": "2026-05-24T12:34:56Z",
|
||||||
"sourceEnvironment": "dev-cluster-a",
|
"sourceEnvironment": "dev-cluster-a",
|
||||||
"exportedBy": "alice@corp.example",
|
"exportedBy": "alice@corp.example",
|
||||||
@@ -561,7 +562,7 @@ The `manifest.json` file is always present in the ZIP root and is never encrypte
|
|||||||
| Field | Description |
|
| Field | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `bundleFormatVersion` | Integer. Importer hard-refuses any value other than the code constant `ManifestBuilder.CurrentBundleFormatVersion`. Stays `1` through T18. The schema and format versions are code constants by design — there is no `Transport:SchemaVersionMajor` option (removed 2026-10-22; it was validated but never read). |
|
| `bundleFormatVersion` | Integer. Importer hard-refuses any value other than the code constant `ManifestBuilder.CurrentBundleFormatVersion`. Stays `1` through T18. The schema and format versions are code constants by design — there is no `Transport:SchemaVersionMajor` option (removed 2026-10-22; it was validated but never read). |
|
||||||
| `schemaVersion` | Semver string. Minor increments are additive-only and accepted by older importers. T18 bumped this `1.0 → 1.1` (adding the `sites`/`dataConnections`/`instances` content arrays); a pre-T18 importer lists those new entries as "skipped — unsupported in this version" since `ManifestValidator` gates only on `bundleFormatVersion`. ScadaBridge#118 bumped it `1.1 → 1.2` (the additive `Derivation` on derived composition-slot templates). |
|
| `schemaVersion` | Semver string. Minor increments are additive-only and accepted by older importers. T18 bumped this `1.0 → 1.1` (adding the `sites`/`dataConnections`/`instances` content arrays); a pre-T18 importer lists those new entries as "skipped — unsupported in this version" since `ManifestValidator` gates only on `bundleFormatVersion`. ScadaBridge#118 bumped it `1.1 → 1.2` (the additive `Derivation` on derived composition-slot templates); TRN-8 bumped it `1.2 → 1.3` (the additive instance `AreaPath`). |
|
||||||
| `createdAtUtc` | ISO-8601 UTC timestamp of when the export was created. |
|
| `createdAtUtc` | ISO-8601 UTC timestamp of when the export was created. |
|
||||||
| `sourceEnvironment` | The `SourceEnvironment` name of the exporting cluster (from `TransportOptions`). Displayed in the import wizard and required to be retyped at the confirm step. |
|
| `sourceEnvironment` | The `SourceEnvironment` name of the exporting cluster (from `TransportOptions`). Displayed in the import wizard and required to be retyped at the confirm step. |
|
||||||
| `exportedBy` | Authenticated username of the person who performed the export. |
|
| `exportedBy` | Authenticated username of the person who performed the export. |
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ public sealed class ManifestBuilder
|
|||||||
// 1.1 → 1.2 (ScadaBridge#118): TemplateDto.Derivation marks derived composition-slot
|
// 1.1 → 1.2 (ScadaBridge#118): TemplateDto.Derivation marks derived composition-slot
|
||||||
// templates. Additive — an older importer ignores the field (and imports the slot as
|
// templates. Additive — an older importer ignores the field (and imports the slot as
|
||||||
// it always did), a 1.0/1.1 bundle has no derivations and imports unchanged.
|
// it always did), a 1.0/1.1 bundle has no derivations and imports unchanged.
|
||||||
public const string CurrentSchemaVersion = "1.2";
|
// 1.2 → 1.3 (TRN-8): InstanceDto.AreaPath carries the instance's root→leaf area path.
|
||||||
|
// Additive — an older importer ignores the field and resolves the leaf AreaName as it
|
||||||
|
// always did; a 1.0–1.2 bundle has no path and imports via the leaf-name fallback.
|
||||||
|
public const string CurrentSchemaVersion = "1.3";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds a <see cref="BundleManifest"/> with the current format version, a SHA-256 content hash,
|
/// Builds a <see cref="BundleManifest"/> with the current format version, a SHA-256 content hash,
|
||||||
|
|||||||
+1
-1
@@ -614,7 +614,7 @@ public sealed class DerivedTemplateTransportTests : IDisposable
|
|||||||
await SeedPumpWithDerivedMotorAsync(provider);
|
await SeedPumpWithDerivedMotorAsync(provider);
|
||||||
var bundle = await ExportAsync(provider, null, "Pump");
|
var bundle = await ExportAsync(provider, null, "Pump");
|
||||||
Assert.Contains("\"Derivation\"", ReadEntry(bundle, "content.json"), StringComparison.Ordinal);
|
Assert.Contains("\"Derivation\"", ReadEntry(bundle, "content.json"), StringComparison.Ordinal);
|
||||||
Assert.Contains("\"SchemaVersion\":\"1.2\"", ReadEntry(bundle, "manifest.json"), StringComparison.Ordinal);
|
Assert.Contains("\"SchemaVersion\":\"" + ManifestBuilder.CurrentSchemaVersion + "\"", ReadEntry(bundle, "manifest.json"), StringComparison.Ordinal);
|
||||||
|
|
||||||
await WipeTemplatesAsync(provider);
|
await WipeTemplatesAsync(provider);
|
||||||
var session = await LoadAsync(provider, bundle);
|
var session = await LoadAsync(provider, bundle);
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ public sealed class ManifestBuilderTests
|
|||||||
Assert.Equal("user", manifest.ExportedBy);
|
Assert.Equal("user", manifest.ExportedBy);
|
||||||
Assert.Equal("1.0.0", manifest.ScadaBridgeVersion);
|
Assert.Equal("1.0.0", manifest.ScadaBridgeVersion);
|
||||||
Assert.Equal(1, manifest.BundleFormatVersion);
|
Assert.Equal(1, manifest.BundleFormatVersion);
|
||||||
// Schema minor bumped 1.0 → 1.1; format version stays 1.
|
// Schema minor bumped 1.2 → 1.3 (TRN-8 AreaPath); format version stays 1.
|
||||||
Assert.Equal("1.2", manifest.SchemaVersion);
|
Assert.Equal("1.3", manifest.SchemaVersion);
|
||||||
|
Assert.Equal(ManifestBuilder.CurrentSchemaVersion, manifest.SchemaVersion);
|
||||||
Assert.Null(manifest.Encryption);
|
Assert.Null(manifest.Encryption);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +113,37 @@ public sealed class ManifestBuilderTests
|
|||||||
Assert.Equal(ManifestValidationResult.Ok, result);
|
Assert.Equal(ManifestValidationResult.Ok, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verifies that every schema minor up to and including the current one validates Ok —
|
||||||
|
/// minor bumps are additive, so a 1.0/1.1/1.2 bundle keeps importing after the 1.3 bump
|
||||||
|
/// (TRN-8 AreaPath), and so does a future additive minor (the validator gates only on
|
||||||
|
/// <see cref="ManifestBuilder.CurrentBundleFormatVersion"/>).
|
||||||
|
/// </summary>
|
||||||
|
[Theory]
|
||||||
|
[InlineData("1.0")]
|
||||||
|
[InlineData("1.1")]
|
||||||
|
[InlineData("1.2")]
|
||||||
|
[InlineData("1.3")]
|
||||||
|
[InlineData("1.4")]
|
||||||
|
public void Validate_accepts_every_schema_minor_under_format_version_1(string schemaVersion)
|
||||||
|
{
|
||||||
|
var bytes = Encoding.UTF8.GetBytes("bundle-" + schemaVersion);
|
||||||
|
var hash = "sha256:" + Convert.ToHexString(SHA256.HashData(bytes)).ToLowerInvariant();
|
||||||
|
var manifest = new BundleManifest(
|
||||||
|
BundleFormatVersion: ManifestBuilder.CurrentBundleFormatVersion,
|
||||||
|
SchemaVersion: schemaVersion,
|
||||||
|
CreatedAtUtc: DateTimeOffset.UtcNow,
|
||||||
|
SourceEnvironment: "env",
|
||||||
|
ExportedBy: "u",
|
||||||
|
ScadaBridgeVersion: "v",
|
||||||
|
ContentHash: hash,
|
||||||
|
Encryption: null,
|
||||||
|
Summary: EmptySummary,
|
||||||
|
Contents: NoContents);
|
||||||
|
|
||||||
|
Assert.Equal(ManifestValidationResult.Ok, new ManifestValidator().Validate(manifest, bytes));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Verifies that validation accepts an older schema version 1.0 manifest.</summary>
|
/// <summary>Verifies that validation accepts an older schema version 1.0 manifest.</summary>
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Validate_accepts_older_schemaVersion_1_0_manifest()
|
public void Validate_accepts_older_schemaVersion_1_0_manifest()
|
||||||
|
|||||||
Reference in New Issue
Block a user