diff --git a/.github/workflows/closura-arc-ci.yml b/.github/workflows/closura-arc-ci.yml index f1da93204077..aadcd2c96321 100644 --- a/.github/workflows/closura-arc-ci.yml +++ b/.github/workflows/closura-arc-ci.yml @@ -4,7 +4,9 @@ name: T3 fork ARC CI # macOS/Windows runners, new controller or deployment side effects. on: push: - branches: [feat/assemblyai-current] + # Every merged head of the native release branch gets a check run on its + # exact commit; the private fleet rollout builds only commits that passed. + branches: [feat/assemblyai-current, release/native-0.1.10] pull_request: branches: [feat/assemblyai-current, release/native-0.1.10] workflow_dispatch: @@ -13,14 +15,16 @@ permissions: contents: read concurrency: - group: t3-fork-arc-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + # Pushes group by exact commit, so a burst of merges never cancels a queued + # head: every merged head keeps its own check run. + group: t3-fork-arc-${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.event.pull_request.number || github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: voice-and-inbox: # This is a public fork. Never run untrusted PR code on the private ARC LAN. # Same-repo PR + trusted human author/actor only; push and manual runs - # require an authorized actor and the exact native release branch. + # require an authorized actor and one of the two exact branches above. if: >- ${{ github.repository == 'nullStack65/t3code' && @@ -32,7 +36,8 @@ jobs: contains(fromJSON('["nullStack65","jeffreysmithclosura"]'), github.triggering_actor)) || (github.event_name != 'pull_request' && - github.ref == 'refs/heads/feat/assemblyai-current' && + (github.ref == 'refs/heads/feat/assemblyai-current' || + github.ref == 'refs/heads/release/native-0.1.10') && contains(fromJSON('["nullStack65","jeffreysmithclosura"]'), github.actor)) ) }} @@ -165,7 +170,8 @@ jobs: apps/web/src/components/chat/draftAttachmentUploads.test.ts \ apps/web/src/components/chat/draftUploadReconcile.test.ts \ apps/web/src/lib/attachmentUploadQueue.test.ts \ - apps/server/src/ws.test.ts + apps/server/src/ws.test.ts \ + packages/contracts/src/environment.test.ts - name: Test mobile new-task placement, outbox and uploads shell: bash diff --git a/.github/workflows/closura-deploy-line.yml b/.github/workflows/closura-deploy-line.yml new file mode 100644 index 000000000000..e7bc8fdc3837 --- /dev/null +++ b/.github/workflows/closura-deploy-line.yml @@ -0,0 +1,48 @@ +name: Closura deploy line + +# Every pull request into the native release branch says whether it changes +# what runs, so "merged" is never mistaken for "live". The value is opaque on +# purpose: "fleet" means the private deployment config decides where it runs, +# and no host names are published here. This job reads only the event payload: +# no checkout, no token and no repository code, so it runs on a hosted runner +# and needs no actor guard. +on: + pull_request: + branches: [release/native-0.1.10] + types: [opened, reopened, synchronize, edited, ready_for_review] + +permissions: {} + +concurrency: + group: closura-deploy-line-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + deploy-line: + if: ${{ github.repository == 'nullStack65/t3code' }} + name: Deploy line declared + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: 'Require one Deploy line: none or fleet' + shell: bash + env: + PR_BODY: ${{ github.event.pull_request.body }} + run: | + set -euo pipefail + # Count "Deploy:" lines at the start of a line, outside fenced code blocks. + lines="$(printf '%s\n' "${PR_BODY:-}" | tr -d '\r' \ + | awk '/^[[:space:]]*(```|~~~)/ { fenced = !fenced; next } !fenced && /^Deploy:/' || true)" + count="$(printf '%s' "$lines" | grep -c . || true)" + if test "$count" -ne 1; then + echo "::error::Add exactly one line 'Deploy: none' or 'Deploy: fleet' to the PR body (found $count)." + exit 1 + fi + value="$(printf '%s' "$lines" | sed -E 's/^Deploy:[[:space:]]*//; s/[[:space:]]+$//')" + case "$value" in + none | fleet) echo "Deploy: $value" ;; + *) + echo "::error::The Deploy line must be 'Deploy: none' or 'Deploy: fleet'." + exit 1 + ;; + esac diff --git a/apps/server/src/config.ts b/apps/server/src/config.ts index c707c912d672..63936c572704 100644 --- a/apps/server/src/config.ts +++ b/apps/server/src/config.ts @@ -27,6 +27,13 @@ declare const __T3CODE_TELEMETRY_CHANNEL__: ReleaseChannel | undefined; export const telemetryChannel: ReleaseChannel = typeof __T3CODE_TELEMETRY_CHANNEL__ === "undefined" ? "dev" : __T3CODE_TELEMETRY_CHANNEL__; +// The source commit the build was made from, when the build stamped one (T3CODE_BUILD_COMMIT). +declare const __T3CODE_BUILD_COMMIT__: string | undefined; +export const buildCommit: string | undefined = + typeof __T3CODE_BUILD_COMMIT__ === "undefined" || __T3CODE_BUILD_COMMIT__ === "" + ? undefined + : __T3CODE_BUILD_COMMIT__; + export const DEFAULT_PORT = 3773; export const RuntimeMode = Schema.Literals(["web", "desktop"]); diff --git a/apps/server/src/environment/ServerEnvironment.ts b/apps/server/src/environment/ServerEnvironment.ts index 3b4dc9eb0768..813f1ed59d16 100644 --- a/apps/server/src/environment/ServerEnvironment.ts +++ b/apps/server/src/environment/ServerEnvironment.ts @@ -219,6 +219,7 @@ export const make = Effect.gen(function* () { serverVersion: packageJson.version, orchestrationProtocolVersion: ORCHESTRATION_PROTOCOL_VERSION, ...(databaseMigration === undefined ? {} : { databaseMigration }), + ...(ServerConfig.buildCommit === undefined ? {} : { buildCommit: ServerConfig.buildCommit }), capabilities: { repositoryIdentity: true, connectionProbe: true, diff --git a/apps/server/vite.config.ts b/apps/server/vite.config.ts index 0ec539e5ae16..5d0eaa508181 100644 --- a/apps/server/vite.config.ts +++ b/apps/server/vite.config.ts @@ -34,6 +34,13 @@ if (!TELEMETRY_CHANNELS.includes(telemetryChannel)) { ); } +// The exact source commit this build was made from (40-hex), for deployment receipts. +// Release builds set it; builds without it leave the descriptor's buildCommit absent. +const buildCommit = process.env.T3CODE_BUILD_COMMIT?.trim().toLowerCase() ?? ""; +if (buildCommit !== "" && !/^[0-9a-f]{40}$/.test(buildCommit)) { + throw new Error(`T3CODE_BUILD_COMMIT must be a 40-character hex commit, got "${buildCommit}".`); +} + // tsdown SEA needs one chunk (sourcemaps count) and Node >=25.7, so package separately. // "bundle" emits the embedded CLI. "1" builds dist-exe/t3 from the bootstrap. // TEMPORARY one-time Node fix. Remove when fixed: https://github.com/nodejs/node/issues/67048 @@ -147,6 +154,7 @@ export default mergeConfig( define: { __T3CODE_BUILD_CHANNEL__: JSON.stringify(cliBuildChannel), __T3CODE_TELEMETRY_CHANNEL__: JSON.stringify(telemetryChannel), + __T3CODE_BUILD_COMMIT__: JSON.stringify(buildCommit), __T3CODE_BUILD_RELAY_URL__: JSON.stringify(repoEnv.T3CODE_RELAY_URL?.trim() ?? ""), __T3CODE_BUILD_CLERK_PUBLISHABLE_KEY__: JSON.stringify( repoEnv.T3CODE_CLERK_PUBLISHABLE_KEY?.trim() ?? "", diff --git a/packages/contracts/src/environment.test.ts b/packages/contracts/src/environment.test.ts index 1646684f1da0..2e41b1b136d5 100644 --- a/packages/contracts/src/environment.test.ts +++ b/packages/contracts/src/environment.test.ts @@ -14,6 +14,12 @@ const descriptor = { } as const; describe("ExecutionEnvironmentDescriptor", () => { + it("keeps the optional build commit, absent on unstamped and older servers", () => { + expect(decodeDescriptor(descriptor).buildCommit).toBeUndefined(); + const buildCommit = "4f4c0fbb936f12b27d7d97f05dd9b2e0a9732cb1"; + expect(decodeDescriptor({ ...descriptor, buildCommit }).buildCommit).toBe(buildCommit); + }); + it("decodes old, recognized and future manual installation descriptors", () => { expect(decodeDescriptor(descriptor).capabilities.serverInstallation).toBeUndefined(); for (const installation of [ diff --git a/packages/contracts/src/environment.ts b/packages/contracts/src/environment.ts index 474b8a515ec8..19cd8d427316 100644 --- a/packages/contracts/src/environment.ts +++ b/packages/contracts/src/environment.ts @@ -220,6 +220,8 @@ export const ExecutionEnvironmentDescriptor = Schema.Struct({ orchestrationProtocolVersion: Schema.optionalKey(Schema.Int), /** Highest migration this server's database holds; absent on older servers. */ databaseMigration: Schema.optionalKey(Schema.Int), + /** Full source commit the running build was made from; absent when the build had no stamp. */ + buildCommit: Schema.optionalKey(TrimmedNonEmptyString), capabilities: ExecutionEnvironmentCapabilities, }); export type ExecutionEnvironmentDescriptor = typeof ExecutionEnvironmentDescriptor.Type;