Repository navigation
Make CodeGen deterministic-from-external-source; converge with downstream - #192
Merged
Merged
Conversation
…ream The CodeGen demo embedded a per-build timestamp, which forced a convoluted get-runtime job to share one UTC timestamp across the main/develop matrix legs so output stayed byte-identical. That is unlike the real downstream codegen consumers (NxWitness, LanguageTags), which generate deterministically from an external source with no cross-leg state. - CodeGen app: --runtime is now opt-in. Absent -> deterministic output (the quote alone); `now` -> embed DateTime.UtcNow; ISO literal -> embed it. The timestamp path is a local-only demo of why per-run state diverges. - CodeGen.cs regenerated to the deterministic shape (no timestamp). - run-codegen-pull-request-task.yml: drop the get-runtime job and --runtime; each matrix leg runs a single deterministic dotnet run, like NxWitness/ LanguageTags. Rare day-boundary drift is expected and self-heals. - launch.json: pass --runtime now so a local run still exercises the demo. Convergence with downstream (best end-state): - merge-bot: trigger on pull_request_target, not pull_request (LanguageTags' hardened variant) - jobs hold the App key so action SHAs must resolve from the trusted base; safe because no job checks out PR code. - run-periodic concurrency: workflow-only group (fixes a real dispatch-vs- schedule race the ref-scoped group allowed). Docs: rewrite the AGENTS.md codegen bullet to the deterministic model; note the merge-bot pull_request_target choice in README. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the template's CodeGen example and related workflows to remove CI-specific per-run state sharing and align the template with deterministic-from-external-source patterns used by downstream consumers. It also hardens the merge-bot workflow by switching it to pull_request_target while keeping the safety precondition of not checking out PR code.
Changes:
- Make CodeGen output deterministic by default (timestamp embedding becomes opt-in via
--runtime, intended for local-only demonstration). - Simplify the codegen PR workflow by removing the shared
get-runtimejob and the--runtimeplumbing. - Switch merge-bot to
pull_request_targetand adjust periodic-codegen concurrency to avoid branch write races.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the pull_request_target rationale/safety model for merge-bot. |
| CodeGen/CommandLine.cs | Updates --runtime option help text to reflect new deterministic-by-default behavior. |
| CodeGen/CodeGenBuilder.cs | Splits generation into deterministic vs timestamp-embedded variants; adds runtime resolution (now vs literal). |
| CodeGen/CodeGen.cs | Regenerates the sample output to remove the embedded timestamp in the deterministic default. |
| AGENTS.md | Updates the guidance to emphasize deterministic-from-inputs codegen and positions --runtime as local-only demo. |
| .vscode/launch.json | Adds --runtime now to the CodeGen debug profile to keep the local divergence demo. |
| .github/workflows/run-periodic-codegen-pull-request.yml | Changes concurrency grouping to workflow-only to prevent scheduled/dispatch races on fixed branches. |
| .github/workflows/run-codegen-pull-request-task.yml | Removes the shared runtime capture job and stops passing --runtime in CI. |
| .github/workflows/merge-bot-pull-request.yml | Switches trigger to pull_request_target and documents the safety premise (no PR checkout; merge by URL). |
ptr727
added a commit
that referenced
this pull request
Jun 23, 2026
Closes #193. - Removed the dead intra-doc anchor from the mandated-verbatim PR Review Etiquette callout (its target lives under the hub-only Quick Start, which derived repos don't carry). - Split the codegen-determinism bullet into a carryable provider-agnostic principle (regenerate committed files; output deterministic from inputs, never per-run state; what/how is the derived repo's concern) and a clearly-marked droppable template-demo note (API-Ninjas quote + --runtime). - Stopped naming sibling repos in carried text.
ptr727
added a commit
that referenced
this pull request
Jun 23, 2026
Promotes the current `develop` head to `main` for release. Contents: - **#192** — Make CodeGen deterministic-from-external-source; converge codegen/merge-bot workflows with downstream (drops the per-build timestamp + `get-runtime` state-sharing; merge-bot hardened to `pull_request_target`; periodic concurrency workflow-only group). - **#194** — Make the #192 codegen docs carry cleanly into derived repos (closes #193: dead-anchor removal + split codegen principle from demo specifics). Standard release promotion: merge (not squash). A separate `publish-release.yml` dispatch performs the actual release after this lands. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Makes the CodeGen example deterministic-from-external-source (like the real downstream consumers NxWitness/LanguageTags) and converges the codegen/merge-bot workflows with the best downstream patterns.
Problem
The CodeGen demo embedded a per-build timestamp, so CI needed a
get-runtimejob to capture one UTC timestamp and pass it via--runtimeto both themainanddevelopmatrix legs (to keep output byte-identical and avoiddevelop -> mainconflicts). That state-sharing is convoluted and unlike how the actual downstream codegen consumers work.Core change — timestamp is opt-in, local-only
--runtimeabsent ⇒ deterministic output (the ApiNinjas quote-of-the-day alone);now⇒ embedDateTime.UtcNow; ISO literal ⇒ embed it.get-runtimejob and--runtimeremoved from CI; each leg runs a single deterministicdotnet run.CodeGen.csregenerated without the timestamp.launch.jsonpasses--runtime nowso local runs still demonstrate the per-run-divergence lesson.Convergence with downstream (best end-state, per request)
pull_request_target(LanguageTags' hardened variant): the jobs mint an App token, so the workflow definition and action SHAs now resolve from the trusted base branch, not the PR head. Safe because no job checks out PR code — each only runsgh pr mergeby URL.workflow_dispatchfrom a non-default ref and the scheduled run could run simultaneously against the fixedcodegen-*branches).Verification
dotnet format style --verify-no-changesclean.--runtime⇒ byte-identical across runs, nodateTimeconst;--runtime now⇒ differs per run; literal ⇒ embeds the value.pull_request_targetsafety precondition); line endings preserved.Operational note
pull_request_targetruns triggered by Dependabot still use the Dependabot secrets store, so theCODEGEN_APP_*secrets must be present there (already documented in README) — unchanged by this PR, but worth confirming.Deferred (not in this PR)
merge-upstream-versionmerge-bot job down to NxWitness (a downstream edit).🤖 Generated with Claude Code