Skip to content

writ repo set and unset replace add and remove: a layer has one registration, and re-pointing it is set #791

Closed

Description

@David-Noble-at-work

Ruled 2026-09-04. A layer has exactly one registration, so re-pointing it is the obvious intent behind
registering it again, and a verb that refuses and sends the user to remove first protects a state nobody
wants. The vocabulary for a keyed registration is the one config already uses: set and unset, not
add and remove.

  • writ repo set <layer> <working-tree-root>|<repository-url> [<working-tree-root>] registers or replaces.
    A replacement narrates what changed — personal: was ~/Workspace/Personal, now ~/env — and, when the old
    registration was a clone writ made in its own home, removes that clone (writ repo remove leaves the clone it made in the writ-owned home #792: a writ-owned clone is writ’s
    to remove; a working tree the user registered by path is never touched).
  • writ repo unset <layer> removes the registration.
  • writ repo list stays. add, remove, rm and ls go, not aliased: there is no legacy to keep.
  • --dry-run shows a replacement like any other change.

The design’s §3 records the rule: a keyed registration is set and unset, on every program.

Ruled 2026-09-18

  1. unset is idempotent. Unsetting a layer that is not registered succeeds and emits state: "unregistered". A command that is safe to run twice is a command a script can use.
  2. set to the target a layer already has narrates unchanged and emits its record. Not an error, and not
    silent.
  3. --branch stays, on the repository-url form only, as it is today.
  4. The record below is what reaches stdout. Narration is stderr (§5), so --output json never sees "was X,
    now Y"; whatever a script needs has to be in the result.

The record

{
  "layer": "personal",
  "state": "registered",
  "source": "[email protected]:me/personal.git",
  "root": "/Users/me/.local/share/devlore/writ/repos/personal",
  "owner": "writ",
  "branch": "devlore-cli/writ-layer",
  "previous": {
    "source": "[email protected]:me/personal.git",
    "root": "/Users/me/Workspace/Personal",
    "owner": "user"
  }
}
Field Meaning
layer the layer name
state registered, unregistered, broken, unreadable — unchanged from today
source the URL writ would fetch from: the checked-out branch’s upstream, else origin, else empty
root where the working tree is, which is what writ reads
owner writ or user: who cloned the tree, and so who may delete it
branch present when --branch was given; absent otherwise
previous the displaced registration, in this same shape; absent when nothing was displaced

Three things the shape settles:

  • source and root are different questions. Today’s single root (repo_cmd.go:114) collapses them, so
    repo list --output json cannot say which repository a layer is, nor whether its tree is writ’s or the
    user’s. repo list gains source and owner on every row.
  • owner makes writ repo remove leaves the clone it made in the writ-owned home #792’s ruling machine-readable. A writ-owned clone is writ’s to remove; a user’s tree is
    never touched.
  • There is no removed field. Writ clones only into <data home>/devlore/writ/repos/<name>, so a removed
    clone is always previous.root with previous.owner == "writ". Two fields would always carry one path.

source is empty when a tree has no remote — a repository made by git init and never pushed. That is not a
corner case: writ’s own refusal text tells the user to run git init when a path is not a working tree.

Acceptance

  • writ repo set registers a new layer and replaces an existing one, narrating the change and removing a writ-owned clone it displaces
  • writ repo set to the target a layer already has narrates unchanged and emits the record
  • writ repo unset removes a registration; unsetting an unregistered layer succeeds and emits unregistered
  • add, remove and their aliases are unknown commands
  • the record carries source, root, owner, branch and previous as above, and repo list carries source and owner
  • --branch still applies to the repository-url form, and is refused on the path form
  • the guide docs/guides/writ/repositories.md and the design §3 say set and unset

Plan and design documents

Kind Document
Plan docs/plans/feature/791-repo-set-and-unset.md

Activity

  1. David-Noble-at-work commented on Sep 4, 2026

    @David-Noble-at-work
    ContributorAuthor

    Also here (2026-09-04): repo add, repo remove and repo list write hand-shaped text with
    fmt.Fprintf(cmd.OutOrStdout(), ...), which the #776 walk did not catch (the walk gap is its own bug). When
    the verbs become set, unset and list, each emits a result through cli.Emit: list a row per layer with
    layer, repository and path, so the default json serves a script and -o table reads the way the
    clone-naming fix describes; set and unset the registration they changed. Narration, "was X, now Y" and
    the removed clone, goes to stderr.

  2. David-Noble-at-work commented on Sep 8, 2026

    @David-Noble-at-work
    ContributorAuthor

    The layer-journey scenario (#855, cmd/writ/scenario_layer_journey_test.go, landed in #859) is this issue's acceptance test: Part 1 (steps 1.1–1.5, and the old verbs refused) runs the ruled interface and skips by this issue's number until the binary has it, on all six legs of the scenario job. When this lands, that skip turns into a pass without the scenario changing — and if it does not, the failure message names the step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions