census: record-write inventory for the named-units parameter path
A new layer, namedUnitsParamWriteCensusInventory, on staticcheckSA4006WriteCensusInventory. The three new Put sites are the operator's ssm:PutParameter of /carlos/host/named-units/<instance-id>, off the box with their own AWS profile, not a deployment-bucket record: ssmNamedUnits.Put and runNamedUnitsPut are nonrecord, and the NamedUnitsStore interface is reference, as store interfaces declaring Put are. proofBindingSource.record is re-digested: its decode moved to namedunits.Decode and its guard check to guardNames, and its record-key use and writes are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+63
−1
internal/provision/named_units_param_114_census_test.go+62 −0internal/provision/plan9_b8_census_test.go+1 −1
CI passed — run details
diff --git a/internal/provision/named_units_param_114_census_test.go b/internal/provision/named_units_param_114_census_test.go| new file mode 100644 |
| index 000000000..4b9f62fc3 |
| --- /dev/null |
| +++ b/internal/provision/named_units_param_114_census_test.go |
| @@ -0,0 +1,62 @@ |
| +package provision |
| + |
| +// Record-write census entries for named units from a parameter (branch |
| +// named-units-param-114, #114 follow-up), layered on |
| +// staticcheckSA4006WriteCensusInventory. No deployment-bucket record write is |
| +// added, moved or reclassified. The three new units name Put because the |
| +// operator's `carlos system named-units put` writes an AWS SSM parameter, |
| +// /carlos/host/named-units/<instance-id>, with ssm:PutParameter (Type String, |
| +// Overwrite), off the box with the operator's own AWS profile. That is not a |
| +// release.Store and no record key, prefix or record literal is involved. |
| +// hostenv's other SSM writers (awsssm.go's Set and SetNew) are not listed |
| +// because they name no census method; these are classified as the census |
| +// classifies a non-record Put and an interface that only declares one. |
| +// - proofBindingSource.record (internal/host/proofnamed.go): re-digested. |
| +// Its declaration decode moved, unchanged in effect, into |
| +// namedunits.Decode (DisallowUnknownFields, one document, schema 1, the |
| +// host, app and account checks; any failure still os.ErrPermission), and |
| +// the console guard comparison into guardNames and consoleReadyMarker. |
| +// Its record-key use (key:RecordKey) and its writes are unchanged. |
| +// - ssmNamedUnits.Put (internal/hostenv/namedunits.go, new): defines Put as |
| +// ssm:PutParameter of the instance's named-units parameter; nonrecord. |
| +// - type NamedUnitsStore (internal/hostenv/namedunits.go, new): the |
| +// interface put and show use, which declares Put; reference, as the |
| +// store interfaces that declare Put are. |
| +// - runNamedUnitsPut (system_namedunits.go, new): the operator's put verb; |
| +// validates the file, then calls NamedUnitsStore.Put; nonrecord. |
| +func namedUnitsParamWriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), staticcheckSA4006WriteCensusInventory()...) |
| + repins := []censusEntry{ |
| + {"internal/host/proofnamed.go", "proofBindingSource.record", "key-site", "key:RecordKey", "21a528f71bb3be3f53468c641de4dbbb1205abfe29ffb0a394f3545934aa9a72"}, |
| + } |
| + for _, r := range repins { |
| + found := false |
| + for i, e := range entries { |
| + if e.File == r.File && e.Unit == r.Unit { |
| + if e.Class != r.Class || e.Kinds != r.Kinds { |
| + panic("named-units-param-114 re-pin changes the class or kinds of " + r.File + ":" + r.Unit) |
| + } |
| + entries[i], found = r, true |
| + } |
| + } |
| + if !found { |
| + panic("named-units-param-114 re-pin of an unlisted unit " + r.File + ":" + r.Unit) |
| + } |
| + } |
| + added := []censusEntry{ |
| + // ssm:PutParameter of /carlos/host/named-units/<instance-id>, operator's AWS profile; no store, no record key. |
| + {"internal/hostenv/namedunits.go", "ssmNamedUnits.Put", "nonrecord", "def:Put", "10ec8f4102ceda1775cb9d1baf6377354c0c79f8a25f8d43515deedef53c0b40"}, |
| + // The SSM parameter interface put and show use; declares Put, writes nothing itself. |
| + {"internal/hostenv/namedunits.go", "type NamedUnitsStore", "reference", "id:Put", "6c569bdf216ac1bbca2b7cc5e886a92fbba474029f1e5c9f2ee34a68ea2e7405"}, |
| + // carlos system named-units put: validates the file, then NamedUnitsStore.Put (SSM); no store, no record key. |
| + {"system_namedunits.go", "runNamedUnitsPut", "nonrecord", "sel:Put", "f13d985d5c19ed627e5e8028733bb30481f36e00dc8804ac4fa70f44aad14a50"}, |
| + } |
| + for _, a := range added { |
| + for _, e := range entries { |
| + if e.File == a.File && e.Unit == a.Unit { |
| + panic("named-units-param-114 addition of a listed unit " + a.File + ":" + a.Unit) |
| + } |
| + } |
| + } |
| + return append(entries, added...) |
| +} |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index 8b06d91df..6b27623ee 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := staticcheckSA4006WriteCensusInventory() |
| + inventory := namedUnitsParamWriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |