Skip to content

Project commands for 1.0.0: init, profiles, source and connection - #61

Merged
david-Darkcollective merged 3 commits into
developfrom
feat/project-commands
Oct 16, 2026
Merged

david-Darkcollective merged 3 commits into
developfrom
feat/project-commands

Conversation

@david-Darkcollective

Copy link
Copy Markdown
Member

The three 1.0.0 issues, one commit each.

relix init (#55)

Creates a project's .relix/: catalog/, profiles.json at 0600, a .gitignore inside .relix/ holding profiles.json, plus relixrc with -o/-P and the root marker with --root. It trusts what it wrote, refuses (exit 2) a directory that already has a .relix/, warns outside $HOME, and writes nothing to stdout.

One deviation: with -P NAME, profiles.json is {"NAME": {}} rather than {}. Otherwise the relixrc it writes names a profile nothing defines, and the very next run fails with "no profile".

relix profiles ls | set | get | rm, and the trust rule (#56)

  • ls lists profile, variable and file, never a value. A bare relix profiles does the same.
  • set reads the value from a prompt that does not echo on a terminal, or from stdin otherwise, never from an argument.
  • get prints the value a run under that profile would resolve, nearest file first.
  • rm PROFILE [VARIABLE] removes one variable, or the whole profile.
  • set and rm write the nearest project's file, or ~/.relix's with --user, at 0600. They refuse a looser file and warn when git tracks it.
  • Trust.keep is the rule every writing command follows. A project that is trusted and unchanged since stays trusted across the command's own write. Any other stays untrusted. Which one happened is said on stderr.
  • Tests cover both directions, plus an externally changed project.

relix source / relix connection: add | ls | edit | rm | test (#57)

  • Files. Each add writes one declaration to catalog/00-source-<name>.relix or 00-connection-<name>.relix, printed by ScriptFormatter. That is the engine's canonical one-line form, so relix fmt leaves it unchanged.
  • Parsing. The declaration is parsed by the engine before it is written. A missing option is the parser's "missing 'url'", reported as exit 2 naming --url.
  • Locations. A relative LOCATION is rewritten relative to the catalog file, which is what it resolves against.
  • Secrets. A secret is accepted only as ${NAME}: an option named password, secret, token, key or credential, or a URL carrying password=.
  • Hand-written files. edit and rm change only a declaration alone in its file. One beside others is reported with its file and line, and --editor opens $VISUAL/$EDITOR at that line.
  • rm. It refuses a name another declaration reads, unless --force, and says when a farther declaration now shows through.
  • test. source test reads one row per source under the profile and checks a declared schema against what was read. connection test opens each database connection with a probe of a table no database has: "table not found" means it connected. Both exit 5 when one fails.

Three choices worth a look:

  • --global, not --user, writes ~/.relix for source and connection. The issue's own example passes --user='${WAREHOUSE_USER}' as a connection option, so --user can't also be the scope flag there. profiles keeps --user.
  • A JSON source takes no --infer-schema. The engine's JSON source is schema-on-read and has no schema option, so the flag is refused with exit 2. --infer-schema covers CSV files, connection tables and database sources.
  • connection test only opens database connections. Any other kind (a file connection, mongodb) is listed as untested after its placeholders are checked. The engine has no public API to open one.

Docs

New command pages (init, profiles, source, connection), sections in catalog.md and secrets.md, and design.md §3, §5.1, §5.3 and §5.4. Every new example runs in GuideExamplesTest.

./gradlew clean build passes, and so does each commit on its own.

Fixes #55
Fixes #56
Fixes #57

relix init [DIR] writes catalog/, a profiles.json only its owner can read,
and a .gitignore inside .relix/ holding profiles.json, so it never edits a
file of the user's. -o and -P write a relixrc with those defaults, the
profile -P names is defined, empty, so the next run finds it, and --root
writes the root marker. It then trusts what it wrote, as catalog trust
would, so the first run shows no warning. A directory that already has a
.relix/ is refused with exit 2, and outside $HOME it warns that only the
working directory's .relix/ is read there.

Part of #55.
…oss them

relix profiles ls lists profile, variable and file, never a value, and is
what a bare relix profiles does. set takes the value from a prompt that
does not echo on a terminal, or from stdin otherwise, never from an
argument, so it stays out of shell history and ps. get prints the value a
run under the profile would resolve, nearest file first. rm removes a
variable, or without one the whole profile. set and rm write the nearest
project's profiles.json, or ~/.relix's with --user, at 0600, refuse a
looser file as reading does, and warn when git tracks it.

Any change under a trusted .relix/ untrusts it, so Trust.keep checks,
before a command writes, that the directory is trusted and unchanged since;
if so it records the new hash after the write, and otherwise the directory
stays untrusted, so a change someone else made is still reviewed. The
command says which happened. source and connection will write the same way.

Part of #56.
…lags

The two nouns mirror the language's two declarations. add takes NAME
KIND|CONNECTION [LOCATION] and every other option of the declaration as a
--OPTION=VALUE flag, or --OPTION for true, and writes one declaration to
catalog/00-source-<name>.relix or 00-connection-<name>.relix, printed as
relix fmt prints it. The text is parsed by the engine before it is
written, so a missing option is the parser's "missing 'url'", reported as
a usage error naming --url. A relative LOCATION is rewritten relative to
the catalog file, which is what it resolves against. A secret is accepted
only as a ${NAME} placeholder. --infer-schema reads a CSV file's heading,
or a table's columns as its database describes them; a JSON source is
schema-on-read and declares no schema, so it is refused there. A name an
outer level declares is allowed and warned about, naming the file it
shadows. --global writes ~/.relix; --user stays free for a connection's
own user option.

ls lists name, kind, location and file. edit sets and --unset options, and
--location moves a file source; --editor opens $VISUAL or $EDITOR at the
declaration's line. rm refuses a name another declaration reads, listing
them, unless --force, and says when a farther declaration now shows
through. edit and rm change only a declaration alone in its file, and
report one beside others with its file and line. source test reads one
row of each source under the profile and checks a declared schema against
what was read; connection test opens each database connection with a
probe of a table no database has. Both exit 5 when one fails.

Every write keeps a trusted project trusted, by the rule profiles uses.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant