From 8fa8d3f27ee0b0891975bec0469aa1ca59d5ed43 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Thu, 3 Dec 2026 02:35:39 +0000 Subject: [PATCH] . --- .../document/how-to_update-from-skeleton.html | 109 +++++++++++++ developer/document/writing_installer.html | 97 ++++++++++++ document/handing-over-work_numbered-pass.html | 146 ++++++++++++++++++ document/introduction_Harmony.html | 15 +- ...role-and-workflow_product-development.html | 8 +- setup | 14 +- 6 files changed, 375 insertions(+), 14 deletions(-) create mode 100644 administrator/document/how-to_update-from-skeleton.html create mode 100644 developer/document/writing_installer.html create mode 100644 document/handing-over-work_numbered-pass.html diff --git a/administrator/document/how-to_update-from-skeleton.html b/administrator/document/how-to_update-from-skeleton.html new file mode 100644 index 0000000..f824b6a --- /dev/null +++ b/administrator/document/how-to_update-from-skeleton.html @@ -0,0 +1,109 @@ + + + + + Updating a project from the skeleton + + + + + + + + + + + +

Purpose

+

+ new-project makes a project from a copy of the Harmony skeleton. From then on the project has its own copy, so a fix made to the skeleton in Harmony reaches a project only when it is carried there. This document gives how the administrator sees how far a project has drifted from the skeleton, and brings it up to date, with two tools in administrator/tool: +

+
    +
  1. skeleton_diff : compares a project with Harmony, and changes nothing.
  2. +
  3. skeleton_update : brings a project onto the current skeleton.
  4. +
+

+ Both are given the two checkouts by path, so they are run from the administrator role of either, for example with Harmony and the project side by side in ~/project. +

+ +

What the skeleton is

+

+ The skeleton is the set of files in Harmony's last commit, as new-project takes it, less what a project has of its own: README.md, LICENSE, the Opus file 0pus_Harmony, and the example developer/authored/ExampleGreet.make/. A fix to the skeleton is therefore made in Harmony and committed there first: a change not committed in Harmony is not part of the skeleton. +

+

+ A file in one of these trees that is not a skeleton file belongs to the project, and stays where it is: administrator/authored/, administrator/document/, developer/authored/, developer/document/, developer/experiment/, document/, shared/authored/, tester/authored/ and tester/document/. Harmony's own documents in these trees, such as document/introduction_Harmony.html, are skeleton files: an update replaces the project's copies with Harmony's, so a project's documents about Harmony stay current with it. +

+ +

Seeing the drift

+ + > skeleton_diff ~/project/Harmony ~/project/Jizo + +

+ It compares the files git sees in each checkout, those tracked and those untracked that no .gitignore excludes, leaving out scratchpad, consumer and authored directories, which are never skeleton. Given all_files first, it compares every file on disk instead. It reports in five sections: +

+
    +
  1. The Opus file: present, and named 0pus_<project>.
  2. +
  3. Skeleton files the project is missing.
  4. +
  5. Skeleton files whose content differs, grouped by which copy was modified last: Harmony's, the project's, or neither. Harmony newer usually means a fix not yet carried over; project newer, a change made in the project that perhaps belongs in Harmony.
  6. +
  7. Files that differ in their permissions alone.
  8. +
  9. The project's own files, outside the skeleton, for information.
  10. +
+

+ The count of issues at the end covers the first four sections. A project newer than Harmony is worth reading before updating: a fix made in the project is lost when the update replaces the file, unless it is first made in Harmony, or the project keeps its own version, as below. +

+ +

Updating

+
    +
  1. Commit the project. skeleton_update run refuses a work tree with uncommitted changes, so that what it does is one change git can show and undo.
  2. +
  3. Read what it would do: + + > skeleton_update preview run ~/project/Harmony ~/project/Jizo + +
  4. +
  5. Run it, without preview.
  6. +
  7. git add -A, read git status and the diff, then commit. git takes each moved file as a rename, by its content, so git log --follow follows its history.
  8. +
  9. Run skeleton_update preview run again: it reports nothing left to do.
  10. +
