diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78586a96d..fc40a3a89 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ env: jobs: microkernel: uses: ./.github/workflows/core-protocol.yml + with: + split_rust_targets: true web: name: Web checks and production build runs-on: ubuntu-24.04 diff --git a/.github/workflows/core-protocol.yml b/.github/workflows/core-protocol.yml index 371961fd6..6af424493 100644 --- a/.github/workflows/core-protocol.yml +++ b/.github/workflows/core-protocol.yml @@ -2,7 +2,12 @@ name: Microkernel implementation checks on: workflow_dispatch: workflow_call: -# ci.yml owns automatic push/PR runs so this expensive suite runs only once. + inputs: + split_rust_targets: + description: Run unit and integration targets on separate PostgreSQL services. + type: boolean + default: false +# Manual qualification keeps a single runner and the full Cargo target set. permissions: contents: read defaults: @@ -13,11 +18,17 @@ concurrency: cancel-in-progress: true jobs: protocol: + name: ${{ matrix.targets == 'integration' && 'Rust integration targets' || 'protocol' }} + strategy: + fail-fast: false + matrix: + targets: ${{ fromJSON(inputs.split_rust_targets && '["unit","integration"]' || '["all"]') }} runs-on: ubuntu-24.04 # Budget for cold builds, serial real PostgreSQL tests, and the following # payment, Go, and RPC checks while keeping the complete job bounded. timeout-minutes: 150 env: + RUST_TARGET_GROUP: ${{ matrix.targets }} GOWORK: "off" DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/postgres CARGO_BUILD_JOBS: "2" @@ -76,7 +87,7 @@ jobs: - name: Preserve source before checks uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: - name: microkernel-source-${{ github.sha }}-${{ github.run_id }} + name: microkernel-source-${{ github.sha }}-${{ github.run_id }}${{ matrix.targets == 'integration' && '-integration' || '' }} path: | ${{ runner.temp }}/core-source.tar.gz ${{ runner.temp }}/core-source-sha.txt @@ -196,7 +207,7 @@ jobs: if: ${{ !cancelled() && steps.rust_test_compile.outcome == 'success' }} uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: - name: commerce-acceptance-driver-${{ github.sha }}-${{ github.run_id }} + name: commerce-acceptance-driver-${{ github.sha }}-${{ github.run_id }}${{ matrix.targets == 'integration' && '-integration' || '' }} path: ${{ runner.temp }}/commerce-acceptance-driver if-no-files-found: error compression-level: 0 @@ -232,9 +243,15 @@ jobs: LMM_PAYMENT_BOOTSTRAP_SHA256="$(sha256sum "$LMM_PAYMENT_BOOTSTRAP_BIN" | cut -d ' ' -f1)" export LMM_PAYMENT_CORE_BIN LMM_PAYMENT_CORE_SHA256 LMM_PAYMENT_GO_BIN LMM_PAYMENT_GO_SHA256 LMM_PAYMENT_BOOTSTRAP_BIN LMM_PAYMENT_BOOTSTRAP_SHA256 # Emit panic diagnostics immediately, including when the job times out. - cargo test --locked --all-targets --no-fail-fast -- --skip synthetic_live_proof_crosses_core_go_processes_and_posts_once --nocapture 2>&1 | tee "$RUNNER_TEMP/core-tests.log" + case "$RUST_TARGET_GROUP" in + all) targets=(--all-targets) ;; + unit) targets=(--lib --bins --examples --benches) ;; + integration) targets=(--test '*') ;; + *) echo "Unknown Rust target group: $RUST_TARGET_GROUP" >&2; exit 1 ;; + esac + cargo test --locked "${targets[@]}" --no-fail-fast -- --skip synthetic_live_proof_crosses_core_go_processes_and_posts_once --nocapture 2>&1 | tee "$RUNNER_TEMP/core-tests.log" - name: Repeat rejected event acknowledgement regression - if: ${{ !cancelled() && steps.rust_test_compile.outcome == 'success' }} + if: ${{ !cancelled() && matrix.targets != 'integration' && steps.rust_test_compile.outcome == 'success' }} working-directory: services/core run: | for attempt in {1..10}; do @@ -245,7 +262,7 @@ jobs: if: ${{ !cancelled() }} run: python3 -B scripts/ci-payment-live.py --output "$(realpath -m "$RUNNER_TEMP/payment-live")" 2>&1 | tee "$RUNNER_TEMP/payment-live-build.log" - name: Go contract and race tests - if: ${{ !cancelled() }} + if: ${{ !cancelled() && matrix.targets != 'integration' }} working-directory: services/extensions run: | bash ../../scripts/check-go-format.sh . @@ -254,7 +271,7 @@ jobs: go test -race ./... -count=1 -json | tee "$RUNNER_TEMP/extension-tests.jsonl" CGO_ENABLED=0 go build -mod=readonly -trimpath -o "$RUNNER_TEMP/lmm-extensions" ./cmd/extensions - name: Store and support real PostgreSQL acceptance - if: ${{ !cancelled() }} + if: ${{ !cancelled() && matrix.targets != 'integration' }} env: LMM_STORE_TEST_DSN: postgres://postgres:postgres@127.0.0.1:5432/lmm_store_test?sslmode=disable run: | @@ -265,13 +282,13 @@ jobs: go vet -mod=readonly ./... go test -mod=readonly -race -count=1 -json ./... | tee "$RUNNER_TEMP/store-postgres.jsonl" - name: Durable cross-language event process recovery - if: ${{ !cancelled() }} + if: ${{ !cancelled() && matrix.targets != 'integration' }} run: | (cd services/core && cargo build --locked --example protocol-events-fixture) (cd contracts/proto/tests/go && go vet -mod=readonly ./... && go build -mod=readonly -o "$RUNNER_TEMP/mk06-go-fixture" .) MK06_GO_FIXTURE="$RUNNER_TEMP/mk06-go-fixture" python3 contracts/proto/tests/process_recovery.py 2>&1 | tee "$RUNNER_TEMP/events-process.log" - name: Native protobuf round trips and failure recovery - if: ${{ !cancelled() }} + if: ${{ !cancelled() && matrix.targets != 'integration' }} run: | # Absolute, symlink-free, and absent: the fixture creates a private empty 0700 root. evidence="$(realpath -m -- "$RUNNER_TEMP/core-rpc-docker-evidence")" @@ -281,7 +298,7 @@ jobs: fi python3 -B scripts/test-core-rpc-docker.py --output-root "$evidence" --build-timeout-seconds 2400 2>&1 | tee "$RUNNER_TEMP/core-rpc-docker.log" - name: Stage readable core RPC evidence - if: ${{ always() }} + if: ${{ always() && matrix.targets != 'integration' }} run: | # Secret files are chowned to container uid 65532 and mode 0400. # upload-artifact fails the whole zip if any selected file is unreadable. @@ -313,7 +330,7 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: - name: microkernel-checks-${{ github.sha }}-${{ github.run_id }} + name: microkernel-checks-${{ github.sha }}-${{ github.run_id }}${{ matrix.targets == 'integration' && '-integration' || '' }} path: | ${{ runner.temp }}/core-source-sha.txt ${{ runner.temp }}/core-format.log diff --git a/.github/workflows/linux-packages.yml b/.github/workflows/linux-packages.yml index 4c00cfbc3..98aa117a6 100644 --- a/.github/workflows/linux-packages.yml +++ b/.github/workflows/linux-packages.yml @@ -82,6 +82,7 @@ jobs: git rev-parse HEAD | tee out/evidence/revision.txt nfpm --version | tee out/evidence/nfpm-version.txt node --test scripts/workflow-topology.test.mjs + python3 -B packaging/linux/test_extore_receipts.py python3 -B packaging/linux/test_native.py -v 2>&1 | tee out/evidence/native-tests.log go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color .github/workflows/linux-packages.yml - name: Build the three product binaries for this architecture @@ -99,6 +100,7 @@ jobs: docker buildx build --platform "linux/$ARCH" -f deployment/docker/extensions.Dockerfile \ --target binaries-musl --output type=local,dest=out/extensions-musl . - name: Build verified source archives and native packages + id: packages run: | revision=$(git rev-parse HEAD) SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) @@ -109,6 +111,7 @@ jobs: done python3 scripts/build-distribution.py build --component extensions \ --version 0.1.0-preview --revision "$revision" --platform "linux-musl-$ARCH" --input out/extensions-musl + package_paths=() for component in core extensions cli; do package="lmm-$component" if [[ "$component" == cli ]]; then package=lmm; fi @@ -118,12 +121,19 @@ jobs: archive="out/distributions/${package}-0.1.0-preview-${platform}.tar.gz" digest=$(sha256sum "$archive" | cut -d ' ' -f 1) for release in 1 2; do - python3 packaging/linux/build.py --archive "$archive" --sha256 "$digest" \ - --revision "$revision" --component "$component" --format "$format" --release "$release" + built=$(python3 packaging/linux/build.py --archive "$archive" --sha256 "$digest" \ + --revision "$revision" --component "$component" --format "$format" --release "$release") + package_paths+=("$built" "$built.sha256" "$built.buildinfo.json") done done done (cd out/linux-packages && sha256sum --check ./*.sha256) + for path in "${package_paths[@]}"; do test -s "$path"; done + { + echo 'paths<> "$GITHUB_OUTPUT" - name: Install, upgrade, run and remove in disposable distribution containers run: | set -o pipefail @@ -159,23 +169,39 @@ jobs: -f packages/extore/tests/native_plugin_alpine.Dockerfile --target fixture \ --build-arg "EXTORE_RUST_TARGET=$RUST_TARGET" -t lmm-extore-alpine-fixture packages/extore docker image inspect lmm-extore-alpine-fixture --format '{{.Id}}' > out/evidence/extore-fixture-image.txt + umask 077 + staging=$(mktemp -d "$RUNNER_TEMP/extore-receipts.XXXXXXXX") + report=extore-native-alpine.json + touch "$staging/$report" "$staging/$report.package.json" timeout 300 docker run --rm --network none --add-host localhost.localdomain:127.0.0.1 \ --cap-add NET_ADMIN --cpus 1 --memory 768m --pids-limit 256 \ --security-opt no-new-privileges:true -e LMM_PACKAGING_ISOLATED=1 \ -v "$PWD/out/linux-packages:/packages:ro" -v "$PWD/out/native-probe:/probe:ro" \ - -v "$PWD/out/evidence:/evidence" \ + -v "$staging/$report:/receipts/$report" \ + -v "$staging/$report.package.json:/receipts/$report.package.json" \ -v "$PWD/packaging/linux/extore-plugin-smoke.py:/package-probe.py:ro" \ --entrypoint python3 lmm-extore-alpine-fixture /package-probe.py \ --arch "$ARCH" --revision "$(git rev-parse HEAD)" \ --parent-netns "$(readlink /proc/self/ns/net)" \ - --report /evidence/extore-native-alpine.json 2>&1 | tee out/evidence/extore-native-alpine.log + --report "/receipts/$report" > "$staging/fixture.log" 2>&1 + for receipt in "$staging/$report" "$staging/$report.package.json"; do + test -s "$receipt" + test -O "$receipt" + done + mv -- "$staging/$report" "$staging/$report.package.json" out/evidence/ - name: Preserve preview packages and scoped evidence, never publish if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with: name: native-linux-${{ matrix.arch }}-${{ github.sha }} path: | - out/linux-packages/ - out/evidence/ + ${{ steps.packages.outputs.paths }} + out/evidence/revision.txt + out/evidence/nfpm-version.txt + out/evidence/install-matrix.txt + out/evidence/image-digests.txt + out/evidence/extore-fixture-image.txt + out/evidence/extore-native-alpine.json + out/evidence/extore-native-alpine.json.package.json if-no-files-found: error retention-days: 7 diff --git a/.github/workflows/mk-01-identity.yml b/.github/workflows/mk-01-identity.yml index 7c9a53123..f33551f84 100644 --- a/.github/workflows/mk-01-identity.yml +++ b/.github/workflows/mk-01-identity.yml @@ -19,3 +19,5 @@ jobs: identity: # All merged modules use the same preserved executors and private fixtures. uses: ./.github/workflows/core-protocol.yml + with: + split_rust_targets: true diff --git a/apps/web/src/features/auth/components/oauth-providers-google.test.tsx b/apps/web/src/features/auth/components/oauth-providers-google.test.tsx index ffb410e8b..09962b507 100644 --- a/apps/web/src/features/auth/components/oauth-providers-google.test.tsx +++ b/apps/web/src/features/auth/components/oauth-providers-google.test.tsx @@ -32,6 +32,8 @@ for (const key of [ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true }) const clicks: string[] = [] const consent: boolean[] = [] +let oauthPending = false +let telegramPending = false mock.module('react-i18next', () => ({ useTranslation: () => ({ t: (key: string, options?: { name?: string }) => @@ -42,7 +44,7 @@ mock.module('../hooks/use-oauth-login', () => ({ useOAuthLogin: (_: unknown, __: unknown, acceptedLegal: boolean) => { consent.push(acceptedLegal) return { - isLoading: false, + isLoading: oauthPending, githubButtonText: '', githubButtonDisabled: false, handleGoogleLogin: () => clicks.push('builtin:google'), @@ -53,7 +55,7 @@ mock.module('../hooks/use-oauth-login', () => ({ handleLinuxDOLogin: () => {}, handleTelegramLogin: () => {}, isTelegramDialogOpen: false, - isTelegramPending: false, + isTelegramPending: telegramPending, handleTelegramAuthorization: () => {}, handleTelegramDialogChange: () => {}, } @@ -97,6 +99,7 @@ async function render( props: { registrationOnly?: boolean disabled?: boolean + isWeChatLoading?: boolean acceptedLegal?: boolean registrationCapabilitiesReady?: boolean } = {} @@ -134,10 +137,63 @@ afterEach(async () => { await unmount() document.body.replaceChildren() clicks.length = 0 + oauthPending = false + telegramPending = false consent.length = 0 }) after(() => dom.close()) +test('browser OAuth pending is announced and clears when the attempt settles', async () => { + oauthPending = true + const host = await render(supported, { acceptedLegal: true }) + const button = getButton(host) + assert.equal(button.disabled, true) + assert.equal(button.getAttribute('aria-busy'), 'true') + assert.equal( + host.querySelector('[role="status"]')?.textContent, + 'Signing in...' + ) + assert.equal( + host.querySelector('[role="status"]')?.getAttribute('aria-live'), + 'polite' + ) + await act(async () => button.click()) + assert.deepEqual(clicks, []) + oauthPending = false + await act(async () => + root?.render( + + ) + ) + assert.equal(getButton(host).disabled, false) + assert.equal(getButton(host).getAttribute('aria-busy'), 'false') + assert.equal(host.querySelector('[role="status"]'), null) + await act(async () => getButton(host).click()) + assert.deepEqual(clicks, ['builtin:google']) +}) + +for (const provider of ['Telegram', 'WeChat'] as const) { + test(`${provider} pending has visible accessible progress`, async () => { + telegramPending = provider === 'Telegram' + const host = await render(supported, { + isWeChatLoading: provider === 'WeChat', + }) + assert.equal( + host.querySelector('[role="status"]')?.textContent, + 'Signing in...' + ) + assert.equal( + host.querySelector('[role="status"]')?.getAttribute('aria-live'), + 'polite' + ) + }) +} + describe('Google provider buttons', () => { test('native supported browser Google wins, custom duplicate is not invoked', async () => { const host = await render(supported, { acceptedLegal: true }) diff --git a/apps/web/src/features/auth/components/oauth-providers.tsx b/apps/web/src/features/auth/components/oauth-providers.tsx index 9f1d9fef0..1392a7b69 100644 --- a/apps/web/src/features/auth/components/oauth-providers.tsx +++ b/apps/web/src/features/auth/components/oauth-providers.tsx @@ -209,6 +209,7 @@ export function OAuthProviders({ (provider) => !provider.featured ) const showProviderDivider = !featuredProvider || otherProviders.length > 0 + const pending = isLoading || isWeChatLoading || isTelegramPending const renderProviderButton = (provider: ProviderButton, compact: boolean) => ( - {passkeySupported && ( -

