High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix(remedy): capability-gate and config-set remedies are mode-neutral so following one no longer destroys a bridge (PIN-403)
Luigi Agosti8f02c357e93d
diff --git a/cmd/pinchtab/capability_remedy_executable_test.go b/cmd/pinchtab/capability_remedy_executable_test.goindex e59bdc01..5abeec9a 100644--- a/cmd/pinchtab/capability_remedy_executable_test.go+++ b/cmd/pinchtab/capability_remedy_executable_test.go@@ -199,19 +199,29 @@ func TestCapabilityRemedySettingsAreAcceptedByTheConfigEditor(t *testing.T) {}}-// The restart half must name a command that exists at that exact path. Finding it-// through the tree rather than asserting the literal means a renamed or moved-// verb reds here instead of shipping a remedy nobody can run.-func TestCapabilityRemedyRestartCommandExists(t *testing.T) {- line, _ := httpx.DisabledEndpointDetails("security.allowCookies")["remedy"].(string)-- const restart = "pinchtab server restart"- if !strings.Contains(line, restart) {- t.Fatalf("remedy = %q, want it to name %q", line, restart)+// The capability remedy must be the mode-neutral config write, never the+// server-only restart: this gate answers on a bridge too, where `pinchtab server+// restart` would kill it. The restart guidance lives in the hint instead. This+// supersedes the old test that required the remedy to name `pinchtab server+// restart`. That command must still resolve, because the config-set CLI hint names+// it on the one surface where the mode is known to be a server.+func TestCapabilityRemedyIsModeNeutralAndServerRestartStillResolves(t *testing.T) {+ details := httpx.DisabledEndpointDetails("security.allowCookies")+ remedy, _ := details["remedy"].(string)+ hint, _ := details["hint"].(string)++ if remedy != "pinchtab config set security.allowCookies true" {+ t.Fatalf("remedy = %q, want the mode-neutral config write", remedy)+ }+ if strings.Contains(remedy, "pinchtab server restart") {+ t.Fatalf("remedy names `pinchtab server restart`, which destroys a bridge if run: %q", remedy)+ }+ if !strings.Contains(strings.ToLower(hint), "restart pinchtab") {+ t.Fatalf("hint does not carry the mode-neutral restart guidance: %q", hint)}found, _, err := rootCmd.Find([]string{"server", "restart"})if err != nil || found.CommandPath() != "pinchtab server restart" {- t.Fatalf("`%s` does not resolve to itself (got %q, err %v); the remedy names a command that no longer exists",- restart, found.CommandPath(), err)+ t.Fatalf("`pinchtab server restart` does not resolve to itself (got %q, err %v); the config-set hint names a command that no longer exists",+ found.CommandPath(), err)}}diff --git a/cmd/pinchtab/cmd_config_actions.go b/cmd/pinchtab/cmd_config_actions.goindex 32653139..b0bdf593 100644--- a/cmd/pinchtab/cmd_config_actions.go+++ b/cmd/pinchtab/cmd_config_actions.go@@ -1,9 +1,12 @@package mainimport (+ "encoding/json""fmt"+ "net/http""os""strings"+ "time""github.com/pinchtab/pinchtab/internal/cli""github.com/pinchtab/pinchtab/internal/cli/output"@@ -233,7 +236,34 @@ func emitDefaultConfigHint() {func hintRestartIfRunning() {cfg := loadLocalConfig()- if server.CheckPinchTabRunning(cfg.Port, cfg.Token) {- output.Hint("Server is running — restart it to apply changes: pinchtab server restart")+ probe := server.ProbeHealthWithToken(+ fmt.Sprintf("http://localhost:%s/health", cfg.Port), 500*time.Millisecond, cfg.Token)+ if !probe.Reachable || probe.StatusCode != http.StatusOK {+ return+ }+ output.Hint(restartHintForMode(healthMode(probe.Body)))+}++// restartHintForMode names the restart appropriate to the running instance. Only+// the server/daemon front door (/health mode "dashboard") is safe to restart with+// `pinchtab server restart`; a bridge is Ctrl-C + re-run `pinchtab bridge`, and+// naming the server command would tell a bridge user to kill their bridge. Any+// other or unknown mode gets the mode-neutral instruction.+func restartHintForMode(mode string) string {+ if mode == "dashboard" {+ return "Server is running — restart it to apply changes: pinchtab server restart"+ }+ return "A PinchTab instance is running — restart it to apply this change."+}++// healthMode reads the "mode" field from a /health body, or "" when the body is+// absent or not the expected JSON.+func healthMode(body []byte) string {+ var payload struct {+ Mode string `json:"mode"`+ }+ if err := json.Unmarshal(body, &payload); err != nil {+ return ""}+ return payload.Mode}diff --git a/cmd/pinchtab/cmd_config_test.go b/cmd/pinchtab/cmd_config_test.goindex ad091704..afacd84d 100644--- a/cmd/pinchtab/cmd_config_test.go+++ b/cmd/pinchtab/cmd_config_test.go@@ -419,11 +419,33 @@ func resetConfigSchemaPrintFlag(t *testing.T) {}}+// restartHintForMode names `pinchtab server restart` only for the server/daemon+// front door ("dashboard"); a bridge (or an unknown mode) gets a mode-neutral+// instruction, because that command would stop a bridge. This is the config-set+// path counterpart of the capability-gate remedy test.+func TestRestartHintForMode(t *testing.T) {+ dashboard := restartHintForMode("dashboard")+ if !strings.Contains(dashboard, "pinchtab server restart") {+ t.Errorf("dashboard hint should name the server restart command: %q", dashboard)+ }+ for _, mode := range []string{"bridge", "server", ""} {+ hint := restartHintForMode(mode)+ if strings.Contains(hint, "pinchtab server restart") {+ t.Errorf("mode %q hint names `pinchtab server restart`, which is wrong off the dashboard: %q", mode, hint)+ }+ if !strings.Contains(strings.ToLower(hint), "restart") {+ t.Errorf("mode %q hint does not tell the caller to restart: %q", mode, hint)+ }+ }+}+func TestConfigSetHintsRestartWhenServerRunning(t *testing.T) {- // Spin up a fake health endpoint so hintRestartIfRunning detects a running server.+ // Spin up a fake dashboard health endpoint so hintRestartIfRunning detects a+ // running server (mode "dashboard"), the surface where `pinchtab server restart`+ // is the correct command.srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {w.WriteHeader(200)- _, _ = w.Write([]byte(`{"status":"ok"}`))+ _, _ = w.Write([]byte(`{"status":"ok","mode":"dashboard"}`))}))defer srv.Close()@@ -460,6 +482,45 @@ func TestConfigSetHintsRestartWhenServerRunning(t *testing.T) {}}+// AC: config set of a capability while a BRIDGE is running must not print a hint+// that names `pinchtab server restart` — running it would kill the bridge.+func TestConfigSetHintDoesNotNameServerRestartForBridge(t *testing.T) {+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(200)+ _, _ = w.Write([]byte(`{"status":"ok","mode":"bridge"}`))+ }))+ defer srv.Close()++ port := srv.URL[strings.LastIndex(srv.URL, ":")+1:]++ configPath := filepath.Join(t.TempDir(), "pinchtab", "config.json")+ t.Setenv("PINCHTAB_CONFIG", configPath)+ configJSON := []byte(`{"configVersion":"0.8.0","server":{"port":"` + port + `","token":"test-token-for-restart-hint-00000"}}`)+ if err := os.MkdirAll(filepath.Dir(configPath), 0o755); err != nil {+ t.Fatalf("MkdirAll() error = %v", err)+ }+ if err := os.WriteFile(configPath, configJSON, 0o600); err != nil {+ t.Fatalf("WriteFile() error = %v", err)+ }+ t.Cleanup(func() { rootCmd.SetArgs(nil) })++ stderr := captureStderr(t, func() {+ _ = captureStdout(t, func() {+ rootCmd.SetArgs([]string{"config", "set", "security.allowScreencast", "true"})+ if err := rootCmd.Execute(); err != nil {+ t.Fatalf("Execute() error = %v", err)+ }+ })+ })++ if strings.Contains(stderr, "pinchtab server restart") {+ t.Fatalf("bridge-mode config set named `pinchtab server restart`, which would kill the bridge: %q", stderr)+ }+ if !strings.Contains(stderr, "restart") {+ t.Fatalf("expected a mode-neutral restart hint on stderr, got %q", stderr)+ }+}+func TestIsSensitiveConfigPath(t *testing.T) {cases := map[string]bool{"server.token": true,diff --git a/internal/handlers/capability_refusal_test.go b/internal/handlers/capability_refusal_test.goindex cc1136ed..a6b0b953 100644--- a/internal/handlers/capability_refusal_test.go+++ b/internal/handlers/capability_refusal_test.go@@ -49,11 +49,18 @@ func capabilityRefusal(t *testing.T, method, path string, call func(*Handlers, h}// remedyFor is the one place the expected remedy is spelled, so every assertion-// below compares against the same contract rather than its own copy.+// below compares against the same contract rather than its own copy. The remedy is+// the mode-neutral config write only: `pinchtab server restart` would destroy a+// bridge, which answers these same gates, so the restart guidance lives in the hint+// instead (see restartHint).func remedyFor(setting string) string {- return "pinchtab config set " + setting + " true && pinchtab server restart"+ return "pinchtab config set " + setting + " true"}+// restartHint is the mode-neutral prose the hint carries so a caller applies the+// change with the restart correct for their own mode.+const restartHint = "restart pinchtab"+// /storage is gated by the stateExport capability, so the old wording sent the// reader looking for a "stateExport endpoint" that does not exist. /cookies is// the shape whose label already matched, and must still read correctly.@@ -107,10 +114,11 @@ func TestCapabilityRefusalNamesTheCapabilityAndKeepsTheCode(t *testing.T) {}}-// The dead end this closes: the remedy stopped at the config write. Writing the-// setting is a successful no-op for the caller — the security block is read at-// boot — so the identical 403 came back, and the agent reading it has no other-// instruction to try.+// Every capability refusal must carry the mode-neutral config-write remedy AND a+// hint that names the restart — never `pinchtab server restart` in the executable+// remedy, which would kill a bridge answering this same gate. Writing the setting+// is only half the fix (the security block is read at boot), so the restart the+// caller still needs is stated in the hint as prose they apply for their own mode.//// The scope is derived from the route catalogue rather than listed here, so a// capability added there is covered the day it is added. Recording and clipboard@@ -176,6 +184,13 @@ func TestEveryCapabilityRefusalCarriesTheRunnableRemedy(t *testing.T) {if remedy != remedyFor(g.setting) {t.Errorf("remedy = %q, want %q; a gate building its own string drifts from every other capability", remedy, remedyFor(g.setting))}+ if strings.Contains(remedy, "pinchtab server restart") {+ t.Errorf("%s remedy names `pinchtab server restart`, which destroys a bridge if run verbatim: %q", g.name, remedy)+ }+ hint, _ := details["hint"].(string)+ if !strings.Contains(strings.ToLower(hint), restartHint) {+ t.Errorf("%s refusal hint does not carry the mode-neutral restart guidance: %q", g.name, hint)+ }})}}@@ -219,9 +234,11 @@ func TestWaitFnRefusesExactlyAsEvaluateDoesForTheSameCapability(t *testing.T) {t.Errorf("details.%s = %q on /wait, %q on /evaluate", key, got, want)}}- // Writing the setting is only half the remedy; the security block is read at boot.- if remedy, _ := waitDetails["remedy"].(string); !strings.Contains(remedy, "restart") {- t.Errorf("remedy = %q, want it to name the restart", remedy)+ // Writing the setting is only half the fix; the security block is read at boot,+ // so the restart the caller still needs is named in the hint (mode-neutral, since+ // a bridge cannot run `pinchtab server restart`).+ if hint, _ := waitDetails["hint"].(string); !strings.Contains(strings.ToLower(hint), restartHint) {+ t.Errorf("hint = %q, want it to name the restart", hint)}}@@ -413,8 +430,8 @@ func TestClipboardReadAndWriteRefusalsAreIdentical(t *testing.T) {// modelled: SetConfigValue is what `pinchtab config set` performs, and// ApplyFileConfigToRuntime is what a restart does with the resulting file — the// running config is built from it at boot and never rebuilt on an edit, which is-// precisely why the remedy has to name the restart. Doing only the first half-// leaves the gate shut, which is the loop the caller was stuck in.+// precisely why the hint has to name a restart. Doing only the config write leaves+// the gate shut, which is the loop the caller was stuck in.func TestFollowingTheRemedyClearsTheRefusal(t *testing.T) {cfg := &config.RuntimeConfig{}h := New(&mockBridge{}, cfg, nil, nil, nil)@@ -427,13 +444,14 @@ func TestFollowingTheRemedyClearsTheRefusal(t *testing.T) {}setting, _ := details["setting"].(string)remedy, _ := details["remedy"].(string)+ hint, _ := details["hint"].(string)fc := config.FileConfig{}if err := config.SetConfigValue(&fc, setting, "true"); err != nil {t.Fatalf("the remedy's config write fails: %v (remedy=%q)", err, remedy)}- if !strings.Contains(remedy, "pinchtab server restart") {- t.Fatalf("remedy = %q carries no restart, so the retry below would model a step the caller was never told to take", remedy)+ if !strings.Contains(strings.ToLower(hint), restartHint) {+ t.Fatalf("hint = %q names no restart, so the retry below would model a step the caller was never told to take", hint)}config.ApplyFileConfigToRuntime(cfg, &fc)@@ -445,7 +463,7 @@ func TestFollowingTheRemedyClearsTheRefusal(t *testing.T) {}// The config write ALONE must not clear the gate. If it did, the restart in the-// remedy would be noise and this whole card would be wrong — so the negative is+// hint would be noise and this whole card would be wrong — so the negative is// what makes the test above evidence for naming the restart rather than against.func TestTheConfigWriteAloneDoesNotClearTheRefusal(t *testing.T) {cfg := &config.RuntimeConfig{}diff --git a/internal/handlers/download_guard.go b/internal/handlers/download_guard.goindex 15140e8e..7bde0d25 100644--- a/internal/handlers/download_guard.go+++ b/internal/handlers/download_guard.go@@ -26,8 +26,11 @@ const codeDownloadHostBlocked = "download_host_blocked"var errDownloadHostBlocked = errors.New("internal or blocked host")+// The restart is named in the hint, not this executable remedy: the download+// guard answers on a bridge as well as a server, and `pinchtab server restart`+// would stop a bridge, so only the mode-neutral config write is executable here.var downloadHostGrant = remedy.Declare(- `pinchtab config set security.downloadAllowedDomains "$(pinchtab config get security.downloadAllowedDomains),<host>" && pinchtab server restart`)+ `pinchtab config set security.downloadAllowedDomains "$(pinchtab config get security.downloadAllowedDomains),<host>"`)type downloadHostBlockedError struct{ host string }@@ -220,7 +223,7 @@ func downloadHostBlockedDetails(host string) map[string]any {return nil}details := remedy.Details(- "Name the host in security.downloadAllowedDomains to let the download endpoint reach it; a loopback entry exposes services on the server's own machine.",+ "Name the host in security.downloadAllowedDomains to let the download endpoint reach it, then restart PinchTab to apply the change; a loopback entry exposes services on the server's own machine.",downloadHostGrant.Fill(host))details["host"] = hostdetails["setting"] = "security.downloadAllowedDomains"diff --git a/internal/handlers/download_guard_test.go b/internal/handlers/download_guard_test.goindex c7d3f018..2c28d856 100644--- a/internal/handlers/download_guard_test.go+++ b/internal/handlers/download_guard_test.go@@ -119,6 +119,7 @@ func TestABlockedDownloadHostRefusalNamesTheSettingAndTheRemedy(t *testing.T) {Host string `json:"host"`Setting string `json:"setting"`Remedy string `json:"remedy"`+ Hint string `json:"hint"`} `json:"details"`}if err := json.Unmarshal(w.Body.Bytes(), &body); err != nil {@@ -133,9 +134,17 @@ func TestABlockedDownloadHostRefusalNamesTheSettingAndTheRemedy(t *testing.T) {if body.Details.Host != "127.0.0.1" || body.Details.Setting != "security.downloadAllowedDomains" {t.Errorf("details name host %q setting %q", body.Details.Host, body.Details.Setting)}- for _, want := range []string{"config set security.downloadAllowedDomains", "127.0.0.1", "server restart"} {+ for _, want := range []string{"config set security.downloadAllowedDomains", "127.0.0.1"} {if !strings.Contains(body.Details.Remedy, want) {t.Errorf("remedy %q lacks %q", body.Details.Remedy, want)}}+ // The mode-neutral config write only: `server restart` would kill a bridge, so+ // the restart guidance lives in the hint.+ if strings.Contains(body.Details.Remedy, "server restart") {+ t.Errorf("remedy %q names `server restart`, which destroys a bridge if run", body.Details.Remedy)+ }+ if !strings.Contains(strings.ToLower(body.Details.Hint), "restart pinchtab") {+ t.Errorf("hint %q should remind the user to restart PinchTab", body.Details.Hint)+ }}diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.goindex 50c45c63..122e8fd0 100644--- a/internal/handlers/handlers.go+++ b/internal/handlers/handlers.go@@ -186,7 +186,7 @@ func (h *Handlers) annotateBrowserCrash(message string, details map[string]any)}return crashAnnotation(message, details, crash,- "this error is a symptom of the dead browser, not of your selector or timeout; restart it with: pinchtab server restart")+ "this error is a symptom of the dead browser, not of your selector or timeout; restart PinchTab to recover it")}// crashAnnotation is the one shape a crash takes in an error body: the reason indiff --git a/internal/handlers/idpi_domain_block.go b/internal/handlers/idpi_domain_block.goindex 2ab0f8af..5a037533 100644--- a/internal/handlers/idpi_domain_block.go+++ b/internal/handlers/idpi_domain_block.go@@ -28,7 +28,7 @@ var idpiDriftedTabRemedy = remedy.Declare("pinchtab back")// A refused target URL is the opposite case: nothing navigated, there is nothing// to recover from, and the allowlist genuinely is the only lever — so this is the// only remedy that names it, and the only place that guidance is rendered.-const idpiRefusedURLHint = "the requested URL is outside security.allowedDomains, so the request was refused and nothing navigated. Allowing it widens what automation may reach — see docs/guides/security.md."+const idpiRefusedURLHint = "the requested URL is outside security.allowedDomains, so the request was refused and nothing navigated. Widen the allowlist, then restart PinchTab to apply the change; allowing it widens what automation may reach — see docs/guides/security.md."// writeIDPIDomainBlocked is the single writer of an IDPI domain-block refusal, so// the status and code cannot differ between the three sites that produce one.@@ -55,10 +55,12 @@ func idpiBlockDetails(url, hint string, r remedy.Remedy) map[string]any {return details}-// allowlistWidening appends to the current allowlist rather than replacing it, and carries-// the restart because the security block is snapshotted at boot.+// allowlistWidening appends to the current allowlist rather than replacing it. The security+// block is snapshotted at boot, so the change needs a restart to apply — but the restart is+// named in the hint, not this executable remedy, because `pinchtab server restart` would stop+// a bridge, and this refusal answers on a bridge as well as a server.var allowlistWidening = remedy.Declare(- `pinchtab config set security.allowedDomains "$(pinchtab config get security.allowedDomains),<domain>" && pinchtab server restart`)+ `pinchtab config set security.allowedDomains "$(pinchtab config get security.allowedDomains),<domain>"`)// idpiAllowlistRemedy is the copy-pasteable widening of the allowlist. A hostless target// (about:blank) cannot be allowlisted at all, so it gets no remedy instead of one thatdiff --git a/internal/handlers/navigation.go b/internal/handlers/navigation.goindex 48249657..0c071c7a 100644--- a/internal/handlers/navigation.go+++ b/internal/handlers/navigation.go@@ -204,7 +204,7 @@ func (h *Handlers) resolveNavigateBrowser(w http.ResponseWriter, r *http.Request// (still scans and wraps, just warns instead of hard-blocking).func idpiScannerHint() string {return ". To read pages like this, set strict mode off: `pinchtab config set security.idpi.strictMode false` " +- "then `pinchtab server restart` — content is still scanned and wrapped, just warned instead of blocked (see docs/guides/security.md)"+ "then restart PinchTab to apply — content is still scanned and wrapped, just warned instead of blocked (see docs/guides/security.md)"}// validateNavigateTargets runs URL validation, the IDPI domain guard, and SSRF@@ -523,7 +523,7 @@ func (h *Handlers) runNavigate(w http.ResponseWriter, r *http.Request, ex navExeif ex.isNewTab && errors.Is(navErr, context.DeadlineExceeded) {httpx.Error(w, http.StatusServiceUnavailable, fmt.Errorf("new tab did not load in time: %v; the browser may be out of memory or overloaded; "+- "close tabs or restart the instance with `pinchtab server restart`", navErr))+ "close tabs or restart PinchTab", navErr))return}navigateErrorWithHint(w, classifyNavigateError(navErr), navErr, ex.url)diff --git a/internal/handlers/navigation_idpi_hint_test.go b/internal/handlers/navigation_idpi_hint_test.goindex 0d9489b2..682146d7 100644--- a/internal/handlers/navigation_idpi_hint_test.go+++ b/internal/handlers/navigation_idpi_hint_test.go@@ -17,8 +17,11 @@ func TestIDPIAllowlistRemedy(t *testing.T) {if !strings.Contains(line, "security.allowedDomains") {t.Errorf("remedy should name the allowlist config key; got %q", line)}- if !strings.Contains(line, "server restart") {- t.Errorf("remedy should remind the user to restart; got %q", line)+ // The remedy is the mode-neutral config write only: `pinchtab server restart`+ // would destroy a bridge answering this gate, so the restart guidance moved to+ // the hint (checked below).+ if strings.Contains(line, "server restart") {+ t.Errorf("remedy must not name `server restart`, which destroys a bridge; got %q", line)}if strings.ContainsRune(line, '…') {t.Errorf("remedy must not contain the … placeholder; got %q", line)@@ -26,6 +29,9 @@ func TestIDPIAllowlistRemedy(t *testing.T) {if !strings.Contains(line, "config get security.allowedDomains") {t.Errorf("remedy should append to existing domains via config get; got %q", line)}+ if hint, _ := idpiRefusedURLDetails("https://example.com/some/path")["hint"].(string); !strings.Contains(strings.ToLower(hint), "restart pinchtab") {+ t.Errorf("refused-URL hint should remind the user to restart PinchTab; got %q", hint)+ }// A hostless target cannot be allowlisted, so it gets no remedy rather than// one that cannot work.@@ -42,7 +48,10 @@ func TestIDPIScannerHint(t *testing.T) {if !strings.Contains(hint, "strictMode") {t.Errorf("scanner hint should point at strictMode; got %q", hint)}- if !strings.Contains(hint, "server restart") {- t.Errorf("scanner hint should remind the user to restart; got %q", hint)+ if strings.Contains(hint, "server restart") {+ t.Errorf("scanner hint must not name `server restart`, which destroys a bridge; got %q", hint)+ }+ if !strings.Contains(strings.ToLower(hint), "restart pinchtab") {+ t.Errorf("scanner hint should remind the user to restart PinchTab; got %q", hint)}}diff --git a/internal/httpx/endpointlock.go b/internal/httpx/endpointlock.goindex b2e5af99..23a7e66c 100644--- a/internal/httpx/endpointlock.go+++ b/internal/httpx/endpointlock.go@@ -15,19 +15,21 @@ func DisabledEndpointMessage(capability, setting string) string {return fmt.Sprintf("this endpoint requires the %s capability; enable %s in config to use it", capability, setting)}-// The remedy names the restart because writing the config is not enough: the-// security block is snapshotted at boot and is not rebuilt on a config edit, so-// enabling a capability never takes effect until the server restarts. Without-// the restart a caller who follows the remedy verbatim gets the identical 403-// back, and an agent — which reads this refusal, not the config command's-// stdout — has no exit from that loop.-var enableCapability = remedy.Declare("pinchtab config set <setting> true && pinchtab server restart")+// Writing the config is not enough: the security block is snapshotted at boot and+// is not rebuilt on a config edit, so enabling a capability only takes effect once+// PinchTab restarts. The restart is named in the hint, not the executable remedy,+// because the restart command is mode-dependent while this gate is not: the same+// gate answers on a bridge and on a server, and `pinchtab server restart` stops a+// bridge and silently replaces it with a server. The handler cannot know how the+// caller launched this instance, so the remedy carries only the mode-neutral+// config write and the hint tells the caller to restart PinchTab to apply it.+var enableCapability = remedy.Declare("pinchtab config set <setting> true")// DisabledEndpointDetails builds the error details every capability refusal// carries, so the guidance is written once rather than restated at each gate.func DisabledEndpointDetails(setting string) map[string]any {details := remedy.Details(- fmt.Sprintf("Enable %s to use this feature.", setting),+ fmt.Sprintf("Enable %s to use this feature, then restart PinchTab to apply the change.", setting),enableCapability.Fill(setting))details["setting"] = settingreturn detailsdiff --git a/internal/httpx/endpointlock_test.go b/internal/httpx/endpointlock_test.goindex 737bdc7b..054873ce 100644--- a/internal/httpx/endpointlock_test.go+++ b/internal/httpx/endpointlock_test.go@@ -41,8 +41,14 @@ func TestDisabledEndpointHandlerIncludesHintAndRemedy(t *testing.T) {if remedy == "" {t.Fatal("expected non-empty remedy in details")}- if remedy != "pinchtab config set security.allowScreencast true && pinchtab server restart" {- t.Fatalf("remedy = %q, want the config set AND the restart that applies it", remedy)+ if remedy != "pinchtab config set security.allowScreencast true" {+ t.Fatalf("remedy = %q, want the mode-neutral config write with no `server restart`", remedy)+ }+ if strings.Contains(remedy, "pinchtab server restart") {+ t.Fatalf("remedy names the server-only restart, which destroys a bridge: %q", remedy)+ }+ if !strings.Contains(strings.ToLower(hint), "restart pinchtab") {+ t.Fatalf("hint does not carry the mode-neutral restart guidance: %q", hint)}}@@ -99,8 +105,8 @@ func TestDisabledEndpointHandlerKeepsSettingHintAndRemedy(t *testing.T) {}for key, want := range map[string]string{"setting": "security.allowStateExport",- "hint": "Enable security.allowStateExport to use this feature.",- "remedy": "pinchtab config set security.allowStateExport true && pinchtab server restart",+ "hint": "Enable security.allowStateExport to use this feature, then restart PinchTab to apply the change.",+ "remedy": "pinchtab config set security.allowStateExport true",} {if got, _ := resp.Details[key].(string); got != want {t.Fatalf("details[%q] = %q, want %q", key, got, want)@@ -108,38 +114,34 @@ func TestDisabledEndpointHandlerKeepsSettingHintAndRemedy(t *testing.T) {}}-// The defect this pins: the remedy used to stop at the config write. Writing the-// setting is a successful no-op for the caller — the security block is read at-// boot, so the very same 403 comes back — and the caller reading this refusal is-// an agent that has no other instruction to try. The properties, not the-// sentence: both commands present, the config write FIRST, joined so a shell can-// run the string verbatim, and no prose asking the reader to interpret anything.-func TestDisabledEndpointRemedyIsOneRunnableLineEndingInTheRestart(t *testing.T) {+// This gate answers on a bridge as well as a server, and `pinchtab server restart`+// stops a bridge and silently swaps it for a server. So the executable remedy must+// carry ONLY the mode-neutral config write — no server-restart verb a bridge user+// could run verbatim — and the restart, which is what actually applies the change+// (the security block is read at boot), is stated in the hint as mode-neutral prose+// the caller applies for their own mode. This supersedes the old contract that put+// `&& pinchtab server restart` in the executable remedy.+func TestDisabledEndpointRemedyIsModeNeutralConfigWriteWithRestartInTheHint(t *testing.T) {for _, setting := range []string{"security.allowCookies", "security.allowStateExport", "security.allowClipboard"} {- remedy, _ := DisabledEndpointDetails(setting)["remedy"].(string)+ details := DisabledEndpointDetails(setting)+ remedy, _ := details["remedy"].(string)+ hint, _ := details["hint"].(string)configCmd := "pinchtab config set " + setting + " true"- restartCmd := "pinchtab server restart"-- if strings.Contains(remedy, "\n") {- t.Errorf("remedy for %s spans lines, so it cannot be run verbatim: %q", setting, remedy)+ if remedy != configCmd {+ t.Errorf("remedy for %s = %q, want exactly the mode-neutral config write %q", setting, remedy, configCmd)}- if !strings.Contains(remedy, configCmd) {- t.Errorf("remedy for %s does not enable the setting: %q", setting, remedy)+ if strings.Contains(remedy, "pinchtab server restart") {+ t.Errorf("remedy for %s names the server-only restart, which destroys a bridge if run: %q", setting, remedy)}- if !strings.Contains(remedy, restartCmd) {- t.Errorf("remedy for %s omits the restart, so following it verbatim returns the identical 403: %q", setting, remedy)- }- if strings.Index(remedy, configCmd) > strings.Index(remedy, restartCmd) {- t.Errorf("remedy for %s restarts before writing the setting, so the restart applies nothing: %q", setting, remedy)+ if strings.Contains(remedy, "\n") {+ t.Errorf("remedy for %s spans lines, so it cannot be run verbatim: %q", setting, remedy)}- if !strings.Contains(remedy, "&&") {- t.Errorf("remedy for %s joins its two commands with prose rather than a shell operator: %q", setting, remedy)+ if !strings.Contains(strings.ToLower(hint), "restart pinchtab") {+ t.Errorf("hint for %s does not tell the caller to restart PinchTab to apply the change: %q", setting, hint)}- for _, prose := range []string{" then", "then:", "after that", "first ", "next "} {- if strings.Contains(remedy, prose) {- t.Errorf("remedy for %s contains prose %q an agent would have to interpret: %q", setting, prose, remedy)- }+ if strings.Contains(hint, "pinchtab server restart") {+ t.Errorf("hint for %s names the server-only restart command, wrong on a bridge: %q", setting, hint)}}}