Move harness profiles between host and Docker and stop silent draft retargeting
Native installs left Docker-era harness profiles in harnesses.json, so every authoring launch failed trying to reach a Docker service, and a retained draft bound to the old Docker server was silently projected onto the configured one. - harness: add Profile.Mode and VerifyDockerLink as the single mode/verification helpers. `harness setup --host` configures or converts a host profile and clears docker_directory; reconfiguring a Docker-linked profile re-verifies the recorded directory still owns compose.yaml and fails naming it instead of saving a link that cannot launch. Setup's summary and `harness list` (via the new List/ListView shape) report the resulting mode and, for Docker, the directory, without changing the stored Config schema. - setup-native.py: after build/install-skill it writes host (no docker_directory) profiles for the detected harnesses, defaulting to the detected OpenCode profile rather than a stale pi default, taking models from --model or the existing valid profile and never inventing one; it clears a stale Docker link and preserves unrelated keys/profiles. Detection-only: no harness install, upgrade or download. - draft: add Draft.Resolve, the shared mismatch helper, which projects a draft onto the configured server and returns a dual-URL notice. CLI validate/submit and the TUI draft browser use it so a foreign draft is never silently retargeted; the TUI pre-wraps the notice to the panel width. - Tests cover the Docker->host and host->host transitions, the missing-directory failure, installer write/migration (Python), and the CLI/TUI notice, using the real config file path in a temp dir. - Update help text, README, docs and the packaged authoring skill reference to describe host as the default and the Docker-linked case.
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package draft
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPublicationScopeForServer(t *testing.T) {
|
||||
original := Draft{Path: "/retained/draft.md", Name: "demo", Server: "ws://origin/connect", BaseVersion: 7}
|
||||
@@ -21,3 +24,23 @@ func TestPublicationScopeForServer(t *testing.T) {
|
||||
t.Fatal("unbound legacy draft lost its version guard", bound)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveReportsForeignServerAndKeepsMatchSilent(t *testing.T) {
|
||||
configured := "ws://127.0.0.1:8080/connect"
|
||||
foreign := Draft{Name: "stale", Server: "ws://127.0.0.1:8081/connect", BaseVersion: 4}
|
||||
resolved, notice := foreign.Resolve(configured)
|
||||
if notice == "" || !strings.Contains(notice, foreign.Server) || !strings.Contains(notice, configured) {
|
||||
t.Fatalf("foreign notice did not name both servers: %q", notice)
|
||||
}
|
||||
if resolved.Server != configured || !resolved.CreateOnly || resolved.BaseVersion != 0 {
|
||||
t.Fatalf("foreign draft not projected create-only: %+v", resolved)
|
||||
}
|
||||
match := Draft{Name: "current", Server: configured, BaseVersion: 4}
|
||||
resolvedMatch, matchNotice := match.Resolve(configured)
|
||||
if matchNotice != "" || resolvedMatch.CreateOnly || resolvedMatch.BaseVersion != 4 {
|
||||
t.Fatalf("matching draft produced a notice or lost its guard: %q %+v", matchNotice, resolvedMatch)
|
||||
}
|
||||
if _, unboundNotice := (Draft{Name: "legacy"}).Resolve(configured); unboundNotice != "" {
|
||||
t.Fatalf("unbound draft produced a notice: %q", unboundNotice)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user