Give the config module a home to load from #45

Closed
opened 2026-08-15 18:57:34 +00:00 by rosa · 0 comments
Owner

What to build

Nothing can point the casino at a directory other than the player's real home.
The config module asks ProjectDirs where it lives whenever it wants to know,
which means loading a config, creating one, or resolving a save path all write
into the actual ~/.config/casino — so none of it has ever been under test.
The tests that exist cover deserialization and stop there.

Give the module its locations instead of letting it find them. Two values, in
two stages, because resolution genuinely has two: you need the config directory
to find the config, and then the config itself to finish settling where the save
and stats files are.

  • Home — the two directories the casino was given. Built either from a
    pair of directories outright, which is the seam a test uses, or by asking the
    system where a user's files go. This follows the shape ADR 0002 already
    established for engines: a seam constructor taking the thing that would
    otherwise be reached for, and a convenient constructor that stays a thin
    wrapper over it. It is also the only place in the crate that names
    ProjectDirs.
  • Files — the path of every file the casino writes, settled from a Home
    and a Config. It keeps its Home, so anything that needs both the files and
    the directories they sit in takes one argument.

The save and stats paths become optional overrides rather than settings that are
always present. Today they are serialized with defaults computed from the global
data directory at deserialize time, so a fresh install writes absolute paths into
the player's own config file as though they had chosen them, and Config's
Default cannot be computed without touching the filesystem. As overrides, an
absent value means the standard place, a present one wins, and the default
becomes pure.

Config gains a single door — load against a Home, creating the file with the
house defaults when it isn't there. That replaces the three that exist now, one
of which welds loading to first-run creation behind a name that says neither.

The casino keeps the signature it has and reaches for a Home internally; the
ticket that hands it one properly comes next.

Acceptance criteria

  • A config can be loaded, created, and saved against a temp directory, with
    the real home untouched
  • An absent save or stats override resolves to the standard place under the
    data directory
  • A config naming a relocated save still resolves to that location — a
    player who moved their save does not lose it
  • A freshly created config file does not contain absolute save or stats
    paths
  • Config's Default touches no filesystem and asks nothing of the system
  • ProjectDirs is named in exactly one place in the crate
  • Creating a config on first run still writes the currency out, so a player
    can find the setting and edit it
  • Failing to create the directory a config is being saved into returns an
    error rather than panicking past the Result it is already in
  • An existing config file reads as it did before, including one that names
    save and stats paths explicitly
  • CHANGELOG notes that a fresh config no longer writes absolute save and
    stats paths into itself

Blocked by

## What to build Nothing can point the casino at a directory other than the player's real home. The config module asks `ProjectDirs` where it lives whenever it wants to know, which means loading a config, creating one, or resolving a save path all write into the actual `~/.config/casino` — so none of it has ever been under test. The tests that exist cover deserialization and stop there. Give the module its locations instead of letting it find them. Two values, in two stages, because resolution genuinely has two: you need the config directory to find the config, and then the config itself to finish settling where the save and stats files are. - **`Home`** — the two directories the casino was given. Built either from a pair of directories outright, which is the seam a test uses, or by asking the system where a user's files go. This follows the shape ADR 0002 already established for engines: a seam constructor taking the thing that would otherwise be reached for, and a convenient constructor that stays a thin wrapper over it. It is also the only place in the crate that names `ProjectDirs`. - **`Files`** — the path of every file the casino writes, settled from a `Home` and a `Config`. It keeps its `Home`, so anything that needs both the files and the directories they sit in takes one argument. The save and stats paths become optional overrides rather than settings that are always present. Today they are serialized with defaults computed from the global data directory at deserialize time, so a fresh install writes absolute paths into the player's own config file as though they had chosen them, and `Config`'s `Default` cannot be computed without touching the filesystem. As overrides, an absent value means the standard place, a present one wins, and the default becomes pure. `Config` gains a single door — load against a `Home`, creating the file with the house defaults when it isn't there. That replaces the three that exist now, one of which welds loading to first-run creation behind a name that says neither. The casino keeps the signature it has and reaches for a `Home` internally; the ticket that hands it one properly comes next. ## Acceptance criteria - [ ] A config can be loaded, created, and saved against a temp directory, with the real home untouched - [ ] An absent save or stats override resolves to the standard place under the data directory - [ ] A config naming a relocated save still resolves to that location — a player who moved their save does not lose it - [ ] A freshly created config file does not contain absolute save or stats paths - [ ] `Config`'s `Default` touches no filesystem and asks nothing of the system - [ ] `ProjectDirs` is named in exactly one place in the crate - [ ] Creating a config on first run still writes the currency out, so a player can find the setting and edit it - [ ] Failing to create the directory a config is being saved into returns an error rather than panicking past the `Result` it is already in - [ ] An existing config file reads as it did before, including one that names save and stats paths explicitly - [ ] CHANGELOG notes that a fresh config no longer writes absolute save and stats paths into itself ## Blocked by - #44
rosa closed this issue 2026-08-15 19:49:29 +00:00
Sign in to join this conversation.
No description provided.