Repository navigation
feat!: run AutoIDM portal commands on servers and in clouds - #307
autoidm-jon wants to merge 133 commits into
Conversation
ReviewA comment review, three Codex reviews of the branch (server side, cloud and providers, command line and copies), and four Codex verification rounds of the fixes. The last round found no defect.
|
Terminal output before and afterEach section shows one command that this PR adds or changes. I ran each command with the wheel of
|
|
PR tier:
A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/42039314819 |
Review, round 2This round closes the open items of the first review and fixes O2. Codex gpt-6.1-sol (effort xhigh) reviewed the round-2 diff
Decisions are product calls: they change what a person sees, what a person grants, or a shape of the service contract. Each needs a person to choose. Live tests still needed: O2 and B12 (Azure), O3 (Google Cloud), B9 (AWS), P1 (Azure), and the |
Terminal output before and after:
|
Review, round 3This round applies the decisions on A11, B7, B9, B12, B13, C10, V4, W5, and P1. Codex gpt-6.1-sol (effort xhigh) reviewed the diff
Live tests still needed: B9 (AWS: a scheduled job carries the tag, and |
Terminal output before and after: B7, B13, and C10B7 and B13: the MR test of B13, a second MR test of merge request !1 while the first one runs: -The command cmd_20261105T150420Z_81f6f206 ended as done.
+error: /v1/gitlab/commands answered 409: {"error": "mr_run_active", "message": "Merge request !1 already has the run_mr command cmd_20261105T152801Z_ac7ad86b, which is waiting on ins_3457c49677. Wait for it to end, or cancel it, then run the job again."}
-[second mr-test exit 0]
+[second mr-test exit 1]B7, an MR test of an app whose -The command cmd_20261105T150427Z_b5dd01f7 ended as done.
-[exit 0]
+The command cmd_20261105T152843Z_062631fd ended as refused. hello-world-i95/run.py line 2 pins pdt-cli 0.1.13. A merge request run needs pdt-cli 0.1.14 or newer, which keeps the state of the run apart from the state of the deployed job.
+Next steps:
+ pdt upgrade move pdt, and the pdt version each app pins, to the newest release; then push the change
+[exit 1]C10: a Windows 11 VM with the wheel of 86e8665 and with the wheel of 04688d2. The $ pdt run hello-world --kill
-This project has no enabled apps. Every app has enabled: false.
-Set enabled: true in an app's config.yml, or delete the line, to turn it on.
-Next steps:
- pdt list see every app and whether it is enabled
-[exit 1]
+No run of hello-world runs: Windows task pdt-hello-world is not running.
+[exit 0] |
|
Stale Draft PR, closing |
A registration is per customer on a machine. A cloud deploy makes a separate registration for the secret store. The autoidm alert type is removed.
- A cloud secret keeps a registration only for the customer that pdt.yml names, and a run checks it. - A deploy stops when the app secret cannot be read, instead of overwriting the registration. - pdt register restricts the key file before it writes the key, and keeps the pending key until the registration is saved. - A bad backend answer, a full disk, an unreadable artifact, a large log, or a project name with spaces no longer changes the run result; artifacts skip links that leave the output folder.
- On Windows, pdt register restricts the registrations folder before it writes any key, and writes keys atomically. - Azure rereads any refused secret before it writes it. - Bad upload URLs, truncated responses, log setup failures, and symlink loops warn and leave the run alone; a symlinked output folder sends no artifacts. - PowerShell runs and generated runners use the run output folder, with a temporary fallback when the app folder cannot be written.
- pdt register sets the whole registrations folder DACL to SYSTEM and Administrators, owner Administrators, and reads it back before it writes a key. - A retry after a crash before pdt.yml is saved finishes with the same key. - A malformed upload URL, a ZIP encoding error, and an output folder that is a junction are warnings that keep the run result.
- Upload fields that are not text, or that cannot be encoded, are an AutoIDM warning and keep the exit code. - A broken stdout stops only the printing; pdt keeps reading the app output and writing the log. - The log stops at the upload limit while the app runs, and the upload is skipped with the existing warning.
- run_job calls managed_services through one guard: any exception is a one-line warning and the run keeps its exit code. - JSON that nests too deep, a closed stdout, and registration metadata of the wrong shape are warnings.
Windows PowerShell started from PowerShell 7 inherits its PSModulePath and cannot load Get-Acl and Set-Acl, so pdt register failed from a pwsh terminal and in CI.
pdt run by a person keeps a config change, such as the time zone that a first deploy saves, in the project folder. The hosted runner now sends each unit whose pdt.yml or <app>/config.yml the run changed to /v1/runner/copies/start and /finish, with the SHA-256 of the copy it got as base_sha256, so a copy that changed in the meantime keeps that change. A unit that could not be saved goes into the log and the result message.
test_console_values failed on this line and on the CodeBuild retry delay of 97fe6ee. The delay is a time, which the console rule prints unstyled, so the test now allows it.
The portal artifacts operation now runs `pdt storage APP get --run N --yes DEST` through `pdt.cli`, and `pdt.run_output` is gone. `get PATH` of a folder now saves every file under it.
|
PR tier:
A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/45450547629 |
Main renamed the app's settings file from config.yml to pdt.yml. The tests now set the new app keys, give a gcloud JSON secret read, and expect the time zone that a plan keeps.
Each browser run makes a new key, so a key that an earlier approval claimed no longer makes AutoIDM refuse each later approval. A second registration for the same customer revokes the new installation and deletes its key. An address that is not an AutoIDM backend is named with the flag to change it. The pending status, the no-project line, and the Windows access-list error state the facts.
pdt service install refuses on macOS and Linux, and pdt register there prints that portal commands cannot reach the computer, only where it would have installed the service. The registration itself is the same on each system. BREAKING CHANGE: the systemd, launchd, and cron service types are gone, and `--backend` takes only `windows`.
A new Windows computer adds a root certificate to its store only when Windows first needs it, so pdt register on a fresh Windows VM failed with CERTIFICATE_VERIFY_FAILED. The calls to the API, the doorbell, the copies, and the WebSocket now use the roots of the computer and of certifi.
The service runs only on Windows, so the table of service managers keeps only the Windows entry and loses the code that chose among several. BREAKING CHANGE: `pdt service install --backend windows` fails; run `pdt service install`.
A copy from AutoIDM holds at most `MAX_COPY_FILES` (10,000) files and at most `MAX_COPY_BYTES` of file data in all, so a small zip cannot fill the disk. A path with the DEL character is refused like the other control characters.
The `pdtjob` user owns only `job/`. The log and `artifacts.zip` stay in the folder of root, and the child writes the log through the file it gets as its output. When the child ends, the runner ends each process of `pdtjob`, then reads no path under a link (`copies.inside`) for the artifact zip, the config files it saves, and `copies.build_zip`. The runner sends the zip from its file after it checks the size, and masks the run token and the cloud secrets in the log.
When the service runs as SYSTEM, the child of a `run_mr` runs as NT AUTHORITY\LOCAL SERVICE with a restricted token that keeps only the bypass of traverse checks (`DISABLE_MAX_PRIVILEGE`). It starts suspended in the job object of the command, and it gets only its output file and NUL as handles. Only LOCAL SERVICE, SYSTEM, and Administrators can open the work folder (`WORK_SDDL`), and the child's home, temporary, uv, and Python folders are in it. The program folders (`READABLE_SDDL`) give LOCAL SERVICE read access. The artifact zip of the service reads no path under a link. The child cannot read the registration keys or the service settings, and cannot write a project or the program folders. An elevated terminal that is not SYSTEM cannot log on as LOCAL SERVICE, so there the child runs as that account, as before.
`iam:TagRole` can put the managed-by tag on a `pdt-*` role that pdt did not make, so the grant can call `iam:DeleteRole` and `iam:UpdateAssumeRolePolicy` only on a role that has the grant boundary. A destroy by the grant puts the boundary on the role before it deletes the role's policies and the role. AWS has no `iam:PermissionsBoundary` condition key for `iam:PassRole`, so `iam:PassRole` keeps only the managed-by tag condition.
The script `google-cloud-grant.sh` stops when `PDT_PROJECT`, `PDT_EXTERNAL_ID`, `PDT_AWS_ACCOUNT`, or `PDT_AWS_ROLE` does not have its form, and it quotes each role name that it binds.
- A command token whose `exp` is not after its `iat`, or whose `iat` is more than `CLOCK_SKEW_SECONDS` ahead, is refused. - A new key set is refused when a key has an empty `kid` or a PEM that does not parse. - `post_file` refuses a quote or a new line in the file name and the field names. - The service opens no WebSocket URL that is not `wss://`, or `ws://` to this computer. - The Event Log and syslog line shows each control character of `requested_by` as `?`. - `pdt register` makes the registrations folder mode 700 on macOS and Linux, and deletes `pending-device.key` when the browser approval fails.
5616987 to
63bd121
Compare
|
PR tier:
A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/45661407216 |
Summary
Adds the AutoIDM managed-service integration to
pdt: registration, the Windows service runner, the hosted cloud runner, code-copy syncing, and cloud-provider grant templates.What this PR ships
pdt register,src/pdt/register_cli.py,src/pdt/utils/autoidm.py)body_sha256andjti).certifiroot certificates for AutoIDM API calls.pdt service install|remove|status|run,src/pdt/service*.py)NT AUTHORITY\SYSTEM, Windows-only service installation).run_mrchild processes on Windows under a restrictedNT AUTHORITY\LOCAL SERVICEtoken (DisableMaxPrivilege) inside a Windows Job Object with an explicitSY/BA/LS-only work folder ACL (verified live on a Windows VM running asSYSTEM).src/pdt/hosted_runner.py,src/pdt/copies.py,pdt sync)aws,azure,google_cloud), runs commands as an unprivilegedpdtjobuser with symlink/secret isolation, output masking, and process-group/UID cleanup, and reports results and artifacts back to the backend.src/pdt/grant_templates.py,src/pdt/grants.py,src/pdt/deploy_*.py,src/pdt/managed_services.py)deploy,destroy,pause,resume,run,run_mr,sync).Verification
origin/main(includingconfig.yml→pdt.ymlcompatibility) withfix/i104-registerfixes folded in.uv run pytest -q: 3366 passed, 12 skippeduv run ruff check: All checks passedNT AUTHORITY\SYSTEMscheduled task runningrun_mras restrictedNT AUTHORITY\LOCAL SERVICEviaservice_runner.prepare()/start_child()): verified child execution, output collection, access denials on registrations/settings/journal/projects/versions, Job Object process-tree kill, and work-folder cleanup.