+

+ Skeleton files are copied in from Harmony, replacing the project's copies, and an Opus file, 0pus_<project>, is made when the project has none. Two are merged instead, the project's own lines kept beside Harmony's: .gitignore and shared/tool/version. Compiled Python caches are deleted, and directories left empty are removed. Files the project's .gitignore ignores, such as a local Python build, are left where they are, and listed at the end of the log. +

+ +

A project that differs from the skeleton

+

+ A project laid out after Harmony needs nothing more. One that is not, such as an older project brought onto Harmony, or one that keeps its own version of a skeleton file, is given a plan: a Python file, named as the last argument, holding these names: +

+
    +
  1. MOVE : {old path: new path}; a path ending in / moves a directory tree.
  2. +
  3. KEEP : paths kept as they are, including skeleton files the project has its own version of.
  4. +
  5. DEPRECATE : paths deprecated even though Harmony has a place for them.
  6. +
  7. DUPLICATE : trees whose files are copies of files kept elsewhere.
  8. +
  9. EXECUTABLE : paths, after any move, given execute permission where they have read permission.
  10. +
+

+ A file in no place Harmony has, and not moved by the plan, is deprecated: moved, its path kept, under developer/authored/deprecated/. Nothing is lost, and each file's old place can be read from its new path. A file under a DUPLICATE tree is deleted when the project holds a file of the same content elsewhere, and deprecated otherwise. +

+ +

Not yet settled

+

+ Each project holds a copy of the skeleton, so each fix is made once in Harmony and then carried into every project. Making Harmony the one authoritative copy, while still letting a project customize a skeleton file, would end the carrying; how to do that is an open question. +

+ +
+ + diff --git a/developer/document/writing_installer.html b/developer/document/writing_installer.html new file mode 100644 index 0000000..1c00176 --- /dev/null +++ b/developer/document/writing_installer.html @@ -0,0 +1,97 @@ + + + + + Writing an installer + + + + + + + + + + + +

Purpose

+

+ A project whose work product runs outside the checkout, for other accounts, or under root, is installed: copied into a place in the system, such as /usr/local/lib/<project>, owned by root. This document gives how an RT installer is written, and why. Jizo's install is a worked example of each point. An installer is a tool script, so writing_tool-script.html applies to it too. +

+ +

Root runs only what root installed

+

+ Root does not run code another account can change. Were root to run a program from a checkout, the account owning the checkout could change the program and wait: the next time root ran it, that account would have root. So root runs the installed copy, which only root can change, and an account using the program runs a version that stays as it was installed, however the checkout changes. +

+

+ The trust is given once, at each install, by the person acting as root, who reads what would change before the installer changes it. The first install runs the installer from the checkout; after that, root runs the installed installer, given the checkout's directory to install from, so root runs only what it installed before. +

+ +

It installs from consumer

+

+ The installer installs from the checkout's consumer directory, wherever it is run from, so what is installed is what the tester tested. build and promote fill consumer from developer/authored, so the installer compares the two, and warns, naming the files, when they differ: a change not yet built is not installed, and without the warning the installer would say that nothing would change. +

+ +

It reads the checkout as data

+

+ Running under root, the installer reads files another account owns. It reads them as data, never runs them, and does not follow a symbolic link: the account could point a link at a file only root can read, such as /etc/shadow, and have root copy it where the account can read it. It walks the tree through directory descriptors, as Python's os.fwalk with follow_symlinks=False, opens each file with O_NOFOLLOW, and refuses a link it finds. +

+ +

It checks where it installs

+
    +
  1. Every directory from the installation up to / is owned by root, and writable by no other account; otherwise another account could replace what was installed, and the installer refuses.
  2. +
  3. The installation holds only what the installer put there. Finding a file it does not know, it refuses, naming the file, and removes nothing; files of an earlier layout of its own, which it knows by name, it removes.
  4. +
  5. What the installed program needs from the system, such as a command it runs, is there.
  6. +
