Skip to content

Add CodeQL analysis workflow configuration - #4

Merged
Pierre Malarme (pmalarme) merged 1 commit into
mainfrom
feature/add-codeql
Jul 7, 2026
Merged

Pierre Malarme (pmalarme) merged 1 commit into
mainfrom
feature/add-codeql

Conversation

@pmalarme

Copy link
Copy Markdown
Collaborator

This pull request adds a new GitHub Actions workflow for CodeQL analysis to the repository. The workflow is set up to automatically scan the codebase for security vulnerabilities and code quality issues in both GitHub Actions and Python code. It will run on pushes, pull requests, and on a weekly schedule.

New CI/CD workflow for security analysis:

  • Added .github/workflows/codeql-analysis.yml to enable automated CodeQL scanning for 'actions' and 'python' languages, triggered on push, pull request, manual dispatch, and a weekly schedule.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@pmalarme
Pierre Malarme (pmalarme) merged commit 2843c63 into main Jul 7, 2026
2 of 3 checks passed
@pmalarme
Pierre Malarme (pmalarme) deleted the feature/add-codeql branch July 7, 2026 10:30
Pierre Malarme (pmalarme) added a commit that referenced this pull request Jul 9, 2026
Three non-blocking findings from an independent review (no blockers):

1. Drop the event-payload fallback in advance-on-push.yml guard #4. GitHub caps
   the push payload's .commits[] at 20 entries, so on a large force-push it could
   omit a delivery path and wrongly classify the push as machinery-only ->
   wrongly suppress a real advance (strand the participant). Use only
   git diff BEFORE..SHA (full-depth checkout, uncapped); when BEFORE is
   unreachable, treat the changed set as unknown and advance (legacy) rather than
   risk stranding.

3. Capture the classifier output in its own variable so a nonzero exit trips
   set -e (fail closed) instead of the `[[ "$(...)" == "true" ]]` comparison
   quietly evaluating false and advancing.

2. Add a drift test: every tracked top-level path in the real repo must classify
   as machinery (MACHINERY_PATHS) or known delivery (travel_assistant/ or a
   _root sibling), so a future root-level machinery file can't silently
   reintroduce the wrong-advance bug.

129 tests pass, lint 0 failures. Guard #4 re-simulated: machinery-only -> skip;
mixed / overlay / unknown -> advance; classifier failure -> step aborts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pierre Malarme (pmalarme) added a commit that referenced this pull request Jul 9, 2026
* guard: don't advance on manual machinery-only pushes

advance-on-push.yml only suppressed auto-advance for pushes carrying a
[skip-advance] marker or a .workshop-state.json change. A participant who
pulled the latest machinery from upstream and pushed it MANUALLY (no marker)
was therefore bumped to the next step they never worked on.

Add a fourth guard: classify the push's changed paths and skip advancing when
they are ALL workshop machinery / platform files (.github/, .workshop/,
Makefile, .devcontainer/, README.md, ...) and never the delivery
(travel_assistant/ or its _root overlay siblings such as travel_toolbox/).

The machinery list lives in advance_step.py as the single source of truth,
exposed via a new `--is-machinery-only` mode that the workflow pipes the push's
changed paths into, so the list is never duplicated in YAML.

- advance_step.py: MACHINERY_PATHS, _is_machinery_path, _is_machinery_only_push,
  --is-machinery-only CLI mode
- advance-on-push.yml: guard #4 using git diff (fallback: event payload union)
- 00-intro.md: document the machinery-only skip in the troubleshooting note
- tests: 12 new cases (classifier + CLI); 128 pass, lint 0 failures

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* refactor: rename --is-machinery-only to --check-machinery-only

The other advance_step.py modes are actions (--init, --reset, --on-push), so a
boolean-adjective flag name read like a toggle. Rename the query-mode flag to a
command-style --check-machinery-only for consistency; update the dest, the
runner (_run_check_machinery_only), the workflow invocation, and the CLI tests.
The boolean predicate helpers (_is_machinery_path / _is_machinery_only_push)
keep the is_ prefix, which is correct for predicates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* harden machinery guard after rubber-duck review

Three non-blocking findings from an independent review (no blockers):

