Commit Graph
196 Commits
Author SHA1 Message Date
Martin VogelandYury Romanov c8de7dcb68 fix(daemon): read the peer pid on FreeBSD via LOCAL_PEERCRED
cbm_daemon_ipc_connection_peer_pid() had branches for Linux
(SO_PEERCRED), macOS (LOCAL_PEERPID) and NetBSD (LOCAL_PEEREID), but
FreeBSD defines none of them, so it fell through to `return 0`, and
runtime_accept_connection() closes every connection whose peer pid is
0: on FreeBSD the daemon rejected every client.

Read the peer credentials with getsockopt(SOL_LOCAL, LOCAL_PEERCRED)
into a struct xucred and accept only the expected layout version, the
caller's effective uid and a positive pid, mirroring the Linux branch.
The branch and its <sys/ucred.h> include compile only on FreeBSD.

Carried forward from #2492, which also raised three timeouts on every
platform; those are left out (CBM_STARTUP_TIMEOUT_MS covers slow hosts).

Co-authored-by: Yury Romanov <romanov@outlook.com>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-12 20:36:45 +01:00
Martin Vogel f5d57465fd Merge pull request #2951 from DeusData/distill/2215-idle-cadence-guard
test(daemon): pin the idle maintenance-probe cadence
2026-11-11 19:38:21 +01:00
Martin Vogelandlorenzozanee fb23905e63 test(daemon): pin the idle maintenance-probe cadence
The frontend maintenance monitor probes for a maintenance request on
every cycle, and each probe try-acquires the maintenance marker lock (on
Windows that revalidates the whole ancestor directory chain). The quiet
no-maintenance cadence was raised from 10 ms to 250 ms because the 10 ms
loop burned a large share of a core for the life of every MCP session,
but nothing pinned that cadence: a regression back to the hot loop would
pass every suite.

The monitor now sleeps on a local idle_ms in its ABSENT branch and, under
CBM_ENABLE_TEST_SEAMS only, records that exact value immediately before
sleeping on it (cleared by cbm_daemon_frontend_test_observer_reset). The
new test starts an idle monitor, waits until a value is recorded, stops
the monitor and asserts the recorded sleep is at least 250 ms. Once set,
the recorded value is stable, so the verdict depends on neither elapsed
time nor scheduler cadence; the deadline is only a hang guard. Production
builds carry no seam code and sleep the same 250 ms as before.

The original test counted presence observations inside a 100 ms window,
which asserts a transient timing window; it is replaced by the recorded
cadence above.

Refs #2093

Distilled from #2215.

Co-authored-by: lorenzozanee <wyz0707@proton.me>
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-11 00:43:14 +01:00
Martin Vogel d6dcb3218b Merge origin/main into fix/hook-augment-startup-deadline
Conflicts resolved:

- src/daemon/runtime.h: both sides add test seams at the end of the
  CBM_ENABLE_TEST_SEAMS block. Kept main's connection-cap and HELLO-order
  seams and placed this branch's fingerprint-cache seams after them; the
  branch's added lines are unchanged.
- src/cli/hook_augment.c: kept main's re-arm guard, which opens the
  timeouts log only once and keeps that descriptor. Dropped main's early
  return and breadcrumb formatting after the open: this branch formats
  the breadcrumb before the log path is resolved, so stderr gets it even
  when the log cannot be opened. That formatting runs on every arm, so
  main's re-arm comment now says the text above is refreshed, and the
  #858 header comment now says the breadcrumb also goes to stderr.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-10 23:08:14 +01:00
Martin Vogel 45bac491ed fix(daemon): cache only the process's own image fingerprint
The fingerprint cache sat in every fingerprinting acquire, including
peer verification. Limit it to the process's own image: every acquire
site now passes the process id to the shared resolve step, which marks
a peer's key invalid, so a peer is never looked up, never committed,
and is hashed on every fingerprint. Re-hashing of verified peer copies
is handled by the runtime service's retained peer references (#2335).
The daemon's saving is unchanged: it hashes its own image once at start
instead of twice.

A process has one own image, so the cache drops from 8 entries to 1,
which removes the slot search and the round-robin eviction.