+ +

A command root runs is isolated

+

+ A root shell reached with su keeps the account's PATH and PYTHONPATH, so a Python command root runs could take another account's python3, or import another account's module. The installer replaces the first line of each command root runs with #!/usr/bin/python3 -IB: the interpreter is named by its full path, isolated mode, -I, ignores PYTHONPATH and the account's own packages, and -B writes no compiled cache. The commands are installed in a directory of their own, named for the privilege they run with, such as privileged, apart from those any account runs, in unprivileged, which keep their first line. +

+ +

It writes only what differs

+

+ As promote does, the installer compares what it would install with what is installed, and writes only what differs. It reports each file Added, Updated, when its content, owner or mode differed, or Removed, when the checkout no longer has it. It first says what it compared: the number of files on each side, and anything that must agree between them, such as the version of a data format the program reads. +

+

+ Each file is written through a temporary file in the same directory, made with O_CREAT | O_EXCL | O_NOFOLLOW, given its owner and mode, then renamed over the old one. A rename within a directory is atomic, so a program starting meanwhile finds the old file or the new one, never part of one. +

+ +

Its commands

+ + help | -h | --help print the help, also printed given no arguments + preview say what would be added, updated and removed, install nothing + diff the same, with the lines that would change in each file + run install, under root + remove remove what the installer put there, under root + from <consumer dirp> the checkout's consumer directory to install from; needed + when the installer run is the installed one + +

+ preview and diff run under any account; run and remove refuse under any account but root. The exit status is 0 when done, 1 when refused, 2 when given wrong arguments. +

+ +

Tests do not install

+

+ The tester runs the work product from consumer, under the tester's own account, so nothing is installed for a test. A program that would act as root when installed takes, under the tester's account, test places the tester owns, such as test devices under the tester's data directory. +

+ +
+ + diff --git a/document/handing-over-work_numbered-pass.html b/document/handing-over-work_numbered-pass.html new file mode 100644 index 0000000..60f3c58 --- /dev/null +++ b/document/handing-over-work_numbered-pass.html @@ -0,0 +1,146 @@ + + + + + Handing over work in numbered passes + + + + + + + + + + + +

Purpose

+

+ Work made outside the project's checkout, by a collaborator, a person or an AI, working in a copy of it, is handed to the project in passes. A pass is one coherent change, numbered in the order it was made, that the administrator can read before anything changes, apply with one command, and take back with git. This document gives what a pass holds, how it is run, and how one is made. +

+ +

What a pass holds

+
    +
  1. pass_<N>.patch : the change to the project's files, as git diff makes it.
  2. +
  3. pass_<N> : the pass program. It checks that it is run where it belongs, applies the patch, makes any change a patch cannot, such as one to a database the program keeps, and says what is left to do. What it acts on, such as the database's path, is built in.
  4. +
  5. Documents, each sent whole, never in the patch: a patch to prose is hard to read, while a whole document is read as it will stand, and compared with the old copy before it replaces it. A document changed in the project since the collaborator's copy was taken is said to the collaborator first, so the change is not overwritten.
  6. +
+

+ The number orders the passes: each patch is made against the project as the pass before it left it, and applies on that. A pass sent and not yet run can be replaced by another of the same number; once run, a correction is a new pass. +

+ +

Where the files go

+

+ The patch and the pass program are put in $REPO_HOME/scratchpad. git ignores the scratchpad, so they never end up in the repository. Documents go straight to their place in the project, over the old copy. +

+ +

Running a pass

+

+ In the administrator's shell, which ./setup administrator leaves at the top of the project, $REPO_HOME: +

+ + > ./scratchpad/pass_<N> preview + > ./scratchpad/pass_<N> run + +

