Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: stop nagging about a fork PortOS is not allowed to update

Adam Eivyb63e0f268cde
diff --git a/client/src/components/apps/tabs/RepositorySourcePanel.jsx b/client/src/components/apps/tabs/RepositorySourcePanel.jsx
index 598bffb6f3..4060cdac20 100644
--- a/client/src/components/apps/tabs/RepositorySourcePanel.jsx
+++ b/client/src/components/apps/tabs/RepositorySourcePanel.jsx
@@ -11,9 +11,11 @@ import {
import * as api from '../../../services/api';
import {
countText,
+ describeForkUnsyncable,
primaryRepositorySource,
repositoryForkDiverged,
repositoryForkNeedsSync,
+ repositoryForkPushable,
} from '../../../lib/managedAppSources';
import BrailleSpinner from '../../BrailleSpinner';
import Modal from '../../ui/Modal';
@@ -40,7 +42,10 @@ function sourceStatus(source) {
if (source.forkVsUpstream?.state === 'diverged') {
return { tone: 'error', label: 'Fork diverged' };
}
- const forkBehind = source.forkVsUpstream?.behind || 0;
+ // A fork PortOS may fast-forward is actionable drift; one it can only read is
+ // context, not a call to action, so it must not colour the badge as if a
+ // button here would clear it.
+ const forkBehind = repositoryForkNeedsSync(source) ? source.forkVsUpstream.behind : 0;
const localBehind = source.localVsOrigin?.behind || 0;
if (forkBehind > 0 && localBehind > 0) {
return { tone: 'attention', label: 'Fork and checkout behind' };
@@ -70,6 +75,7 @@ function RepositoryCard({ source }) {
const upstreamName = source.upstream?.fullName || 'canonical upstream';
const local = source.localVsOrigin;
const fork = source.forkVsUpstream;
+ const unsyncable = describeForkUnsyncable(source);
return (
<section className="rounded-xl border border-port-border bg-port-bg/50 p-4" data-testid={`repository-source-${source.id}`}>
@@ -123,6 +129,7 @@ function RepositoryCard({ source }) {
Fork is {countText(fork.behind, 'commit')} behind and {countText(fork.ahead, 'commit')} ahead of {upstreamName}.
</p>
)}
+ {unsyncable && <p className="text-xs text-gray-500">{unsyncable}</p>}
{source.remoteError && (
<p className="flex items-start gap-1.5 text-xs text-port-warning">
<AlertTriangle size={13} className="mt-0.5 shrink-0" />
@@ -336,7 +343,7 @@ export default function RepositorySourcePanel({ appId, appName, onUpdated, refre
{updateSummary}
</div>
<div className="flex flex-wrap items-center gap-2">
- {primary?.origin?.isFork && (
+ {repositoryForkPushable(primary) && (
<button
onClick={handleSyncOnly}
disabled={syncingFork || operationBusy || updateRequested || forkDiverged}
diff --git a/client/src/components/apps/tabs/RepositorySourcePanel.test.jsx b/client/src/components/apps/tabs/RepositorySourcePanel.test.jsx
index 085f382e9c..30b4082f6f 100644
--- a/client/src/components/apps/tabs/RepositorySourcePanel.test.jsx
+++ b/client/src/components/apps/tabs/RepositorySourcePanel.test.jsx
@@ -23,6 +23,7 @@ const source = ({
origin,
localVsOrigin = { ahead: 0, behind: 0, state: 'current' },
forkVsUpstream = null,
+ forkSyncable,
}) => ({
id,
label,
@@ -44,6 +45,12 @@ const source = ({
},
localVsOrigin,
forkVsUpstream,
+ // Mirrors the server's `isForkSyncable` so fixtures carry the payload the
+ // client actually reads (server/services/managedAppRepositories.js).
+ forkSyncable: forkSyncable ?? (id === 'primary'
+ && Boolean(origin?.isFork)
+ && origin?.canPush !== false
+ && forkVsUpstream?.state !== 'diverged'),
remoteFresh: true,
remoteError: null,
});
@@ -147,6 +154,45 @@ describe('managed app repository sources', () => {
expect(useAppOperation.mock.results[0].value.startUpdate).not.toHaveBeenCalled();
});
+ // Eidoverse's video checkout is cloned from `anima-research`'s fork of a third
+ // project. The drift from upstream is real and worth reporting, but PortOS can
+ // only read that fork — so the panel must say so instead of offering a sync
+ // that would 403 and a badge that reads like a pending chore (#6321).
+ it('reports a read-only fork\'s drift without offering a sync it cannot perform', async () => {
+ const status = canonicalStatus();
+ status.updateAvailable = false;
+ status.sources[0] = source({
+ id: 'primary',
+ label: 'Example App',
+ branch: 'main',
+ head: '1'.repeat(40),
+ origin: { fullName: 'anima-research/example-app', isUpstream: true, isFork: false },
+ });
+ status.sources[1] = source({
+ id: 'companion-1',
+ label: 'example-runtime',
+ branch: 'prod-serving',
+ head: '2'.repeat(40),
+ origin: {
+ fullName: 'other-owner/example-runtime',
+ isUpstream: false,
+ isFork: true,
+ canPush: false,
+ },
+ forkVsUpstream: { available: true, ahead: 0, behind: 12, state: 'behind', error: null },
+ });
+ api.getAppRepositorySources.mockResolvedValue(status);
+ render(<RepositorySourcePanel appId="app-example" appName="Example App" />);
+
+ const companion = await screen.findByTestId('repository-source-companion-1');
+ expect(companion).toHaveTextContent('Fork is 12 commits behind');
+ expect(companion).toHaveTextContent('cannot push to it');
+ // Not "Fork 12 behind": that badge is a call to action, and there is none.
+ expect(within(companion).getByText('Custom origin')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Sync fork' })).toBeNull();
+ expect(screen.getByText('All checkouts are current.')).toBeInTheDocument();
+ });
+
it('confirms that one managed update syncs the fork and updates every checkout', async () => {
const status = canonicalStatus();
status.sources[0] = source({
diff --git a/client/src/components/eidoverse/EidoverseUpdateBanner.test.jsx b/client/src/components/eidoverse/EidoverseUpdateBanner.test.jsx
index 9d490136a2..bcca9a37fe 100644
--- a/client/src/components/eidoverse/EidoverseUpdateBanner.test.jsx
+++ b/client/src/components/eidoverse/EidoverseUpdateBanner.test.jsx
@@ -13,7 +13,10 @@ import * as api from '../../services/api';
import { useAppOperation } from '../../hooks/useAppOperation';
import EidoverseUpdateBanner from './EidoverseUpdateBanner';
-const source = ({ id, label, origin = {}, localVsOrigin = { ahead: 0, behind: 0, state: 'current' }, forkVsUpstream = null }) => ({
+const source = ({
+ id, label, origin = {}, localVsOrigin = { ahead: 0, behind: 0, state: 'current' },
+ forkVsUpstream = null, forkSyncable,
+}) => ({
id,
label,
present: true,
@@ -24,6 +27,12 @@ const source = ({ id, label, origin = {}, localVsOrigin = { ahead: 0, behind: 0,
upstream: { fullName: 'anima-research/eidoverse-worlds', branch: 'main' },
localVsOrigin,
forkVsUpstream,
+ // Mirrors the server's `isForkSyncable` so fixtures carry the payload the
+ // client actually reads (server/services/managedAppRepositories.js).
+ forkSyncable: forkSyncable ?? (id === 'primary'
+ && Boolean(origin.isFork)
+ && origin.canPush !== false
+ && forkVsUpstream?.state !== 'diverged'),
remoteFresh: true,
remoteError: null,
});
@@ -99,7 +108,13 @@ describe('Eidoverse out-of-date advisory', () => {
cleanup();
startUpdate.mockClear();
localStorage.clear();
- status.sources[0].forkVsUpstream = { available: true, ahead: 1, behind: 2, state: 'diverged', error: null };
+ status.sources[0] = source({
+ id: 'primary',
+ label: 'Eidoverse Worlds',
+ origin: { fullName: 'example-owner/eidoverse-worlds', isUpstream: false, isFork: true },
+ forkVsUpstream: { available: true, ahead: 1, behind: 2, state: 'diverged', error: null },
+ });
+ api.getAppRepositorySources.mockResolvedValue(status);
renderBanner();
await screen.findByRole('status');
@@ -107,6 +122,58 @@ describe('Eidoverse out-of-date advisory', () => {
expect(startUpdate).toHaveBeenCalledWith('app-eidoverse', 'Eidoverse Worlds', { syncFork: false });
});
+ // The real Eidoverse shape: the video checkout is cloned from a third party's
+ // fork of the canonical project. `gh repo sync` would 403 on it and pulling it
+ // from its own origin brings nothing new, so an advisory raised for that drift
+ // could never be cleared by any button PortOS offers (#6321).
+ it('says nothing about a fork PortOS has no push access to', async () => {
+ api.getAppRepositorySources.mockResolvedValue({
+ kind: 'managed-app',
+ // The server computes this from the same rule; a fork PortOS may only
+ // read is not an available update.
+ updateAvailable: false,
+ updatePullsAll: true,
+ updateRestartsApp: true,
+ sources: [
+ source({ id: 'primary', label: 'Eidoverse Worlds' }),
+ source({
+ id: 'companion-1',
+ label: 'eidoverse-video',
+ origin: {
+ fullName: 'anima-research/eidoverse-video',
+ isUpstream: false,
+ isFork: true,
+ canPush: false,
+ },
+ forkVsUpstream: { available: true, ahead: 0, behind: 12, state: 'behind', error: null },
+ }),
+ ],
+ });
+ renderBanner();
+
+ await waitFor(() => expect(api.getAppRepositorySources).toHaveBeenCalled());
+ expect(screen.queryByRole('status')).toBeNull();
+ });
+
+ // A checkout behind its OWN origin is still actionable even when the same
+ // stack carries an unsyncable fork — the advisory must name only the part an
+ // update moves, not the part it cannot.
+ it('names only the drift an update can pull forward', async () => {
+ const status = behindStatus();
+ status.sources[1] = source({
+ id: 'companion-1',
+ label: 'eidoverse-video',
+ origin: { fullName: 'anima-research/eidoverse-video', isUpstream: false, isFork: true, canPush: false },
+ forkVsUpstream: { available: true, ahead: 0, behind: 12, state: 'behind', error: null },
+ });
+ api.getAppRepositorySources.mockResolvedValue(status);
+ renderBanner();
+
+ const banner = await screen.findByRole('status');
+ expect(banner).toHaveTextContent('Eidoverse Worlds is 3 commits behind its origin');
+ expect(banner).not.toHaveTextContent('eidoverse-video');
+ });
+
it('keeps a dismissal until the upstream revision changes', async () => {
renderBanner();
fireEvent.click(await screen.findByRole('button', { name: 'Dismiss' }));
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index bd0af0843f..389b6c10b1 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -179,7 +179,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `drumPlayback.js` | Synthesized drum-kit play-along for the SongBook `drum` format (#3115) — the third consumer of `lookaheadTransport.js` alongside `scorePlayback`/`midiPlayback`. `buildDrumSchedule(chart, { bpm, loop, countInBars })` is the PURE chart→`[{ bar, step, piece, sound, velocity, startSec, durSec, countIn }]` mapping (one notated beat = `60/bpm`, one grid step = beat/`subdivision`; per-glyph velocity; a looped bar range is sliced and rebased while keeping the CHART's bar numbers for the playhead) — unit-tested with no Web Audio; `resolveLoopRange(barCount, loop)` clamps/normalizes a 1-based inclusive bar range; the count-in is scheduled as real `countIn: true` events on the same clock so there is no second timer. `createDrumPlayer(chart, { bpm, countInBars, loopBars, clickEnabled, clickVolume, kit, onStep, onEnded })` sounds it on the shared `AudioContext` from a SYNTHESIZED kit (no shipped samples — recipes in `drumKits.js`, realized here as per-layer oscillator/noise + optional tanh drive + optional filter into a soft-clipped master bus; open-hat tail, flam grace note) with an optional layered metronome click, loops the range scheduler-exactly (count-in only on the first pass), and reports `onStep({ bar, step, countIn })` for the `<DrumSheetView>` playhead. The metronome — the through-music click AND the count-in, which both sound `CLICK_VOICE`, never a kit piece — rides its OWN gain bus into the master, so `setClickVolume(0–1)` moves clicks already queued in the lookahead window instead of only the next ones (a level of 0 additionally schedules no click voice at all — the level persists, so a silenced click must not keep building a voice per beat forever) (`clampClickVolume` returns null for an unset/garbled level so a caller can tell "never chosen" from a stored `DEFAULT_CLICK_VOLUME`-vs-silence). `setKit(id)`, `setClick(enabled)` and `setClickVolume(level)` apply LIVE (they touch no timing, unlike `setBpm`/`setLoop`/`setCountIn`, which only rebuild while idle). Pure (no React) — `SongBookViewer` owns the transport UI. |
| `lookaheadTransport.js` | Shared lookahead-transport state machine for the synth players (#2493) — `createLookaheadTransport({ getTotalSec, scheduleWindow, prepare?, seekCursors?, onStop?, onEnded?, onTeardown? })` owns the Web Audio clock + live-node lifecycle (playing / interval / startTime / offsetSec / nodes / playToken, the `resumeAudioContext()` call with the teardown-race guard, the optional `audioSession` claim held for exactly as long as the transport sounds, `track()` node pruning, and the play / pause / stop / seek / position transitions); each player supplies only the scheduling + notify callbacks and stays a thin scheduler over it, so a fix to the token-guard race or teardown lands in one place. Also the single source of the `SYNTH_TIMING` lookahead constants (`LEAD`/`LOOKAHEAD_MS`/`SCHEDULE_AHEAD`) `scorePlayback`/`midiPlayback` share. No React, no score/MIDI concepts — imports only the shared `AudioContext`. |
| `lossSparkline.js` | `lossSparklineGeometry(series, box)` — projects an unbounded training-loss series (`{step,loss}[]`) into SVG polyline coords, normalized to its own min/max (unlike `editorialHealth.sparklineGeometry`'s fixed 0–100 axis). Returns `{ points, coords, last, min, max }`. Drives the Render Queue's training-row loss curve (#1408). No React. |
-| `managedAppSources.js` | Readers for the managed-app repository-source payload (`GET /api/apps/:id/repository-sources`). `primaryRepositorySource` picks the application checkout out of the source list; `repositoryForkDiverged` / `repositoryForkNeedsSync` answer whether a managed update may ask the server to fast-forward the origin fork (a DIVERGED fork never can, so this is a correctness rule, not a label); `describeRepositorySourcesBehind` renders one clause per checkout that is behind, over the shared `countText` pluralizer both surfaces phrase counts with. Shared by the app Git tab's Repository sources panel and the Eidoverse page's out-of-date advisory. |
+| `managedAppSources.js` | Readers for the managed-app repository-source payload (`GET /api/apps/:id/repository-sources`). `primaryRepositorySource` picks the application checkout out of the source list; `repositoryForkDiverged` / `repositoryForkPushable` / `repositoryForkNeedsSync` answer whether a managed update may ask the server to fast-forward the origin fork (a diverged fork never can, nor can a fork PortOS lacks push access to — a correctness rule, not a label), with `describeForkUnsyncable` explaining why when it may not; `describeRepositorySourcesBehind` renders one clause per checkout an update can actually pull forward, over the shared `countText` pluralizer both surfaces phrase counts with. Shared by the app Git tab's Repository sources panel and the Eidoverse page's out-of-date advisory. |
| `metronome.js` | Sample-accurate Web Audio metronome — the shared timing grid for the song system and first consumer of the song `tempo` field. `createMetronome({ bpm, beatsPerBar, countInBars, onBeat, onCountInComplete })` lookahead-schedules accented click tones on the shared `AudioContext` clock (same pattern as `songPlayback.js`), emits `{ beat, bar, accent, countIn, whenAudioTime }` per beat (the beat-clock callback color-match/sing-to-score subscribe to), and tears down all timers on `stop()`. Plus `clampBpm` (20–320), `secondsPerBeat`, `timeSignatureFromScore`, `beatDescriptor`, and `normalizeBeatsPerBar` — the ONE reading of a time-signature numerator (garbled/zero/negative → 4), shared by the scheduler and the visual `<BeatPulse>` so the dots can't disagree with the clicks. |
| `mindThinkingPresets.js` | Presentation helpers for the Persistent Mind's temporary thinking sessions (#6285). `classifyMindRouteBilling(provider)` answers the question the composer must settle without contacting anything: does borrowing this route run on THIS machine (`local`), stand behind a credential/subscription (`account`), or can PortOS not tell (`unknown`)? Unknown is treated as billable — guessing "free" is the one direction that costs money. Plus `formatMindRoute` (the one "provider / model · effort" phrasing), `sameMindRoute` (client mirror of the server's route-only equality, so a label rename does not read as a changed route), `findMindThinkingPreset` / `mintMindPresetId` (a server-legal id minted from a label), and the receipt readers `formatMindCallUsage` / `formatMindCallOutcome` / `formatMindElapsed` / `mindTurnOutcome` / `mindTurnElapsedMs` / `temporaryMindTurns` — all of which keep "the provider reported nothing" rendering as unknown rather than as a free, instant, successful call. Pure; no fetches, so previewing a preset can never start an inference. |
| `midiChords.js` | Chord detection for the MIDI visualization UI (#2477). `detectChordWindows(notes, { minWindowSec })` sweeps the normalized note list for maximal spans where ≥2 distinct pitch classes sound simultaneously → `[{ startSec, endSec, label, midis }]` (adjacent same-label windows merged); `nameChord(pcs, bassPc)` maps a pitch-class set to a compact symbol (maj/min/dim/aug triads, maj7/7/m7/m7b5/dim7, sus2/sus4/add9, slash-chord inversions) and falls back to sorted pitch-class names (`C E G#`) rather than guessing wrong; `chordNoteNames(midis)` for tooltips. Pure — no canvas/React. |
diff --git a/client/src/lib/managedAppSources.js b/client/src/lib/managedAppSources.js
index 3e72951494..deb02082fa 100644
--- a/client/src/lib/managedAppSources.js
+++ b/client/src/lib/managedAppSources.js
@@ -15,26 +15,57 @@ export const primaryRepositorySource = (sources = []) =>
export const repositoryForkDiverged = (source) => source?.forkVsUpstream?.state === 'diverged';
-/** Can this checkout's origin fork be fast-forwarded from canonical upstream? */
-export const repositoryForkNeedsSync = (source) => Boolean(source?.origin?.isFork)
- && (source?.forkVsUpstream?.behind || 0) > 0
- && !repositoryForkDiverged(source);
+/**
+ * Would a push to this checkout's origin fork be accepted? `canPush` is
+ * tri-state: an unknown answer (no forge metadata) stays offerable, and only an
+ * explicit "no" retracts the sync affordance.
+ */
+export const repositoryForkPushable = (source) => Boolean(source?.origin?.isFork)
+ && source?.origin?.canPush !== false;
+
+/**
+ * Can a managed update fast-forward this checkout's origin fork from canonical
+ * upstream? The server owns the rule (`isForkSyncable` in
+ * `server/services/managedAppRepositories.js`) because the same rule decides
+ * `updateAvailable`; the client reads its answer rather than re-deriving it.
+ */
+export const repositoryForkNeedsSync = (source) => Boolean(source?.forkSyncable)
+ && (source?.forkVsUpstream?.behind || 0) > 0;
+
+/**
+ * Why an out-of-date fork is not something an update can fix, or null when it
+ * is (or when the fork is current). The Git tab still reports the drift — it is
+ * true and worth knowing — but must say plainly that no button here clears it.
+ */
+export function describeForkUnsyncable(source) {
+ if ((source?.forkVsUpstream?.behind || 0) === 0) return null;
+ if (repositoryForkNeedsSync(source)) return null;
+ if (repositoryForkDiverged(source)) {
+ return 'The fork has its own commits, so it cannot be fast-forwarded; reconcile them on GitHub first.';
+ }
+ if (source?.origin?.canPush === false) {
+ return `PortOS can read ${source.origin.fullName || 'this fork'} but cannot push to it, so it cannot fast-forward it from upstream. Updating still pulls this checkout from the fork.`;
+ }
+ return 'PortOS updates companion checkouts from their own origin, so it cannot fast-forward this fork from upstream.';
+}
/** `countText(2, 'commit')` → "2 commits". One phrasing for both update surfaces. */
export const countText = (count, noun) => `${count} ${noun}${count === 1 ? '' : 's'}`;
/**
* One human clause per checkout that is behind something an update would pull
- * it forward from. Empty when the whole source stack is current.
+ * it forward from — so a fork only counts when PortOS may fast-forward it.
+ * Empty when nothing an update could move is behind.
*/
export function describeRepositorySourcesBehind(sources = []) {
const clauses = [];
for (const source of sources) {
const label = source?.label || 'checkout';
const localBehind = source?.localVsOrigin?.behind || 0;
- const forkBehind = source?.forkVsUpstream?.behind || 0;
if (localBehind > 0) clauses.push(`${label} is ${countText(localBehind, 'commit')} behind its origin`);
- if (forkBehind > 0) clauses.push(`the ${label} fork is ${countText(forkBehind, 'commit')} behind upstream`);
+ if (repositoryForkNeedsSync(source)) {
+ clauses.push(`the ${label} fork is ${countText(source.forkVsUpstream.behind, 'commit')} behind upstream`);
+ }
}
return clauses;
}
diff --git a/docs/features/eidoverse.md b/docs/features/eidoverse.md
index fab40d9da8..9acf403af0 100644
--- a/docs/features/eidoverse.md
+++ b/docs/features/eidoverse.md
@@ -49,12 +49,23 @@ managed as a version-visible sidecar, not pinned as a PortOS submodule.
That topology is only visible to someone who goes looking for it, so freshness
is also reported where a user actually lives. Opening **Eidoverse** runs the
same repository-source check once per visit and, when a checkout or its fork is
-behind, raises an advisory above the world naming what is behind and offering
-the same one-click managed update. Dismissing it silences that revision only —
-the next Eidoverse release raises it again. The check is scoped to this page
-rather than added to the global PortOS update banner because it costs a
-`git fetch` on both checkouts plus GitHub fork metadata, which is not a price
-every screen should pay.
+behind something the update can pull it forward from, raises an advisory above
+the world naming what is behind and offering the same one-click managed update.
+Dismissing it silences that revision only — the next Eidoverse release raises it
+again. The check is scoped to this page rather than added to the global PortOS
+update banner because it costs a `git fetch` on both checkouts plus GitHub fork
+metadata, which is not a price every screen should pay.
+
+The advisory reports only drift an update can actually clear. The Video checkout
+is cloned from a third party's *fork* of the canonical project, and PortOS can
+read that fork but never push to it — so when it falls behind its own upstream,
+neither `gh repo sync` nor a pull from its origin can move it, and an advisory
+raised for that drift would never clear. PortOS therefore counts a fork toward
+"update available" only when it is the application checkout's own fork, the
+credential can push to it, and it has not diverged (`isForkSyncable` in
+`server/services/managedAppRepositories.js`, surfaced to the client as each
+source's `forkSyncable`). The drift is still reported on the app's **Git** tab,
+where the card explains why no button there clears it.
## Runtime and data ownership
diff --git a/server/services/managedAppRepositories.js b/server/services/managedAppRepositories.js
index 5dcdeedb5e..1d045a9ac7 100644
--- a/server/services/managedAppRepositories.js
+++ b/server/services/managedAppRepositories.js
@@ -55,6 +55,7 @@ async function githubRepositoryMetadata(repoPath, origin) {
'api', ...(host === 'github.com' ? [] : ['--hostname', host]),
`repos/${origin.fullName}`, '--jq',
'{fullName: .full_name, defaultBranch: .default_branch, isFork: .fork, '
+ + 'canPush: .permissions.push, '
+ 'parentFullName: .parent.full_name, parentDefaultBranch: .parent.default_branch, '
+ 'sourceFullName: .source.full_name, sourceDefaultBranch: .source.default_branch}',
], GH_TIMEOUT_MS, {
@@ -74,7 +75,13 @@ async function githubRepositoryMetadata(repoPath, origin) {
export async function resolveRepositoryTopology(repoPath) {
const origin = await getOriginInfo(repoPath);
if (!origin.hasOrigin) {
- return { origin, upstream: null, isFork: false, available: false, error: 'No origin remote configured' };
+ return {
+ origin: { ...origin, canPush: null },
+ upstream: null,
+ isFork: false,
+ available: false,
+ error: 'No origin remote configured',
+ };
}
const [metadata, upstreamUrl] = await Promise.all([
@@ -96,8 +103,17 @@ export async function resolveRepositoryTopology(repoPath) {
? (metadata.sourceDefaultBranch || metadata.parentDefaultBranch || metadata.defaultBranch || 'main')
: metadata?.defaultBranch || null;
+ // `canPush` is tri-state on purpose: `false` only when the forge answered and
+ // said no, `null` when nothing answered. A fork PortOS cannot push to cannot
+ // be fast-forwarded, and an unknown answer must not silently retract a sync
+ // PortOS has always offered.
return {
- origin: { ...origin, isFork, isUpstream: upstream ? !isFork : null },
+ origin: {
+ ...origin,
+ isFork,
+ isUpstream: upstream ? !isFork : null,
+ canPush: typeof metadata?.canPush === 'boolean' ? metadata.canPush : null,
+ },
upstream: upstream ? { ...upstream, branch: defaultBranch } : null,
isFork,
available: Boolean(upstream),
@@ -208,6 +224,26 @@ async function inspectCheckout({ id, label, repoPath }) {
return { ...checkout, forkVsUpstream: await compareForkWithUpstream(checkout, repoPath) };
}
+/**
+ * Can a managed update fast-forward THIS checkout's origin fork from canonical
+ * upstream? Only when all three hold:
+ *
+ * - it is the primary checkout — `syncManagedAppFork` only ever touches
+ * `app.repoPath`, so a companion's fork has no sync path at all;
+ * - the credential can push to that fork — cloning someone else's fork of a
+ * third project is normal (Eidoverse's video checkout is `anima-research`'s
+ * fork), and PortOS can never move a repository it can only read;
+ * - the fork has not diverged — a diverged fork cannot be fast-forwarded.
+ *
+ * This is what separates "behind, and one click fixes it" from "behind, and
+ * nothing PortOS can do will change that" — an out-of-date advisory raised for
+ * the latter is unactionable and never clears (#6321).
+ */
+const isForkSyncable = (source) => source.id === 'primary'
+ && Boolean(source.origin?.isFork)
+ && source.origin?.canPush !== false
+ && source.forkVsUpstream?.state !== 'diverged';
+
function sourceDescriptors(app) {
const companions = Array.isArray(app?.companionRepoPaths)
? [...new Set(app.companionRepoPaths)].filter((path) => path && path !== app.repoPath)
@@ -236,7 +272,8 @@ function publicTarget(repository, role) {
export async function getManagedAppRepositorySources(app) {
const descriptors = sourceDescriptors(app);
- const sources = await Promise.all(descriptors.map(inspectCheckout));
+ const inspected = await Promise.all(descriptors.map(inspectCheckout));
+ const sources = inspected.map((source) => ({ ...source, forkSyncable: isForkSyncable(source) }));
const primary = sources[0] || null;
const originTarget = publicTarget(primary?.origin, 'origin');
const upstreamTarget = publicTarget(primary?.upstream, 'upstream');
@@ -244,8 +281,12 @@ export async function getManagedAppRepositorySources(app) {
return {
kind: 'managed-app',
checkedAt: new Date().toISOString(),
+ // Only what a managed update can actually pull forward: any checkout behind
+ // its own origin, plus a fork behind upstream that PortOS is allowed to
+ // fast-forward. A fork PortOS can only read stays visible on the Git tab
+ // but never claims an update is available.
updateAvailable: sources.some((source) => source.localVsOrigin?.behind > 0
- || (source.forkVsUpstream?.behind || 0) > 0),
+ || (source.forkSyncable && (source.forkVsUpstream?.behind || 0) > 0)),
updatePullsAll: true,
updateRestartsApp: Array.isArray(app?.pm2ProcessNames) && app.pm2ProcessNames.length > 0,
issueTargets: {
@@ -284,6 +325,13 @@ export async function syncManagedAppFork(app) {
if (!topology.isFork) {
throw new ServerError(`The origin is already the canonical ${origin.fullName} repository.`, { status: 400, code: 'ALREADY_UPSTREAM' });
}
+ if (origin.canPush === false) {
+ throw new ServerError(
+ `The ${origin.fullName} fork belongs to someone else — PortOS can read it but cannot push to it, `
+ + `so it cannot be fast-forwarded from ${upstream.fullName}. Ask its owner to sync it, or point this app at a fork you control.`,
+ { status: 403, code: 'FORK_NOT_WRITABLE' },
+ );
+ }
const branch = upstream.branch || null;
const forge = await resolveForgeForRepo(app.repoPath).catch(() => null);
const args = ['repo', 'sync', origin.fullName, '--source', upstream.fullName];
diff --git a/server/services/managedAppRepositories.test.js b/server/services/managedAppRepositories.test.js
index f553df2569..e92c6e3b25 100644
--- a/server/services/managedAppRepositories.test.js
+++ b/server/services/managedAppRepositories.test.js
@@ -146,6 +146,91 @@ describe('managed app repository topology', () => {
expect(result.updateAvailable).toBe(true);
});
+ // Cloning someone else's fork of a third project is normal — Eidoverse's video
+ // checkout is `anima-research`'s fork of the canonical repo. PortOS can read
+ // that fork but never push to it, so its drift from upstream is not an update
+ // PortOS can offer, and claiming otherwise raises an advisory that no button
+ // clears (#6321).
+ it('does not call a fork it cannot push to an available update', async () => {
+ mock.execGh.mockImplementation(async (args) => {
+ if (args[1] === 'repos/example-owner/example-app') {
+ return JSON.stringify({
+ fullName: 'example-owner/example-app',
+ defaultBranch: 'main',
+ isFork: true,
+ canPush: false,
+ sourceFullName: 'example-org/example-app',
+ sourceDefaultBranch: 'main',
+ });
+ }
+ if (String(args[1]).includes('/compare/')) return JSON.stringify({ status: 'behind', ahead: 0, behind: 12 });
+ return '';
+ });
+ // The checkout itself is level with its origin; only the fork is behind.
+ mock.execGit.mockImplementation(async (args) => {
+ if (args[0] === 'status') return { stdout: '', stderr: '', exitCode: 0 };
+ if (args[0] === 'rev-list') return { stdout: '0\t0\n', stderr: '', exitCode: 0 };
+ if (args[0] === 'rev-parse' && args[1] === '--abbrev-ref') return { stdout: 'main\n', stderr: '', exitCode: 0 };
+ if (args[0] === 'rev-parse') return { stdout: `${'1'.repeat(40)}\n`, stderr: '', exitCode: 0 };
+ return { stdout: '', stderr: '', exitCode: 1 };
+ });
+
+ const result = await getManagedAppRepositorySources(app);
+
+ // The drift stays reported — it is true, and the Git tab shows it.
+ expect(result.sources[0]).toMatchObject({
+ forkSyncable: false,
+ origin: { canPush: false, isFork: true },
+ forkVsUpstream: { behind: 12, state: 'behind' },
+ });
+ expect(result.updateAvailable).toBe(false);
+ await expect(syncManagedAppFork(app)).rejects.toMatchObject({ code: 'FORK_NOT_WRITABLE', status: 403 });
+ });
+
+ // `syncManagedAppFork` only ever touches `app.repoPath`, so a companion's fork
+ // has no sync path at all — and pulling that companion from its own origin
+ // cannot move it past what the fork already has.
+ it('does not call a companion checkout fork behind upstream an available update', async () => {
+ const withCompanion = { ...app, companionRepoPaths: ['/example/companion'] };
+ mock.execGit.mockImplementation(async (args) => {
+ if (args[0] === 'status') return { stdout: '', stderr: '', exitCode: 0 };
+ if (args[0] === 'rev-list') return { stdout: '0\t0\n', stderr: '', exitCode: 0 };
+ if (args[0] === 'rev-parse' && args[1] === '--abbrev-ref') return { stdout: 'main\n', stderr: '', exitCode: 0 };
+ if (args[0] === 'rev-parse') return { stdout: `${'1'.repeat(40)}\n`, stderr: '', exitCode: 0 };
+ return { stdout: '', stderr: '', exitCode: 1 };
+ });
+ // The companion is a checkout of someone else's fork, behind its upstream.
+ mock.getOriginInfo.mockImplementation(async (repoPath) => (repoPath === '/example/companion'
+ ? { ...forkOrigin, owner: 'other-owner', repo: 'companion', fullName: 'other-owner/companion', originUrl: '[email protected]:other-owner/companion.git' }
+ : forkOrigin));
+ mock.execGh.mockImplementation(async (args) => {
+ if (args[1] === 'repos/other-owner/companion') {
+ return JSON.stringify({
+ fullName: 'other-owner/companion',
+ defaultBranch: 'main',
+ isFork: true,
+ canPush: true,
+ sourceFullName: 'example-org/companion',
+ sourceDefaultBranch: 'main',
+ });
+ }
+ if (args[1] === 'repos/example-owner/example-app') {
+ return JSON.stringify({ fullName: 'example-owner/example-app', defaultBranch: 'main', isFork: false, canPush: true });
+ }
+ if (String(args[1]).includes('/compare/')) return JSON.stringify({ status: 'behind', ahead: 0, behind: 12 });
+ return '';
+ });
+
+ const result = await getManagedAppRepositorySources(withCompanion);
+
+ expect(result.sources[1]).toMatchObject({
+ id: 'companion-1',
+ forkSyncable: false,
+ forkVsUpstream: { behind: 12, state: 'behind' },
+ });
+ expect(result.updateAvailable).toBe(false);
+ });
+
it('resolves upstream by default while honoring an explicit origin choice', async () => {
await expect(resolveManagedAppIssueTarget(app)).resolves.toMatchObject({
role: 'upstream',