Repository navigation
π fix: warn before boot recovery drops safety gates - #16446
thatguywob wants to merge 1 commit into
Conversation
Compare the selected boot config against surviving runtime, backup and dashboard layers before replacing the runtime snapshot. Keep gate deltas visible in status and settings, expose hive config diff, and support strict startup refusal through config.refuse_gate_regression. Hive-Run: hivecommons#16438 Hive-Plan: boot-safety-gate-regression Hive-Spec: issue-16438#proposed-behaviour Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> Signed-off-by: thatguywob <thatguywob@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@thatguywob this PR is back in your court ( Failing checks:
Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path. Your relay could not take this as a |
96d5ad5
|
Open PR overlap checkBase branch:
Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Decision needed: @clubanderson should decide whether #16446 (entrypoint hive config diff before the snapshot write) or #16449 (Go-side boot check) is the implementation of #16438 that lands β they add the same config.refuse_gate_regression key with different Go fields, status shapes and prior-file sets, so both cannot merge.
Conclusion: the mechanism is sound and does what the body says, but this PR conflicts with #16449 (same issue, same YAML key, incompatible shapes), it carries sentinel-alert for touching src/deploy/entrypoint.sh (routing to a maintainer is required for that alone), and consulting the legacy /data/hive.yaml.bak makes the warning β and strict mode β fire on every boot of a migrated hive.
Conflict with #16449 (both Fixes #16438)
Read both diffs in full. Same intent, different change β not a duplicate, a conflict:
| #16446 (this) | #16449 | |
|---|---|---|
config: block Go field |
Config.Config *ConfigLoadPolicy (config.go:77) |
Config.ConfigGuard ConfigGuardConfig |
/api/status shape |
configSafetyWarnings: []string (server.go:554) |
config.gate_regressions: [{gate,previous,effective,source}] |
| where the compare runs | entrypoint, before the cp at entrypoint.sh:1157, via new hive config diff |
Go boot, after that cp |
| prior files | runtime, runtime.bak, legacy .bak, dashboard |
runtime, runtime.bak, dashboard |
Whichever lands second will not apply (both are labelled conflicts-with-open-pr).
Finding β legacy .bak makes this fire forever on migrated hives (medium)
src/cmd/hive/config_diff.go:29includesconfig.RuntimeConfigFileLegacy(/data/hive.yaml.bak) in the default prior set.src/deploy/entrypoint.sh:1217callshive_check_safety_gatesunconditionally on every boot, including the steady-state "boot from runtime config" path atentrypoint.sh:992.- The legacy file is never removed or refreshed: migration leaves it in place (
entrypoint.sh:1189, "legacy left in place"), and the seed branch comment at:1155says the same. It is frozen at the moment of the rename.
Consequence: on any hive that migrated from .bak and whose operator later removed a gate on purpose (e.g. un-paused a repo via the dashboard), every subsequent boot logs safety gate dropped β¦ (previous: /data/hive.yaml.bak), and with config.refuse_gate_regression: true the pod refuses to start until someone deletes the legacy file. #16449 excludes the legacy file for exactly this reason. Dropping RuntimeConfigFileLegacy from the default list in config_diff.go:29 (keeping it available as a positional arg) would fix it.
What holds up
- Warnings are exported as
HIVE_BOOT_SAFETY_WARNINGSand read at status-build time (safety_gates.go:26,status_builder.go:395), so they survive the rootβdev re-exec and config reloads β #16449 loses its result on the first reload. hive_check_safety_gatesis idempotent via the-zguard, so the second call at:1217is a no-op after the seed-branch call at:1154.- Parser errors are deliberately not echoed (
safety_gates.go:80) β good, overlays carry credentials.
Scoping caveat (same in #16449)
The seed branch is only reached when hive_runtime_config_read returned empty (entrypoint.sh:991), so the a1 scenario is caught only if the moved-aside overlay sits at hive.yaml.runtime.bak or the legacy name. "Before the snapshot write" does not by itself rescue a runtime file that is already gone.
CI is red on this head (docker, dashboard/rest test shards, coverage, changelog-fragment-guard); not triaged here. Fork PR β I cannot push fixes here.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Security perspective (read at head Strict mode is itself a safety gate the recovery path drops silently β Suggested fix β honour strict mode from any surviving prior layer, and report its loss like the other gates: --- a/src/pkg/config/safety_gates.go
+++ b/src/pkg/config/safety_gates.go
@@ func SafetyGateDiff(path string, previous []string) ([]string, bool, error) {
warnings := []string{}
+ strict := effective.Config.RefuseGateRegression
for _, priorPath := range previous {
prior, err := readGateSnapshot(priorPath)
if os.IsNotExist(err) {
continue
}
if err != nil {
// Do not print parser errors: they can contain unrelated secret values.
warnings = append(warnings, fmt.Sprintf("safety gate comparison unavailable: %s (unreadable or invalid YAML)", priorPath))
continue
}
dropped := func(key string, was any) {
value, _ := json.Marshal(was)
warnings = append(warnings, fmt.Sprintf("safety gate dropped: %s (was %s) β effective config has none or a weaker restriction (previous: %s)", key, value, priorPath))
}
+ if prior.Config.RefuseGateRegression && !effective.Config.RefuseGateRegression {
+ dropped("config.refuse_gate_regression", true)
+ // A prior layer asked for refusal; the seed cannot silently waive it.
+ strict = true
+ }
if len(nonemptyLabels(prior.Review.RequireLabels)) > 0 && len(nonemptyLabels(effective.Review.RequireLabels)) == 0 {
@@
- return warnings, effective.Config.RefuseGateRegression, nil
+ return warnings, strict, nil
}Plus a case in Checked and found no issue: banner output is routed through Review findings from Intent alignment vs #16438 (read at head The three proposed behaviours land: per-gate Strict mode is read only from the effective config, so it cannot guard the scenario the issue describes β Suggested fix: honor strict mode from any surviving prior layer and flag its removal like the other gates: --- a/src/pkg/config/safety_gates.go
+++ b/src/pkg/config/safety_gates.go
@@ func SafetyGateDiff(path string, previous []string) ([]string, bool, error) {
warnings := []string{}
+ strict := effective.Config.RefuseGateRegression
for _, priorPath := range previous {
prior, err := readGateSnapshot(priorPath)
@@
warnings = append(warnings, fmt.Sprintf("safety gate dropped: %s (was %s) β effective config has none or a weaker restriction (previous: %s)", key, value, priorPath))
}
+ if prior.Config.RefuseGateRegression && !effective.Config.RefuseGateRegression {
+ dropped("config.refuse_gate_regression", true)
+ strict = true
+ }
if len(nonemptyLabels(prior.Review.RequireLabels)) > 0 && len(nonemptyLabels(effective.Review.RequireLabels)) == 0 {
@@
- return warnings, effective.Config.RefuseGateRegression, nil
+ return warnings, strict, nil
}and adjust the doc comment at Review findings from Correctness review (head 1. Default prior list includes the frozen legacy
|
|
|
@thatguywob the hive has adopted this PR ( |
|
Closing: #16438 was closed by the maintainer after #16449 (merged) landed the same boot-time safety-gate regression warning on v5 ( π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
Fixes #16438
Boot recovery could replace the runtime snapshot with a ConfigMap seed before reporting that safety gates had disappeared. Compare the selected boot config against surviving runtime,
.runtime.bak, legacy.bak, and dashboard files before that write, and log each removed label gate, repository pause, or relaxed per-repo writeback mode.The boot warnings remain visible in
/api/status(configSafetyWarnings) and the Settings banner across config reloads and the entrypoint's privilege-drop re-exec.config.refuse_gate_regression: truerefuses startup before snapshot replacement; unreadable or malformed prior files also produce a diagnostic and refuse startup in strict mode.hive config diff --config <path> [previous paths...]exposes the same comparison without starting services. Gate enforcement is unchanged.Added Go regression coverage for all prior file names, partial loss, preserved/stronger gates, malformed baselines, strict-mode persistence and CLI dispatch, and status visibility across reloads. Extended the existing entrypoint recovery suite to assert strict refusal happens before the snapshot write and normal recovery preserves its warning.
gofmt -lis clean for every changed Go file. Tests were not run locally, as required by AGENTS.md; CI supplies the test verdict. This has not been deployed.β hive: backend=codex
π Hive Agent:
contributor| SHA:96d5ad5db