+ preview makes the checks, and says what run would do, changing nothing. run makes the checks, applies the patch, makes the change to the data, if the pass has one, then lists, numbered, the steps left, which belong to other roles and so are not the pass program's to take: +

+
    +
  1. Administrator: read git status and git diff, then commit.
  2. +
  3. Developer: build and promote write.
  4. +
  5. Tester: the tests.
  6. +
  7. Root, in its own terminal: the install, when the project installs.
  8. +
+

+ git apply changes the working tree, not the history: the commit is the administrator's own, made after reading the change. It applies the whole patch or nothing, so a patch that does not fit changes no file. +

+ +

What the pass program checks

+

+ Before it changes anything, the pass program checks that the shell, the directory, and the checkout all belong to the project the pass was made for, and refuses, saying which check failed and how to put it right: +

+
    +
  1. REPO_HOME is set: a role has been taken on.
  2. +
  3. PROJECT is the project the pass was made for, which is built in.
  4. +
  5. The current directory is $REPO_HOME.
  6. +
  7. The pass program itself is in $REPO_HOME/scratchpad.
  8. +
  9. $REPO_HOME is the top of a git working tree, and no tracked file in it has a change not committed. What the pass changes is then exactly what git diff shows afterward, and git restore . takes it back.
  10. +
  11. The patch applies, by git apply --check; or it was applied before, by git apply --reverse --check, and is not applied again.
  12. +
+

+ The first four checks guard against a shell out of step with its directory. A role's shell carries its project's REPO_HOME, PATH and tools with it, so a person who takes on a role in one project and then changes into another, to fix something there, has a shell whose environment names one project while its directory is in the other. A pass run there would apply its patch to one checkout while the tools it names act on the other. Requiring the current directory to be $REPO_HOME catches that, and also a shell with no role taken on at all. +

+ +

The change to the data

+

+ A pass's change to data changes what git cannot take back, so it is written to be safe to run, and safe to run again: +

+
    +
  1. It refuses while the program has the data open, as by taking the same lock the program takes.
  2. +
  3. It refuses data that is not in the state the pass expects, such as a database of another schema version, saying what it found.
  4. +
  5. Before it changes anything it makes a backup, named for the pass, beside the original, and keeps it. A database is copied through the database's own backup, not as a file.
  6. +
  7. It makes the whole change in one transaction, so an interruption leaves the data as it was.
  8. +
  9. Made before, it says so, and changes nothing.
  10. +
  11. Before a step that takes long, such as the backup of a large database, it says what it is starting, and how large the job is, so the person waiting knows it is working.
  12. +
+

+ So a pass interrupted part way is run again: the patch, applied before, is passed over, and the change to the data is made, or found made. +

+ +

Taking a pass back

+
    +
  1. Before the commit: git restore ., and any file the patch added removed, or git apply -R scratchpad/pass_<N>.patch.
  2. +
  3. After the commit: git revert of it.
  4. +
  5. The data: the backup the pass made, put back with the program stopped.
  6. +
+ +

Making a pass

+

+ The collaborator commits the work in a copy of the checkout, at the commit the project is at, then makes the patch from that commit to the work, leaving out the documents: +

+ + > git diff -M --binary <base> HEAD -- . ':!document' > pass_<N>.patch + +

+ -M carries a renamed file as a rename, and --binary carries a binary file and a file's mode. Before sending it, the collaborator checks that it applies to the base, in a fresh worktree of it: git worktree add /tmp/check <base>, then git apply --check there. +

+

+ The pass program follows the conventions of a tool script (see writing_tool-script.html): given nothing it prints its help, which says what the pass holds and what is left for a later pass; its exit status is 0 when done, or done before, 1 when refused, and 2 when given wrong arguments. Its checks begin like this: +

