From 62e86467338c7e4bdb3cac5fedf28e0b79699f56 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Thu, 5 Nov 2026 22:23:27 -0300 Subject: [PATCH 1/3] feat(macos): edit Device aliases with account and target ownership --- docs/architecture/macos-app.md | 2 + .../zh-Hans.lproj/Localizable.strings | 5 ++ macos/Sources/Beans/Model/AppStore.swift | 25 ++++++ macos/Sources/Beans/Model/Models.swift | 27 ++++++ macos/Sources/Beans/Model/Protocol.swift | 4 +- .../DeviceSettingsViewControllers.swift | 86 ++++++++++++++++++- .../Notifications/DeviceNamePromptTests.swift | 59 +++++++++++++ 7 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 macos/Tests/Notifications/DeviceNamePromptTests.swift diff --git a/docs/architecture/macos-app.md b/docs/architecture/macos-app.md index 7a2770e6..2daf2828 100644 --- a/docs/architecture/macos-app.md +++ b/docs/architecture/macos-app.md @@ -23,6 +23,8 @@ Native installation uses a health-only strict decoder shared with its compatibil Settings rows share `Settings/SettingsRows.swift`: accessory rows keep a 10 pt gap between the wrapping label and the trailing control, and their height grows with the label. A settings pop-up takes at most 55% of its row, truncates long selected titles before the chevron platter, and keeps the full choice in its native menu and tooltip. Each accessory exposes its row label to accessibility clients. General's update row puts the version and last-check status below the label and native Check for Updates action, so the status wraps without squeezing the action. `sh macos/Tests/run-settings-layout.sh` checks production AppKit rows at 280, 360, 504, and 760 pt with English and Chinese text in light and dark appearances; `SettingsLayoutTests` also runs in the existing `BeansTests` target. +Known Devices offer a native Rename prompt using `device.set_name`; blank input restores the machine name. Prompt intent is separate from the displayed model. Account, connection, snapshot, target membership/key and view generations fence confirmation and late errors. See [Device names](device-names.md). + The Devices pane reports the CLI/core version. Beans does not advertise standalone CLI self-update availability; its native app updater continues to use Beans signed readiness and Runner admission drain. Help › Diagnostics… (Command-Option-Shift-D) opens a resizable native review window and requests only `diagnostics.report` through the existing local CLI client. The window displays schema-1 JSON with an explicit relay host/port disclosure and configured-only provider, cache-only anonymous plugin, and presence-only Runner limitations; a busy port is a note rather than failure proof. Refresh clears the previous report and disables sharing until a new report succeeds. Copy Report (Command-Shift-C) and Export Report… (Command-Shift-S) share only the reviewed report, with export using a native JSON save sheet; nothing uploads automatically. Unsupported schemas and request/validation failures show fixed messages without raw errors or snapshot fallback. The typed consumer discards unknown fields and preserves nullable report fields. English and Simplified Chinese labels use the existing `L()` tables and update in the open window when the app language changes; selectable report text, accessibility labels and a native key-view loop support review. See the [report contract](runtime.md#diagnostics-report). diff --git a/macos/Resources/zh-Hans.lproj/Localizable.strings b/macos/Resources/zh-Hans.lproj/Localizable.strings index f1b3db39..cc8eef2e 100644 --- a/macos/Resources/zh-Hans.lproj/Localizable.strings +++ b/macos/Resources/zh-Hans.lproj/Localizable.strings @@ -636,6 +636,11 @@ "Rename Chat" = "重命名聊天"; "Rename Chat…" = "重命名聊天…"; "Rename…" = "重命名…"; +"Rename Device" = "重命名设备"; +"Device name" = "设备名称"; +"Couldn’t rename Device" = "无法重命名设备"; +"Keep the name to 64 characters" = "名称不能超过 64 个字符"; +"This name appears on every paired Device. Leave it blank to use the machine’s name." = "此名称会显示在每台已配对设备上。留空以使用机器名称。"; "Reply" = "回复"; "Reply failed: %@" = "回复失败:%@"; "Reply…" = "回复…"; diff --git a/macos/Sources/Beans/Model/AppStore.swift b/macos/Sources/Beans/Model/AppStore.swift index 3233c326..1168c70f 100644 --- a/macos/Sources/Beans/Model/AppStore.swift +++ b/macos/Sources/Beans/Model/AppStore.swift @@ -79,6 +79,11 @@ final class AppStore { /// True when the CLI answers on localhost (mock: toggled from the Debug menu). private(set) var isConnected = false + private var deviceNaming = DeviceNameOwnership() + var deviceNameOwner: UInt64? { + guard isConnected, hasIdentity == true, (isMock || (!isBootstrapping && identityID != nil)) else { return nil } + return deviceNaming.generation + } /// The first connection is still loading. The window is visible throughout this phase. private(set) var isStarting = true /// nil until the CLI has supplied the initial snapshot. @@ -478,6 +483,7 @@ final class AppStore { private func emit(_ event: StoreEvent) { guard !isApplyingBootstrap else { return } + deviceNaming.observe(event, devices: devices) subscriptions.removeAll { $0.owner == nil } for subscription in subscriptions { subscription.handler(event) @@ -1649,6 +1655,25 @@ final class AppStore { return created.phrase } + func setDeviceName(_ id: Device.ID, name: String, owner: UInt64) async throws { + guard deviceNameOwner == owner, let current = device(id), current.os != .unknown else { + throw CancellationError() + } + let name = name.trimmingCharacters(in: .whitespacesAndNewlines) + guard name.unicodeScalars.count <= 64 else { + throw CLIClient.RequestError(message: L("Keep the name to 64 characters")) + } + if isMock { + guard let index = devices.firstIndex(where: { $0.id == id }) else { return } + let original = current.machineName.isEmpty ? current.name : current.machineName + devices[index].machineName = original + devices[index].name = name.isEmpty ? original : name + emit(.rosterChanged) + return + } + _ = try await client.request("device.set_name", ["id": id, "name": name]) + guard deviceNameOwner == owner else { throw CancellationError() } + } /// Unpairs another Device. The CLI has the relay drop its key; the Device wipes its copy of /// the account the next time it connects. Throws when the relay could not be told. func unpairDevice(_ id: Device.ID) async throws { diff --git a/macos/Sources/Beans/Model/Models.swift b/macos/Sources/Beans/Model/Models.swift index 719dcfb2..9d45af13 100644 --- a/macos/Sources/Beans/Model/Models.swift +++ b/macos/Sources/Beans/Model/Models.swift @@ -423,6 +423,8 @@ struct Device: Identifiable, Hashable { /// Set for a CLI that updates itself (one installed with the site's script); a CLI an app /// carries updates with the app. var update: CLIUpdate? = nil + /// Original machine-reported name, independent of the account alias. + var machineName: String = "" /// A self-updating CLI's updates, as its `machine` blob says. struct CLIUpdate: Hashable { @@ -1201,3 +1203,28 @@ extension Format { return "\(count)" } } + +/// A naming prompt's target excludes mutable labels and presence. +struct DeviceNameTarget: Equatable { + let id: Device.ID + let machineKey: String + let os: Device.OS + init(_ device: Device) { id = device.id; machineKey = device.machineKey; os = device.os } +} + +/// Connection/account epochs and membership changes revoke old naming intents. +struct DeviceNameOwnership { + private(set) var generation: UInt64 = 0 + private var targets: [Device.ID: DeviceNameTarget] = [:] + mutating func observe(_ event: StoreEvent, devices: [Device]) { + let reset: Bool + switch event { + case .connectionChanged, .snapshotReplaced, .identityChanged: reset = true + case .rosterChanged: reset = false + default: return + } + let next = devices.reduce(into: [Device.ID: DeviceNameTarget]()) { $0[$1.id] = DeviceNameTarget($1) } + if reset || next != targets { generation &+= 1 } + targets = next + } +} diff --git a/macos/Sources/Beans/Model/Protocol.swift b/macos/Sources/Beans/Model/Protocol.swift index 7275f240..d2d1be3a 100644 --- a/macos/Sources/Beans/Model/Protocol.swift +++ b/macos/Sources/Beans/Model/Protocol.swift @@ -251,6 +251,7 @@ enum Wire { struct Device: Decodable { var id: String var name: String + var machineName: String? var model: String var os: String var osVersion: String @@ -751,7 +752,8 @@ extension Wire.Device { machineKey: machineKey, plugins: (plugins ?? []).map { $0.toModel() }, version: version ?? "", - update: update.map { Device.CLIUpdate(auto: $0.auto, latest: $0.latest, state: $0.state, error: $0.error) } + update: update.map { Device.CLIUpdate(auto: $0.auto, latest: $0.latest, state: $0.state, error: $0.error) }, + machineName: machineName ?? name ) } } diff --git a/macos/Sources/Beans/Settings/DeviceSettingsViewControllers.swift b/macos/Sources/Beans/Settings/DeviceSettingsViewControllers.swift index 3edc4ce8..8298143d 100644 --- a/macos/Sources/Beans/Settings/DeviceSettingsViewControllers.swift +++ b/macos/Sources/Beans/Settings/DeviceSettingsViewControllers.swift @@ -427,15 +427,29 @@ final class PluginsSettingsViewController: DevicePaneViewController { final class AboutDeviceSettingsViewController: DevicePaneViewController { private let header = DeviceHeaderView() private let machineSection = SectionView(title: L("Machine")) + private var renameGeneration: UInt64 = 0 + private var renameTarget: DeviceNameTarget? override func viewDidLoad() { title = L("Devices") add(header) addSection(machineSection) super.viewDidLoad() + header.onRename = { [weak self] in self?.askDeviceName() } + } + + override func viewWillAppear() { + super.viewWillAppear() + renameGeneration &+= 1 + reload() } override func reload() { + let target = device.map(DeviceNameTarget.init) + if renameTarget != target { + renameGeneration &+= 1 + renameTarget = target + } guard let device else { return } header.configure(device: device) @@ -478,6 +492,72 @@ final class AboutDeviceSettingsViewController: DevicePaneViewController { machineSection.setRows(rows) } + override func viewWillDisappear() { + renameGeneration &+= 1 + super.viewWillDisappear() + } + + private func askDeviceName() { + guard let device, device.os != .unknown, let owner = store.deviceNameOwner, + let window = view.window else { return } + let generation = renameGeneration + let prompt = DeviceNamePrompt(device: device, owner: owner, generation: generation) + prompt.alert.beginSheetModal(for: window) { [weak self] response in + guard let self, self.renameGeneration == generation, + self.deviceID == device.id, self.store.deviceNameOwner == owner, + let name = prompt.name(for: response, owner: self.store.deviceNameOwner, + target: self.deviceID, generation: self.renameGeneration) else { return } + Task { @MainActor [weak self] in + guard let self, self.renameGeneration == generation, + self.deviceID == device.id, self.store.deviceNameOwner == owner else { return } + do { + try await self.store.setDeviceName(device.id, name: name, owner: owner) + } catch is CancellationError { + return + } catch { + guard self.renameGeneration == generation, self.deviceID == device.id, + self.store.deviceNameOwner == owner else { return } + let alert = NSAlert() + alert.messageText = L("Couldn’t rename Device") + alert.informativeText = error.localizedDescription + await alert.beginSheetModal(for: window) + } + } + } + } + +} + +/// The native prompt keeps the proposed name separate from the displayed Device. +@MainActor +final class DeviceNamePrompt { + let alert = NSAlert() + let field: NSTextField + private let owner: UInt64 + private let target: Device.ID + private let generation: UInt64 + + init(device: Device, owner: UInt64, generation: UInt64) { + self.owner = owner + self.target = device.id + self.generation = generation + field = NSTextField(string: device.name) + alert.messageText = L("Rename Device") + alert.informativeText = L("This name appears on every paired Device. Leave it blank to use the machine’s name.") + alert.addButton(withTitle: L("Rename")) + alert.addButton(withTitle: L("Cancel")) + field.frame = NSRect(x: 0, y: 0, width: 300, height: 24) + field.placeholderString = device.machineName + field.setAccessibilityLabel(L("Device name")) + alert.accessoryView = field + alert.window.initialFirstResponder = field + } + + func name(for response: NSApplication.ModalResponse, owner: UInt64?, target: Device.ID?, generation: UInt64) -> String? { + guard response == .alertFirstButtonReturn, owner == self.owner, + target == self.target, generation == self.generation else { return nil } + return field.stringValue + } } final class DeviceHeaderView: NSView { @@ -486,6 +566,8 @@ final class DeviceHeaderView: NSView { private let model = Build.label("", font: .systemFont(ofSize: 12.5), color: .secondaryLabelColor) private let dot = StatusDotView(size: 8) private let status = Build.label("", font: .systemFont(ofSize: 11.5, weight: .medium)) + var onRename: (() -> Void)? + private lazy var renameButton = NSButton(title: L("Rename…"), target: self, action: #selector(rename)) init() { super.init(frame: .zero) @@ -494,7 +576,7 @@ final class DeviceHeaderView: NSView { icon.contentTintColor = .secondaryLabelColor let statusLine = Build.stack([dot, status], orientation: .horizontal, spacing: 6) - let text = Build.stack([name, model, statusLine], spacing: 3) + let text = Build.stack([name, renameButton, model, statusLine], spacing: 3) text.setCustomSpacing(8, after: model) addSubview(icon) @@ -515,12 +597,14 @@ final class DeviceHeaderView: NSView { @available(*, unavailable) required init?(coder: NSCoder) { fatalError() } + @objc private func rename() { onRename?() } func configure(device: Device) { icon.image = NSImage(systemSymbolName: device.symbolName, accessibilityDescription: nil) icon.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 34, weight: .regular) name.stringValue = device.name model.stringValue = "\(device.model) · \(device.osVersion)" model.isHidden = device.os == .unknown + renameButton.isHidden = device.os == .unknown dot.status = device.status switch device.status { diff --git a/macos/Tests/Notifications/DeviceNamePromptTests.swift b/macos/Tests/Notifications/DeviceNamePromptTests.swift new file mode 100644 index 00000000..7bae0d2a --- /dev/null +++ b/macos/Tests/Notifications/DeviceNamePromptTests.swift @@ -0,0 +1,59 @@ +import AppKit +import XCTest +@testable import Beans + +@MainActor +final class DeviceNamePromptTests: XCTestCase { + func testCancelAndRevokedOwnersDoNotProduceRenameIntent() throws { + _ = NSApplication.shared + let json = #"{"id":"peer","name":"Office","machine_name":"MacBook","model":"MacBook","os":"macos","os_version":"26","machine_key":"peer","is_this_device":false,"status":"offline","last_seen":0}"# + let device = try Wire.decoder.decode(Wire.Device.self, from: Data(json.utf8)).toModel() + XCTAssertEqual(device.name, "Office") + XCTAssertEqual(device.machineName, "MacBook") + let prompt = DeviceNamePrompt(device: device, owner: 7, generation: 3) + XCTAssertTrue(prompt.alert.accessoryView === prompt.field) + XCTAssertEqual(prompt.field.stringValue, "Office") + prompt.field.stringValue = "Changed" + XCTAssertNil(prompt.name(for: .alertSecondButtonReturn, owner: 7, target: "peer", generation: 3)) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: nil, target: "peer", generation: 3)) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: 8, target: "peer", generation: 3)) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: 7, target: "other", generation: 3)) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: 7, target: "peer", generation: 4)) + XCTAssertEqual(prompt.name(for: .alertFirstButtonReturn, owner: 7, target: "peer", generation: 3), "Changed") + prompt.field.stringValue = "" + XCTAssertEqual(prompt.name(for: .alertFirstButtonReturn, owner: 7, target: "peer", generation: 3), "") + XCTAssertEqual(device.name, "Office", "Editing or canceling the prompt must not mutate the displayed model.") + } + func testTargetBindingTracksRemovalAndReplacementButNotLabels() throws { + let json = #"{"id":"peer","name":"Office","machine_name":"MacBook","model":"MacBook","os":"macos","os_version":"26","machine_key":"peer","is_this_device":false,"status":"offline","last_seen":0}"# + let device = try Wire.decoder.decode(Wire.Device.self, from: Data(json.utf8)).toModel() + var ownership = DeviceNameOwnership() + ownership.observe(.snapshotReplaced, devices: [device]) + let admitted = ownership.generation + let original = DeviceNameTarget(device) + var renamed = device + renamed.name = "New label" + renamed.machineName = "New machine label" + XCTAssertEqual(DeviceNameTarget(renamed), original) + ownership.observe(.rosterChanged, devices: [renamed]) + XCTAssertEqual(ownership.generation, admitted, "Label changes preserve the open prompt") + ownership.observe(.rosterChanged, devices: []) + ownership.observe(.rosterChanged, devices: [device]) + XCTAssertNotEqual(ownership.generation, admitted, "Remove/reappear must revoke the old prompt") + let restored = ownership.generation + var replaced = device + replaced.machineKey = "replacement" + XCTAssertNotEqual(DeviceNameTarget(replaced), original) + ownership.observe(.rosterChanged, devices: [replaced]) + ownership.observe(.rosterChanged, devices: [device]) + XCTAssertNotEqual(ownership.generation, restored, "Key replacement and return must revoke the old prompt") + for event in [StoreEvent.connectionChanged, .identityChanged, .snapshotReplaced] { + let before = ownership.generation + ownership.observe(event, devices: [device]) + XCTAssertNotEqual(ownership.generation, before) + } + replaced = device + replaced.os = .linux + XCTAssertNotEqual(DeviceNameTarget(replaced), original) + } +} From 0e299598901f2a6c745f764100f933a9ccc318a1 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Fri, 6 Nov 2026 11:51:58 +0000 Subject: [PATCH 2/3] chore(tooling): propagate reviewed Beans AI tooling --- .codegraph-version | 1 + .codegraph/.gitignore | 5 +++ AGENTS.md | 2 + docs/ai-tooling.md | 86 +++++++++++++++++++++++++++++++++++++++++++ scripts/codegraph.sh | 17 +++++++++ 5 files changed, 111 insertions(+) create mode 100644 .codegraph-version create mode 100644 .codegraph/.gitignore create mode 100644 docs/ai-tooling.md create mode 100755 scripts/codegraph.sh diff --git a/.codegraph-version b/.codegraph-version new file mode 100644 index 00000000..fdd3be6d --- /dev/null +++ b/.codegraph-version @@ -0,0 +1 @@ +1.6.2 diff --git a/.codegraph/.gitignore b/.codegraph/.gitignore new file mode 100644 index 00000000..d20c0fe4 --- /dev/null +++ b/.codegraph/.gitignore @@ -0,0 +1,5 @@ +# CodeGraph data files — local to each machine, not for committing. +# Ignore everything in .codegraph/ except this file itself, so transient +# files (the database, daemon.pid, sockets, logs) never show up in git. +* +!.gitignore diff --git a/AGENTS.md b/AGENTS.md index a6f3edd8..e4ffb564 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Beans +For T3 onboarding, retrieval, command output and model reservations, follow [AI tooling](docs/ai-tooling.md). Product work remains HOLD until Heitor explicitly says OK. + Read [ARCHITECTURE.md](./ARCHITECTURE.md) before writing code, then the subject docs it lists for the parts you change. Identity is a local key pair. Paired Devices sync through an E2E relay. Provider credentials belong to the account: they sync to every paired Device as a blob encrypted with the account key. The AppKit app talks to the local CLI. diff --git a/docs/ai-tooling.md b/docs/ai-tooling.md new file mode 100644 index 00000000..b781f692 --- /dev/null +++ b/docs/ai-tooling.md @@ -0,0 +1,86 @@ +# Prepare and use AI tooling + +Read [AGENTS.md](../AGENTS.md), [BEANS.md](../BEANS.md) and [ARCHITECTURE.md](../ARCHITECTURE.md) before changing Beans. `CLAUDE.md` points to `AGENTS.md`; preserve that link and all existing instructions. + +## Keep product work on HOLD + +This preparation permits onboarding, tooling installation, independently reviewed tooling PRs, normal tooling merges and branch propagation. Product work remains HOLD until Heitor explicitly says OK. Green checks, a tooling merge and completed propagation do not release product work. Do not merge product PRs during this rollout. + +The central coordinator owns global settings and routing. Read `/Users/heitor/.config/ai-tooling/COORDINATION.md` and the current `GLOBAL-ROLLOUT.md` linked there. Report global configuration gaps to that coordinator. Keep one external rollout REPORT with commands, exit codes, receipt hashes, exact heads, resources and blockers. + +Target `bloodf/beans` explicitly for GitHub operations. `origin` is the Beans repository; `upstream` is `egoist/lorca`. T3's upstream canonical identity does not authorize upstream publication or integration. Confirm remotes, branch, HEAD, current base, worktrees and dirty state before writing. Similar source content does not prove ancestry. + +Preserve all refs with a verified Git bundle before propagation. Save staged and unstaged patches, untracked files and their hashes separately. Use an isolated tooling checkout. Preserve existing worktrees and previous work. Do not use automatic stash, `reset --hard`, force push or shared cleanup. + +## Retrieve source with CodeGraph 1.6.2 + +The standalone CLI is pinned by `.codegraph-version`. `scripts/codegraph.sh` checks the installed version, disables telemetry for its process and runs from this checkout's root. Keep CodeGraph outside application dependencies. + +Use the existing installation when it matches the pin. For workstation installation, inspect the installer at `https://raw.githubusercontent.com/colbymchenry/codegraph/f72c9d2efb14454ff4f9fd7b8460abd82f19a287/install.sh`, then run the inspected file with `CODEGRAPH_VERSION=v1.6.2`. Installation and user-specific MCP configuration belong to the central coordinator. + +Run these commands from the repository root: + +```sh +sh scripts/codegraph.sh init --yes +sh scripts/codegraph.sh sync +sh scripts/codegraph.sh status --json +sh scripts/codegraph.sh query dispatch --limit 5 --json +sh scripts/codegraph.sh callers dispatch --file crates/cli/src/api.rs --limit 5 --json +sh scripts/codegraph.sh explore --max-files 3 'api dispatch websocket serve' +``` + +Start with a bounded query before broad source reads. For exact text, missing results or unsupported syntax, use bounded `rg` and exact file ranges. Inspect the actual definition and caller before changing a flow. A graph relationship does not prove runtime behavior or complete dynamic call coverage. + +Each worktree has its own `.codegraph/` index. Do not copy databases between checkouts. Run `sync` and inspect `status --json` after checkout or edits. Check indexed languages, file/node counts, pending changes, worktree mismatch and index completion. Rebuild with `index` after changing include/exclude/extension rules. Version 1.6.2 has no `--strict` flag. + +Track only `.codegraph/.gitignore` inside `.codegraph/`. The ignore file excludes databases, logs, sockets, locks and daemon state. Never commit generated graphs or index data. With a configured CodeGraph MCP, keep the default single `codegraph_explore` tool; otherwise use the same bounded CLI commands. + +## Preserve command status with RTK 1.0.1 + +Read `/Users/heitor/.codex/RTK.md` when present. With a native RTK PreToolUse hook, run normal commands and do not wrap them twice. Without a native hook, use supported explicit commands such as `rtk git status` and `rtk gh pr list --repo bloodf/beans`. MiniMax uses this CLI route. Do not assume one harness's hooks apply to another. + +Preserve the actual exit code and first failure receipt. If condensed output is empty, contradictory or unusable, recover it with `rtk bypass ` or the stored raw receipt. Diagnose the first failure before another attempt. Do not weaken a check, timeout, baseline, security boundary or review requirement to obtain green results. + +## Use Caveman and Ponytail + +Use concise, complete Portuguese sentences with the user. Keep errors, identifiers, numbers and negations exact. Write code, persisted documents and critical instructions in complete language. + +Inspect the affected flow and callers, reuse existing code and standard libraries, and make the smallest complete change. Verify behavior at the relevant boundary. Preserve security, accessibility, approval, encryption and data-loss controls. Installation, synthetic probes, local checks, hosted checks and live behavior are separate evidence. + +## Verify TokenEconomizer per harness + +Reuse the central installation. Preserve the mode without auxiliary paid model calls: `microskills=envfacts`, `loopguard=off`, `repomap=off` and `toolprune=propose`. Do not set a paid model or enable paid proposers. Keep orchestration, review, device and required verification tools available; proposals cannot override project policy. + +From the checkout, inspect effective state without a model call: + +```sh +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" status +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" config show +"${TOKENECONOMIZER_HOME:-$HOME/.tokeneconomizer}/bin/te" --host codex --cwd "$PWD" repos list +``` + +Confirm the repository identity is the Beans origin and verify a worktree maps to that same repository. Record the installed adapter's supported events for each harness actually used. Codex's installed hook file declares `SessionStart`, `UserPromptSubmit`, `PostToolUse`, `Stop` and `SessionEnd`; declaration alone does not prove delivery through T3. + +Separate configuration present from fresh-session runtime proof. Loading a skill, starting a process or seeing a zero-session status does not prove the full lifecycle. Record unproved events as UNKNOWN. Do not invent adapters or hook support for Antigravity, MiniMax or another harness. TokenEconomizer learns repository facts and proposes tool pruning; it is not a generic output compressor. No local token savings are claimed without measurement. + +## Reserve every worker through the central dispatcher + +Before each tooling worker, reserve a route: + +```sh +t3-model-route reserve --project beans --purpose tooling --task '' +``` + +Launch only the exact returned provider, model and options through the applicable T3 delegation mechanism. Antigravity accepts Google models only. MiniMax M3.1 Flash requires `m:minimax:MiniMax-M3.1-Flash:v:thinking`. Quota UNKNOWN is not proof of capacity. Never substitute another project, provider or model, retry quota blindly, edit the global helper or implement a local round robin. + +Give each worker exact scope and file ownership. State that concurrent work must be preserved. Record the lease, task/run, provider, model and terminal outcome. Release only the exact lease after terminal evidence. Start no top-level thread for a worker. Use a fresh independent reviewer for each review or re-check, with the exact base/head and applicable risk requirements. No author approves their own change. + +## Verify and propagate tooling + +Keep the existing Beans gates. `bun run check:docs`, `bun run check:catalog` and the same-repository PR test matrix remain applicable. Inspect the current workflow definitions before execution; a local tooling smoke does not replace hosted checks. Product homes, accounts, relays, signing inputs and deployments are not tooling fixtures. + +Create one tooling PR against current Beans `main` and link it immediately to T3. Merge only after independent exact-head review and the real required checks pass. When waiting for hosted checks, use T3's PR watch and end the run; do not poll CI. + +Before propagation, prepare a per-ref plan with original head, target payload, old-head ancestry proof and recovery instructions. Append only tooling to every existing local and origin branch, including historical branches and open PR heads. Preserve each branch's existing instruction and ignore bytes. Do not merge unrelated product history, silently resolve divergence or recreate a branch absent from the server. Push fast-forward with explicit refspecs. Stop on the first remote write failure, re-read remote state and report to central before retry or a strategy change. + +Recheck current remote and PR heads, rescan for new refs, validate indexes in used checkouts and settle owned processes and leases. Record any uncovered ref as BLOCKED with a concrete reason. Product work still waits for Heitor's explicit OK. diff --git a/scripts/codegraph.sh b/scripts/codegraph.sh new file mode 100755 index 00000000..d6aa27fb --- /dev/null +++ b/scripts/codegraph.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Run from any directory with the repository's reviewed CodeGraph version. +set -eu +codegraph_root=$(CDPATH= cd "$(dirname "$0")/.." && pwd) +cd "$codegraph_root" +codegraph_expected=$(cat .codegraph-version) +if ! command -v codegraph >/dev/null 2>&1; then + echo "CodeGraph $codegraph_expected required. See docs/ai-tooling.md." >&2 + exit 1 +fi +codegraph_actual=$(codegraph --version) +if [ "$codegraph_actual" != "$codegraph_expected" ]; then + echo "CodeGraph $codegraph_expected required; found $codegraph_actual. See docs/ai-tooling.md." >&2 + exit 1 +fi +export CODEGRAPH_TELEMETRY=0 +exec codegraph "$@" From 946ce9601bbb125c0d23797010507193c2075787 Mon Sep 17 00:00:00 2001 From: Heitor Ramon Ribeiro Date: Sat, 7 Nov 2026 03:16:29 -0300 Subject: [PATCH 3/3] test(macos): cover alias prompt membership revocation --- .../Notifications/DeviceNamePromptTests.swift | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/macos/Tests/Notifications/DeviceNamePromptTests.swift b/macos/Tests/Notifications/DeviceNamePromptTests.swift index 7bae0d2a..9975bb26 100644 --- a/macos/Tests/Notifications/DeviceNamePromptTests.swift +++ b/macos/Tests/Notifications/DeviceNamePromptTests.swift @@ -4,6 +4,45 @@ import XCTest @MainActor final class DeviceNamePromptTests: XCTestCase { + func testObservedRemovalAndReturnCannotRestoreAnOpenPrompt() throws { + _ = NSApplication.shared + let json = #"{"id":"peer","name":"Office","machine_name":"MacBook","model":"MacBook","os":"macos","os_version":"26","machine_key":"peer","is_this_device":false,"status":"offline","last_seen":0}"# + let device = try Wire.decoder.decode(Wire.Device.self, from: Data(json.utf8)).toModel() + var ownership = DeviceNameOwnership() + ownership.observe(.snapshotReplaced, devices: [device]) + let prompt = DeviceNamePrompt(device: device, owner: ownership.generation, generation: 3) + prompt.field.stringValue = "Stale alias" + + ownership.observe(.rosterChanged, devices: []) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: ownership.generation, + target: device.id, generation: 3)) + // A returning machine blob can retain the same full id and abbreviated key. + ownership.observe(.rosterChanged, devices: [device]) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: ownership.generation, + target: device.id, generation: 3)) + let fresh = DeviceNamePrompt(device: device, owner: ownership.generation, generation: 3) + fresh.field.stringValue = "Fresh alias" + XCTAssertEqual(fresh.name(for: .alertFirstButtonReturn, owner: ownership.generation, + target: device.id, generation: 3), "Fresh alias") + } + + func testUnknownDeviceAndReturnCannotRestoreAnOpenPrompt() throws { + _ = NSApplication.shared + let knownJSON = #"{"id":"peer","name":"Office","machine_name":"MacBook","model":"MacBook","os":"macos","os_version":"26","machine_key":"peer","is_this_device":false,"status":"offline","last_seen":0}"# + let unknownJSON = #"{"id":"peer","name":"","model":"","os":"","os_version":"","machine_key":"peer","is_this_device":false,"status":"offline","last_seen":0,"unknown":true}"# + let known = try Wire.decoder.decode(Wire.Device.self, from: Data(knownJSON.utf8)).toModel() + let unknown = try Wire.decoder.decode(Wire.Device.self, from: Data(unknownJSON.utf8)).toModel() + XCTAssertEqual(unknown.os, .unknown) + var ownership = DeviceNameOwnership() + ownership.observe(.snapshotReplaced, devices: [known]) + let prompt = DeviceNamePrompt(device: known, owner: ownership.generation, generation: 3) + prompt.field.stringValue = "Stale alias" + ownership.observe(.rosterChanged, devices: [unknown]) + ownership.observe(.rosterChanged, devices: [known]) + XCTAssertNil(prompt.name(for: .alertFirstButtonReturn, owner: ownership.generation, + target: known.id, generation: 3)) + } + func testCancelAndRevokedOwnersDoNotProduceRenameIntent() throws { _ = NSApplication.shared let json = #"{"id":"peer","name":"Office","machine_name":"MacBook","model":"MacBook","os":"macos","os_version":"26","machine_key":"peer","is_this_device":false,"status":"offline","last_seen":0}"#