1. Drop the event-payload fallback in advance-on-push.yml guard #4. GitHub caps
   the push payload's .commits[] at 20 entries, so on a large force-push it could
   omit a delivery path and wrongly classify the push as machinery-only ->
   wrongly suppress a real advance (strand the participant). Use only
   git diff BEFORE..SHA (full-depth checkout, uncapped); when BEFORE is
   unreachable, treat the changed set as unknown and advance (legacy) rather than
   risk stranding.

3. Capture the classifier output in its own variable so a nonzero exit trips
   set -e (fail closed) instead of the `[[ "$(...)" == "true" ]]` comparison
   quietly evaluating false and advancing.

2. Add a drift test: every tracked top-level path in the real repo must classify
   as machinery (MACHINERY_PATHS) or known delivery (travel_assistant/ or a
   _root sibling), so a future root-level machinery file can't silently
   reintroduce the wrong-advance bug.

129 tests pass, lint 0 failures. Guard #4 re-simulated: machinery-only -> skip;
mixed / overlay / unknown -> advance; classifier failure -> step aborts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* ci: re-trigger checks (transient CodeQL runner-acquisition failure)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pierre Malarme (pmalarme) added a commit that referenced this pull request Jul 16, 2026
Address rubber-duck findings on the local --back backup engine:

- Atomic publish: snapshot now renames the prior step-<N>/ aside, swaps the
  new snapshot in, and only deletes the old copy once the swap succeeds, with
  rollback on failure and staging cleanup on every failure path — so a mid-swap
  crash never leaves a step without a valid backup (#1).
- Always capture the travel_assistant/ namespace, even a lone .gitkeep, so a
  root-only snapshot restores the placeholder instead of an empty dir (#2).
- Protect repo machinery: _root overlay targets that resolve to MACHINERY_PATHS
  or .git are rejected up front, compared casefolded so case variants can't slip
  past on case-insensitive filesystems (#3).
- Exact restore: clear each destination before copying so an undeclared stale
  target (e.g. left after a template sync) is replaced, not merged (#4).
- Validate the backup manifest step is an integer before trusting it (#5).

Add regression tests for each fix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fea011c8-1399-4f8a-a3bd-277408cae6c2
Pierre Malarme (pmalarme) added a commit that referenced this pull request Jul 16, 2026
* Add local --back step for the workshop engine

Local learners who advance without committing each step had no way to
move back. Add `advance_step.py --back` (plus a `make back` alias, README
docs, and a `back-workshop.yml` CI pipeline) that restores the learner's
saved work from the previous step's snapshot, or rebuilds the canonical
step files when no snapshot exists.

Namespace the backup layout so the agent snapshot and repo-root overlay
targets never collide: `step-<N>/travel_assistant/`, `step-<N>/_root/`,
and a `backup.json` completion manifest written last. This makes root-name
collisions structurally impossible (#1) and lets `--back` restore
structurally rather than by name. Snapshots are now published atomically
(stage -> copy -> manifest -> swap) and fully replace any prior snapshot,
so files deleted on a revisit are never resurrected (#3).

Also: gate `--back` restore on a valid manifest (legacy/partial backups
degrade to a canonical rebuild with a clear warning), reject `_root`
overlay targets that shadow protected repo paths, and make reset/back/step
backup dirs unique within the same second.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fea011c8-1399-4f8a-a3bd-277408cae6c2

* Harden backup snapshot/restore per review

Address rubber-duck findings on the local --back backup engine:

- Atomic publish: snapshot now renames the prior step-<N>/ aside, swaps the
  new snapshot in, and only deletes the old copy once the swap succeeds, with
  rollback on failure and staging cleanup on every failure path — so a mid-swap
  crash never leaves a step without a valid backup (#1).
- Always capture the travel_assistant/ namespace, even a lone .gitkeep, so a
  root-only snapshot restores the placeholder instead of an empty dir (#2).
- Protect repo machinery: _root overlay targets that resolve to MACHINERY_PATHS
  or .git are rejected up front, compared casefolded so case variants can't slip
  past on case-insensitive filesystems (#3).
- Exact restore: clear each destination before copying so an undeclared stale
  target (e.g. left after a template sync) is replaced, not merged (#4).
- Validate the backup manifest step is an integer before trusting it (#5).

Add regression tests for each fix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fea011c8-1399-4f8a-a3bd-277408cae6c2

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants