Add timestamps to artifacts and auto-update baseline on drift#6
Merged
Conversation
- api_reference.md footer now shows when and from which machine it was generated - openapi_baseline.json wrapped with _meta.saved_at and _meta.saved_by_machine - drift_summary.md includes detection timestamp and machine - audit_report.md includes generation timestamp and machine - Backward compatible: check command handles both old (raw spec) and new (_meta wrapper) baseline formats Co-Authored-By: unknown <>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
When drift is detected, cmd_check now writes the baseline with the _meta wrapper (saved_at, saved_by_machine) instead of the raw spec, keeping provenance info consistent with cmd_baseline. Co-Authored-By: unknown <>
- Pre-commit hook now runs 'drift_guard baseline' automatically when drift is detected, stages the updated files, and lets the commit proceed - CI workflow also auto-updates baseline instead of failing on drift - No more manual 'python -m drift_guard.guard baseline' step needed Co-Authored-By: unknown <>
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.
Add timestamps to artifacts and auto-update baseline on drift
Summary
Two changes in this PR:
1. Timestamps & machine info on all generated artifacts
docs/api_reference.mdfooter now includes generation timestamp and machine nameartifacts/openapi_baseline.jsonis wrapped in a{"_meta": {"saved_at": ..., "saved_by_machine": ...}, "spec": {...}}envelopedrift_summary.mdandaudit_report.mdinclude detection/generation timestampscmd_checkhas backward compatibility to read both old (raw spec) and new (wrapped) baseline formats_timestamp()and_machine()helpers inguard.py2. Pre-commit hook & CI auto-update baseline instead of blocking
drift_guard baselineautomatically when drift is detected, stages the updatedartifacts/openapi_baseline.jsonanddocs/api_reference.md, and lets the commit proceed — instead of blocking with a "run baseline manually" messagedrift_guard baselinewhen drift is detected instead of failing the jobUpdates since last revision
cmd_checknow wraps the updated baseline with_metawhen drift is detected (commit a92436c), matching the behavior ofcmd_baseline. Previously it wrote the raw spec, losing provenance info on subsequent runs.Review & Testing Checklist for Human
baselineto update files on the runner, and overrides the exit code to 0 so the job passes. But it does not commit or push the updated baseline back to the branch. This means CI will silently pass even when the committed baseline is stale. Decide whether CI should (a) still fail and require the developer to commit the fix, (b) auto-commit viaactions/checkout+git push, or (c) keep current behavior where CI just doesn't block.git add artifacts/openapi_baseline.json docs/api_reference.mdduring the pre-commit phase, adding files the developer didn't explicitly stage. Verify this is acceptable — if the baseline regeneration produces unexpected output, it gets committed without the developer reviewing it.openapi_to_md.py's docstring promises "identical content when the schema hasn't changed." Every call tobaselinenow produces a differentapi_reference.md(different timestamp), creating noisy git diffs even when the API hasn't changed. Decide if this is acceptable or if timestamps should live elsewhere."saved_by_machine": "devin-box"— regenerating locally will change this to your hostname, creating a diff.uvicorn app.main:app --reload), install hooks (pip install pre-commit && pre-commit install)python -m drift_guard.guard baseline— verify baseline JSON has_metaand docs footer has timestampapp/main.pyto add a new field (e.g.,age: int = 0toUsermodel), stage it withgit add app/main.py, and rungit commit -m "test"— verify the pre-commit hook auto-updates baseline and docs, stages them, and lets the commit proceed (checkgit logandgit diff HEAD~1to confirm the baseline was included in the commit)artifacts/openapi_baseline.json, copy in an old baseline (raw spec without_meta), runcheck— verify backward compatibility worksNotes
Link to Devin run: https://app.devin.ai/sessions/23d1e596e5f845ec8c47886363e9b2b8
Requested by: @justinemach