Skip to content

feat!: run AutoIDM portal commands on servers and in clouds - #307

Open
autoidm-jon wants to merge 133 commits into
mainfrom
feat/pdt-service
Open

autoidm-jon wants to merge 133 commits into
mainfrom
feat/pdt-service

Conversation

@autoidm-jon

@autoidm-jon autoidm-jon commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Registration (pdt register, src/pdt/register_cli.py, src/pdt/utils/autoidm.py)
    • Interactive browser sign-in or one-time enrollment code registration with Ed25519 keypair generation and signed JWT requests (including body_sha256 and jti).
    • Uses certifi root certificates for AutoIDM API calls.
    • Handles existing registrations and re-approval cleanly.
  • Windows service (pdt service install|remove|status|run, src/pdt/service*.py)
    • Runs as a Windows Scheduled Task (NT AUTHORITY\SYSTEM, Windows-only service installation).
    • Verifies ES256-signed portal commands against the backend's command-signing key set (with strict timestamp, key, and URL validation).
    • Supports live wakeups via WebSocket + S3 doorbell fallback, heartbeat check-ins, log/output streaming, cancellation, and crash recovery journal.
    • Isolates run_mr child processes on Windows under a restricted NT AUTHORITY\LOCAL SERVICE token (DisableMaxPrivilege) inside a Windows Job Object with an explicit SY/BA/LS-only work folder ACL (verified live on a Windows VM running as SYSTEM).
  • Hosted cloud runner (src/pdt/hosted_runner.py, src/pdt/copies.py, pdt sync)
    • Claims signed commands for cloud targets (aws, azure, google_cloud), runs commands as an unprivileged pdtjob user with symlink/secret isolation, output masking, and process-group/UID cleanup, and reports results and artifacts back to the backend.
    • Uploads and extracts immutable project/app code copies with SHA-256 verification and zip-bomb caps (file count and unpacked byte limits).
  • Cloud grants & provider hardening (src/pdt/grant_templates.py, src/pdt/grants.py, src/pdt/deploy_*.py, src/pdt/managed_services.py)
    • Generates least-privilege AWS CloudFormation, Azure ARM, and Google Cloud shell grant templates for AutoIDM-managed deployments (with AWS permissions-boundary enforcement on role delete/retrust and strict input validation in the GCP grant script).
    • Adds cloud-managed registration, ownership checks (AWS/GCP bucket ownership, Azure resource group ownership), and managed-services lifecycle operations (deploy, destroy, pause, resume, run, run_mr, sync).

