fix(templateengine): audit projected template/script summaries instead of the tracked graph and script bodies (review 2026-10-21 08/G1)

This commit is contained in:
Joseph Doherty
2026-10-22 06:28:17 -04:00
parent c0792cff3e
commit 52aab37299
5 changed files with 232 additions and 7 deletions
@@ -332,6 +332,26 @@ The same validation logic is available to Design users in the Central UI without
Gating against the instance surface is a design decision worth knowing: a shared script executes inline inside the calling script's context, so it is type-checked as if it were an instance script. A shared script that references an identifier the instance surface does not expose fails at save, and one that uses an instance accessor (`Attributes`, `Instance`, …) compiles — whether that accessor is meaningful at run time depends on the caller.
## Configuration Audit Shape
`IAuditService.LogAsync` serialises the after-state it is handed into the
indefinitely-retained `AuditLogEntries.AfterStateJson`. Template Engine services
therefore hand it a **projected summary** for aggregates, never a tracked entity
graph (review 2026-10-21 08/G1, `TemplateAuditShapes`):
- **Template** create / update / move — identity and scalar fields (`Id`, `Name`,
`Description`, `ParentTemplateId`, `FolderId`, `IsDerived`, `OwnerCompositionId`),
per-collection member counts, and `ChangedFields` (e.g. `Name`, `Description`,
`FolderId`). No member rows. A rename of a 40-script template used to write all 40
script bodies.
- **Template script** and **shared script** create / update — every scalar field
except the body, which is recorded as `CodeLength` + `CodeSha256`, so an auditor can
tell whether (and to what) a body changed without the table storing every revision
of every body.
Small leaf entities (attributes, alarms, compositions, folders, areas, instance
overrides) are still audited as-is.
## Dependencies
- **Configuration Database (MS SQL)**: Stores all templates, instances, areas, and their relationships.