+ + PROJECT = "<project>" + FILENAME__PATCH = "pass_<N>.patch" + + def where__problem(): + "None when the shell, the directory and this program belong to PROJECT; otherwise what is wrong" + repo_home = os.environ.get("REPO_HOME") + if not repo_home: + return f"no role is taken on: ./setup administrator, in {PROJECT}, first" + if os.environ.get("PROJECT") != PROJECT: + return f"this shell is set up for {os.environ.get('PROJECT')}, not {PROJECT}" + if os.path.realpath(os.getcwd()) != os.path.realpath(repo_home): + return f"run it from {repo_home}, the top of {PROJECT}, not from {os.getcwd()}" + if os.path.dirname(os.path.realpath(__file__)) != os.path.realpath(os.path.join(repo_home ,"scratchpad")): + return f"it is to be in {repo_home}/scratchpad" + return None + + +
+ + diff --git a/document/introduction_Harmony.html b/document/introduction_Harmony.html index c3065e5..44303b5 100644 --- a/document/introduction_Harmony.html +++ b/document/introduction_Harmony.html @@ -24,7 +24,7 @@ @@ -67,7 +67,7 @@ Because the new project starts with its own git history, work done in it cannot be checked in to the Harmony skeleton by accident.

- Leave the Harmony line in the version file. It records which skeleton the project was made from, so that an administrator can later see what has changed in the skeleton since, and bring the project up to date. The administrator tool skeleton_diff compares a project with a Harmony checkout for this purpose. + Leave the Harmony line in the version file. It records which skeleton the project was made from, so that an administrator can later see what has changed in the skeleton since, and bring the project up to date. The administrator tools skeleton_diff, which compares a project with a Harmony checkout, and skeleton_update, which brings the project onto the current skeleton, are for this purpose; administrator/document/how-to_update-from-skeleton.html gives how.

Taking on a role

@@ -78,7 +78,7 @@ > ./setup developer

- setup starts a new bash shell configured for the role, and leaves the person in the role's directory. The prompt shows the project and the role. exit leaves the role and returns to the shell setup was run from, so a role taken on inside another role's shell stacks on it. It is common to have several terminal windows or Emacs shells open, each in a different role; document/role-and-workflow_product-development.html gives an arrangement of them, and its use in Emacs. + setup starts a new bash shell configured for the role, and leaves the person in the role's directory; the administrator, who administers the project as a whole, is left at its top, $REPO_HOME. The prompt shows the project and the role. exit leaves the role and returns to the shell setup was run from, so a role taken on inside another role's shell stacks on it. It is common to have several terminal windows or Emacs shells open, each in a different role; document/role-and-workflow_product-development.html gives an arrangement of them, and its use in Emacs.

