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: preserve trusted PR scope in scheduled task inputs

[._.]/ Adam Eivyb48f22e9b92a
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index 9972957cb4..68cb7abfc6 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -2963,7 +2963,10 @@ export async function prepareManagedAppImprovementTask(taskType, app, state, {
planConstraint: planConstraintBlock
}
});
- const taskDataInputs = await resolveTaskDataInputs(interval.dataInputs, { app, taskMetadata: metadata, taskType: promptTaskType });
+ const taskDataInputs = await resolveTaskDataInputs(interval.dataInputs, {
+ app, taskMetadata: metadata, taskType: promptTaskType,
+ trustedPullRequestData: prDataBlock,
+ });
const description = scopeDescriptionToPullRequest(
appendTaskDataInputs(baseDescription, taskDataInputs),
metadata
diff --git a/server/services/taskDataInputs.js b/server/services/taskDataInputs.js
index 5f7ca48185..640d3e3ffa 100644
--- a/server/services/taskDataInputs.js
+++ b/server/services/taskDataInputs.js
@@ -275,7 +275,12 @@ const INPUT_LOADERS = {
+ (result.truncated ? TRUNCATION_NOTICE : '')
: forgeUnavailable('Open issues', forge, result);
},
- 'open-pull-requests': async ({ app, deps, forge }) => {
+ 'open-pull-requests': async ({ app, deps, forge, taskType, trustedPullRequestData }) => {
+ // Maintenance already resolved live author authority and screened discussion.
+ // A second, generic listing would put excluded PRs back into the prompt.
+ if (taskType === 'pr-watcher') {
+ return trustedPullRequestData || 'Trusted PR data is unavailable. Do not fetch an unfiltered PR list or expand the maintenance scope.';
+ }
if (!forge) return unavailableMessage('Open pull requests', 'repository forge is unavailable');
const result = await deps.listPullRequests({ cli: forge.cli, cwd: app.repoPath, env: forge.env, state: 'open' });
return result.ok
@@ -292,7 +297,7 @@ const INPUT_LOADERS = {
};
/** Resolve selected input ids into prompt-ready sections without throwing. */
-export async function resolveTaskDataInputs(inputIds, { app, taskMetadata = {}, taskType, dependencies = {} } = {}) {
+export async function resolveTaskDataInputs(inputIds, { app, taskMetadata = {}, taskType, trustedPullRequestData, dependencies = {} } = {}) {
const selected = Array.isArray(inputIds) ? [...new Set(inputIds)] : [];
if (!selected.length) return [];
const definitions = new Map(TASK_DATA_INPUT_DEFINITIONS.map((definition) => [definition.id, definition]));
@@ -309,7 +314,8 @@ export async function resolveTaskDataInputs(inputIds, { app, taskMetadata = {},
environment: process.env,
...dependencies,
};
- const needsForge = selected.some((id) => id.includes('issues') || id.includes('pull-requests'));
+ const needsForge = selected.some((id) => id.includes('issues') || (id.includes('pull-requests')
+ && !(taskType === 'pr-watcher' && id === 'open-pull-requests')));
const forge = needsForge
? await resolveForgeContext(app, deps).catch(() => null)
: null;
@@ -318,7 +324,7 @@ export async function resolveTaskDataInputs(inputIds, { app, taskMetadata = {},
const definition = definitions.get(id);
const loader = INPUT_LOADERS[id];
if (!definition || !loader) return null;
- const content = await loader({ app, deps, forge, taskMetadata, taskType }).catch(() => unavailableMessage(definition.label));
+ const content = await loader({ app, deps, forge, taskMetadata, taskType, trustedPullRequestData }).catch(() => unavailableMessage(definition.label));
return { id, label: definition.label, content };
}));
return sections.filter(Boolean);
diff --git a/server/services/taskDataInputs.test.js b/server/services/taskDataInputs.test.js
index 703a8296ee..3941da8f49 100644
--- a/server/services/taskDataInputs.test.js
+++ b/server/services/taskDataInputs.test.js
@@ -50,6 +50,29 @@ describe('taskDataInputs', () => {
}));
});
+ it('reuses the screened maintenance scope instead of reintroducing external PRs through preload', async () => {
+ const listPullRequests = vi.fn().mockResolvedValue({
+ ok: true, items: [{ number: 99, title: 'External change', author: { login: 'external' } }],
+ });
+ const resolveTracker = vi.fn();
+ const trustedPullRequestData = 'Trusted maintenance scope only.\n- **#7**\n - by owner';
+ const options = {
+ app: APP, taskType: 'pr-watcher', taskMetadata: { prAuthorFilter: 'any' },
+ trustedPullRequestData, dependencies: { listPullRequests, resolveTracker },
+ };
+ const sections = await resolveTaskDataInputs(['open-pull-requests'], options);
+ expect(sections[0].content).toBe(trustedPullRequestData);
+ expect(appendTaskDataInputs('Maintain listed PRs.', sections)).not.toContain('External change');
+ expect(listPullRequests).not.toHaveBeenCalled();
+ expect(resolveTracker).not.toHaveBeenCalled();
+
+ const missing = await resolveTaskDataInputs(['open-pull-requests'], {
+ ...options, trustedPullRequestData: undefined,
+ });
+ expect(missing[0].content).toContain('Do not fetch an unfiltered PR list');
+ expect(listPullRequests).not.toHaveBeenCalled();
+ });
+
it('preserves failed versus legitimately empty tracker reads', async () => {
const common = {
app: APP,