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

feat: add branchReconcile settings schema + default

Adam Eivyf5e5aa713355
diff --git a/data.reference/settings.json b/data.reference/settings.json
index 3fd040e6c7..f25de010ac 100644
--- a/data.reference/settings.json
+++ b/data.reference/settings.json
@@ -54,5 +54,15 @@
"apiAccess": {
"voice": { "exposed": false, "requireAuth": false },
"sdapi": { "exposed": false, "requireAuth": false }
+ },
+ "branchReconcile": {
+ "enabled": false,
+ "cron": "0 3 * * *",
+ "actions": {
+ "cleanupMerged": true,
+ "openPr": true,
+ "resolveConflicts": true,
+ "autoMerge": true
+ }
}
}
\ No newline at end of file
diff --git a/server/lib/validation.js b/server/lib/validation.js
index d443ba80f6..ad1bcfde3f 100644
--- a/server/lib/validation.js
+++ b/server/lib/validation.js
@@ -315,6 +315,18 @@ export const backupConfigSchema = z.object({
disabledDefaultExcludes: z.array(z.string()).optional().default([])
});
+// Branch & PR Reconciler config (opt-in, disabled by default so a fresh install
+// never spawns agents on a schedule without the user turning it on). `actions`
+// are independent toggles for each rectification behavior. Used by the settings
+// PUT route (.partial()) and re-read on every scheduled run.
+export const branchReconcileConfigSchema = z.object({
+ enabled: z.boolean().optional().default(false),
+ cron: z.string().optional().default('0 3 * * *'),
+ actions: z.object(optionalBooleanMap([
+ 'cleanupMerged', 'openPr', 'resolveConflicts', 'autoMerge'
+ ])).optional().default({})
+});
+
// Per-API external-access flags (issue: public API surface). Stored under the
// top-level `apiAccess` settings key (client-readable — NOT under `secrets`).
// Drives `server/lib/apiRegistry.js`: an entry that is `exposed && !requireAuth`
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 4ef905776e..e643c071a3 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -25,10 +25,38 @@ import {
restoreRequestSchema,
subdirFilterSchema,
isPaginationRequested,
- paginateArray
+ paginateArray,
+ branchReconcileConfigSchema,
} from './validation.js';
describe('validation.js', () => {
+ describe('branchReconcileConfigSchema', () => {
+ it('accepts the shipped default block', () => {
+ const parsed = branchReconcileConfigSchema.parse({
+ enabled: false,
+ cron: '0 3 * * *',
+ actions: { cleanupMerged: true, openPr: true, resolveConflicts: true, autoMerge: true }
+ });
+ expect(parsed.enabled).toBe(false);
+ expect(parsed.actions.autoMerge).toBe(true);
+ });
+
+ it('defaults enabled to false and cron to the daily 3am expression', () => {
+ const parsed = branchReconcileConfigSchema.parse({});
+ expect(parsed.enabled).toBe(false);
+ expect(parsed.cron).toBe('0 3 * * *');
+ expect(parsed.actions).toEqual({});
+ });
+
+ it('rejects a non-boolean enabled', () => {
+ expect(branchReconcileConfigSchema.safeParse({ enabled: 'yes' }).success).toBe(false);
+ });
+
+ it('.partial() allows a single-field toggle patch', () => {
+ expect(branchReconcileConfigSchema.partial().safeParse({ enabled: true }).success).toBe(true);
+ });
+ });
+
describe('isPaginationRequested', () => {
it('is false when neither limit nor offset is present', () => {
expect(isPaginationRequested({})).toBe(false);
diff --git a/server/routes/settings.js b/server/routes/settings.js
index 9dbb008897..dd99a92525 100644
--- a/server/routes/settings.js
+++ b/server/routes/settings.js
@@ -10,7 +10,7 @@ import {
} from '../services/mediaJobQueue/index.js';
import { asyncHandler } from '../lib/errorHandler.js';
import { isPlainObject } from '../lib/objects.js';
-import { backupConfigSchema, sharingSettingsPatchSchema, featureProviderConfigSchema, codeReviewSettingsSchema, locationSettingsSchema, settingsEmbeddingsSchema, citySnapshotConfigSchema, imessageConfigSchema, apiAccessSettingsSchema, loraTrainingConfigSchema, pipelineEditorialChecksSettingsSchema, creativeDirectorSettingsSchema, validateRequest } from '../lib/validation.js';
+import { backupConfigSchema, sharingSettingsPatchSchema, featureProviderConfigSchema, codeReviewSettingsSchema, locationSettingsSchema, settingsEmbeddingsSchema, citySnapshotConfigSchema, imessageConfigSchema, apiAccessSettingsSchema, loraTrainingConfigSchema, pipelineEditorialChecksSettingsSchema, creativeDirectorSettingsSchema, branchReconcileConfigSchema, validateRequest } from '../lib/validation.js';
const router = Router();
@@ -176,6 +176,12 @@ router.put('/', asyncHandler(async (req, res) => {
if (req.body?.pipelineEditorialChecks !== undefined) {
validateRequest(pipelineEditorialChecksSettingsSchema.partial(), req.body.pipelineEditorialChecks);
}
+ // Branch & PR Reconciler slice (#branch-reconcile) — validate when present so a
+ // malformed toggle save can't write a non-boolean enabled / bad cron the
+ // scheduler would then choke on.
+ if (req.body?.branchReconcile !== undefined) {
+ validateRequest(branchReconcileConfigSchema.partial(), req.body.branchReconcile);
+ }
// User-defined catalog types moved out of settings.json into PostgreSQL
// (`catalog_user_types`, #1001). The `/api/catalog/types` routes are the only
// write path; a `catalogUserTypes` key in a PUT /api/settings body (legacy