Commit graph

5425 commits

Author SHA1 Message Date
Tom Foster
b481ff31c0 ci: Consolidate workflows and optimise build pipeline performance
Merge rust-checks.yml and release-image.yml into unified ci-build.yml
workflow that runs faster and more efficiently. The previous setup ran
4+ parallel jobs immediately (format, clippy, test, builds), causing
resource contention. The new pipeline runs max 2 jobs in parallel at
each stage, catching lint/format issues quickly before attempting
expensive compilation.

Extract all Rust setup logic from both workflows into reusable
rust-with-cache composite action. This replaces 6 separate actions
(rust-toolchain, sccache, timelord, plus inline APT/cache steps) with
a single action that handles:
- Rust toolchain installation with component selection
- Cross-compilation configuration (previously scattered across
  release-image.yml)
- System dependency installation with proper error handling
- Comprehensive caching (sccache, cargo registry, cargo target, uv
  tools)
- Timeline tracking and performance monitoring

The previous release-image.yml had cross-compilation support but it
was implemented inline with complex environment variables. The new
rust-with-cache action centralises this with proper parameters for
pkg-config paths, foreign architecture setup, and toolchain selection.

Performance improvements make the pipeline fast enough to consolidate:
- Warmed sccache cache shared between check and build stages
- Optimised cargo target cache to exclude incremental/ and binaries
  (was caching entire target/ directory via buildkit-cache-dance)
- Add restore-keys fallback for better cache hit rates
- Parallel background tasks for Rust setup while APT runs
- Fail-fast on format/lint errors before expensive compilation
- Enable Haswell CPU optimisations for x86_64 builds (AVX2, FMA, etc.)
- Add cross-language LTO (Link-Time Optimisation) for better performance

Fix ARM64 cross-compilation reliability issues:
- Move APT installations from background to foreground (background
  processes would hang during package downloads despite
  DEBIAN_FRONTEND=noninteractive)
- Set proper pkg-config environment for cross-compilation
- Configure APT sources to ports.ubuntu.com for foreign architectures
- Replace hardened_malloc with jemalloc (ARM64 unsupported)

Modernisation from previous commit (b0ebdb59):
- prefligit renamed to prek (avoid typosquatting)
- Direct uvx rustup replacing custom rust-toolchain action
- Workflow renames: deploy-element, deploy-docs, docker-mirror
- Renovate configuration for .forgejo/ workflows
- fix-byte-order-marker replacing check-byte-order-marker

Docker improvements:
- Remove buildkit-cache-dance injection (now handled natively)
- Align tag naming between arch-specific and multi-platform builds
- Add branch- prefix for non-default branches
- Reserve latest-{arch} tags for version releases only
- Remove dynamic library extraction logic (ldd doesn't work for
  cross-compiled binaries; Rust --release produces mostly-static binaries)

Additional improvements based on maintainer feedback:
- Generate SBOM (Software Bill of Materials) for security compliance
- Include SBOM in uploaded build artefacts alongside binary

The consolidated pipeline completes in ~10 minutes with better
resource utilisation and clearer failure diagnostics. Both x86_64 and
ARM64 builds now work reliably with the centralised cross-compilation
configuration.
2025-08-15 22:50:41 +01:00
Tom Foster
583cb924f1 refactor: address code review feedback for auth and pagination improvements
- Extract duplicated thread/message pagination functions to shared utils module
- Refactor pagination token parsing to use Option combinators instead of defaults
- Split access token generation from assignment for clearer error handling
- Add appservice token collision detection at startup and registration
- Allow appservice re-registration with same token (for config updates)
- Simplify thread relation chunk building using iterator chaining
- Fix saturating_inc edge case in relation queries with explicit filtering
- Add concise comments explaining non-obvious behaviour choices
2025-08-12 05:29:41 +01:00
Tom Foster
9286838d23 fix(relations): improve thread pagination and include root event
Replace unreliable PduCount pagination tokens with ShortEventId throughout
the relations and messages endpoints. ShortEventId provides stable, unique
identifiers that persist across server restarts and database operations.

Key improvements:
- Add token parsing helpers that try ShortEventId first, fall back to
  PduCount for backwards compatibility
- Include thread root event when paginating backwards to thread start
- Fix off-by-one error in get_relations that was returning the starting
  event in results
- Only return next_batch/prev_batch tokens when more events are available,
  preventing clients from making unnecessary requests at thread boundaries
- Ensure consistent token format between /relations, /messages, and /sync
  endpoints for interoperability

This fixes duplicate events when scrolling at thread boundaries and ensures
the thread root message is visible when viewing a thread, matching expected
client behaviour.
2025-08-10 19:12:56 +01:00
Tom Foster
d1ebcfaf0b fix(auth): prevent token collisions and optimise lookups
Ensures access tokens are unique across both user and appservice tables to
prevent authentication ambiguity and potential security issues.

