features

package
v0.48.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

View Source
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 gates startup/post-mutation/monitor autosync behavior.
	SyncAutosync = Feature{
		Name:        "sync_autosync",
		Default:     false,
		Description: "Enable background autosync hooks",
	}

	// 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",
	}
)
View Source
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 td sync command entry point",
	},
	{
		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:   "Gates sync diagnostics command",
	},
	{
		Feature: SyncAutosync.Name,
		Surface: "cmd/root.go#PersistentPreRun",
		Notes:   "Gates startup push/pull hook",
	},
	{
		Feature: SyncAutosync.Name,
		Surface: "cmd/root.go#PersistentPostRun",
		Notes:   "Gates post-mutation autosync hook",
	},
	{
		Feature: SyncAutosync.Name,
		Surface: "cmd/monitor.go",
		Notes:   "Gates monitor periodic autosync loop",
	},
	{
		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

func IsEnabled(baseDir, name string) bool

IsEnabled resolves a feature using env overrides, then project config, then defaults.

func IsEnabledForProcess

func IsEnabledForProcess(name string) bool

IsEnabledForProcess resolves a feature using env overrides then defaults. Useful during command registration when project config may not be available.

func IsKnownFeature

func IsKnownFeature(name string) bool

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

func Resolve(baseDir, name string) (bool, string)

Resolve returns the resolved feature state and the source ("env", "config", "default").

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):

  1. TD_FEATURE_REVIEW_POLICY_MODE env var (explicit) -> use it
  2. config.FeatureStringFlags["review_policy_mode"] (explicit) -> use it
  3. legacy balanced_review_policy EXPLICITLY set (env or config, NOT default) -> map true->balanced / false->strict AND emit a one-time deprecation warning.
  4. 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 Feature

type Feature struct {
	Name        string
	Default     bool
	Description string
}

Feature describes a named feature flag.

func ListAll

func ListAll() []Feature

ListAll returns all known features.

type GateMapEntry

type GateMapEntry struct {
	Feature string
	Surface string
	Notes   string
}

GateMapEntry records a concrete sync surface that must be gated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL