← Back to Pull requests

feat: add maintenance, link-health, and non-secret settings toolsets (#397) #417

Merged
trueline-antigravity-agent[bot] merged 15 files (2365 lines) on Dec 01, 2026 02:50 UTC
View on GitHub
trueline-antigravity-agent[bot] trueline-antigravity-agent[bot] commented on Nov 30, 2026 07:24 UTC
Author

Closes #397
Part of #394

Summary

Adds the Phase 2B maintenance.health and settings.manage capability toolsets (10 new tools across 2 toolsets, bringing the canonical registry to 39 tools across 8 toolsets) routed through useAppController's ref-backed facade with strict secret isolation, SSRF protection, untrusted-content markers, and non-destructive review staging:

New Toolsets & Tools


  • maintenance.health (src/tools/capabilities/maintenanceHealth.js, src/tools/capabilities/maintenanceLinks.js)

  • - duplicates_find: detects rule-based (findDuplicatePairs) and optional semantic duplicates, opens DuplicateReviewModal when requested, never deletes directly, and marks title/reason output untrusted: true.
    - links_sweep_control: inspects status, triggers start without blocking on completion, or calls stop (failing closed with EXECUTION_ERROR if the sweep controller is unavailable).
    - links_check_single: checks a single bookmark via the service-worker CHECK_URL SSRF boundary (isPublicHttpUrl), skips urlStatus === "ignored" unless force: true, and rejects private/loopback/non-HTTP(S) URLs with UNSAFE_HOST.
    - links_find_archive: queries Internet Archive snapshots via useArchiveRecovery (recoverables, paced, max 50) and optionally opens ChangeReviewModal (untrusted: true), never overwriting URLs automatically.
    - page_fetch_metadata: fetches page title/description/text via FETCH_PAGE_META in public/background.js, enforces isPublicHttpUrl (UNSAFE_HOST), restricts WebMCP callers to saved bookmark ids (POLICY_DENIED for arbitrary url on WebMCP), and stamps untrusted: true.
    - digest_generate: defaults to local deterministic grouping (digestSets + fallbackThemes + withRemainder, untrusted: true); requesting includeAiThemes: true or openView: true requires a policy beyond read_only (POLICY_DENIED) and an unlocked key (KEY_LOCKED).
    - bookmarks_organize: checks key lock (KEY_LOCKED) and provider readiness (PROVIDER_NOT_READY), restricts suggestions strictly to tags, folderId, and description (stripping any title diffs), and stages ChangeReviewModal without writing directly.
  • settings.manage (src/tools/capabilities/settingsManage.js)

  • - settings_get: projects a strict non-secret allowlist (theme, availableThemes, locale, availableLocales, reduceMotion, effects, remoteFavicons, viewMode, sidebarCollapsed, activeStoreType, llm.{provider,model,enableTemperature,temperature,hasApiKey,encrypted,locked}, webMcp.{available,enabled,registeredToolCount}).
    - settings_update: updates non-secret appearance & layout preferences validated against installed themes/locales/VIEW_MODES, enforces a privacy ratchet blocking remoteFavicons: true (POLICY_DENIED) while allowing false, and blocks any denylisted or unknown setting.
    - settings_llm_update: updates non-secret LLM preferences (provider, model, enableTemperature, temperature), enforces OpenAI o1/o3 temperature compatibility, blocks all edits when locked: true (KEY_LOCKED), blocks provider switching from WebMCP (POLICY_DENIED), and blocks apiKey/baseUrl/passphrase (POLICY_DENIED).

    Supporting Architecture & Security Hardenings


  • src/tools/registry.js: checks findDeniedArgKey(rawArgs) before schema validation so denylisted keys passed to strict-schema tools fail with ERROR_CODES.POLICY_DENIED instead of VALIDATION_ERROR, and registers maintenance.health and settings.manage (both off by default on WebMCP).

  • src/hooks/controllerMaintenanceSettings.js, src/hooks/useAppController.js, src/hooks/useWebMcpTools.js, src/components/BookmarkApp.jsx: clean extracted controller builders, WebMCP proxy forwarding, and BookmarkApp hook wiring without touching src/llm/aiVendor.js, src/hooks/useAgentEngine.js, or src/components/OptionsModal.jsx.

  • DESIGN.md & .changeset/maintenance-settings-tools.md: updated canonical toolset & boundary documentation and added a minor changeset.
  • Verification


  • npx eslint ... && npm run format && npm run ci </dev/null: exited 0 (version policy 0.20.3, notices current, Prettier clean, ESLint 0 errors / 0 warnings on touched files, 125/125 Vitest test files / 1,612/1,612 tests passing including explicit secret-leak, privilege-escalation, and SSRF regression suites, build:chrome + check-chunk-laziness.mjs, and build:storybook).

  • Pre-push Claude Sonnet review: LGTM with no blocking issues.
  • <!-- agent-bot-write: ghw_1557007cee9e53da session=210bdd5e08f0 bot=trueline-antigravity-agent[bot] conversation_id=e99b26b3-53f9-4d7f-8337-fb33257bb240 conversation_id_source=self-reported -->

    Diff: 2365 lines (+2326 / -39) across 15 files Reviewer: qwts Review duration: 1165m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.92) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.92 · 2365 lines diff across 15 files
    0.92
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.79 · 5 substantive comment(s)
    0.79
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Sensitive Paths sensitive_paths
    0.092
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    10 items
    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 07:25 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"c32fa39a00152b4a5d1d051140c2b9e678d1b93e","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

    <details>
    <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-30T07:29:04.166762Z">2026-11-30T07:29:04.166762Z</relative-time> | c32fa39 | PR opened |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 07:29 UTC
    Code Review
    src/hooks/controllerMaintenanceSettings.js:1
    @@ -0,0 +1,174 @@
    +// Maintenance and non-secret settings controller builders extracted from useAppController.js.
    +
    +import { VIEW_MODES } from "../utils/listView.js";
    +
    +function applyPatchesToBookmarks(bookmarks = [], patches = []) {
    +  const byId = new Map(patches.map((p) => [p.id, p]));
    +  return bookmarks.map((b) => (byId.has(b.id) ? { ...b, ...byId.get(b.id) } : b));
    +}
    +
    +export function buildMaintenanceMethods(latest) {
    +  return {
    +    proposeSemanticDuplicates: async (list) =>
    +      (await latest.current.proposeSemanticDuplicates?.(list)) ?? { pairs: [] },
    +
    +    stageDuplicateReview: (rows) => {
    +      const s = latest.current;
    +      s.duplicateReview = { rows };
    +      s.stageDuplicateReviewRows?.(rows);
    +    },
    +
    +    sweep: {
    +      status: () => {
    +        const s = latest.current;
    +        return {
    +          running: Boolean(s.sweepRunning),
    +          checked: s.sweepChecked ?? 0,
    +          total: s.sweepTotal ?? 0,
    +          checkedTotal: s.sweepCheckedTotal ?? 0,
    +          lastSweepAt: s.sweepLastSweepAt ?? null,
    +        };
    +      },
    +      start: () => {
    +        if (typeof latest.current.startSweep !== "function") {
    +          throw new Error("Link sweep controller is unavailable.");
    +        }
    +        latest.current.sweepRunning = true;
    +        return latest.current.startSweep();
    +      },
    +      stop: () => {
    +        latest.current.sweepRunning = false;
    +        return latest.current.stopSweep?.();
    +      },
    +    },
    +
    +    checkSingleUrl: async (url, bookmark) => {
    +      if (typeof latest.current.checkSingleUrl !== "function") {
    +        throw new Error("Link checker is unavailable.");
    +      }
    +      const res = await latest.current.checkSingleUrl(url, bookmark);
    +      if (res?.patch) {
    +        latest.current.bookmarks = applyPatchesToBookmarks(latest.current.bookmarks, [res.patch]);
    +      }
    +      return res ?? { status: "invalid", reason: null, updated: false };
    +    },
    +
    +    findArchiveSnapshots: async (list) =>
    +      (await latest.current.runArchiveLookup?.(list)) ?? { rows: [], asked: [] },
    +
    +    fetchPageMetadata: async (url) => (await latest.current.fetchPageMetadata?.(url)) ?? null,
    +
    +    buildDigest: async (list) => (await latest.current.buildDigest?.(list)) ?? null,
    +
    +    openDigestView: (built) => {
    +      const s = latest.current;
    +      s.digest = built;
    +      s.linkHealthOpen = false;
    +      s.openDigestView?.(built);
    +    },
    +
    +    organizeBookmarks: async (list, fields) =>
    +      (await latest.current.runOrganizer?.(list, fields)) ?? [],
    +
    +    isLlmReady: () => Boolean(latest.current.isLlmReady?.()),
    +  };
    +}
    +
    +function projectLlmSettings(s) {
    +  const provider = s.runtimeProvider ?? "gemini";
    +  const activeOpts = (s.providerOptionsMap?.[provider] ?? s.providerOptions) || {};
    +  const enc = s.encryption ?? {};
    +  return {
    +    provider,
    +    model: typeof activeOpts.model === "string" ? activeOpts.model : "",
    +    enableTemperature: Boolean(activeOpts.enableTemperature),
    +    temperature: typeof activeOpts.temperature === "number" ? activeOpts.temperature : null,
    +    hasApiKey: Boolean(String(activeOpts.apiKey ?? "").trim()),

    <sub><sub>!P2 Badge</sub></sub> Merge build-time defaults into the LLM settings projection

    When a deployment supplies __llm_options__ but has no stored runtime overrides, requests and the Options UI use those effective defaults through resolveProviderOptions, while this projection reports an empty model and hasApiKey: false. Consequently settings_get incorrectly describes a configured provider, and validations based on this snapshot can use different settings from the actual request. Project the merged effective options rather than only providerOptionsMap.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 07:29 UTC
    Code Review
    src/tools/capabilities/settingsManage.js:1
    @@ -0,0 +1,294 @@
    +// Non-secret application & LLM preference tools (`settings.manage`).
    +// Strictly allowlisted projection on read and strictly allowlisted mutations on
    +// write — never exposes or alters apiKey, baseUrl, passphrases, encrypted blobs,
    +// Firebase config/tokens, WebMCP opt-in, or agent write policies.
    +
    +import { LLM_PROVIDERS } from "../../llm/index.js";
    +import { VIEW_MODES } from "../../utils/listView.js";
    +import { ERROR_CODES, RISK_TIERS, SURFACES, errorResult, okResult } from "../schema.js";
    +
    +const SURFACES_ALL = Object.freeze([SURFACES.BUILTIN, SURFACES.WEBMCP]);
    +const PROVIDER_ENUM = Object.freeze(Object.values(LLM_PROVIDERS));
    +
    +const APPEARANCE_KEYS = new Set([
    +  "theme",
    +  "locale",
    +  "reduceMotion",
    +  "effects",
    +  "remoteFavicons",
    +  "viewMode",
    +  "sidebarCollapsed",
    +]);
    +
    +const LLM_PREF_KEYS = new Set(["provider", "model", "enableTemperature", "temperature"]);
    +
    +const DENIED_SETTING_KEYS = new Set([
    +  "apikey",
    +  "baseurl",
    +  "passphrase",
    +  "encryptedblob",
    +  "firebaseconfig",
    +  "authtoken",
    +  "webmcpenabled",
    +  "webmcp",
    +  "agentpolicy",
    +  "writepolicy",
    +]);
    +
    +const normalizeKey = (key) =>
    +  String(key ?? "")
    +    .toLowerCase()
    +    .replace(/[^a-z0-9]/gu, "");
    +
    +export function modelSupportsTemperature(providerKey, modelName) {
    +  if (providerKey === LLM_PROVIDERS.OPENAI && modelName) {
    +    return !/^o[13]/i.test(modelName);
    +  }
    +  return true;
    +}
    +
    +const strOr = (v, fallback) => (typeof v === "string" ? v : fallback);
    +const listOr = (v, fallback) => (Array.isArray(v) ? [...v] : fallback);
    +
    +function sanitizeLlmSummary(llm = {}) {
    +  return {
    +    provider: strOr(llm.provider, LLM_PROVIDERS.GEMINI),
    +    model: strOr(llm.model, ""),
    +    enableTemperature: Boolean(llm.enableTemperature),
    +    temperature: typeof llm.temperature === "number" ? llm.temperature : null,
    +    hasApiKey: Boolean(llm.hasApiKey),
    +    encrypted: Boolean(llm.encrypted),
    +    locked: Boolean(llm.locked),
    +  };
    +}
    +
    +function sanitizeWebMcpSummary(webMcp = {}) {
    +  const count = Number(webMcp.registeredToolCount);
    +  return {
    +    available: Boolean(webMcp.available),
    +    enabled: Boolean(webMcp.enabled),
    +    registeredToolCount: Number.isFinite(count) ? count : 0,
    +  };
    +}
    +
    +export function sanitizeNonSecretSettings(raw = {}) {
    +  return {
    +    theme: strOr(raw.theme, "default"),
    +    availableThemes: listOr(raw.availableThemes, ["default"]),
    +    locale: strOr(raw.locale, "system"),
    +    availableLocales: listOr(raw.availableLocales, ["en"]),
    +    reduceMotion: Boolean(raw.reduceMotion),
    +    effects: raw.effects !== false,
    +    remoteFavicons: Boolean(raw.remoteFavicons),
    +    viewMode: VIEW_MODES.includes(raw.viewMode) ? raw.viewMode : "flow",
    +    sidebarCollapsed: Boolean(raw.sidebarCollapsed),
    +    activeStoreType: strOr(raw.activeStoreType, "unknown"),
    +    llm: sanitizeLlmSummary(raw.llm),
    +    webMcp: sanitizeWebMcpSummary(raw.webMcp),
    +  };
    +}
    +
    +function validateAllowedPatchKeys(args, allowedKeys, emptyMessage) {
    +  if (!args || typeof args !== "object" || Array.isArray(args)) {
    +    return errorResult(ERROR_CODES.VALIDATION_ERROR, emptyMessage);
    +  }
    +  const keys = Object.keys(args);
    +  if (keys.length === 0) {
    +    return errorResult(ERROR_CODES.VALIDATION_ERROR, emptyMessage);
    +  }
    +  for (const key of keys) {
    +    if (allowedKeys.has(key)) continue;
    +    if (DENIED_SETTING_KEYS.has(normalizeKey(key))) {
    +      return errorResult(
    +        ERROR_CODES.POLICY_DENIED,
    +        `Setting "${key}" is protected and cannot be viewed or modified by agents.`
    +      );
    +    }
    +    return errorResult(ERROR_CODES.VALIDATION_ERROR, `Unknown or unsupported setting "${key}".`);
    +  }
    +  return null;
    +}
    +
    +export function executeSettingsGet(_args, controller) {
    +  return okResult(sanitizeNonSecretSettings(controller.getSettings?.() ?? {}));
    +}
    +
    +export function executeSettingsUpdate(args, controller) {
    +  const keyError = validateAllowedPatchKeys(
    +    args,
    +    APPEARANCE_KEYS,
    +    "Provide at least one appearance or layout setting to update."
    +  );
    +  if (keyError) return keyError;
    +
    +  if (args.remoteFavicons === true) {
    +    return errorResult(
    +      ERROR_CODES.POLICY_DENIED,
    +      "Enabling third-party remote favicon fetching must be toggled directly by the user in Options."
    +    );
    +  }
    +
    +  const current = sanitizeNonSecretSettings(controller.getSettings?.() ?? {});
    +  if (args.theme !== undefined && !current.availableThemes.includes(args.theme)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Unknown theme "${args.theme}". Available: ${current.availableThemes.join(", ")}.`
    +    );
    +  }
    +  if (args.locale !== undefined && !current.availableLocales.includes(args.locale)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Unknown locale "${args.locale}". Available: ${current.availableLocales.join(", ")}.`
    +    );
    +  }
    +  if (args.viewMode !== undefined && !VIEW_MODES.includes(args.viewMode)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Invalid viewMode "${args.viewMode}". Expected one of: ${VIEW_MODES.join(", ")}.`
    +    );
    +  }
    +
    +  controller.updateAppearanceSettings(args);
    +  return okResult(sanitizeNonSecretSettings(controller.getSettings?.() ?? {}));
    +}
    +
    +function validateLlmValues(args, currentLlm) {
    +  if (args.provider !== undefined && !PROVIDER_ENUM.includes(args.provider)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Unsupported provider "${args.provider}". Expected one of: ${PROVIDER_ENUM.join(", ")}.`
    +    );
    +  }
    +  if (args.temperature !== undefined && (args.temperature < 0 || args.temperature > 2)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      "temperature must be between 0 and 2 inclusive."
    +    );
    +  }
    +  const effectiveProvider = args.provider ?? currentLlm.provider;
    +  const effectiveModel = args.model ?? currentLlm.model;
    +  const touchesTemp = args.enableTemperature === true || args.temperature !== undefined;
    +  if (touchesTemp && !modelSupportsTemperature(effectiveProvider, effectiveModel)) {

    <sub><sub>!P2 Badge</sub></sub> Validate temperature against the target provider's model

    When a built-in caller switches providers and changes temperature without also supplying model, effectiveModel comes from the currently active provider rather than the target provider's saved options. For example, switching from Gemini to a previously configured OpenAI o3 provider with {provider: "openai", enableTemperature: true} passes validation against the Gemini model and then enables an unsupported option on o3. Resolve the target provider's model before applying the compatibility check.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 07:29 UTC
    Code Review
    src/tools/capabilities/maintenanceHealth.js:1
    @@ -0,0 +1,389 @@
    +// Maintenance capability tools (`maintenance.health`): duplicate detection,
    +// link-health checks & archive lookups, page metadata, weekly digest, and AI organization.
    +// Proposal tools stage review rows rather than mutating bookmarks directly.
    +
    +import { digestSets, fallbackThemes, hasDigest, withRemainder } from "../../utils/digest.js";
    +import { findDuplicatePairs, getDuplicateKey } from "../../utils/duplicates.js";
    +import { ORGANIZE_FIELDS } from "../../utils/organizePlan.js";
    +import {
    +  ERROR_CODES,
    +  RISK_TIERS,
    +  SURFACES,
    +  WRITE_POLICIES,
    +  clampLimit,
    +  errorResult,
    +  okResult,
    +} from "../schema.js";
    +import {
    +  MAINTENANCE_LINK_TOOLS,
    +  executeLinksCheckSingle,
    +  executeLinksFindArchive,
    +  executeLinksSweepControl,
    +  executePageFetchMetadata,
    +  linksCheckSingleTool,
    +  linksFindArchiveTool,
    +  linksSweepControlTool,
    +  pageFetchMetadataTool,
    +} from "./maintenanceLinks.js";
    +
    +const SURFACES_ALL = Object.freeze([SURFACES.BUILTIN, SURFACES.WEBMCP]);
    +const ORGANIZE_FIELD_SET = new Set(ORGANIZE_FIELDS);
    +const MAX_ORGANIZE_PREVIEW = 50;
    +
    +function buildRuleDuplicateRows(list) {
    +  return findDuplicatePairs(list).map(({ keep, drop }) => ({
    +    id: drop.id,
    +    keep,
    +    drop,
    +    source: "rule",
    +    headline: getDuplicateKey(drop).startsWith("title:") ? "sameTitle" : "exactUrl",
    +  }));
    +}
    +
    +export async function executeDuplicatesFind(args, controller) {
    +  const list =
    +    args?.scope === "displayed"
    +      ? (controller.getDisplayedBookmarks() ?? [])
    +      : (controller.getBookmarks() ?? []);
    +
    +  const ruleRows = buildRuleDuplicateRows(list);
    +  const droppedIds = new Set(ruleRows.map((row) => row.id));
    +  let aiRows = [];
    +
    +  if (
    +    args?.includeSemantic === true &&
    +    typeof controller.proposeSemanticDuplicates === "function"
    +  ) {
    +    const remaining = list.filter((b) => !droppedIds.has(b?.id));
    +    const semantic = (await controller.proposeSemanticDuplicates(remaining)) ?? { pairs: [] };
    +    aiRows = (semantic.pairs ?? []).map(({ keep, drop, reason }) => ({
    +      id: drop.id,
    +      keep,
    +      drop,
    +      source: "ai",
    +      headline: reason ?? "",
    +    }));
    +  }
    +
    +  const allRows = [...ruleRows, ...aiRows];
    +  const openedReview = Boolean(args?.openReview && allRows.length > 0);
    +  if (openedReview) {
    +    controller.stageDuplicateReview(allRows);
    +  }
    +
    +  const limit = clampLimit(args?.limit, 50, 100);
    +  const pairs = allRows.slice(0, limit).map((row) => ({
    +    keepId: row.keep?.id ?? null,
    +    keepTitle: row.keep?.title ?? "",
    +    dropId: row.drop?.id ?? row.id,
    +    dropTitle: row.drop?.title ?? "",
    +    url: row.drop?.url ?? row.keep?.url ?? "",
    +    source: row.source,
    +    reason: row.headline,
    +  }));
    +
    +  return okResult({
    +    totalPairs: allRows.length,
    +    rulePairsCount: ruleRows.length,
    +    semanticPairsCount: aiRows.length,
    +    openedReview,
    +    pairs,
    +    truncated: allRows.length > pairs.length,
    +    untrusted: true,
    +  });
    +}
    +
    +function formatThemeSummary(theme) {
    +  const rawIds = Array.isArray(theme?.ids)
    +    ? theme.ids
    +    : (theme?.items ?? []).map((b) => b?.id).filter(Boolean);
    +  return {
    +    theme: theme?.title ?? theme?.theme ?? "",
    +    summary: theme?.summary ?? "",
    +    count: rawIds.length,
    +    ids: rawIds.slice(0, 20),
    +  };
    +}
    +
    +function buildDeterministicDigest(bookmarks) {
    +  const sets = digestSets(bookmarks);
    +  if (!hasDigest(sets)) return null;
    +  const themes =
    +    sets.added.length === 0 ? [] : withRemainder(fallbackThemes(sets.added), sets.added);
    +  return { ...sets, themes };
    +}
    +
    +function extractDigestCounts(built) {
    +  const totals = built.totals ?? {};
    +  return {
    +    added: totals.added ?? built.added?.length ?? 0,
    +    neverOpened: totals.neverOpened ?? built.neverOpened?.length ?? 0,
    +    untagged: totals.untagged ?? built.untagged?.length ?? 0,
    +  };
    +}
    +
    +function checkDigestAiPreconditions(args, controller, ctx) {
    +  if (ctx?.writePolicy === WRITE_POLICIES.READ_ONLY) {
    +    return errorResult(
    +      ERROR_CODES.POLICY_DENIED,
    +      "AI digest themes require a policy beyond read_only."
    +    );
    +  }
    +  if (controller.getSettings?.()?.llm?.locked) {
    +    return errorResult(
    +      ERROR_CODES.KEY_LOCKED,
    +      "Unlock your encrypted API key before generating AI digest themes."
    +    );
    +  }
    +  return null;

    <sub><sub>!P2 Badge</sub></sub> Reject unavailable providers before claiming AI digest themes

    When includeAiThemes is true under an allowed policy but the default hosted provider has no API key, this precondition passes because the settings are merely unlocked. useDigest.build then silently falls back to deterministic local themes, and the tool returns a successful result indistinguishable from AI-generated themes even though the requested operation never occurred. Check controller.isLlmReady() here or explicitly report that AI generation was skipped.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 07:29 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: c32fa39a00

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    trueline-antigravity-agent[bot] trueline-antigravity-agent[bot] commented on code on Dec 01, 2026 02:46 UTC
    Code Review
    src/hooks/controllerMaintenanceSettings.js:1
    @@ -0,0 +1,174 @@
    +// Maintenance and non-secret settings controller builders extracted from useAppController.js.
    +
    +import { VIEW_MODES } from "../utils/listView.js";
    +
    +function applyPatchesToBookmarks(bookmarks = [], patches = []) {
    +  const byId = new Map(patches.map((p) => [p.id, p]));
    +  return bookmarks.map((b) => (byId.has(b.id) ? { ...b, ...byId.get(b.id) } : b));
    +}
    +
    +export function buildMaintenanceMethods(latest) {
    +  return {
    +    proposeSemanticDuplicates: async (list) =>
    +      (await latest.current.proposeSemanticDuplicates?.(list)) ?? { pairs: [] },
    +
    +    stageDuplicateReview: (rows) => {
    +      const s = latest.current;
    +      s.duplicateReview = { rows };
    +      s.stageDuplicateReviewRows?.(rows);
    +    },
    +
    +    sweep: {
    +      status: () => {
    +        const s = latest.current;
    +        return {
    +          running: Boolean(s.sweepRunning),
    +          checked: s.sweepChecked ?? 0,
    +          total: s.sweepTotal ?? 0,
    +          checkedTotal: s.sweepCheckedTotal ?? 0,
    +          lastSweepAt: s.sweepLastSweepAt ?? null,
    +        };
    +      },
    +      start: () => {
    +        if (typeof latest.current.startSweep !== "function") {
    +          throw new Error("Link sweep controller is unavailable.");
    +        }
    +        latest.current.sweepRunning = true;
    +        return latest.current.startSweep();
    +      },
    +      stop: () => {
    +        latest.current.sweepRunning = false;
    +        return latest.current.stopSweep?.();
    +      },
    +    },
    +
    +    checkSingleUrl: async (url, bookmark) => {
    +      if (typeof latest.current.checkSingleUrl !== "function") {
    +        throw new Error("Link checker is unavailable.");
    +      }
    +      const res = await latest.current.checkSingleUrl(url, bookmark);
    +      if (res?.patch) {
    +        latest.current.bookmarks = applyPatchesToBookmarks(latest.current.bookmarks, [res.patch]);
    +      }
    +      return res ?? { status: "invalid", reason: null, updated: false };
    +    },
    +
    +    findArchiveSnapshots: async (list) =>
    +      (await latest.current.runArchiveLookup?.(list)) ?? { rows: [], asked: [] },
    +
    +    fetchPageMetadata: async (url) => (await latest.current.fetchPageMetadata?.(url)) ?? null,
    +
    +    buildDigest: async (list) => (await latest.current.buildDigest?.(list)) ?? null,
    +
    +    openDigestView: (built) => {
    +      const s = latest.current;
    +      s.digest = built;
    +      s.linkHealthOpen = false;
    +      s.openDigestView?.(built);
    +    },
    +
    +    organizeBookmarks: async (list, fields) =>
    +      (await latest.current.runOrganizer?.(list, fields)) ?? [],
    +
    +    isLlmReady: () => Boolean(latest.current.isLlmReady?.()),
    +  };
    +}
    +
    +function projectLlmSettings(s) {
    +  const provider = s.runtimeProvider ?? "gemini";
    +  const activeOpts = (s.providerOptionsMap?.[provider] ?? s.providerOptions) || {};
    +  const enc = s.encryption ?? {};
    +  return {
    +    provider,
    +    model: typeof activeOpts.model === "string" ? activeOpts.model : "",
    +    enableTemperature: Boolean(activeOpts.enableTemperature),
    +    temperature: typeof activeOpts.temperature === "number" ? activeOpts.temperature : null,
    +    hasApiKey: Boolean(String(activeOpts.apiKey ?? "").trim()),

    Fixed in d2d46e85088e6965dd7492c49ac0a8abc5aa8b47.

    Updated projectLlmSettings in controllerMaintenanceSettings.js to merge build-time __llm_options__ via resolveProviderOptions(...) while projecting strictly non-secret fields, with unit tests verifying merged model/temperature/hasApiKey without leaking apiKey or baseUrl.

    <!-- agent-bot-write: ghw_d033e15b10ceacee session=210bdd5e08f0 bot=trueline-antigravity-agent[bot] conversation_id=e99b26b3-53f9-4d7f-8337-fb33257bb240 conversation_id_source=self-reported -->

    trueline-antigravity-agent[bot] trueline-antigravity-agent[bot] commented on code on Dec 01, 2026 02:47 UTC
    Code Review
    src/tools/capabilities/settingsManage.js:1
    @@ -0,0 +1,294 @@
    +// Non-secret application & LLM preference tools (`settings.manage`).
    +// Strictly allowlisted projection on read and strictly allowlisted mutations on
    +// write — never exposes or alters apiKey, baseUrl, passphrases, encrypted blobs,
    +// Firebase config/tokens, WebMCP opt-in, or agent write policies.
    +
    +import { LLM_PROVIDERS } from "../../llm/index.js";
    +import { VIEW_MODES } from "../../utils/listView.js";
    +import { ERROR_CODES, RISK_TIERS, SURFACES, errorResult, okResult } from "../schema.js";
    +
    +const SURFACES_ALL = Object.freeze([SURFACES.BUILTIN, SURFACES.WEBMCP]);
    +const PROVIDER_ENUM = Object.freeze(Object.values(LLM_PROVIDERS));
    +
    +const APPEARANCE_KEYS = new Set([
    +  "theme",
    +  "locale",
    +  "reduceMotion",
    +  "effects",
    +  "remoteFavicons",
    +  "viewMode",
    +  "sidebarCollapsed",
    +]);
    +
    +const LLM_PREF_KEYS = new Set(["provider", "model", "enableTemperature", "temperature"]);
    +
    +const DENIED_SETTING_KEYS = new Set([
    +  "apikey",
    +  "baseurl",
    +  "passphrase",
    +  "encryptedblob",
    +  "firebaseconfig",
    +  "authtoken",
    +  "webmcpenabled",
    +  "webmcp",
    +  "agentpolicy",
    +  "writepolicy",
    +]);
    +
    +const normalizeKey = (key) =>
    +  String(key ?? "")
    +    .toLowerCase()
    +    .replace(/[^a-z0-9]/gu, "");
    +
    +export function modelSupportsTemperature(providerKey, modelName) {
    +  if (providerKey === LLM_PROVIDERS.OPENAI && modelName) {
    +    return !/^o[13]/i.test(modelName);
    +  }
    +  return true;
    +}
    +
    +const strOr = (v, fallback) => (typeof v === "string" ? v : fallback);
    +const listOr = (v, fallback) => (Array.isArray(v) ? [...v] : fallback);
    +
    +function sanitizeLlmSummary(llm = {}) {
    +  return {
    +    provider: strOr(llm.provider, LLM_PROVIDERS.GEMINI),
    +    model: strOr(llm.model, ""),
    +    enableTemperature: Boolean(llm.enableTemperature),
    +    temperature: typeof llm.temperature === "number" ? llm.temperature : null,
    +    hasApiKey: Boolean(llm.hasApiKey),
    +    encrypted: Boolean(llm.encrypted),
    +    locked: Boolean(llm.locked),
    +  };
    +}
    +
    +function sanitizeWebMcpSummary(webMcp = {}) {
    +  const count = Number(webMcp.registeredToolCount);
    +  return {
    +    available: Boolean(webMcp.available),
    +    enabled: Boolean(webMcp.enabled),
    +    registeredToolCount: Number.isFinite(count) ? count : 0,
    +  };
    +}
    +
    +export function sanitizeNonSecretSettings(raw = {}) {
    +  return {
    +    theme: strOr(raw.theme, "default"),
    +    availableThemes: listOr(raw.availableThemes, ["default"]),
    +    locale: strOr(raw.locale, "system"),
    +    availableLocales: listOr(raw.availableLocales, ["en"]),
    +    reduceMotion: Boolean(raw.reduceMotion),
    +    effects: raw.effects !== false,
    +    remoteFavicons: Boolean(raw.remoteFavicons),
    +    viewMode: VIEW_MODES.includes(raw.viewMode) ? raw.viewMode : "flow",
    +    sidebarCollapsed: Boolean(raw.sidebarCollapsed),
    +    activeStoreType: strOr(raw.activeStoreType, "unknown"),
    +    llm: sanitizeLlmSummary(raw.llm),
    +    webMcp: sanitizeWebMcpSummary(raw.webMcp),
    +  };
    +}
    +
    +function validateAllowedPatchKeys(args, allowedKeys, emptyMessage) {
    +  if (!args || typeof args !== "object" || Array.isArray(args)) {
    +    return errorResult(ERROR_CODES.VALIDATION_ERROR, emptyMessage);
    +  }
    +  const keys = Object.keys(args);
    +  if (keys.length === 0) {
    +    return errorResult(ERROR_CODES.VALIDATION_ERROR, emptyMessage);
    +  }
    +  for (const key of keys) {
    +    if (allowedKeys.has(key)) continue;
    +    if (DENIED_SETTING_KEYS.has(normalizeKey(key))) {
    +      return errorResult(
    +        ERROR_CODES.POLICY_DENIED,
    +        `Setting "${key}" is protected and cannot be viewed or modified by agents.`
    +      );
    +    }
    +    return errorResult(ERROR_CODES.VALIDATION_ERROR, `Unknown or unsupported setting "${key}".`);
    +  }
    +  return null;
    +}
    +
    +export function executeSettingsGet(_args, controller) {
    +  return okResult(sanitizeNonSecretSettings(controller.getSettings?.() ?? {}));
    +}
    +
    +export function executeSettingsUpdate(args, controller) {
    +  const keyError = validateAllowedPatchKeys(
    +    args,
    +    APPEARANCE_KEYS,
    +    "Provide at least one appearance or layout setting to update."
    +  );
    +  if (keyError) return keyError;
    +
    +  if (args.remoteFavicons === true) {
    +    return errorResult(
    +      ERROR_CODES.POLICY_DENIED,
    +      "Enabling third-party remote favicon fetching must be toggled directly by the user in Options."
    +    );
    +  }
    +
    +  const current = sanitizeNonSecretSettings(controller.getSettings?.() ?? {});
    +  if (args.theme !== undefined && !current.availableThemes.includes(args.theme)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Unknown theme "${args.theme}". Available: ${current.availableThemes.join(", ")}.`
    +    );
    +  }
    +  if (args.locale !== undefined && !current.availableLocales.includes(args.locale)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Unknown locale "${args.locale}". Available: ${current.availableLocales.join(", ")}.`
    +    );
    +  }
    +  if (args.viewMode !== undefined && !VIEW_MODES.includes(args.viewMode)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Invalid viewMode "${args.viewMode}". Expected one of: ${VIEW_MODES.join(", ")}.`
    +    );
    +  }
    +
    +  controller.updateAppearanceSettings(args);
    +  return okResult(sanitizeNonSecretSettings(controller.getSettings?.() ?? {}));
    +}
    +
    +function validateLlmValues(args, currentLlm) {
    +  if (args.provider !== undefined && !PROVIDER_ENUM.includes(args.provider)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      `Unsupported provider "${args.provider}". Expected one of: ${PROVIDER_ENUM.join(", ")}.`
    +    );
    +  }
    +  if (args.temperature !== undefined && (args.temperature < 0 || args.temperature > 2)) {
    +    return errorResult(
    +      ERROR_CODES.VALIDATION_ERROR,
    +      "temperature must be between 0 and 2 inclusive."
    +    );
    +  }
    +  const effectiveProvider = args.provider ?? currentLlm.provider;
    +  const effectiveModel = args.model ?? currentLlm.model;
    +  const touchesTemp = args.enableTemperature === true || args.temperature !== undefined;
    +  if (touchesTemp && !modelSupportsTemperature(effectiveProvider, effectiveModel)) {

    Fixed in d2d46e85088e6965dd7492c49ac0a8abc5aa8b47.

    Added getLlmProviderSummary(provider) on AppController and forwarded it through useWebMcpTools's proxy so settings_llm_update validates temperature compatibility against the target provider's saved model (including build-time defaults) on provider switches without requiring model in the patch.

    <!-- agent-bot-write: ghw_d033e15b10ceacee session=210bdd5e08f0 bot=trueline-antigravity-agent[bot] conversation_id=e99b26b3-53f9-4d7f-8337-fb33257bb240 conversation_id_source=self-reported -->

    trueline-antigravity-agent[bot] trueline-antigravity-agent[bot] commented on code on Dec 01, 2026 02:47 UTC
    Code Review
    src/tools/capabilities/maintenanceHealth.js:1
    @@ -0,0 +1,389 @@
    +// Maintenance capability tools (`maintenance.health`): duplicate detection,
    +// link-health checks & archive lookups, page metadata, weekly digest, and AI organization.
    +// Proposal tools stage review rows rather than mutating bookmarks directly.
    +
    +import { digestSets, fallbackThemes, hasDigest, withRemainder } from "../../utils/digest.js";
    +import { findDuplicatePairs, getDuplicateKey } from "../../utils/duplicates.js";
    +import { ORGANIZE_FIELDS } from "../../utils/organizePlan.js";
    +import {
    +  ERROR_CODES,
    +  RISK_TIERS,
    +  SURFACES,
    +  WRITE_POLICIES,
    +  clampLimit,
    +  errorResult,
    +  okResult,
    +} from "../schema.js";
    +import {
    +  MAINTENANCE_LINK_TOOLS,
    +  executeLinksCheckSingle,
    +  executeLinksFindArchive,
    +  executeLinksSweepControl,
    +  executePageFetchMetadata,
    +  linksCheckSingleTool,
    +  linksFindArchiveTool,
    +  linksSweepControlTool,
    +  pageFetchMetadataTool,
    +} from "./maintenanceLinks.js";
    +
    +const SURFACES_ALL = Object.freeze([SURFACES.BUILTIN, SURFACES.WEBMCP]);
    +const ORGANIZE_FIELD_SET = new Set(ORGANIZE_FIELDS);
    +const MAX_ORGANIZE_PREVIEW = 50;
    +
    +function buildRuleDuplicateRows(list) {
    +  return findDuplicatePairs(list).map(({ keep, drop }) => ({
    +    id: drop.id,
    +    keep,
    +    drop,
    +    source: "rule",
    +    headline: getDuplicateKey(drop).startsWith("title:") ? "sameTitle" : "exactUrl",
    +  }));
    +}
    +
    +export async function executeDuplicatesFind(args, controller) {
    +  const list =
    +    args?.scope === "displayed"
    +      ? (controller.getDisplayedBookmarks() ?? [])
    +      : (controller.getBookmarks() ?? []);
    +
    +  const ruleRows = buildRuleDuplicateRows(list);
    +  const droppedIds = new Set(ruleRows.map((row) => row.id));
    +  let aiRows = [];
    +
    +  if (
    +    args?.includeSemantic === true &&
    +    typeof controller.proposeSemanticDuplicates === "function"
    +  ) {
    +    const remaining = list.filter((b) => !droppedIds.has(b?.id));
    +    const semantic = (await controller.proposeSemanticDuplicates(remaining)) ?? { pairs: [] };
    +    aiRows = (semantic.pairs ?? []).map(({ keep, drop, reason }) => ({
    +      id: drop.id,
    +      keep,
    +      drop,
    +      source: "ai",
    +      headline: reason ?? "",
    +    }));
    +  }
    +
    +  const allRows = [...ruleRows, ...aiRows];
    +  const openedReview = Boolean(args?.openReview && allRows.length > 0);
    +  if (openedReview) {
    +    controller.stageDuplicateReview(allRows);
    +  }
    +
    +  const limit = clampLimit(args?.limit, 50, 100);
    +  const pairs = allRows.slice(0, limit).map((row) => ({
    +    keepId: row.keep?.id ?? null,
    +    keepTitle: row.keep?.title ?? "",
    +    dropId: row.drop?.id ?? row.id,
    +    dropTitle: row.drop?.title ?? "",
    +    url: row.drop?.url ?? row.keep?.url ?? "",
    +    source: row.source,
    +    reason: row.headline,
    +  }));
    +
    +  return okResult({
    +    totalPairs: allRows.length,
    +    rulePairsCount: ruleRows.length,
    +    semanticPairsCount: aiRows.length,
    +    openedReview,
    +    pairs,
    +    truncated: allRows.length > pairs.length,
    +    untrusted: true,
    +  });
    +}
    +
    +function formatThemeSummary(theme) {
    +  const rawIds = Array.isArray(theme?.ids)
    +    ? theme.ids
    +    : (theme?.items ?? []).map((b) => b?.id).filter(Boolean);
    +  return {
    +    theme: theme?.title ?? theme?.theme ?? "",
    +    summary: theme?.summary ?? "",
    +    count: rawIds.length,
    +    ids: rawIds.slice(0, 20),
    +  };
    +}
    +
    +function buildDeterministicDigest(bookmarks) {
    +  const sets = digestSets(bookmarks);
    +  if (!hasDigest(sets)) return null;
    +  const themes =
    +    sets.added.length === 0 ? [] : withRemainder(fallbackThemes(sets.added), sets.added);
    +  return { ...sets, themes };
    +}
    +
    +function extractDigestCounts(built) {
    +  const totals = built.totals ?? {};
    +  return {
    +    added: totals.added ?? built.added?.length ?? 0,
    +    neverOpened: totals.neverOpened ?? built.neverOpened?.length ?? 0,
    +    untagged: totals.untagged ?? built.untagged?.length ?? 0,
    +  };
    +}
    +
    +function checkDigestAiPreconditions(args, controller, ctx) {
    +  if (ctx?.writePolicy === WRITE_POLICIES.READ_ONLY) {
    +    return errorResult(
    +      ERROR_CODES.POLICY_DENIED,
    +      "AI digest themes require a policy beyond read_only."
    +    );
    +  }
    +  if (controller.getSettings?.()?.llm?.locked) {
    +    return errorResult(
    +      ERROR_CODES.KEY_LOCKED,
    +      "Unlock your encrypted API key before generating AI digest themes."
    +    );
    +  }
    +  return null;

    Fixed in d2d46e85088e6965dd7492c49ac0a8abc5aa8b47.

    Added controller.isLlmReady() precondition checking inside checkDigestAiPreconditions in maintenanceHealth.js so digest_generate with includeAiThemes: true returns PROVIDER_NOT_READY instead of silently falling back to deterministic themes.

    <!-- agent-bot-write: ghw_d033e15b10ceacee session=210bdd5e08f0 bot=trueline-antigravity-agent[bot] conversation_id=e99b26b3-53f9-4d7f-8337-fb33257bb240 conversation_id_source=self-reported -->

    qwts qwts approved these changes on Dec 01, 2026 02:50 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    trueline-antigravity-agent[bot] trueline-antigravity-agent[bot]
    Labels
    risk: low confidence: 81.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 91.7% (HIGH) · Higher = larger blast radius
    91.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 81.8% · Lower = rushed or shallow review
    81.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%