The cache comment no longer claims that SetFileTime cannot reset the
Windows change time; SetFileInformationByHandle can set it. Limited to
the own image, the key does not rely on it: Windows keeps a running
image locked against modification for as long as the process, and so
the cache, exists.

Test: daemon_runtime_process_fingerprint_caches_only_own_image spawns
this runner as a peer, whose image has the same file identity as the
own image, and asserts that two peer fingerprints cost two hashes, two
own fingerprints one more, and a later peer fingerprint one more again.
Before this change the second peer fingerprint was served from the
cache.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-10 23:06:35 +01:00
Martin Vogel 6ab3653b85 Merge origin/main into feat/index-resource-worker
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-03 18:09:48 +01:00
Martin Vogel b42159e227 Merge origin/main into fix/mcp-frontend-recovery
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-03 01:28:38 +01:00
Martin Vogel 2921415586 Merge pull request #1430 from vitalNohj/fm/cbm-worktree-ignore-1
feat(config): add ignore_worktrees to skip linked git worktrees
2026-11-02 21:59:10 +01:00
Martin Vogel 140e2998a1 Merge origin/main into feat/index-resource-worker
Brings the branch up to main 9c19b5dd.

Two same-spot insertion conflicts, each resolved as the main version
of the file plus the own diff of this branch:
- src/daemon/application.c: the job struct gained watch_owners on main
  and request_started_ms plus the request facts here; both kept.
- tests/test_daemon_application.c: main added the #1818
  autoindex-skipped helpers where this branch added the worker resource
  failure test; both kept, the test placed after the doc_candidates
  test.

