Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/nftban-installer/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// meta:description="CLI flag definitions and environment variable overrides"
// meta:inventory.files="cmd/nftban-installer/flags.go"
// meta:inventory.binaries=""
// meta:inventory.env_vars="NFTBAN_TAKEOVER, NFTBAN_INSTALLER_LOG"
// meta:inventory.env_vars="NFTBAN_TAKEOVER, NFTBAN_INSTALLER_LOG, NFTBAN_LIFECYCLE"
// meta:inventory.config_files=""
// meta:inventory.systemd_units=""
// meta:inventory.network=""
Expand Down Expand Up @@ -41,6 +41,7 @@ type config struct {
stateDir string // override state directory
logPath string // override log file path
showVersion bool // print version and exit
lifecycle bool // v1.98: use canonized lifecycle flow (feature flag)
}

func parseFlags() *config {
Expand Down Expand Up @@ -69,6 +70,9 @@ func parseFlags() *config {
if envLog := os.Getenv("NFTBAN_INSTALLER_LOG"); envLog != "" {
cfg.logPath = envLog
}
// v1.98 Phase 2: Canonized lifecycle feature flag
// Default: ON. Set NFTBAN_LIFECYCLE=0 to use legacy path.
cfg.lifecycle = os.Getenv("NFTBAN_LIFECYCLE") != "0"

// Validate
if !cfg.showVersion && !cfg.repair {
Expand Down
43 changes: 28 additions & 15 deletions cmd/nftban-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,14 @@ func run(ctx context.Context, exec executor.Executor, sf *state.StateFile, cfg *

// runInstall runs all phases in order for a fresh install or upgrade.
func runInstall(ctx context.Context, exec executor.Executor, sf *state.StateFile, cfg *config, log *logging.Logger) int {
// v1.98: Initialize lifecycle bridge (observational only — INV-I-004)
lb := newLifecycleBridge(cfg.mode, log)
// v1.98 Phase 2: Feature flag controls lifecycle bridge activation
var lb *lifecycleBridge
if cfg.lifecycle {
log.Info("lifecycle_mode=canonized (NFTBAN_LIFECYCLE=on)")
lb = newLifecycleBridge(cfg.mode, log)
} else {
log.Info("lifecycle_mode=legacy (NFTBAN_LIFECYCLE=0)")
}

phases := []struct {
phase state.Phase
Expand All @@ -151,7 +157,9 @@ func runInstall(ctx context.Context, exec executor.Executor, sf *state.StateFile
if ctx.Err() != nil {
log.Error("installer timed out or cancelled during phase %s", p.name)
sf.Transition(state.StateFailedRebuild, p.phase, "timeout")
lb.observeResult(sf) // v1.98: record failure
if lb != nil {
lb.observeResult(sf)
}
return report(sf, log)
}

Expand All @@ -160,25 +168,30 @@ func runInstall(ctx context.Context, exec executor.Executor, sf *state.StateFile
log.Error("phase %s failed: %v", p.name, err)
log.PhaseEnd(p.name)

// v1.98: Emit lifecycle observations for the phase that completed before failure
if p.phase == state.PhaseDetect {
lb.observeDetect(&globalPhaseData, sf)
lb.observePlan(&globalPhaseData)
if lb != nil {
if p.phase == state.PhaseDetect {
lb.observeDetect(&globalPhaseData, sf)
lb.observePlan(&globalPhaseData)
}
lb.observeResult(sf)
}
lb.observeResult(sf) // record failure outcome
return report(sf, log)
}

// v1.98: Lifecycle observations at phase boundaries
switch p.phase {
case state.PhaseDetect:
lb.observeDetect(&globalPhaseData, sf)
lb.observePlan(&globalPhaseData)
// Lifecycle observations at phase boundaries (only when flag is on)
if lb != nil {
switch p.phase {
case state.PhaseDetect:
lb.observeDetect(&globalPhaseData, sf)
lb.observePlan(&globalPhaseData)
}
}
}

// v1.98: Record final lifecycle result
lb.observeResult(sf)
// Record final lifecycle result (only when flag is on)
if lb != nil {
lb.observeResult(sf)
}

log.PhaseEnd("Validate")
return report(sf, log)
Expand Down
Loading