Verification

  • Rebased onto latest origin/main (including config.yml → pdt.yml compatibility) with fix/i104-register fixes folded in.
  • uv run pytest -q: 3366 passed, 12 skipped
  • uv run ruff check: All checks passed
  • Live Windows VM verification (NT AUTHORITY\SYSTEM scheduled task running run_mr as restricted NT AUTHORITY\LOCAL SERVICE via service_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.

@autoidm-jon

Copy link
Copy Markdown
Contributor Author

Review

A 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. uv run pytest -q: 3104 passed, 5 skipped. uv run --group dev ruff check: clean.

# Severity Disposition Finding Action
A1 blocker fixed The Windows access check of a served project read only the top folder, so a user-writable file deeper in the project ran as SYSTEM The check covers every item below the project, skips no folder, and refuses when its item limit stops it
A2 blocker fixed A project found after the service started got no access check Each project is checked before its first command; install and start check the projects folder
A3 blocker fixed Output masking used the secret values from when the command was queued Values are read again right before the command starts and added to the earlier ones
A4 should-fix fixed A Windows child stayed suspended while the service wrote a large stdin value The child joins its job object and resumes before stdin is written
A5 should-fix fixed Cancel of a deployed Windows run called a function that does not exist Uses service_backends.run with Stop-ScheduledTask
A6 should-fix fixed kill waited behind a running command of the same app kill conflicts with no command and has one place over MAX_RUNNING
A7 should-fix fixed Concurrent workers changed the process-wide PDT_PROJECT in_project holds a module lock
A8 should-fix fixed A result could be sent while output was still undelivered, and recovery then dropped the output The result goes only after all output is delivered
A9 should-fix fixed HTTP 429 after retries counted as a delivered result 429 is sent again later
A10 should-fix fixed Report retries blocked cancel and the run limit for minutes Each report is one request; the next interval sends again
A11 should-fix open run_mr cannot check that the copy matches the signed commit SHA Needs a sha field in the copy manifest of the service contract
A12 should-fix fixed The lock test helper imported fcntl on Windows Uses msvcrt.locking on Windows
A13 should-fix fixed The cron backend said "running" whenever its crontab entry existed Also requires the service process
A14 should-fix fixed artifacts never uploaded its log Its log is uploaded like run
B1 blocker fixed The hosted runner child kept HOME=/root as pdtjob The child gets its own home and drops root cache paths
B2 blocker fixed Azure and Google credential folders were unreadable for pdtjob The runner gives the folder to pdtjob
B3 blocker fixed PDT_KEEP_DEPLOYED_SECRET was set for secrets_set, so it changed nothing Set only for deploy and plan
B4 blocker fixed The Azure grant did not cover the storage group pdt-data The template creates and grants pdt-data
B5 blocker fixed The Google grant could not use the build service account pdt-builder The script creates it and grants serviceAccountUser on it; destroy keeps both runner accounts while the grant exists
B6 blocker fixed Store.push wrote state/ in a merge request run Push of any spelling of state/ is skipped and the lock released
B7 blocker open A Python app pinned to an older pdt-cli still writes production state in an MR run Needs a decision: raise the pin in the MR image or refuse the run
B8 should-fix fixed Destroy of the last app could delete the grant's resource groups Grant groups carry pdt-lifecycle=retain; destroy deletes the pdt resources inside them one by one
B9 should-fix open batch:TerminateJob is not limited to pdt jobs Scheduled jobs carry no tags; needs scheduler tags and a live AWS test
B10 should-fix fixed A silent child never saw a cancel The runner sends a report each interval, empty or not
B11 should-fix fixed A failed MR run left its cloud job running AWS terminates, Azure stops, Google cancels before clean-up
B12 should-fix open The Azure MR run starts under the production job A separate job needs its own data store access; needs a live Azure test
B13 should-fix open Two runs of one MR share the image tag and job resource Needs one active run_mr per MR in the backend, or a name per run
B14 should-fix fixed Google --set-env-vars broke on a comma in a value Uses the gcloud alternate delimiter
B15 should-fix fixed Two secrets set on Windows could lose one update .env is locked for the read and write
B16 should-fix fixed in part Windows storage unlock failed after deploy The deploying user can write storage\; app destroy already runs elevated
B17 should-fix fixed The runner read a whole large log into memory Reads the size first and only the tail when over the limit
B18 blocker fixed AWS secrets set NAME wrote the secret name as the key (found while fixing B3) Renamed the local variable that hid NAME
C1 blocker fixed The generated PowerShell run.py wrote MR state Releases the lease in an MR run
C2 blocker fixed sync up in a Git clone sent tracked secret files Secret name patterns apply to tracked files
C3 should-fix fixed A tracked file under a linked folder reached the copy Any link in the path leaves the file out
C4 should-fix fixed sync down could write through a link at the temporary name Removes it and creates the file exclusively
C5 should-fix fixed An app copy with no config.yml deleted the local one The local file stays
C6 should-fix fixed Two syncs in one second shared a backup folder The folder name has microseconds
C7 should-fix fixed A second register with the same code crashed on the removed pending key Tolerates a missing pending key
C8 should-fix nit The grant wait can pass 15 minutes because each status call retries Recorded
C9 should-fix rejected --kill uses the current config, not the recorded place Same rule as start, pause, and logs; only destroy uses the recorded place
C10 should-fix nit --kill cannot select a disabled app Recorded
C11 should-fix fixed Nothing checked the command set against the approved set A test checks service, sync, run --kill, and no grant
G1 blocker fixed The Google grant could not create a secret or set its IAM policy A create-only custom role, Secret Manager Editor on pdt-*, and a custom IAM policy role on pdt-*; no new read right
Z1 blocker fixed One Azure token could act for every customer that granted the app A managed identity pdt-autoidm with a federated credential for pdtSubject holds the roles; the app keeps only Reader on pdt; output identityClientId
V1 blocker fixed The access scan skipped __pycache__, .venv, .git, .pdt No folder is skipped
V2 blocker rejected Old Azure assignments of the app stay after a redeploy No earlier version of the template was ever deployed
V3 should-fix fixed A link inside the project still passed the copy check See C3
V4 should-fix open Recovery after a restart masks with the current .env, not the values of the command Fixing it means storing secret values on disk
V5 should-fix fixed The scan succeeded when its item limit stopped it Refuses
V6 should-fix fixed Retained Azure groups stopped destroy from releasing the environment Destroy deletes each pdt resource one by one
V7 should-fix fixed Ctrl+C left an Azure MR execution running finally stops an unfinished execution
V8 should-fix fixed ./state/ passed the MR push guard The path is normalized first
W1 blocker fixed A failed group read in Azure destroy chose whole-group deletion, with the grant identity Destroy stops and deletes nothing
W2 should-fix fixed A lock refusal in a retained group did not stop the shared deletes The first lock refusal stops the destroy of that group
W3 should-fix fixed .\state\ and a state/ folder under an empty remote passed the MR push guard Each destination is normalized for separators, dot segments, and case
W4 should-fix nit After Ctrl+C, a failed status read skips the stop of an Azure MR execution Recorded
W5 should-fix open A destroy interrupted between vault delete and purge does not purge on retry Recorded; needs a deleted-vault read on the retained path
X1 should-fix fixed After a lock refusal in a retained group, remove_app deleted the already deleted job again and failed The registry, which a concurrent deploy locks, goes first, so a refusal leaves the rest to remove_app
X2 should-fix fixed The _done marker path skipped the MR push guard The marker path is checked with the others
O1 should-fix open A cancel or timeout of run_mr leaves the cloud run (no SIGTERM clean-up) Needs a SIGTERM handler in the provider scripts
O2 blocker open The Azure grant cannot create or delete the management locks deploy uses Needs a lock role on the grant groups and a live Azure test
O3 should-fix open The Google bucket condition may block bucket creation Needs a live Google test
O4 nit open Windows pdt run APP --kill says "Stopped" also when nothing ran Recorded

@autoidm-jon

Copy link
Copy Markdown
Contributor Author

Terminal output before and after

Each section shows one command that this PR adds or changes. I ran each command with the wheel of main (e97557e) and with the wheel of this branch, and removed the color codes. On macOS, the project is a new windows project with the hello-world app. The Windows sections ran on a Windows 11 VM. <project> stands for the local project path.

pdt --help

   new         add an app to the project
+  register    authenticate this computer for AutoIDM managed services
   upgrade     move pdt, and the pdt version each app pins, to the newest release
@@
   storage     read or manage an app's data store
 
+Work with the AutoIDM portal:
+  service     run commands from the AutoIDM portal on this computer
+  sync        copy this project to or from AutoIDM
+
 Cloud CLIs:
@@
-Every command except init, examples, upgrade, completion, aws, az, and gcloud needs a project.
+Every command except init, examples, upgrade, completion, register, service, aws, az, and gcloud
+needs a project.

pdt service install|start|status|remove

 $ pdt service --help
-pdt: error: argument <command>: invalid choice: 'service' (choose from 'init', ..., 'gcloud').
+Usage: pdt service [-h] <action> ...
+    install   start the service now and at each boot
+    status    show the service, its last checks, and running commands
+    start     start the installed service through its service manager
+    remove    stop the service and remove it from this computer
 $ pdt service status
-pdt: error: argument <command>: invalid choice: 'service' (choose from 'init', ..., 'gcloud').
-[exit 2]
+This computer has no pdt service. To add one, run pdt service install.
+[exit 0]

pdt register

 $ pdt register --help
-pdt: error: argument <command>: invalid choice: 'register' (choose from 'init', ..., 'gcloud').
+Usage: pdt register [-h] [--code CODE] [--api-url API_URL] [-y]
+  --code CODE        the one-time enrollment code from AutoIDM, such as KQ7M-2RTX; leave it off to
+                     sign in through a browser
+  --api-url API_URL  the AutoIDM address (default: PDT_API_URL, else https://app.autoidm.com)
+  -y, --yes          accept the access statement of the service install, and do not wait for the
+                     Connect pages

pdt sync up|down

 $ pdt sync up --help
-pdt: error: argument <command>: invalid choice: 'sync' (choose from 'init', ..., 'gcloud').
+Usage: pdt sync up [-h] [-y] [app]
+  app         one app folder; leave it off for the project
 $ pdt sync down --yes
-pdt: error: argument <command>: invalid choice: 'sync' (choose from 'init', ..., 'gcloud').
-[exit 2]
+error: <project>/pdt.yml has no managed_services, so AutoIDM does not know this project. To add it, run `pdt register` in this project.
+[exit 1]

pdt sync up --yes gives the same lines as pdt sync down --yes in a project with no registration.

pdt run --kill

 $ pdt run --help
-Usage: pdt run [-h] [--deployed] [--follow] [app]
+Usage: pdt run [-h] [--deployed] [--follow] [--kill] [app]
@@
   --follow    print the run's log until it ends and exit with the run's result; a run on this
               machine always does
+  --kill      stop each run of the deployed job that runs now, with its child processes
 $ pdt run hello-world --kill        (app not deployed)
-pdt: error: unrecognized arguments: --kill.
-[exit 2]
+error: hello-world is not deployed; run pdt deploy hello-world first
+[exit 1]

On Windows, with hello-world deployed by the branch:

 $ pdt run hello-world --kill
-pdt: error: unrecognized arguments: --kill.
-[exit 2]
+Stopped hello-world: Windows task pdt-hello-world.
+[exit 0]

pdt secrets APP set NAME on the windows provider (Windows)

 $ pdt secrets hello-world set GREETING   (value "hello" on stdin)
-note: the windows provider reads your .env file at every run, so there is nothing to compare, save, get, or set.
+Added GREETING in C:\pdt-tests\i95-before-after\project-branch\hello-world\.env. The next run reads it.
 [exit 0]
 --- hello-world\.env
+GREETING="hello"

Removed commands

pdt grant, pdt sync diff, pdt service author, and pdt service run existed only on earlier commits of this branch, never on main. On main each one gives "invalid choice" for grant, sync, or service. On the branch, grant gives the same error, and the other three give an error that names the remaining actions:

 $ pdt sync diff
-pdt: error: argument <command>: invalid choice: 'sync' (choose from 'init', ..., 'gcloud').
+pdt sync: error: argument <action>: invalid choice: 'diff' (choose from 'up', 'down').
 $ pdt service run
-pdt: error: argument <command>: invalid choice: 'service' (choose from 'init', ..., 'gcloud').
+pdt service: error: argument <action>: invalid choice: 'run' (choose from 'install', 'status', 'start', 'remove').

pdt service author gives the same error as pdt service run, with 'author'.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

PR tier: tier::architectural (rules and Claude agree)

  • pyproject.toml changes a dependency or build setting
  • src/pdt/cli.py is the command line
  • src/pdt/config.py is config loading and validation
  • src/pdt/deploy.py is provider-neutral deploy flow
  • src/pdt/deploy_common.py is shared by every provider
  • src/pdt/utils/autoidm.py is public API that deployed apps import
  • src/pdt/utils/storage.py is public API that deployed apps import
  • pyproject.toml adds three new core dependencies: cryptography, pyjwt, websockets>=17.4
  • src/pdt/config.py adds the new root config key managed_services (ROOT_KEYS, KEY_HOME, save_managed_customer) and PDT_SERVICE_ENV_FILES, which changes where env values come from
  • src/pdt/utils/autoidm.py is new public API and src/pdt/utils/storage.py changed, which AGENTS.md treats as breaking for deployed apps

A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/42039314819

@autoidm-jon

Copy link
Copy Markdown
Contributor Author

Review, round 2

This round closes the open items of the first review and fixes O2. Codex gpt-6.1-sol (effort xhigh) reviewed the round-2 diff d7129669..86e86651 once, before its last commit. It found P1 to P4. The last commit fixes P2 and P3, and reverts the W5 fix because of P1. uv run pytest -q: 3111 passed, 5 skipped. uv run --group dev ruff check: clean. The backend serves the templates that this head generates, byte for byte.

# Severity Disposition Finding Action
A11 should-fix decision run_mr cannot check that the copy matches the signed commit SHA Needs a commit field in the copy manifest of the service contract; the copy and the command come from the same MR pipeline token
B7 blocker decision A Python app pinned to an older pdt-cli still writes production state in an MR run Refuse the MR run of such an app with a message to raise the pin, or raise the pin in the MR image
B9 should-fix decision batch:TerminateJob is not limited to pdt jobs Tag the scheduled jobs and add a tag condition, after a live AWS test
B12 should-fix decision The Azure MR run starts under the production job A separate job needs its own data store access; needs a live Azure test
B13 should-fix decision Two runs of one MR share the image tag and job resource One active run_mr per MR in the backend, or a name per run
C8 should-fix fixed The grant wait can pass 15 minutes because each status call retries Each poll sends one status request with no retry; the next poll asks again
C10 should-fix decision --kill cannot select a disabled app Same rule as start, pause, and logs; a change applies to all four
V4 should-fix decision Recovery after a restart masks with the current .env, not the values of the command Fixing it means storing secret values on disk
W4 should-fix fixed After Ctrl+C, a failed status read skips the stop of an Azure MR execution An unknown status also sends the stop
O1 should-fix fixed A cancel or timeout of run_mr leaves the cloud run (no SIGTERM clean-up) The provider mr-run takes the first SIGTERM as Ctrl+C and runs its clean-up; the parent waits; the runner waits 120 s before SIGKILL
O2 blocker fixed The Azure grant cannot create or delete the management locks deploy uses Custom role pdt-autoidm-locks-<subscription> with lock read, write, delete on pdt and pdt-shared, the groups of the deploy locks; needs a live Azure test
O3 should-fix open The Google bucket condition may block bucket creation On the live Google test list
O4 nit fixed Windows pdt run APP --kill says "Stopped" also when nothing ran Says that no run runs and stops nothing
W5 should-fix decision A destroy interrupted between vault delete and purge does not purge on retry The read and purge of a soft-deleted vault need subscription rights that the grant does not hold; see P1
P1 blocker decision The grant identity cannot read or purge a soft-deleted Key Vault, so a hosted Azure destroy leaves the vault soft-deleted, and a redeploy of the app finds its name taken Needs a subscription-scope right for deleted vaults (read, purge) in the grant; a round-2 fix of W5 that read deleted vaults was reverted
P2 should-fix fixed A SIGTERM that came during the mr-run clean-up cut it short The clean-up ignores SIGTERM, and so do the programs it starts
P3 should-fix fixed A failed Azure stop after an unknown status was silent It prints a warning with the stop command
P4 nit open The grant wait test does not answer 429 or 503 Recorded

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 mr-run clean-up after a cancel on each cloud.

@autoidm-jon

Copy link
Copy Markdown
Contributor Author

Terminal output before and after: pdt run APP --kill on Windows when nothing runs

I ran the command on a Windows 11 VM with the wheel of d712966 and with the wheel of 7c56017. The hello-world app was deployed to the windows provider, and its task was not running.

 $ pdt run hello-world --kill
-Stopped hello-world: Windows task pdt-hello-world.
+No run of hello-world runs: Windows task pdt-hello-world is not running.
 [exit 0]

@autoidm-jon

Copy link
Copy Markdown
Contributor Author

Review, round 3

This 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 d7129669..05a27448 in a first pass, then each fix in four more passes. Its findings are rows Q1 to Q8. The fifth pass found no blocker. Its two should-fix findings and one nit are Open rows Q6 to Q8. uv run pytest -q: 3140 passed, 5 skipped. uv run --group dev ruff check: clean. The backend serves the templates that this head generates, byte for byte.

# Severity Disposition Finding Action
A11 should-fix fixed run_mr cannot check that the copy matches the signed commit SHA The copy manifest holds commit, the sha claim of the GitLab ID token that sent it; the service and the hosted runner refuse a run_mr whose copy has another commit (MR 3)
B7 blocker fixed A Python app pinned to an older pdt-cli still writes production state in an MR run The service and the hosted runner read the PEP 723 block of the app's run.py, and refuse the MR run when a pdt-cli bound keeps out every release from 0.1.14 up; the message names the file, the line, the minimum version, and pdt upgrade as the next step
B9 should-fix fixed batch:TerminateJob is not limited to pdt jobs Each job pdt submits, also a scheduled one, has the tag managed-by=pdt; the grant and the deployer policy allow TerminateJob only on such a job; needs a live AWS test
B12 should-fix Not changed The Azure MR run starts under the production job Decided: the MR run stays under the production job; on the live Azure test list
B13 should-fix fixed Two runs of one MR share the image tag and job resource The backend allows one active run_mr per merge request, and answers a second one with 409 mr_run_active that names the running command (MR 3)
C10 should-fix fixed --kill cannot select a disabled app pdt run APP --kill also finds a deployed app with enabled: false; start, pause, and logs keep their rule
V4 should-fix Not changed Recovery after a restart masks with the current .env, not the values of the command Accepted: a fix stores secret values on disk; the current .env still masks each value it holds
W5 should-fix Open A destroy interrupted between vault delete and purge does not purge on retry Decided with P1: option (a); the next change adds the rights and the purge
P1 blocker Open The grant identity cannot read or purge a soft-deleted Key Vault, so a hosted Azure destroy leaves the vault soft-deleted, and a redeploy of the app finds its name taken Decided: option (a), the runner behaves as pdt does; the next change adds the deleted-vault read and purge rights to the Azure grant
Q1 blocker Not changed A grant holder can tag a foreign Batch job managed-by=pdt and then terminate it AWS Batch has no condition key that limits batch:TagResource to a tag at SubmitJob (Service Authorization Reference). The grant holder is the AutoIDM backend with 1-hour credentials for that one customer's account, and the person approved that the grant may stop a job
Q2 should-fix Not changed A job of a schedule from before this change has no tag, so the new grant cannot stop it No grant exists yet, and the next deploy tags the schedule
Q3 blocker fixed Some valid script metadata (single quotes, <=, pdt--cli (==0.1.13), a v prefix, a /// inside a TOML string) passed the B7 check The check reads the block with the PEP 723 reference regex, parses it as TOML, normalizes the name, and reads each bound
Q4 blocker fixed A check that asked uv export for the resolution ran build hooks of the customer's code as root in the hosted runner The check reads the metadata and runs nothing
Q5 should-fix Not changed A requirement with an environment marker counts as if it applies, and a file or URL source is not read The check guards against an old pin by mistake; the code of an MR run can write any state on purpose
Q6 should-fix Open The B7 check orders 0.1.14.dev1 as 0.1.14, so pdt-cli<=0.1.14.dev1 passes Add the development release to the version order
Q7 should-fix Open The B7 check pads releases to six parts, so pdt-cli<0.1.14.0.0.0.0 passes Drop trailing zeros before the compare
Q8 nit Open When two pdt-cli requirements name the same version, the message can name the line of the other one Match the whole requirement on the line

Live tests still needed: B9 (AWS: a scheduled job carries the tag, and pdt run APP --kill stops it under the grant), O2 and B12 (Azure), O3 (Google Cloud), and the mr-run clean-up after a cancel on each cloud. P1 and W5: the next change adds the deleted-vault read and purge rights to the Azure grant.

@autoidm-jon

Copy link
Copy Markdown
Contributor Author

Terminal output before and after: B7, B13, and C10

B7 and B13: the MR test of ci/pdt_autoidm.py mr-test against scripts/local_server.py of the backend, with this Mac as the server of the project. Before is the backend at df5b610 and the client at 86e8665. After is the backend at 84ecbea and the client at 63da5cf. Command IDs and installation IDs differ between runs.

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 run.py pins pdt-cli[apps]==0.1.13:

-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 hello-world app was deployed to the windows provider, then given enabled: false; its task was not running.

 $ 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]

@github-actions

Copy link
Copy Markdown

Stale Draft PR, closing

@github-actions github-actions Bot closed this Nov 13, 2026
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.
@github-actions

Copy link
Copy Markdown

PR tier: tier::architectural (rules and Claude agree)

  • pyproject.toml changes a dependency or build setting
  • src/pdt/cli.py is the command line
  • src/pdt/config.py is config loading and validation
  • src/pdt/deploy.py is provider-neutral deploy flow
  • src/pdt/deploy_common.py is shared by every provider
  • src/pdt/utils/autoidm.py is public API that deployed apps import
  • src/pdt/utils/storage.py is public API that deployed apps import
  • pyproject.toml adds four new core runtime dependencies (cryptography, pyjwt, websockets>=17.4, fsspec) to [project.dependencies], with 143 new uv.lock lines
  • src/pdt/config.py adds the managed_services root config key to ROOT_KEYS/KEY_HOME plus a new AUTOIDM_API_URL endpoint, a .pdt-project-name file, and new project/app lock primitives
  • new public API src/pdt/utils/autoidm.py (338 lines) and changes to src/pdt/utils/storage.py — AGENTS.md treats any src/pdt/utils change as breaking for deployed apps

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.
@github-actions

Copy link
Copy Markdown

PR tier: tier::architectural (rules and Claude agree)

  • pyproject.toml changes a dependency or build setting
  • src/pdt/cli.py is the command line
  • src/pdt/config.py is config loading and validation
  • src/pdt/deploy.py is provider-neutral deploy flow
  • src/pdt/deploy_common.py is shared by every provider
  • src/pdt/utils/autoidm.py is public API that deployed apps import
  • src/pdt/utils/storage.py is public API that deployed apps import
  • pyproject.toml adds five new core dependencies (cryptography, pyjwt, websockets, certifi, fsspec) and uv.lock grows by 145 lines
  • src/pdt/config.py adds a new root config key managed_services (ROOT_KEYS) with save_managed_services, and a new AUTOIDM_API_URL constant
  • new public API src/pdt/utils/autoidm.py plus changes to src/pdt/utils/storage.py, which deployed apps import

A changed diff is scored again. Job log: https://github.com/AutoIDM/pdt/actions/runs/45661407216

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant