Refactor logging and files#31
Merged
Merged
Conversation
…lt objects
Implements dev/PLAN.md Track A (file handling) and Track B consumer wiring
(B5), against src-py-lib v0.3.0.
- shared/backups.py: frozen RunPaths resolved once per run
(resolve_run_paths); absolute paths, exclusive run-directory creation
with collision suffixes; artifact_path() family naming; the path
ContextVars and cwd fallbacks are gone
- New flags: --artifacts-dir (root of the artifacts tree, default
unchanged) and --no-files (write nothing; with --apply also requires
--no-backup so giving up restore is stated explicitly twice)
- get now accepts --maps-path (symmetric with set)
- Org-sync snapshots renamed to saml-organizations-{before,after,diff}.json
so combined set --sync-saml-orgs runs cannot collide with permission
snapshots
- Module API: Get/Set/Restore/SyncSamlOrgs return result dataclasses
(GetResult carries the auth provider and code host dicts in memory);
optional event_sink receives structured wide events; module mode never
touches stdlib logging handlers (CLI mode is selected by main() only)
- log.json is now OTel Logs Data Model JSONL via src-py-lib EventSink
- Tests: RunPaths unit coverage incl. path-escape safety, --no-files
rejection matrix, module-mode isolation tests, no-files dry-run parity
with files-enabled, fixture harness routed through temp artifact dirs
Verification: tests/run.py 102/102 fast, 120/120 --live against the
sgdev test instance (apply + restore cycles with GraphQL read-back,
wheel install smoke against PyPI src-py-lib 0.3.0)
Amp-Thread-ID: https://ampcode.com/threads/T-019eba67-c19d-7166-9690-dcb2f0eed165
Co-authored-by: Amp <amp@ampcode.com>
marcleblanc2
added a commit
that referenced
this pull request
Jun 12, 2026
Completes dev/PLAN.md Track A Phase A4 (the one piece deferred from #31). ## What `src.Set(config, mapping_rules=[...])` runs permission sync from parsed rules with no maps YAML file. Combined with `GetResult` data and `no_files=True`, the full get -> assemble -> dry-run loop never touches disk. ## Guarantees - In-memory rules pass through the same structural validation as file-loaded rules, at the edge, before any network or path resolution - With files enabled, the rules **actually used** are serialized into the run directory as the maps.yaml audit copy - a stale customer maps file is never copied - Reversibility invariant unchanged: snapshots still gate `apply`; `no_files` + `apply` keeps requiring `no_backup` - Module-mode diagnostics: swallowed `SystemExit` messages now surface through the package logger so host applications can see why a run failed - `MappingRule` exported for caller typing ## Tests - Rules resolution/validation matrix (file fallback, decoy-file ignored, no file needed, empty rules, invalid structures rejected) - Audit serializer round-trip through the standard loader - e2e parity: file vs in-memory vs in-memory+no_files produce identical mutations and end state on both dry-run and apply fixture cases; audit copy content equals the rules used; invalid rules fail fast with zero mutations - Module-API: falsy results without exceptions, diagnostic on the package logger, no maps file needed (proven via HTTP-attempt counters on the run-end event) ## Verification - `uv run tests/run.py` - 102/102 - `uv run tests/run.py --live` - 120/120 against the sgdev test instance - pyright strict 0 errors, ruff + markdownlint clean Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.