- {t( - 'Enter your username if your security key does not support account discovery.' - )} -

- )} - {!passkeySupported && ( -

- {t('Passkey is not supported on this device.')} -

- )} +

+ {passkeySupport === 'checking' + ? t('Checking Passkey availability...') + : passkeySupport === 'supported' + ? t( + 'Enter your username if your security key does not support account discovery.' + ) + : t('Passkey is not supported on this device.')} +

)} diff --git a/apps/web/src/features/channels/components/dialogs/native-balance-batch-dialog.tsx b/apps/web/src/features/channels/components/dialogs/native-balance-batch-dialog.tsx new file mode 100644 index 000000000..714f5b933 --- /dev/null +++ b/apps/web/src/features/channels/components/dialogs/native-balance-batch-dialog.tsx @@ -0,0 +1,161 @@ +/* Copyright (C) 2026 LIghtJUNction. SPDX-License-Identifier: AGPL-3.0-or-later */ +import { useEffect, useRef, useState } from 'react' +import { useTranslation } from 'react-i18next' + +import { Dialog } from '@/components/dialog' +import { Button } from '@/components/ui/button' +import { formatTimestampToDate } from '@/lib/format' + +import { formatObservedBalance } from '../../lib/channel-utils' +import { + nativeBalanceFailureKey, + refreshNativeChannelBalances, +} from '../../lib/native-balance' +import type { NativeRoutingScope } from '../../native-api' +import type { BalanceObservation } from '../../types' + +export function NativeBalanceBatchDialog({ + scope, + channels, + canProbe, + onClose, +}: { + scope: NativeRoutingScope + channels: Array<{ id: number; name: string }> + canProbe: boolean + onClose: () => void +}) { + const { t } = useTranslation() + const [busy, setBusy] = useState(false) + const [results, setResults] = useState< + Record + >({}) + const request = useRef(null) + const active = useRef(true) + useEffect(() => { + active.current = true + return () => { + active.current = false + request.current?.abort() + } + }, []) + useEffect(() => { + if (!canProbe) request.current?.abort() + }, [canProbe]) + + async function refresh() { + if (request.current || !canProbe) return + const controller = new AbortController() + request.current = controller + setBusy(true) + try { + await refreshNativeChannelBalances( + scope, + channels.map((channel) => channel.id), + controller.signal, + (result) => { + setResults((previous) => ({ + ...previous, + [result.channelId]: + result.status === 'ready' + ? { observation: result.observation } + : { + ...previous[result.channelId], + message: result.message, + }, + })) + } + ) + } catch (error: unknown) { + if (active.current && !controller.signal.aborted) { + setResults((previous) => ({ + ...previous, + ...Object.fromEntries( + channels.map(({ id }) => [ + id, + { + ...previous[id], + message: nativeBalanceFailureKey(error, true), + }, + ]) + ), + })) + } + } finally { + request.current = null + if (active.current) setBusy(false) + } + } + + return ( + { + if (!open) onClose() + }} + title={t('Refresh selected balances')} + description={t('{{count}} selected', { count: channels.length })} + contentHeight='auto' + footer={ + <> + + + + } + > +

+ {t('channelBalance.note')} +

+ {!canProbe && ( +

+ {t('Capability unavailable')} +

+ )} +
    + {channels.map(({ id, name }) => { + const result = results[id] + const observation = result?.observation + return ( +
  • +

    {name}

    + {observation && ( +
    +

    + {formatObservedBalance(observation)} +

    +

    + {t('Last updated:')}{' '} + {observation.balance_updated_time + ? formatTimestampToDate(observation.balance_updated_time) + : '-'} +

    +
    + )} + {result?.message ? ( +

    + {t(result.message)} +

    + ) : !observation ? ( +

    + {t('Not queried')} +

    + ) : null} +
  • + ) + })} +
+
+ ) +} diff --git a/apps/web/src/features/channels/components/dialogs/native-balance-dialog.tsx b/apps/web/src/features/channels/components/dialogs/native-balance-dialog.tsx index 4031b5b46..7b26f0f43 100644 --- a/apps/web/src/features/channels/components/dialogs/native-balance-dialog.tsx +++ b/apps/web/src/features/channels/components/dialogs/native-balance-dialog.tsx @@ -1,5 +1,4 @@ /* Copyright (C) 2026 LIghtJUNction. SPDX-License-Identifier: AGPL-3.0-or-later */ -import { isAxiosError } from 'axios' import { useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' @@ -10,6 +9,7 @@ import { Button } from '@/components/ui/button' import { formatTimestampToDate } from '@/lib/format' import { formatObservedBalance } from '../../lib/channel-utils' +import { nativeBalanceFailureKey } from '../../lib/native-balance' import { getNativeChannelBalance, getNativeChannelCounters, @@ -21,16 +21,6 @@ type BalanceState = | { status: 'loading' } | { status: 'ready'; observation: BalanceObservation } | { status: 'error'; message: string } -function failureMessage(error: unknown, probe = false) { - const status = isAxiosError(error) ? error.response?.status : undefined - return status === 501 && probe - ? 'channelBalance.disabled' - : status === 403 - ? 'channelBalance.denied' - : status === 409 - ? 'channelUsage.identity' - : 'channelBalance.error' -} export function NativeBalanceDialog({ scope, channelId, @@ -67,7 +57,7 @@ export function NativeBalanceDialog({ }, (error: unknown) => { if (!controller.signal.aborted) { - setState({ status: 'error', message: failureMessage(error) }) + setState({ status: 'error', message: nativeBalanceFailureKey(error) }) } } ) @@ -99,7 +89,7 @@ export function NativeBalanceDialog({ if (!controller.signal.aborted) setState({ status: 'ready', observation }) } catch (error: unknown) { if (controller.signal.aborted) return - const message = failureMessage(error, true) + const message = nativeBalanceFailureKey(error, true) if (message === 'channelBalance.disabled') setDisabled(true) if (state.status === 'ready') setNotice(message) else setState({ status: 'error', message }) diff --git a/apps/web/src/features/channels/components/dialogs/native-channel-usage-dialog.tsx b/apps/web/src/features/channels/components/dialogs/native-channel-usage-dialog.tsx index 79ae17c48..14043877d 100644 --- a/apps/web/src/features/channels/components/dialogs/native-channel-usage-dialog.tsx +++ b/apps/web/src/features/channels/components/dialogs/native-channel-usage-dialog.tsx @@ -333,6 +333,7 @@ const legacyProviders = [ [25, 'Moonshot'], [40, 'SiliconFlow'], [43, 'DeepSeek'], + [59, 'Sub2API'], ] as const export function NativeLegacyBalanceSettings({ @@ -429,7 +430,8 @@ export function NativeLegacyBalanceSettings({ } } const unit = - ['1', '8', '20', '43'].includes(kind) || (kind === '25' && rate !== '') + ['1', '8', '20', '43', '59'].includes(kind) || + (kind === '25' && rate !== '') ? 'USD' : kind === '25' ? 'CNY' @@ -465,6 +467,13 @@ export function NativeLegacyBalanceSettings({ {t('Automatic')}

)} + {kind === '59' && ( +

+ {t( + 'Reads Sub2API wallet or key quota in USD. Unlimited or unrecognized balances remain unknown.' + )} +

+ )}