⚠️ This is a diagnostic guess, not a confirmed root cause. Posting it because I think the symptoms point somewhere useful, but I haven't proven the MAS-side claim and would value a sanity check from someone who knows postmoogle's internals better.
Symptom
Running postmoogle against a homeserver fronted by Matrix Authentication Service (MAS), the bridge eventually enters a crash loop:
FTL cannot initialize matrix bot
error="olm account is marked as shared, keys seem to have disappeared from the server"
It's recurred at least twice on my server. Manual workaround that revives it: stop the service, UPDATE crypto_account SET shared = false, start it again. This works for hours/days, then breaks again.
What I observed (facts)
- Postmoogle is configured with
POSTMOOGLE_LOGIN + POSTMOOGLE_PASSWORD.
- In MAS's
compat_sessions table, every postmoogle startup creates a new row for the same device_id, and the previous row gets finished_at set. During the crash loop this happens dozens of times per minute.
- Source-reading in
cmd/postmoogle/main.go shows linkpearl.New() is called with Login+Password only.
go-linkpearl's resolveCredentials() already supports a Token field — when set, it skips /login and just calls /account/whoami.
What I'm guessing (unverified)
- That MAS purges the device's server-side e2e keys when it finishes a compat session, and that this is why postmoogle's locally-stored `shared=true` becomes a lie. I have not confirmed this in MAS source or by inspecting Synapse's device-key tables before/after a session finish. It could just as easily be something else entirely (some other component clearing keys, a postmoogle data-volume issue I haven't spotted, a Synapse cleanup job, etc.).
- That switching postmoogle to token auth would fix it. Plausible because token auth in linkpearl avoids opening a new compat session, if my MAS theory is right. If it's wrong, this change won't help.
Proposed change (if the theory holds)
Plumb a `Token` field through postmoogle's config so it can use linkpearl's existing token path:
- Add `Token string` to `internal/config/types.go` `Config{}`.
- Read `env.String("token", defaultConfig.Token)` in `internal/config/config.go`.
- Pass `Token: cfg.Token` to `linkpearl.New(&linkpearl.Config{...})` in `cmd/postmoogle/main.go` (~L105).
Operators on MAS could then issue a long-lived compat token (`mas-cli manage issue-compatibility-token`) and drop `POSTMOOGLE_PASSWORD`.
Questions
- Has anyone else seen this with MAS?
- Does the `crypto_account.shared` flow assume the device's keys are durable on the server side once published? (If so, that assumption breaks under MAS as I've described it — but again, if my theory is right.)
- Would you accept a PR adding `POSTMOOGLE_TOKEN` even if it turns out not to fix this specific issue, or would you prefer the underlying cause be confirmed first?
Happy to dig deeper (e.g. tail Synapse + MAS logs around a failure) if it'd help.
Symptom
Running postmoogle against a homeserver fronted by Matrix Authentication Service (MAS), the bridge eventually enters a crash loop:
It's recurred at least twice on my server. Manual workaround that revives it: stop the service,
UPDATE crypto_account SET shared = false, start it again. This works for hours/days, then breaks again.What I observed (facts)
POSTMOOGLE_LOGIN+POSTMOOGLE_PASSWORD.compat_sessionstable, every postmoogle startup creates a new row for the samedevice_id, and the previous row getsfinished_atset. During the crash loop this happens dozens of times per minute.cmd/postmoogle/main.goshowslinkpearl.New()is called withLogin+Passwordonly.go-linkpearl'sresolveCredentials()already supports aTokenfield — when set, it skips/loginand just calls/account/whoami.What I'm guessing (unverified)
Proposed change (if the theory holds)
Plumb a `Token` field through postmoogle's config so it can use linkpearl's existing token path:
Operators on MAS could then issue a long-lived compat token (`mas-cli manage issue-compatibility-token`) and drop `POSTMOOGLE_PASSWORD`.
Questions
Happy to dig deeper (e.g. tail Synapse + MAS logs around a failure) if it'd help.