From: Thomas Walker Lynch
Date: Thu, 3 Dec 2026 02:35:39 +0000 (+0000)
Subject: .
X-Git-Url: https://git.reasoningtechnology.com/?a=commitdiff_plain;h=8fa8d3f27ee0b0891975bec0469aa1ca59d5ed43;p=Harmony
.
---
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
+
+
+
+
+
+
+
+
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
+
+ - 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.
+ - 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.
+ - What the installed program needs from the system, such as a command it runs, is there.
+
+
+ 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
+
+ - pass_<N>.patch : the change to the project's files, as git diff makes it.
+ - 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.
+ - 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.
+
+
+ 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:
+
+
+ - Administrator: read git status and git diff, then commit.
+ - Developer: build and promote write.
+ - Tester: the tests.
+ - Root, in its own terminal: the install, when the project installs.
+
+
+ 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:
+
+
+ - REPO_HOME is set: a role has been taken on.
+ - PROJECT is the project the pass was made for, which is built in.
+ - The current directory is $REPO_HOME.
+ - The pass program itself is in $REPO_HOME/scratchpad.
+ - $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.
+ - The patch applies, by git apply --check; or it was applied before, by git apply --reverse --check, and is not applied again.
+
+
+ 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:
+
+
+ - It refuses while the program has the data open, as by taking the same lock the program takes.
+ - It refuses data that is not in the state the pass expects, such as a database of another schema version, saying what it found.
+ - 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.
+ - It makes the whole change in one transaction, so an interruption leaves the data as it was.
+ - Made before, it says so, and changes nothing.
+ - 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.
+
+
+ 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
+
+ - Before the commit: git restore ., and any file the patch added removed, or git apply -R scratchpad/pass_<N>.patch.
+ - After the commit: git revert of it.
+ - The data: the backup the pass made, put back with the program stopped.
+
+
+ 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 @@
- authored/ : Source written by the team. Tracked.
- document/ : Documents for developers, such as coding and naming conventions.
- - experiment/ : Informal, short-lived trials.
+ - experiment/ : Informal, short-lived trials, which run the code being developed straight from authored/, without a build or a promotion. Tracked. A formal test runs from consumer/ instead, under the tester.
- scratchpad/ : Untracked. Intermediate build files and the staged products of a build.
- tool/ : The developer's tools, including build and promote.
@@ -205,8 +205,8 @@
- document/ : The project as a whole, such as this introduction.
- - administrator/document/ : Maintaining the project skeleton, adding dependencies, and making releases.
- - developer/document/ : Coding standards, conventions, and the build.
+ - administrator/document/ : Updating the project from the skeleton, adding dependencies, and making releases.
+ - developer/document/ : Coding standards, conventions, the build, and writing an installer.
- tester/document/ : Test plans and testing tools.
- consumer/<namespace>/document/ : Documents released with the work product, such as manuals and API references.
@@ -241,6 +241,7 @@
- document/role-and-workflow_product-development.html : The roles, how their work interacts, and a shell for each role, in Emacs among others.
- document/role-and-workflow_product-maintenance.html : Issues, triage, and patching releases.
+ - document/handing-over-work_numbered-pass.html : Handing work made outside the checkout to the project, in numbered passes.
- administrator/document/how-to_release.html : Making a release.
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 @@
- - administrator, in $REPO_HOME: git, such as git apply and git commit, and the scripts that repair or migrate the project's data.
+ - 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).
- developer, in $REPO_HOME/developer: build and promote.
- tester, in $REPO_HOME/tester: the tests, run on what was promoted to consumer.
- a shell under no role, in $REPO_HOME/scratchpad, for running the installed program as its users do.
@@ -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}"',