Commit Graph

221 Commits

Author SHA1 Message Date
Simone 29dfbf1cae feat(job): wire use-git-clone + submodules; default in-guest clone
Lint / pssa (push) Failing after 26s
Lint / python (push) Successful in 54s
The job command previously discarded --use-git-clone and --submodules
(`del`) and always in-guest cloned with submodules off — making both
action inputs dead no-ops (submodule repos silently broken).

- job.py: --use-git-clone/--host-clone and --submodules/--no-submodules
  are real booleans defaulting to ON. Default = in-guest clone with
  submodules. --host-clone clones on the host into a temp dir
  (_host_clone) and transfers a zip; temp dir cleaned in finally.
  clone_submodules now honoured (was hardcoded False).
- action.yml: use-git-clone / submodules default 'true'; forward the
  explicit positive/negative flag so the Python default is overridden
  deterministically.
- self-test.yml: add smoke-{windows,linux}-hostclone jobs covering the
  host-side transport (default jobs already cover in-guest).
- tests: default-transport, host-clone, and --no-submodules coverage.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 17:00:46 +02:00
Simone a26a7e784e docs(todo): defer GitHub Actions mirror (fix 1) — checkout still github.com
Artifact github.com dependency removed (fix 2 applied). Remaining:
actions/checkout@v4 in lint.yml. Recorded as deferred §8.1 with
revisit conditions (air-gapped host / total github.com independence).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:44:49 +02:00
Simone d6031a5e32 refactor(ci): drop upload/download-artifact (remove github.com dependency)
actions/upload-artifact and download-artifact run code fetched from
github.com (and v4 is GHES-incompatible, v3 deprecated). The runner
host is single with a shared filesystem, so the orchestrator's
host-side collect dir is the artifact handoff:

- action.yml: replace the two upload-artifact steps with
  host-path report steps; artifacts stay under F:\CI\Artifacts and
  are aged by Invoke-RetentionPolicy.ps1.
- build-nsInnoUnp.yml: release job reads
  F:\CI\Artifacts\{run_id}-{run_attempt}-{target} directly instead of
  download-artifact; existing Gitea REST release-asset upload unchanged.

Tradeoff (accepted): artifacts are no longer downloadable from the
Gitea Actions run page for non-tag builds — only on host disk, and as
release assets for tagged builds.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:42:36 +02:00
Simone 456db0a3e2 refactor(artifacts): harmonize Windows to Linux raw-file collection
Lint / pssa (push) Failing after 23s
Lint / python (push) Successful in 50s
Windows produced an intermediate C:\CI\output\artifacts.zip that
upload-artifact then re-zipped (zip-in-zip), while Linux deposited raw
files. Make both paths consistent: the build stages raw outputs into a
collect dir; collect zips it only as a transport archive, fetches, and
extracts into the host artifact dir; actions/upload-artifact produces
the single final archive.

- _windows_build: param artifact_zip -> output_dir; stage raw files
  (in-place when source IS the collect dir, else wipe+copy), no
  Compress-Archive; absolute artifact-source resolved.
- _windows_collect: zip guest dir as transport, fetch, extract (mirror
  _linux_collect); guest_path is now the collect directory.
- job.py / build_run CLI: pass output_dir; rename --guest-artifact-zip
  -> --guest-output-dir.
- Tests updated for the raw-file contract.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:30:34 +02:00
Simone 2e1f3ec477 fix(build): fetch pinned commit (shallow clone lacks it)
Lint / pssa (push) Failing after 24s
Lint / python (push) Failing after 42s
git clone --depth 1 --branch X only fetches the branch tip. When the
branch advances between workflow trigger and runner pickup, checking
out the pinned commit failed with "reference is not a tree: <sha>".
Fetch that exact commit (git fetch --depth 1 origin <sha>) before
checkout, on both Linux (SSH) and Windows (WinRM) paths.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:17:55 +02:00
Simone ce5e68f357 fix(build): Linux artifact staging — absolute source + don't wipe output
Lint / pssa (push) Failing after 23s
Lint / python (push) Failing after 43s
Two bugs made the Linux smoke "succeed" with an empty artifact:
- artifact_source was always joined as workdir + '/' + src, so an
  absolute source (/opt/ci/output) became /opt/ci/build//opt/ci/output
  and was never found — only a non-fatal WARNING was logged.