Changes:
- On startup, automatically logout any user devices using tokens that
  conflict with appservice tokens (resolves in favour of appservices)
  and log a warning with affected user/device details
- When creating new user tokens, check for conflicts with appservice tokens
  and generate a new token if a collision would occur
- When registering new appservices, reject registration if the token is
  already in use by a user device
- Use futures::select_ok to race token lookups concurrently for better
  performance (adapted from tuwunel commit 066097a8)

This fix-forward approach resolves existing token collisions on startup
whilst preventing new ones from being created, without breaking existing
valid authentications.

The find_token optimisation is adapted from tuwunel (matrix-construct/tuwunel)
commit 066097a8: "Optimize user and appservice token queries" by Jason Volk.
2025-08-10 17:10:06 +01:00
Tom Foster
e820551f62 fix(appservice): create sender_localpart user during appservice startup
Fixes #813: Application services were unable to work because their sender_localpart
user was never created in the database, preventing authentication.

This fix ensures the appservice user account is created when:
- The server starts up and loads existing appservices from the database
- A new appservice is registered via the admin command

Additionally, if an appservice user has been accidentally deactivated, it will be
automatically reactivated when the appservice starts.

The solution centralises all appservice startup logic into a single `start_appservice`
helper method, eliminating code duplication between the registration and startup paths.
2025-08-10 17:10:06 +01:00
Yonatan Sidler
bd3db65cb2
fix(arch): fix config.toml not being loaded from LoadCredentials directory 2025-08-06 20:01:36 +03:00
nexy7574
e4a43b1a5b
fix(policy-server): Call the PS later in the PDU creation process
This avoids accidentally sending partially built PDUs to the policy server,
which may cause issues with some implementations
2025-08-02 00:19:33 +01:00
Jade Ellis
5775e0ad9d
docs: Make traefik router names consistent 2025-07-30 19:55:48 +01:00
Jade Ellis
238cc627e3
docs: Set traefik labels 2025-07-30 19:33:53 +01:00
Jade Ellis
b1516209c4
chore: Update funding file 2025-07-30 19:23:38 +01:00
Jade Ellis
0589884109
docs: Fix documentation link in README
Closes https://forgejo.ellis.link/continuwuation/continuwuity/issues/913
2025-07-28 19:28:34 +01:00
Jade Ellis
4a83df5b57
chore: Fix link 2025-07-25 17:35:18 +01:00
Jade Ellis
aa08edc55f
chore: Release announcement 2025-07-25 17:30:31 +01:00
Jade Ellis
00c7e220bb
chore: Release
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 1s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 1s
Checks / Rust / Clippy (push) Failing after 3s
Checks / Rust / Cargo Test (push) Failing after 3s
2025-07-25 14:10:06 +01:00
Jade Ellis
87be4d1a52
feat: Almost-functional musl builds on Alpine
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 1s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 1s
Checks / Rust / Clippy (push) Failing after 4s
Checks / Rust / Cargo Test (push) Failing after 4s
Lots of fiddling, still can't get stuff to work

