fix(server): a linked launch above the link's access names the link, not the parent mode #27334
Mergedjuliusmarmingemerged 0 commits into
main fromfix/issue-27317merged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -122,3 +131,20 @@122131 Effect.orDie,123132 );124133134+ /**135+ * The linked environment refuses a mode above the link's access too, but as136+ * "broader than parent mode", which misleads when the parent here is broader.137+ * A read-only link refuses the launch there with its own capability error.138+ */139+ const assertWithinLinkAccess = Effect.fn("PeerForwarding.assertWithinLinkAccess")(function* (140+ environmentId: EnvironmentId,141+ requested: unknown,142+ ) {143+ if (!isRuntimeMode(requested)) return;144+ const link = yield* links.get(environmentId).pipe(Effect.mapError(linkStorageFailure));145+ if (Option.isNone(link)) return;146+ const { label, access } = link.value;147+ if (access === "read-only" || runtimeModeRank(requested) <= runtimeModeRank(access)) return;148+ return yield* new OrchestratorMcpFailure({149+ code: "runtime_mode_escalation_denied",150+ message: `Linked environment "${label}" was linked with ${access} access, so work there cannot run in ${requested}. Omit runtimeMode to run it at ${access}, or link it again with broader access.`,
- apps/server/src/peer/PeerForwarding.ts line 149Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -122,3 +131,17 @@122131 Effect.orDie,123132 );124133134+ /**135+ * The linked environment refuses a mode above the link's access too, but as136+ * "broader than parent mode", which misleads when the parent here is broader.137+ * A read-only link refuses the launch there with its own capability error.138+ */139+ const assertWithinLinkAccess = Effect.fn("PeerForwarding.assertWithinLinkAccess")(function* (140+ environmentId: EnvironmentId,141+ requested: unknown,142+ ) {143+ if (!isRuntimeMode(requested)) return;144+ const link = yield* links.get(environmentId).pipe(Effect.mapError(linkStorageFailure));145+ if (Option.isNone(link)) return;146+ const { label, access } = link.value;147+ if (access === "read-only" || runtimeModeRank(requested) <= runtimeModeRank(access)) return;
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:needs-julius
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
tanstack-source added labelsbug
maria-rcks merged thisdc7ea2c
maria-rcks closed this
Sign in to join this conversation.


Approvability#
Verdict: Approved at
14ff084Macroscope's review found this PR approvable — Requests above a linked environment’s access ceiling now receive an error naming the link rather than blaming the parent mode. Existing access limits and default runtime-mode behavior remain unchanged.
No code changes detected at
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).71a780b. Prior analysis still applies.