- `rm -rf output_dir` ran unconditionally; when the build writes
  directly into the collect dir (the smoke case: output == source),
  it deleted the build output before collection.

Resolve absolute vs workdir-relative; when the source is the output
dir, collect in place without wiping; a missing/empty source is now a
hard failure instead of a silent empty artifact.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:12:50 +02:00
Simone ce71c95083 docs(phaseA): mark self-test.yml validated
Both smoke jobs (Linux + Windows) passed end-to-end this session.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:09:52 +02:00
Simone 425d8bc4f3 docs: align documentation with session fixes
Reconcile docs with the end-to-end pipeline fixes:
- upload/download-artifact @v4 -> @v3 (Gitea GHES) in WORKFLOW-AUTHORING
  and workflow-example.yml; add Common Mistakes rows (v4, action ref
  form + DEFAULT_ACTIONS_URL, public action repo).
- BEST-PRACTICES / README / HOST-SETUP: guest credential must live in
  the LocalSystem vault with a host-qualified username; document
  Set-CIGuestCredential.ps1 / Test-CIGuestWinRM.ps1 and auth=ntlm.
- README / AGENTS / HOST-SETUP: production venv install is NON-editable
  (LocalSystem); no CI workflow may install into it.
- HOST-SETUP: add DEFAULT_ACTIONS_URL=github + full-URL uses: + public
  repo + @main requirements discovered during validation.
- Correct stale repo name local-ci-system -> local-ci-cd-system.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 16:09:15 +02:00
Simone 662a4eb85d docs(phaseA): fix Windows smoke artifact-source to match build cmd
The Windows manual smoke used --guest-artifact-source
'C:\ci\workspace\artifact.txt' (a stale absolute path that does not
exist in the build flow; workdir is C:\CI\build). The build command
writes artifact.txt into the workdir, so the source must be relative
'artifact.txt' — matching the Linux example.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 15:55:52 +02:00
Simone d3f129f777 fix(build): run Windows build cmd as PowerShell; resolve absolute artifact-source
Lint / pssa (push) Failing after 25s
Lint / python (push) Failing after 43s
Two Windows-guest build bugs:
- The build command was wrapped in `cmd /c`, so PowerShell-authored
  commands failed ("'New-Item' is not recognized"). Run it as PS
  (seed LASTEXITCODE=0 so PS-only commands exit cleanly).
- artifact_source was always Join-Path'd with the workdir; an absolute
  source (C:\CI\output) became C:\CI\build\C:\CI\output. Use the path
  as-is when rooted, else Join-Path the workdir.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 15:50:17 +02:00
Simone 0726829c5c fix(ci): lint must use an ephemeral venv, not the production one
Lint / pssa (push) Failing after 30s
Lint / python (push) Successful in 1m2s
The python lint job set VENV_DIR=F:\CI\python\venv (the shared
orchestrator venv) and ran `pip install -e ".[dev]"`. Every lint run
repointed ci_orchestrator at the lint job's transient checkout; once
act_runner cleaned that dir, all later smoke/build jobs failed with
"No module named ci_orchestrator". Use a job-local venv under
github.workspace, rebuilt fresh each run.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 15:44:36 +02:00
Simone 21681e7419 feat(scripts): add Test-CIGuestWinRM.ps1 diagnostic
Lint / python (push) Successful in 21s
Lint / pssa (push) Failing after 24s
Reproduces the orchestrator WinRM readiness probe as SYSTEM (the
act_runner account) and surfaces the real error the silent
is_ready() swallows: TCP reachability, guest hostname from the TLS
cert CN, and an auth x username-form matrix, with a classified
fix recommendation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 12:24:35 +02:00
Simone ef6f36c702 fix(winrm): default to NTLM for local-account build VMs
pypsrp defaults to auth='negotiate', which attempts Kerberos with no
domain and fails under SSPI with SEC_E_UNKNOWN_CREDENTIALS for the
workgroup ci_build account. Default to 'ntlm' (configurable). The
guest username must be host-qualified (WINBUILD-2025\ci_build) and
stored that way in the credential vault.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 12:24:34 +02:00
Simone d73c7ff0ff fix(ci): write GITHUB_OUTPUT without BOM; harden artifact path
PowerShell 5.1 `Out-File -Encoding utf8` prepends a UTF-8 BOM. The
act_runner GITHUB_OUTPUT parser then read the key as "artifact-path",
so steps.invoke-ci.outputs.artifact-path resolved empty. Combined with
the trailing backslash, the upload path became "\" -> the F: drive root,
causing upload-artifact to ingest the entire drive (hundreds of GB of
unrelated files).