Next step is a debian builder copying the static libs from alpine
2025-07-24 23:22:27 +01:00
Jade Ellis
205506f206
chore: Update deps 2025-07-24 22:18:10 +01:00
Jade Ellis
66181c61af
chore: Update rocksdb, feature flag changes
Some checks failed
Checks / Prefligit / prefligit (push) Failing after 5s
Release Docker Image / define-variables (push) Failing after 4s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 5s
Checks / Rust / Clippy (push) Failing after 12s
Checks / Rust / Cargo Test (push) Failing after 10s
Most of the way to static musl builds, just zlib I think
2025-07-24 21:51:52 +01:00
Jade Ellis
b7a0442298
feat: Musl images in docker
Not working at the moment, need to upgrade the rust-rocksdb and possibly
zstd to stop them force-enabling dynamic libclang
2025-07-24 19:00:41 +01:00
Jade Ellis
1bc663e1c8
docs: Fix spacing at the top
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 1s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 1s
Checks / Rust / Clippy (push) Failing after 4s
Checks / Rust / Cargo Test (push) Failing after 4s
2025-07-24 13:37:52 +01:00
Jade Ellis
68b0140c42
docs: Add vias to matrix.to links 2025-07-24 13:31:58 +01:00
nexy7574
f32f60d056
fix(policy-server): Return the correct result when an event is marked as spam
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 1s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 3s
Checks / Rust / Clippy (push) Failing after 28s
Checks / Rust / Cargo Test (push) Failing after 27s
2025-07-23 18:01:46 +01:00
nexy7574
fe06d78c8e
fix(policy-server): Update ask_policy_server docstring 2025-07-23 17:58:33 +01:00
nexy7574
99ebe022ed
fix(policy-server): Correctly default to 10 second timeout 2025-07-23 17:56:45 +01:00
nexy7574
f335f45017
feat(policy-server): Add configurable timeout 2025-07-23 17:49:08 +01:00
nexy7574
1726633c0f
fix(policy-server): Fixup refactor 2025-07-23 17:49:08 +01:00
nexy7574
dfda27fadc
feat(policy-server): Don't fail-closed & refactor references 2025-07-23 17:49:08 +01:00
Jade Ellis
9465c5df1f
style: Improve logging and comments 2025-07-23 17:49:07 +01:00
nexy7574
2d475b1220
style(policy-server): Run clippy 2025-07-23 17:49:07 +01:00
nexy7574
d7fa624fd2
feat(policy-server): Optimise policy server lookups 2025-07-23 17:49:07 +01:00
nexy7574
cc9202b0c4
feat(policy-server): Limit policy server request timeout to 10 seconds 2025-07-23 17:49:07 +01:00
nexy7574
a3d62ed0d9
feat(policy-server): Prevent local events that fail the policy check 2025-07-23 17:49:07 +01:00
nexy7574
78b7175677
feat(policy-server): Soft-fail redactions for failed events 2025-07-23 17:49:07 +01:00
nexy7574
74d60f256b
style(policy-server): Restructure logging 2025-07-23 17:49:07 +01:00
nexy7574
732c69f5ca
fix(policy-server): Avoid unnecessary database lookup 2025-07-23 17:49:07 +01:00
nexy7574
8e7801f323
chore: Update ruwuma & fix lints 2025-07-23 17:49:06 +01:00
nexy7574
9017efe45b
feat(policy-server): Policy server following 2025-07-23 17:49:06 +01:00
Jade Ellis
7e2f04a78a
chore: Check all features in CI and docs
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 6s
Release Docker Image / define-variables (push) Failing after 5s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 3s
Checks / Rust / Clippy (push) Failing after 26s
Checks / Rust / Cargo Test (push) Failing after 25s
2025-07-20 21:25:27 +01:00
Jade Ellis
d74514f305
ci: Fix inverted latest tag
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 2s
Release Docker Image / define-variables (push) Failing after 5s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 4s
Checks / Rust / Clippy (push) Failing after 23s
Checks / Rust / Cargo Test (push) Failing after 20s
2025-07-20 20:59:29 +01:00
Jade Ellis
95610499c7
chore: Disable direnv's nix flake interfering with cargo cache
Some checks failed
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 5s
Release Docker Image / define-variables (push) Failing after 3s
Checks / Rust / Format (push) Failing after 5s
Checks / Rust / Clippy (push) Failing after 30s
Checks / Rust / Cargo Test (push) Failing after 28s
2025-07-20 16:36:01 +01:00
Jade Ellis
f593cac58a
feat: Enable hardware-lock-elision and deadlock_detection 2025-07-20 16:35:59 +01:00
Jade Ellis
1c985c59f5
refactor: Allow with_lock to return data and take an async closure 2025-07-20 16:34:48 +01:00
Jade Ellis
b635e825d2
refactor: Implement with_lock for lock_api 2025-07-20 16:34:36 +01:00
Jade Ellis
6d29098d1a
refactor: Replace remaining std RwLocks 2025-07-20 16:33:36 +01:00
Jade Ellis
374fb2745c
refactor: Replace remaining std Mutexes 2025-07-20 16:32:48 +01:00
Jade Ellis
a1d616e3e3
refactor: Replace std RwLock with parking_lot 2025-07-20 16:31:55 +01:00
Jade Ellis
30a8c06fd9
refactor: Replace std Mutex with parking_lot 2025-07-20 16:31:02 +01:00
rooot
0631094350
docs(config): warn about federation key query timeout caveat
Signed-off-by: rooot <hey@rooot.gay>
2025-07-20 16:24:56 +01:00
rooot
9051ce63f7
feat(config): introduce federation connection timeout setting
fixes #906

Signed-off-by: rooot <hey@rooot.gay>
2025-07-20 16:24:26 +01:00
Jade Ellis
f513cb7598
chore: Remove false positives in typo checks
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 4s
Release Docker Image / define-variables (push) Failing after 2s
Checks / Rust / Format (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Clippy (push) Failing after 28s
Checks / Rust / Cargo Test (push) Failing after 28s
2025-07-19 20:31:54 +01:00
nexy7574
c639228f4d
style(space-upgrades): Remove unused import left over from 6691b7672b
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 4s
Release Docker Image / define-variables (push) Failing after 2s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 1s
Checks / Rust / Clippy (push) Failing after 22s
Checks / Rust / Cargo Test (push) Failing after 21s
2025-07-19 18:37:45 +01:00