Bring F3 up to its release branch, with both sides' store tests (part 13 of 14)
mesh/merge-gate head 84a75ed2a412 merged into trunk fcdecb436117 — fail: head 84a75ed2a412 does not merge cleanly into trunk fcdecb436117: in conflict cmd/…
mesh/repo-check head 84a75ed2a412 merged into trunk fcdecb436117 — fail: head 84a75ed2a412 does not merge cleanly into trunk fcdecb436117: in conflict cmd/…
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate head 84a75ed2a412 merged into trunk fcdecb436117 — fail: head 84a75ed2a412 does not merge cleanly into trunk fcdecb436117: in conflict cmd/…
mesh/repo-check head 84a75ed2a412 merged into trunk fcdecb436117 — fail: head 84a75ed2a412 does not merge cleanly into trunk fcdecb436117: in conflict cmd/…
mesh/delivery superseded: a newer head of the same pull request
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,9 +20,11 @@ func (i *Inventory) Layer(ctx context.Context, nodeName, module string) (map[str
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
// Said whole, as it was set: its config values and the placement kept beside them (novox/hq ADR 0348
|
||||
// clause 11), so a person reading it before setting it sees every key they may keep or remove.
|
||||
var raw []byte
|
||||
err = i.store.Pool().QueryRow(ctx,
|
||||
`select values from settings where module = $1 and node is not distinct from $2::uuid`,
|
||||
err = i.store.Pool().QueryRow(ctx, `select `+layerWhole+` from settings s
|
||||
where s.module = $1 and s.node is not distinct from $2::uuid`,
|
||||
module, nodeID).Scan(&raw)
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return nil, false, nil
|
||||
@@ -46,6 +48,9 @@ type PastLayer struct {
|
||||
ReplacedBy string
|
||||
// SetBy is who had set the layer, when it was kept (novox/hq ADR 0277); empty for one set before that was kept.
|
||||
SetBy string
|
||||
// Why is why it went, where that was said: "moved to placement, ADR 0348 clause 11" for a layer whose
|
||||
// placement keys migration 0097 moved out of it (ReplacedBy "moved").
|
||||
Why string
|
||||
}
|
||||
|
||||
// LayerOrigin is who set a layer and when (novox/hq ADR 0277): empty words for a layer set before who set it was
|
||||
@@ -79,7 +84,7 @@ func (i *Inventory) SettingsHistory(ctx context.Context, nodeName, module string
|
||||
return nil, err
|
||||
}
|
||||
rows, err := i.store.Pool().Query(ctx,
|
||||
`select values, set_at, replaced_at, replaced_by, set_by from settings_history
|
||||
`select values, set_at, replaced_at, replaced_by, set_by, why from settings_history
|
||||
where module = $1 and node is not distinct from $2::uuid order by replaced_at desc`,
|
||||
module, nodeID)
|
||||
if err != nil {
|
||||
@@ -90,13 +95,16 @@ func (i *Inventory) SettingsHistory(ctx context.Context, nodeName, module string
|
||||
for rows.Next() {
|
||||
var raw []byte
|
||||
var p PastLayer
|
||||
var by *string
|
||||
if err := rows.Scan(&raw, &p.SetAt, &p.ReplacedAt, &p.ReplacedBy, &by); err != nil {
|
||||
var by, why *string
|
||||
if err := rows.Scan(&raw, &p.SetAt, &p.ReplacedAt, &p.ReplacedBy, &by, &why); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if by != nil {
|
||||
p.SetBy = *by
|
||||
}
|
||||
if why != nil {
|
||||
p.Why = *why
|
||||
}
|
||||
if err := json.Unmarshal(raw, &p.Values); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -107,9 +115,15 @@ func (i *Inventory) SettingsHistory(ctx context.Context, nodeName, module string
|
||||
|
||||
// keepReplacedSQL copies a layer into the history before it is replaced or cleared; run in the same
|
||||
// transaction as the write where there is one, so a write that fails leaves no history of it.
|
||||
//
|
||||
// The layer is kept whole, as it was set: its config values and its placement (novox/hq ADR 0348 clause 11).
|
||||
const keepReplacedSQL = `insert into settings_history (node, module, values, set_at, replaced_by, set_by)
|
||||
select node, module, values, set_at, $3, set_by from settings
|
||||
where module = $1 and node is not distinct from $2::uuid`
|
||||
select s.node, s.module, ` + layerWhole + `, s.set_at, $3, s.set_by from settings s
|
||||
where s.module = $1 and s.node is not distinct from $2::uuid`
|
||||
|
||||
// layerWhole is a settings row `s` with the placement kept beside it folded back in: the layer as it was set.
|
||||
const layerWhole = `s.values || coalesce((select p.values from placement p
|
||||
where p.module = s.module and p.node is not distinct from s.node), '{}'::jsonb)`
|
||||
|
||||
// layerNode is the node id of a layer, nil for the whole mesh's.
|
||||
func (i *Inventory) layerNode(ctx context.Context, nodeName string) (*string, error) {
|
||||
|
||||
Reference in New Issue
Block a user