- Append outputs with UTF8Encoding($false) (no BOM).
- Throw if artifactPath is empty instead of emitting nothing.
- Drop the trailing backslash; use /*.log for the diagnostic glob.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 12:13:22 +02:00
Simone 9972010230 docs(phaseA): production venv install must be non-editable
act_runner runs as LocalSystem; `pip install -e .` writes a .pth to a
path LocalSystem can't resolve (N: user drive or a transient
F:\CI\RunnerWork job dir), causing "No module named ci_orchestrator".
Prescribe `pip install .` and warn about the cd target.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 12:08:57 +02:00
Simone 2ccc9009ff feat(scripts): add Set-CIGuestCredential.ps1
Lint / pssa (push) Failing after 36s
Lint / python (push) Successful in 40s
Stores a guest-VM credential into the LocalSystem keyring vault via a
transient SYSTEM scheduled task, using the production venv's keyring
(the backend ci_orchestrator reads). Fixes the per-user vault mismatch
that made act_runner (LocalSystem) fail with "Credential not found in
keyring" for cmdkey/UI-stored credentials.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 11:56:40 +02:00
Simone 5371ffe48a fix(ci): downgrade artifact actions v4 -> v3 for Gitea compat
Gitea act_runner reports as GHES; @actions/artifact v2 (upload/
download-artifact@v4) uses the Twirp API Gitea does not implement,
failing with GHESNotSupportedError. v3 uses the artifact protocol
Gitea supports.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 11:56:40 +02:00
Simone af25358b5b ci: update artifact upload actions to use standard upload-artifact action 2026-05-17 02:15:36 +02:00
Simone e29f5eb995 ci: update artifact upload actions to use local repository references 2026-05-17 02:13:18 +02:00
Simone ea29203f37 ci: update action references to local-ci-cd-system in workflows and action files 2026-05-17 01:37:03 +02:00
Simone 5cb3a7510f ci: sposta local-ci-build action in .gitea/actions/ 2026-05-17 00:45:43 +02:00
Simone c5b2f36c77 docs: aggiorna checklist FaseA (tracking workflow) 2026-05-17 00:29:21 +02:00
Simone 935b212d1a ci: sposta self-test.yml e build-nsInnoUnp.yml in .gitea/workflows 2026-05-17 00:29:11 +02:00
Simone 9490aec92a chore: allinea .gitignore a main 2026-05-17 00:24:26 +02:00
Simone 4b70172c52 ci: aggiungi workflow_dispatch (trigger manuale) a lint.yml
Lint / pssa (push) Successful in 23s
Lint / python (push) Successful in 26s
2026-05-17 00:23:56 +02:00
Simone e810747557 docs,config: aggiorna AGENTS.md, config.example, HOST-SETUP.md, checklist faseA e fix vari orchestrator (workstation, build, job, wait, winrm, test) 2026-05-17 00:14:04 +02:00
Simone dc8449a0d7 test: cover easy missing branches in report/config/credentials/ssh/wait/job
Lint / pssa (push) Successful in 34s
Lint / python (push) Successful in 41s
2026-05-14 23:23:55 +02:00
Simone b2b31f4b6e test: add coverage for monitor/vm/winrm to reach 90%% gate
Lint / pssa (push) Successful in 35s
Lint / python (push) Successful in 42s
Bring monitor.py 49->99%%, vm.py 79->98%%, winrm.py 76->100%%. Total project coverage 80.10%% -> 90.69%%, satisfying the 90%% gate set in commit 451a61c.
2026-05-14 23:14:08 +02:00
Simone 451a61c6a1 test: bump coverage gate from 80%% to 90%%
Lint / python (push) Failing after 22s
Lint / pssa (push) Successful in 25s
Update --cov-fail-under in lint workflow + docs (AGENTS, README, ARCHITECTURE). Note: A5 closeout reported 80.10%% so this run will likely fail until additional tests are added.
2026-05-14 23:04:56 +02:00
Simone 4f656725bf ci(lint): use CI_PYTHON_LAUNCHER from runner config as single source of truth
Lint / pssa (push) Successful in 24s
Lint / python (push) Successful in 22s
Configure system Python path once in runner/config.yaml (runner.envs) instead of probing N candidate locations in the workflow. Workflow now fails fast with a clear error if the env is unset or points to a missing file. Document the new env in AGENTS.md.
2026-05-14 22:56:51 +02:00
Simone 3c62bbbcbb ci(lint): add Python314 to launcher candidates (host has 3.14.5)
Lint / pssa (push) Successful in 24s
Lint / python (push) Successful in 1m0s
Reorder candidates to put C:\Program Files\Python314 first (verified install path on the production host). Drop py.exe -3.11 hint to plain -3 since host has only 3.14.
2026-05-14 22:53:16 +02:00
Simone 6e0d0cba88 ci(lint): probe multiple Python launcher locations for SYSTEM runner
Lint / python (push) Failing after 10s
Lint / pssa (push) Successful in 24s
act_runner SYSTEM context may not have py.exe or python.exe in PATH. Try a list of common install paths (C:\Python3XX, Program Files, LocalAppData) and allow override via CI_PYTHON_LAUNCHER env var.
2026-05-14 22:51:22 +02:00
Simone 38898a3c21 ci(lint): fix broken-venv probe (AGENTS.md #12 stderr trap)
Lint / python (push) Failing after 11s
Lint / pssa (push) Successful in 24s
Native stderr from a broken python.exe shim ('No Python at ...') becomes a terminating exception under \Continue='Stop' BEFORE \0 can be read. Wrap the probe in try/catch + SilentlyContinue.
2026-05-14 22:50:29 +02:00
Simone 0c7c9272ee ci(lint): detect broken venv (stale base interpreter) and rebuild
Lint / python (push) Failing after 8s
Lint / pssa (push) Successful in 24s
The venv at F:\CI\python\venv may exist but be broken if its pyvenv.cfg points to a deleted base interpreter (e.g. a stale actions/setup-python tool_cache). Detect this by running 'python --version' and rebuild the venv with py.exe -3.11 if it fails.
2026-05-14 22:48:46 +02:00
Simone 406c0e31a9 ci(lint): bootstrap venv via py.exe launcher; bump coverage to 80%
Lint / python (push) Failing after 18s
Lint / pssa (push) Successful in 24s
act_runner runs as SYSTEM and does not have plain 'python' in PATH; use py.exe launcher (-3.11) to bootstrap the venv when missing. The production venv at F:\CI\python\venv normally already exists, so the bootstrap is just a fallback. Also align coverage threshold to 80% (raised in A5, see AGENTS.md).
2026-05-14 22:46:13 +02:00
Simone 632d668327 ci(lint): tweak comment header to trigger workflow re-run
Lint / python (push) Failing after 9s
Lint / pssa (push) Successful in 25s
2026-05-14 22:43:55 +02:00
Simone ebc53b5fb9 ci: trigger lint workflow re-run 2026-05-14 22:39:30 +02:00
Simone 137287176e docs: rename branch references to feature/python-rewrite-and-linux-migration
Update active docs (PhaseA/B checklists, README) after rename of feature/python-rewrite-phase-a -> feature/python-rewrite-and-linux-migration. Historical A1-A5 closeouts left untouched as they document state at the time of writing.
2026-05-14 18:34:04 +02:00
Simone 28523375b9 docs(plans): add A->B bridge checklist (windows prereqs + baseline + logistics)
Bridges the gap between PhaseA-user-checklist.md (Windows validation) and PhaseB-user-checklist.md (Linux setup):

  Section 1: capture pre-migration benchmark to docs/RUNBOOK.md (referenced by B7)

  Section 2: 7 Windows prerequisites (SSH keys, BuildVMGuest password, Gitea PAT, OpenSSH server, template power-off check per AGENTS.md #9, F:\CI\ backup, scheduled task cadence audit)

  Section 3: logistics (hardware, DNS, maintenance window, user comms)
2026-05-14 18:34:04 +02:00
Simone bd61258a42 feat(b6): add Phase B user checklist for CI migration to Linux Mint 2026-05-14 18:34:04 +02:00
Simone 0bd3b52fb5 feat(b5): add systemd unit files for CI periodic tasks (Linux host)
Implements the repo-side artifacts of Phase B5 (plans/implementation-plan-A-B.md). Creates 5 .service + .timer pairs under deploy/systemd/ that replicate the periodic tasks registered on Windows by scripts/Register-CIScheduledTasks.ps1:

  - ci-cleanup-orphans       -> python -m ci_orchestrator vm cleanup --max-age-hours 6 (every 6h + boot)

  - ci-retention-policy      -> pwsh Invoke-RetentionPolicy.ps1 (daily 03:00)

  - ci-watch-disk-space      -> python -m ci_orchestrator monitor disk (every 15min)

  - ci-watch-runner-health   -> python -m ci_orchestrator monitor runner (every 15min)

  - ci-backup-template       -> pwsh Backup-CITemplate.ps1 (weekly Sun 02:00, NEW)

Includes deploy/systemd/README.md with mapping table, install/test/rollback instructions, and PowerShell Core install note for the two PS-only scripts. Plan checklist updated; B5-closeout.md added. Hardware install steps (systemctl enable + smoke) remain user responsibility on the Linux host.
2026-05-14 18:34:04 +02:00
Simone 4e0b796f81 docs: add Fase A user checklist for hardware validation 2026-05-14 18:34:04 +02:00
Simone a658f4ed3b docs(a5): mark A5 as code-complete; add A5-closeout.md
Master checklist + step A5 attivita + 'definizione di fatto' updated; A5-closeout.md added (116 pytest, coverage 80.10% total, gate raised to 80%). Hardware validation (burn-in 4x10 + workflow matrix end-to-end) deferred to user. Shim PS removal deferred to B5 (systemd timers): all 10 shims still referenced by Register-CIScheduledTasks.ps1 / docs / Test-*.ps1.
2026-05-14 18:34:04 +02:00
Simone 4d9c6d07ba docs(a5): document Python orchestrator in AGENTS.md, ARCHITECTURE.md, README.md
AGENTS.md: new 'Python development' section (venv paths, install/lint/typecheck/test commands, conventions, full PS->Python sub-command mapping, list of PS scripts that stay PowerShell, link to phase closeouts). README.md: expand 'Python orchestrator' with examples for all 10 sub-commands (wait-ready, vm new/remove/cleanup, build run, artifacts collect, monitor disk/runner, report job, job), local validation gates with 80% coverage gate, link to test_agents_errors.py. docs/ARCHITECTURE.md: new 'Python orchestrator (Phase A)' section with package layout tree, VmBackend Protocol contract, load_backend(config) factory, Phase C ESXi extension recipe, transport selection note, and CI validation gates.
2026-05-14 18:34:04 +02:00
Simone 5459672b42 test(a5): add pytest regression tests for AGENTS.md errors #9-#12
12 dedicated tests covering: (#9) clone_linked surfaces 'should not be powered on' as typed BackendError; (#10) is_running uses 'vmrun list' only and never falls back to getGuestIPAddress (incl. on vmrun list failure); (#11) two consecutive 'vm new' invocations with identical inputs MUST produce distinct clone names/destinations (timestamp suffix), guarding the orchestrator-side safety net against the machine-id duplicate-IP failure mode; (#12) SshTransport defaults to paramiko AutoAddPolicy with no known_hosts, never shells out to ssh-keygen/ssh.exe/scp.exe, wraps paramiko import/exec/SFTP errors as TransportConnectError. Coverage: 80.10% (gate 80%).
2026-05-14 18:34:04 +02:00
Simone 1bcd40e483 docs(a4): mark A4 as code-complete; add A4-closeout.md
Master checklist + step A4 attivita + 'definizione di fatto' updated; A4-closeout.md added (104 pytest, coverage 79.25% total / 83% commands/job.py). Hardware validation (matrix workflow + benchmark) deferred to user.
2026-05-14 18:34:04 +02:00
Simone e5cd749ea1 ci(a4): switch local-ci-build action.yml to Python CLI; add PYTHONIOENCODING=utf-8
The composite action now invokes & $venvPython -m ci_orchestrator job ... directly instead of splatting a hashtable into Invoke-CIJob.ps1, removing the only mismatch between the new shim's positional args contract and the action's previous PascalCase splatting. runner/config.yaml exports PYTHONIOENCODING=utf-8 so non-ASCII build output survives the act_runner -> Gitea round-trip.
2026-05-14 18:34:03 +02:00
Simone f5091d0903 feat(a4): port Invoke-CIJob.ps1 to ci_orchestrator job
Phase A4 of plans/implementation-plan-A-B.md. Implements the full job orchestrator (clone -> start -> wait -> probe -> build -> collect -> guaranteed cleanup) as a new commands/job.py click command, registered under python -m ci_orchestrator job. Backend selection goes through backends.load_backend(config) so Phase C can swap in remote drivers without touching the command. The legacy scripts/Invoke-CIJob.ps1 is replaced by a thin PS 5.1 shim that delegates to the Python CLI; tests/python/test_commands_job.py adds 13 cases covering Linux/Windows happy paths, override application, skip-artifact, and cleanup on every failure mode.
2026-05-14 18:34:03 +02:00
Simone 816a15503e feat(a3): port build pipeline (vm new, build run, artifacts collect)
Implements Phase A3 of plans/implementation-plan-A-B.md:

- commands/vm.py: vm new (replaces New-BuildVM.ps1)

- commands/build.py: build run (replaces Invoke-RemoteBuild.ps1) with WinRM/SSH dispatch and stdout streaming for act_runner

- commands/artifacts.py: artifacts collect (replaces Get-BuildArtifacts.ps1) using transport.fetch()

- 3 PS scripts reduced to shims preserving \0

- Pester tests/{New-BuildVM,Wait-VMReady,Remove-BuildVM}.Tests.ps1 removed; equivalent cases covered in pytest

- Phase C hook: build/artifacts accept opaque VmHandle/vmx; no Windows path assumptions

Tests: 91 pytest, ruff clean, mypy --strict clean, coverage 78.27% (>=70 gate).

Master checklist + step A3 attivita + 'definizione di fatto' updated; A3-closeout.md added.
2026-05-14 18:34:03 +02:00
Simone 096ba7fe16 docs(a1): sync master checklist + A1 'definizione di fatto' to actual state
A1 items were completed but only A1-closeout.md was updated. Mark all A1 checkboxes done in implementation-plan-A-B.md (master checklist + step-A1 attivita + definizione di fatto), leaving only the real-VM PoC pending (hardware validation deferred).
2026-05-14 18:34:03 +02:00