Python programmers will recognize this as similar to a virtual environment. Harmony calls it the project setup, and the command is setup rather than activate. Unlike a Python virtual environment, there is one setup for each role. @@ -90,7 +90,7 @@

  • Sets ROLE, ROLE_HOME and SETUP.
  • Sources the project-wide shared/tool/setup, which sets REPO_HOME and PROJECT, sources each project dependency's .init file, then puts shared/tool, shared/made and shared/authored in front of what the dependencies added.
  • Sources shared/authored/setup, when the project has one, for project-specific additions to every role.
  • -
  • Puts <role>/tool in front of all of these, changes into the role's directory, and sources <role>/tool/setup, the setup customized for that role in this project.
  • +
  • Puts <role>/tool in front of all of these, changes into the role's directory, or for the administrator into $REPO_HOME, and sources <role>/tool/setup, the setup customized for that role in this project.
  • When running inside Emacs, copies the environment to Emacs with env_to_emacs.
  • @@ -114,7 +114,7 @@

    @@ -205,8 +205,8 @@

    @@ -241,6 +241,7 @@ diff --git a/document/role-and-workflow_product-development.html b/document/role-and-workflow_product-development.html index 5a9e239..a0d1b93 100644 --- a/document/role-and-workflow_product-development.html +++ b/document/role-and-workflow_product-development.html @@ -136,7 +136,7 @@

      -
    1. administrator, in $REPO_HOME: git, such as git apply and git commit, and the scripts that repair or migrate the project's data.
    2. +
    3. administrator, in $REPO_HOME: git, such as git commit, and the passes handed to the project, each of which applies its patch and makes any change to the project's data (see handing-over-work_numbered-pass.html).
    4. developer, in $REPO_HOME/developer: build and promote.
    5. tester, in $REPO_HOME/tester: the tests, run on what was promoted to consumer.
    6. a shell under no role, in $REPO_HOME/scratchpad, for running the installed program as its users do.
    7. @@ -148,7 +148,7 @@

      - Files handed to the project, such as patches and the scripts that come with them, are put in $REPO_HOME/scratchpad, which git ignores, so they never end up in the repository. The administrator applies a patch from there, git apply scratchpad/<name>.patch, and runs a script from there, scratchpad/<name>. + Files handed to the project, such as a pass's patch and the program that applies it, are put in $REPO_HOME/scratchpad, which git ignores, so they never end up in the repository. The administrator runs a pass from the top of the project, ./scratchpad/pass_<N> run, and the pass applies its own patch.

      @@ -187,7 +187,7 @@

      - setup starts the role's shell inside the buffer's shell, in the role's directory; exit leaves it, back to the shell the buffer started with. A buffer already open is renamed with M-x rename-buffer. The shell under no role is made the same way, named run, with cd ~/project/Jizo/scratchpad and no setup. + setup starts the role's shell inside the buffer's shell, in the role's directory, or for the administrator in $REPO_HOME; exit leaves it, back to the shell the buffer started with. A buffer already open is renamed with M-x rename-buffer. The shell under no role is made the same way, named run, with cd ~/project/Jizo/scratchpad and no setup.

      The role's environment in Emacs

      @@ -217,7 +217,7 @@

      - As each buffer holds one role's work, M-r build in the developer's buffer finds builds, and M-r apply in the administrator's finds the patches applied, with nothing of the other roles among them. + As each buffer holds one role's work, M-r build in the developer's buffer finds builds, and M-r pass_ in the administrator's finds the passes run, with nothing of the other roles among them.

      The working directory

      diff --git a/setup b/setup index d2a452a..03c7c7c 100755 --- a/setup +++ b/setup @@ -9,6 +9,13 @@ import tempfile PROJECT_ROLES = ["administrator", "consumer", "developer", "tester"] +# The administrator administers the project as a whole: git, and the passes +# handed to the project, are run from the top of the project. So the +# administrator's shell starts in $REPO_HOME, while every other role's starts +# in its own directory. The administrator's tools and setup are still in +# administrator/tool. +ROLE_WORKING_AT_REPO_HOME = {"administrator"} + # Role shells stack: setup run inside a role shell starts a shell in the new # role, and exiting it returns to the shell it was started from. A loop # through setup, such as one started from ~/.bashrc, is stopped at this depth. @@ -66,6 +73,7 @@ def main(): role_home = os.path.join(repo_home, role) tool_dir = os.path.join(role_home, "tool") setup_file = os.path.join(role, "tool", "setup") + work_dir = repo_home if role in ROLE_WORKING_AT_REPO_HOME else role_home env["ROLE"] = role env["ROLE_HOME"] = role_home @@ -87,9 +95,9 @@ def main(): 'if [[ -f "shared/authored/setup" ]]; then source "shared/authored/setup"; fi', '# the role tool directory is searched before everything the shared setup added', f'PATH="{tool_dir}:$PATH"; export PATH', - f'cd "{role}"', - 'if [[ -f "tool/setup" ]]; then', - ' source "tool/setup"', + f'cd "{work_dir}"', + f'if [[ -f "{role_home}/tool/setup" ]]; then', + f' source "{role_home}/tool/setup"', f' echo "in environment: {setup_file}"', 'else', f' echo "not found: {setup_file}"', -- 2.20.1