Documentation
¶
Index ¶
- Constants
- Variables
- func IsEnabled(baseDir, name string) bool
- func IsEnabledForProcess(name string) bool
- func IsKnownFeature(name string) bool
- func ResetDeprecationWarningsForTests()
- func Resolve(baseDir, name string) (bool, string)
- func ResolveExplicit(baseDir, name string) (value bool, explicit bool)
- func ResolveReviewPolicyMode(baseDir string) (reviewpolicy.Mode, error)
- type Feature
- type GateMapEntry
Constants ¶
const ( ReviewPolicyMode = "review_policy_mode" ReviewPolicyModeDefault = string(reviewpolicy.ModeTrusted) )
ReviewPolicyMode is the string-valued feature name that selects between strict | balanced | delegated | trusted review policies.
Default: trusted (Step 5 / trusted-review-mode final stage). Prior to this the resolver default was delegated, and before that the effective default was balanced via the legacy BalancedReviewPolicy=true feature flag. The final stage flipped the resolver default to trusted — a fresh install with no explicit configuration now runs the trusted flow. Trusted keeps the delegated review-attestation model (prefer an independent reviewer; any session may close once an independent approval is recorded) and adds a flag-gated, audited self-review escape hatch: an implementer/orchestrator who has reviewed their own diff may approve+close with `td approve <id> --self-review --reason "..."`. Projects that want the hard wall can pin review_policy_mode=delegated|balanced|strict.
Implementation note (Option B): the existing Feature struct is boolean- typed, and retrofitting it with a union type would ripple through ListAll / IsKnownFeature / defaultValues / env-override logic. The less invasive path is to keep Feature unchanged and add a parallel string-feature resolver. This keeps the bool-feature surface simple and opts string features in one-by-one. If a second string feature ever shows up, this should be generalized.
Variables ¶
var ( // BalancedReviewPolicy allows creator-only approval for issues implemented by // a different session, while still blocking implementer/self approval. // // DEPRECATED (Step 5): prefer review_policy_mode=balanced. The flag remains // registered so existing configs do not error at load time. When explicitly // set, it still maps to balanced mode (Default=false means an untouched // config does NOT trip the deprecation warning). The flag will be removed // in a future release. BalancedReviewPolicy = Feature{ Name: "balanced_review_policy", Default: false, Description: "DEPRECATED: use review_policy_mode=balanced. Allows creator-only approvals for externally implemented issues.", } // SyncCLI gates user-facing sync/auth commands. SyncCLI = Feature{ Name: "sync_cli", Default: false, Description: "Enable sync/auth CLI commands for end users", } // SyncAutosync is an explicit override for the autosync hooks. As of // td-a4c721 it is no longer the primary gate: autosync fires automatically // when the project is actually configured for sync (sync_state + auth). This // flag only matters when set EXPLICITLY (env or project config) — an explicit // true forces the hooks on, an explicit false forces them off. When unset // (source=default) the per-project sync config decides. The Default stays // false so an untouched config does not count as an explicit override. SyncAutosync = Feature{ Name: "sync_autosync", Default: false, Description: "Explicit override for autosync hooks (default: follow per-project sync config)", } // SyncMonitorPrompt gates the monitor sync prompt UX. SyncMonitorPrompt = Feature{ Name: "sync_monitor_prompt", Default: false, Description: "Enable monitor sync setup prompt", } // SyncNotes gates notes entity sync for sidecar notes plugin rollout. SyncNotes = Feature{ Name: "sync_notes", Default: true, Description: "Enable sync transport for notes entities", } )
var SyncGateMap = []GateMapEntry{ { Feature: SyncCLI.Name, Surface: "cmd/auth.go", Notes: "Gates auth login/logout/status commands", }, { Feature: SyncCLI.Name, Surface: "cmd/sync.go", Notes: "Gates the full td sync entry point and its mutating subcommands (push/pull/init). The read-only `td sync status` diagnostic and the enable/disable kill-switch subcommands live on an always-on parent and are NOT gated (td-78b482, td-735875).", }, { Feature: SyncCLI.Name, Surface: "cmd/sync_conflicts.go", Notes: "Gates td sync conflicts subcommand", }, { Feature: SyncCLI.Name, Surface: "cmd/sync_tail.go", Notes: "Gates td sync tail subcommand", }, { Feature: SyncCLI.Name, Surface: "cmd/sync_init.go", Notes: "Gates guided sync setup wizard", }, { Feature: SyncCLI.Name, Surface: "cmd/project.go", Notes: "Gates sync-project management commands", }, { Feature: SyncCLI.Name, Surface: "cmd/config.go", Notes: "Gates sync configuration commands", }, { Feature: SyncCLI.Name, Surface: "cmd/doctor.go", Notes: "NO LONGER GATED: td doctor is a read-only diagnostic registered ungated so a stranded project can always be diagnosed (td-78b482). Entry retained for traceability; the SyncCLI gate no longer applies to it.", }, { Feature: SyncAutosync.Name, Surface: "cmd/root.go#PersistentPreRun", Notes: "Explicit override for startup push/pull hook (default: per-project sync config decides; td-a4c721)", }, { Feature: SyncAutosync.Name, Surface: "cmd/root.go#PersistentPostRun", Notes: "Explicit override for post-mutation autosync hook (default: per-project sync config decides; td-a4c721)", }, { Feature: SyncAutosync.Name, Surface: "cmd/monitor.go", Notes: "Explicit override for monitor periodic autosync loop (default: per-project sync config decides; td-a4c721)", }, { Feature: SyncMonitorPrompt.Name, Surface: "pkg/monitor/commands.go#checkSyncPrompt", Notes: "Gates first-run monitor sync prompt trigger", }, { Feature: SyncMonitorPrompt.Name, Surface: "pkg/monitor/sync_prompt.go", Notes: "Gates monitor sync prompt modal flows", }, { Feature: SyncNotes.Name, Surface: "cmd/sync.go#syncEntityValidator", Notes: "Gates notes entity handling during manual sync push/pull", }, { Feature: SyncNotes.Name, Surface: "cmd/autosync.go", Notes: "Gates notes entity handling during autosync push/pull", }, }
SyncGateMap is the authoritative map of sync-related surfaces to feature flags. Paths refer to the sync implementation currently on the "sunc" branch.
Functions ¶
func IsEnabled ¶
IsEnabled resolves a feature using env overrides, then project config, then defaults.
func IsEnabledForProcess ¶
IsEnabledForProcess resolves a feature using env overrides then defaults. Useful during command registration when project config may not be available.
func IsKnownFeature ¶
IsKnownFeature returns true when the feature exists in the registry.
func ResetDeprecationWarningsForTests ¶ added in v0.45.0
func ResetDeprecationWarningsForTests()
ResetDeprecationWarningsForTests clears the once-only deprecation warning latches. Intended for use from tests in this package only.
func Resolve ¶
Resolve returns the resolved feature state and the source ("env", "config", "default").
func ResolveExplicit ¶ added in v0.52.0
ResolveExplicit resolves a feature and reports whether the value was set explicitly (env or project config) versus falling back to the registered default. explicit is true when the resolution source is "env" or "config".
This lets callers distinguish "explicitly set false" from "unset/default" — the autosync gate (td-a4c721) uses this to treat sync_autosync as an explicit override rather than a primary on/off switch.
func ResolveReviewPolicyMode ¶ added in v0.45.0
func ResolveReviewPolicyMode(baseDir string) (reviewpolicy.Mode, error)
ResolveReviewPolicyMode returns the effective review-policy mode for the given project baseDir. Resolution order (Step 5):
- TD_FEATURE_REVIEW_POLICY_MODE env var (explicit) -> use it
- config.FeatureStringFlags["review_policy_mode"] (explicit) -> use it
- legacy balanced_review_policy EXPLICITLY set (env or config, NOT default) -> map true->balanced / false->strict AND emit a one-time deprecation warning.
- default: trusted.
Key difference from the pre-flip behavior: the legacy flag's *default* value no longer feeds into mode resolution. Only an explicit set triggers the compat mapping. Users who never touched either flag now get trusted mode (delegated review-attestation plus a flag-gated self-review escape hatch). Explicit review_policy_mode and env overrides are honored unchanged.
Conflict detection: if BOTH review_policy_mode AND balanced_review_policy are set EXPLICITLY (env or config, not default) to values that disagree, refuse to resolve rather than pick a silent winner.
Types ¶
type GateMapEntry ¶
GateMapEntry records a concrete sync surface that must be gated.