Everything else merged cleanly. src/main.c changed on both sides: main
(#2838) lowers the worker CPU priority inside the worker role block,
and this branch strips the publication fence flag before that block
and installs the fence after the worker role options; the hunks are
disjoint and both are kept. tests/test_pipeline.c gained the Next.js
route tests (#2747) on main and the publication gate test here, also
disjoint. No call site needed adapting: no new main code calls a
function this branch re-signed, and main re-signed none that this
branch calls.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 18:15:55 +01:00
Martin Vogel 435a88be62 fix(index): coordinate publication between the worker and its supervisor
A worker resource limit is enforced by the supervisor, but only the worker
replaces the serving database, and it does so before the persistence
artifact export. A limit observed in that window stopped a worker that had
already published, and the response still said serving_index_preserved=true
while the previous index had been replaced.

Publication and resource termination now coordinate through a per-attempt
publication fence: a never-created path next to a reserved unique file in
the private worker directory, which both sides claim by creating it
exclusively (cbm_fopen "wbx": O_EXCL on POSIX, CREATE_NEW on Windows), so
exactly one of them can win.

- The worker claims it through a new pipeline publication gate that
  cbm_pipeline_run calls once, after the last pre-publication check and
  before the serving database is touched. Losing means the supervisor
  already stopped the attempt for a limit: the run aborts before
  publication and the previous generation stays in place.
- The supervisor claims it before it terminates the worker for a limit or
  a failed RSS probe. Losing means the worker already committed to
  publishing: the limit is no longer enforced for that attempt, which runs
  to completion, and index.supervisor.resource_limit_after_publication is
  logged instead. A claim that can be neither won nor lost is retried on
  the next poll rather than risk stopping a committed worker.
- At terminal the supervisor settles the fence into
  result.publication_committed. An unquiesced tree keeps the fence, so a
  surviving member can never publish after the report.

serving_index_preserved now describes the request, not only its last
attempt: a servable index existed when the request began, no attempt of
the request committed to publishing (an earlier attempt can publish and
then crash into recovery), and that index is still servable. The direct
path and the daemon job both fold every attempt into these request facts;
cbm_mcp_index_worker_resource_response takes them as a third argument, and
NULL claims nothing.

The fence path travels as an optional last pair of the exact worker grammar
(--index-worker-publish-fence), accepted by the worker argv parser and by
the daemon bootstrap role check, stripped by the CLI and installed by both
worker entries.

Limits stay opt-in: without index_max_rss_mb or index_max_duration_seconds
there is no fence, no extra argv, no claim and no extra database read.
Graph content is unchanged either way.

RED (c78c077a plus only the new end-to-end test): a FIFO at the artifact
temp path holds the real worker after the rename, and the duration clock
crosses its limit only once the serving database has been replaced. The
supervisor stops the worker there and answers resource_limit_exceeded with
serving_index_preserved=true over a replaced database. GREEN: the worker
claimed first, the supervisor logs the limit as not enforced, and the
released worker finishes and reports the published index.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 18:12:22 +01:00
Martin Vogel 37245a24fd Merge origin/main into fix/mcp-frontend-recovery
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 18:10:07 +01:00
Martin Vogel 1976986f4b Merge origin/main into fm/cbm-worktree-ignore-1
Brings the branch up to main a5b248f47. Eight files conflicted, each a
same-spot insertion where main and this branch added lines next to the
same anchor. Each resolves to the main version plus the change of this
branch:

- src/cli/cli.h, src/cli/cli.c: CBM_CONFIG_IGNORE_WORKTREES and its
  CONFIG_KEYS row next to the new doc_candidates key.
- src/mcp/mcp.c: the index_worktree schema property next to the new
  doc_candidates property.
- README.md, docs/CONFIGURATION.md: the ignore_worktrees line and table
  row next to the rewritten auto_watch entries and the new
  doc_candidates and watch_non_git rows.
- src/git/git_context.c: the env-isolation comment after the new debug
  stage marker, directly above cbm_popen_git.
- src/cli/hook_augment.c: the new SubagentStart cli_hint ahead of the
  parent-graph check of this branch.
- tests/test_mcp.c: both RUN_TEST blocks; main already includes
  str_util.h.

Per file, the lines changed against main equal the changes of this
branch against the merge-base.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-02 02:07:22 +01:00
Martin Vogel e417bbf938 Merge origin/main into fix/mcp-frontend-recovery
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-01 23:48:46 +01:00
Martin Vogel bf30a1aaf0 fix(daemon): replay the session within the startup budget
The recovery path replays the session context and UI settings on the
replacement daemon. It waited on the bootstrap connect budget, which only
bounds a probe (1 s in production), while main.c gives the first
set_context and set_ui_config the startup budget since eb294298e. A
replacement daemon whose UI save runs longer than a probe would end an
otherwise good recovery.

frontend_configure_client now waits on startup_timeout_ms. A test seam
records the budget the replay used, and the recovery fixture gives the
bootstrap distinct connect and startup budgets and exits 75 when the
replay waited on the wrong one. With the old budget exactly the three
recovery tests fail with exit 75; with the fix daemon_frontend is 17/17.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-01 23:48:31 +01:00
Martin Vogel 7e3024dbb8 Merge origin/main into fix/lifetime-lock-probe-drops-held-lock
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-11-01 20:51:22 +01:00
Martin Vogel 83a00063f1 Merge origin/main into fix/1084-background-index-cpu
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-31 16:38:35 +01:00
Pxx500 e6874f07c2 Merge branch 'main' into fix/mcp-frontend-recovery 2026-10-28 23:28:56 +01:00
Martin Vogel 70d6d5017c docs(watcher): describe the watch lifetime under daemon start
A daemon started with `daemon start` now keeps a project watched after its
last owning MCP session closes, until the daemon stops, the project is
deleted, its directory disappears, or auto_watch is set to false. README
(the watcher paragraph and the index_repository row), the watcher_enabled
row of docs/CONFIGURATION.md and the comment above the index_status watch
provider still said every watch ends with its last session.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-28 00:51:48 +01:00
Martin Vogel 631418683e fix(daemon): keep the workspace-policy release under daemon start
Under `daemon start` the session watch release kept every watch whose last
subscriber left, so the daemon could keep watching after the session ended.
The same release also runs when a session's root stops being allowed by
workspace policy (an approval revoked, a boundary declared). That is not a
disconnect: the session is still open and its root is refused, so keeping
the watch there let a permanent daemon go on indexing a root the user had
just withdrawn.

application_release_session_watch_locked() now takes session_ending. The
cancel and close paths pass true and keep the daemon-owned watch exactly as
before; the workspace-policy branch of the watch refresh passes false and
removes the watch in both modes, as it did before permanent watches.

Test: daemon_application_permanent_workspace_release_still_ends_watch
revokes the sensitive-root approval of a permanent session's root and sends
one request; its synchronous refresh must end the watch (RED when the
policy branch passes true).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-28 00:50:51 +01:00
Martin Vogel 74e301d42e fix(daemon): end a permanent watch whose project was deleted
Under `daemon start` a watch now outlives its last session. delete_project
from another session or the CLI removes the project's DB but meets no owner
of the watch: daemon MCP sessions carry no watcher pointer, so nothing
unwatches it, and the next change in that root re-indexed the deleted
project.

When a permanent watch has no subscribers, no job for its project is
running and its DB is gone, the watcher callback now removes the watch and
skips, the rule a session refresh already applies to a deleted project.
The running-job guard is needed because a full reindex unlinks the DB while
it rebuilds it: a second change during that rebuild must join the job, not
end the watch. Session-owned watches are unchanged.

Tests: daemon_application_permanent_watch_ends_when_project_db_is_deleted
(RED before: the deleted project was re-indexed) and
daemon_application_permanent_watch_kept_while_its_reindex_runs (RED
without the running-job guard: the second change ended the watch).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-28 00:45:27 +01:00
Martin Vogel a728eeb0c4 Merge origin/main into fix/permanent-daemon-watch
Bring the permanent-daemon watch ownership change up to current main.
Three conflicts in src/daemon/application.c:

- Struct comments: keep main's index-record bookkeeping struct as is,
  then the branch's comment on watch-job subscriptions describing the
  permanent-mode ownership.
- application_release_session_watch_locked: main now releases every
  watch membership a session holds. Keep that loop and apply the
  branch's rule inside it: a permanent daemon keeps the physical watch
  when its last subscriber leaves; non-permanent applications still
  remove it.
- application_background_index_admit: watch_live keeps main's
  application_watch_root_matches() and the index-args encoding that
  follows it, and additionally admits a permanent watch with no
  subscribers.

Ownership hand-off: main split application_background_index into
_admit and _wait, so the watcher-ownership flag set at admission could
no longer reach the terminal unsubscribe in the wait loop. _admit now
reports it through a bool out-parameter, application_background_index
passes it to _wait, and _wait releases the retained subscription once
when the job is terminal. The terminal block always breaks out of the
loop, so the old reset of the flag after that release is gone.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-28 00:07:04 +01:00
Martin Vogel a9fceeb06d Merge origin/main into fix/1084-background-index-cpu
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-27 19:16:35 +01:00
Martin Vogel b47386db14 Merge origin/main into fix/mcp-frontend-recovery
src/main.c conflicted in two hunks of the stdio server startup. Both
keep the recovery structure of this branch and carry the startup budget
from main (eb294298e) into it:
- set_context: the inline main_session_context() + set_context() of this
  branch stays (the recovery replay needs mcp_session_root and
  mcp_allowed_root), with its endpoint free on the failure path; the
  timeout bootstrap_config.startup_timeout_ms and the startup-budget
  comment are taken from main.
- set_ui_config: the mcp_ui_* variables of this branch, declared above
  the block, stay (they feed the replay); the timeout
  bootstrap_config.startup_timeout_ms is taken from main.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-26 01:12:55 +01:00
Martin Vogel ca419635ee Merge origin/main into fix/1818-daemon-autoindex-skipped-omits-the-effec
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-26 00:53:54 +01:00
Martin Vogel 9c48545766 Merge origin/main into fix/lifetime-lock-probe-drops-held-lock
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-25 20:15:04 +01:00
Martin Vogel 173e11a9da Merge remote-tracking branch 'origin/main' into fix/1084-background-index-cpu
main moved 12 merges past this branch's last base (72c36044). One
conflict, in src/daemon/application.c: #2737 split
application_background_index() into admit/wait helpers and gave it
named result codes. Resolved by taking main's structure and keeping
this branch's one change there: the automatic job's args carry
_cbm_background after the policy call. The watcher path re-encodes
mode/persistence/doc_candidates into the same document, so the marker
survives the re-encode, and the job comparison still drops it.

The net diff against main is unchanged: the same 13 files and the
same added and removed lines as before the merge.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-25 19:48:44 +01:00
Martin Vogel f2dad9ac7a Merge origin/main into fix/cohort-lock-tmp-cleaner
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-25 19:16:41 +01:00
Gaurav Dubey 32272f95e3 fix(daemon): log the effective auto_index_limit in daemon.autoindex.skipped
When daemon-backed auto-indexing refuses a repository, the
daemon.autoindex.skipped warning reported the tracked-file count but not
the limit that caused the refusal. The MCP autoindex.skip event already
carries limit=<n> (#1466); add the same field to the daemon warning,
using the auto_index_limit value the admission check already used.
Admission behavior is unchanged.

daemon_application_auto_index_honors_tracked_file_limit now captures the
warning through a log sink and asserts reason=too_many_files, files=1 and
limit=0 as whole fields.

Fixes #1818

Signed-off-by: Gaurav Dubey <gauravdubey0107@gmail.com>
2026-10-23 19:02:57 +00:00
Martin Vogel b260a4bf70 fix: preserve watcher roots and refresh options
Match canonical Windows separators across watch ownership and admission,
drain all session watches when auto_watch is disabled, and retain the
resolved doc_candidates choice for later refreshes. Add deterministic
regressions for the five observed failures and an absent-option guard.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-21 22:57:14 +02:00
Martin Vogel 38a3ddb29d Merge repaired main baseline
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-21 22:09:31 +02:00
wargloom 0325d6a3fa fix: watch explicit MCP index targets
Signed-off-by: wargloom <wargloom@gmail.com>
2026-10-21 14:03:07 +03:00
Martin Vogel 402cc818f7 Merge pull request #2639 from H4M4CHi-ttr/fix/windows-utf8-watcher-paths
Thank you for the Windows path fix and the careful pre-fix investigation. This uses the existing UTF-8 filesystem helpers so valid repository roots and cached graph databases are not mistaken for missing paths.

Contributor history and DCO are preserved.
2026-10-21 02:03:00 +02:00
Martin Vogel 3f8b6b4138 Merge branch 'main' into fix/cohort-lock-tmp-cleaner 2026-10-20 19:45:49 +02:00
Martin Vogel c080c4a04d Merge branch 'main' into fix/1084-background-index-cpu 2026-10-20 19:45:10 +02:00
Martin Vogel f4522c79b5 Merge branch 'main' into fix/lifetime-lock-probe-drops-held-lock 2026-10-20 19:29:58 +02:00
Martin Vogel a909f8418e fix(daemon): let an explicit index join a running automatic job
Automatic jobs (session auto-index, watcher re-index) now carry
_cbm_background, and the job registry decides whether a new request may
join the job already running for its project by comparing the index
arguments after normalising defaults. An explicit index_repository for
the same root therefore stopped matching the automatic job and was
refused with "another index operation for this project is active with
different options" -- the refusal the repo_path separator fold
(9846c3f1) removed on Windows, now on every platform.

_cbm_background chooses the worker count and never what is indexed, so
drop it from the comparison the same way default-valued options are
dropped. The explicit request joins the running job again.

The new daemon_application test holds an auto-index job open with the
fake worker, checks that its args carry the marker, and sends an
explicit async index_repository for the same root. Without this change
it is refused as an options conflict; with it the request joins (one
worker start, one active job). The async fixture gains an optional
stored config so the test can enable auto_index.

Refs #1084

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-20 19:27:00 +02:00
Martin Vogel f70c6a92b2 Merge remote-tracking branch 'origin/main' into fix/1084-background-index-cpu
main moved 1,029 commits past this branch's base (96c3f41c). Six
same-spot conflicts, each resolved by keeping both sides:

- src/mcp/mcp.c, index_run_supervised_path: the supervised worker args
  keep main's doc_candidates forwarding and add _cbm_background after it.
- src/mcp/mcp.c, autoindex_thread: main's index_doc_candidates_apply()
  runs first, then the committed-index headroom decision.
- src/pipeline/pipeline.c, run_extraction_phase: a frozen pipeline still
  forces one worker and records its route; every other pipeline takes
  cbm_pipeline_worker_count().
- src/pipeline/pipeline_incremental.c, run_extract_resolve: same shape,
  the frozen check first, then the pipeline-aware count.
- src/pipeline/pipeline_incremental.c, closure_probe_surfaces: main's
  def_count < 0 abort is kept; the surface rows borrow probe_ctx with the
  pipeline set only around that one call, as before. probe_ctx never
  allows spilling, so the result lookup takes the same branch it took
  with a NULL context.
- tests/test_mcp.c: both RUN_TEST blocks are kept.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-20 19:27:00 +02:00
Martin Vogel ad1f029645 Merge origin/main into fix/cohort-lock-tmp-cleaner
Bring the branch up to current main (a2227157) so the PR checks run
against today's tree. Textually clean; no conflict resolution.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-20 18:31:17 +02:00
Martin Vogel fc80ed00d7 Merge branch 'main' into fix/windows-utf8-watcher-paths 2026-10-20 00:18:44 +02:00
刘冲 1e4751d3ca fix(index): charge macOS phys_footprint and pin duration across recovery
Watchdogs now sample the OS-charged footprint instead of resident size on
Darwin, and index_max_duration_seconds covers the whole request so a
crash/hang respawn cannot reset the clock.

Signed-off-by: 刘冲 <mail@liuchong.dev>
2026-10-19 17:18:01 +08:00
刘冲 de1615264a feat(index): add worker resource watchdogs
Discovery limits bound what indexing accepts, not what it then costs. A
repository well inside those bounds can still exhaust the host through parser
memory, or simply never finish, and a supervised worker that hangs leaves the
parent waiting with nothing to report.

Add index_max_rss_mb and index_max_duration_seconds, enforced by the parent
against the worker process tree rather than the worker process alone, so a
runaway child cannot hide behind a small parent. Resident memory is sampled
through the platform interface on macOS, Linux and Windows. Crossing a limit
terminates the tree and yields one trusted, structured terminal result that
attributes the failure to the resource that caused it.

Both limits default to off. A measurement that cannot be taken fails the
attempt instead of passing it: a watchdog that quietly stops watching is
worse than no watchdog at all.

The shell fixture that stands in for the supervisor names the two new keys.
The worker accepts only a policy that spells out every key it knows, which is
what keeps a stale supervisor from starting a worker it cannot bound.

Signed-off-by: 刘冲 <mail@liuchong.dev>
2026-10-19 17:18:00 +08:00
Pcristin 187abfd155 Merge branch 'main' into fix/windows-local-transition-cleanup 2026-10-15 12:49:24 +03:00
Martin Vogel 6bf6e34e43 perf(store): evict idle adjacency layers, budget them, own memory class
The daemon keeps adjacency layers (store/graph_mem.h) resident across
requests -- 237 MB for the kernel -- with no end of life but LRU pressure.

- Idle eviction: a layer nobody has held for CBM_GRAPH_MEM_IDLE_EVICT_MS
  (10 minutes, measured from its last release) is evicted on the next
  request: cbm_mcp_handle_tool sweeps after releasing the request store, and
  every acquire sweeps too. No timer thread. Ten minutes outlasts the gaps
  between an agent's graph calls within one task, while a session that moved
  on stops pinning the memory; a wrong guess costs one rebuild (1.2-1.5 s on
  the 17 GB kernel index, tens of ms on ordinary repos). The clock is a test
  seam (cbm_graph_mem_set_clock_for_testing), so tests move time instead of
  waiting.
- Worker budget: application_worker_memory_slice_locked hands index workers
  the aggregate minus the resident layer bytes (cbm_graph_mem_cached_bytes),
  at least one byte per active job so a slice never reads as "no cap".
- Memory class: layers are charged to the new CBM_MEM_CLASS_GRAPH_CACHE
  ("graph_cache" in census and class logs) instead of STORE.

Responses stay byte-identical to the baseline on django and redis (tools
and Cypher) and on the kernel trace/hub and extra BFS/degree cases.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-14 22:54:02 +02:00
H4M4CHi-ttr f1e36b583d fix(watcher): inspect repository and cache paths as UTF-8
Use existing UTF-8 filesystem inspection for watcher roots, .git markers,
and cached graph databases. Preserve symlink following and distinguish
confirmed absence from unavailable inspection before pruning projects.

Cover an existing Unicode root with zero prune grace and capture the
blocked-git test environment through the existing UTF-8 runtime helper.

Split the independently applicable bug fix from the original certified
EmbeddingGemma 2 contribution without changing its file contents.

Signed-off-by: H4M4CHi-ttr <42773515+H4M4CHi-ttr@users.noreply.github.com>
2026-10-14 16:49:39 +09:00
Martin Vogel 859294561a feat(index): the documentation pass follows the index mode by default
Doc-section -> code candidates (doc_link_candidates, #2574/#2610) are the
documentation-in-the-graph feature of this release. They now run by
default for full indexes and not for moderate or fast ones; an explicit
`doc_candidates` argument, or a `doc_candidates` setting the user set,
overrides the default either way in every mode.

- pipeline: the switch is unset/on/off; unset means on only when the
  effective mode is full.
- MCP: forwards only an explicit choice (argument, then a user-set config
  value) to daemon jobs and workers; daemon auto-index and watcher/UI jobs
  now carry a user-set value too (their workers have no config, so
  `doc_candidates false` was ignored there).
- fast + doc_candidates on runs the semantic pass's corpus phases and the
  doc phase only: candidates, and still no SIMILAR_TO or
  SEMANTICALLY_RELATED edges.
- config: `doc_candidates` joins the config key table (default `auto`);
  `config set doc_candidates ...` was refused as an unknown key before.
  README, docs/CONFIGURATION.md and the MCP schema describe the default.

Proof (macOS arm64, django fb11376):
  full 11,304 rows · moderate 0 · fast 0 · full+off 0 · moderate+on 1 ·
  fast+on 1 (moderate/fast discovery skips docs/) -- nodes and edges are
  identical between on and off in every mode; fast+on adds 0 semantic
  edges.
- New tests (RED on the old code): pipeline
  pipeline_doc_candidates_default_follows_mode,
  pipeline_doc_candidates_explicit_wins_over_mode,
  pipeline_doc_candidates_fast_on_legacy_incremental; mcp
  tool_index_repository_doc_candidates_follow_mode,
  tool_index_repository_doc_candidates_forwarded_only_when_explicit;
  daemon_application
  daemon_application_programmatic_index_forwards_set_doc_candidates.
- mcp 374 passed (4 Windows-only skips), daemon_application 73 passed,
  pipeline/store_arch/cli/runtime_settings/index_policy/pipeline_frozen
  green on the release tree.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-13 18:33:40 +02:00
Pcristin fd9b01ad7a fix(daemon): wait out Windows local teardown contention
Signed-off-by: Pcristin <xxxokzxxx@protonmail.com>
2026-10-11 22:33:05 +00:00
Martin Vogel 5d10cb7af7 fix: make Lens settings and impact history portable
Normalize Windows cache paths when reporting runtime settings and resolve
Git executables before spawning history queries. Keep executable lookup
results per thread and cover the ownership contract deterministically.

Support Git 2.43 while denying history-query network transports, and close
the activity database on daemon startup failure so Windows can clean up.

Validation: 463 native macOS tests, 421 Windows tests, 44 MSan UI tests,
and focused canonical lint passed. Production-only revert checks confirm
the repaired failures.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 23:14:24 +02:00
Martin Vogel a19d7a45fb Use memory core for Lens response ownership
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 20:16:34 +02:00
Martin Vogel 0392068d49 Merge main into CBM Lens Beta
Reconcile the complete Atlas and Lens stream with current main while retaining both histories. Preserve architecture functionality, current process and watcher safeguards, test infrastructure, and dependency security updates. Add coverage for Git-environment isolation combined with child-local overrides.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-11 16:57:48 +02:00
Martin Vogel 72edfce600 Merge main into fix/issue-2167 for the release batch
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-10-09 01:57:06 +02:00