Skip to content

Commit 8f129e0

Browse files
committed
Keep five-slice regression changes scoped to their fixtures
1 parent b4519d3 commit 8f129e0

2 files changed

Lines changed: 61 additions & 75 deletions

File tree

‎tests/test_cli.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,7 +4297,7 @@ TEST(cli_cline_data_dir_only_redirects_data_state) {
42974297
}
42984298
free(plan);
42994299

4300-
int install_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
4300+
int install_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-cli", false, false);
43014301
struct stat state;
43024302
const char *const instruction_terms[] = {"Codebase Memory", "codebase-memory-cli search",
43034303
"codebase-memory-cli trace"};
@@ -4474,7 +4474,7 @@ TEST(cli_junie_current_durable_context_contract) {
44744474
yyjson_doc_free(plan_doc);
44754475
free(plan);
44764476

4477-
int first_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
4477+
int first_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-cli", false, false);
44784478
char *skill_once = read_test_file_alloc(skill_path);
44794479
char *agent_after_install = read_test_file_alloc(agent_path);
44804480
char *settings_after_install = read_test_file_alloc(settings_path);
@@ -4488,7 +4488,7 @@ TEST(cli_junie_current_durable_context_contract) {
44884488
free(agent_after_install);
44894489
free(settings_after_install);
44904490

4491-
int second_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
4491+
int second_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-cli", false, false);
44924492
char *skill_twice = read_test_file_alloc(skill_path);
44934493
bool idempotent =
44944494
second_rc == 0 && skill_once && skill_twice && strcmp(skill_once, skill_twice) == 0;
@@ -4506,7 +4506,7 @@ TEST(cli_junie_current_durable_context_contract) {
45064506
free(agent_after_uninstall);
45074507
free(settings_after_uninstall);
45084508

4509-
int reinstall_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
4509+
int reinstall_rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-cli", false, false);
45104510
const char *modified_skill = "---\nname: codebase-memory\n---\nUser-owned Junie skill.\n";
45114511
write_test_file(skill_path, modified_skill);
45124512
int modified_uninstall_rc = cli_test_cmd_uninstall(2, argv);
@@ -8447,7 +8447,7 @@ TEST(cli_upgrade_migrates_released_claude_hook_scripts) {
84478447
cbm_setenv("PATH", tmpdir, 1);
84488448
cbm_unsetenv("CLAUDE_CONFIG_DIR");
84498449
cbm_unsetenv("CODEX_HOME");
8450-
int rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-mcp", false, false);
8450+
int rc = cbm_install_agent_configs(tmpdir, "/opt/codebase-memory-cli", false, false);
84518451

84528452
char *gate = read_test_file_alloc(gate_path);
84538453
char *session = read_test_file_alloc(session_path);

‎tests/test_daemon_application.c‎

Lines changed: 56 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,12 @@ static cbm_daemon_runtime_application_status_t app_test_request(
169169

170170
static bool app_test_response_contains(const uint8_t *response, uint32_t response_length,
171171
const char *needle) {
172-
if (!response || !needle)
173-
return false;
172+
if (!response || !needle) return false;
174173
size_t needle_length = strlen(needle);
175-
if (needle_length == 0)
176-
return true;
177-
if (needle_length > response_length)
178-
return false;
174+
if (needle_length == 0) return true;
175+
if (needle_length > response_length) return false;
179176
for (uint32_t i = 0; i <= response_length - needle_length; i++) {
180-
if (memcmp(response + i, needle, needle_length) == 0)
181-
return true;
177+
if (memcmp(response + i, needle, needle_length) == 0) return true;
182178
}
183179
return false;
184180
}
@@ -686,8 +682,8 @@ TEST(daemon_application_requires_immutable_explicit_context) {
686682
uint8_t *response = NULL;
687683
uint32_t response_length = 0;
688684
bool operation_ok = app_test_tool_request("projects", "{}", &operation, &operation_length);
689-
cbm_daemon_runtime_application_status_t before = app_test_request(
690-
&callbacks, session, operation, operation_length, &response, &response_length);
685+
cbm_daemon_runtime_application_status_t before =
686+
app_test_request(&callbacks, session, operation, operation_length, &response, &response_length);
691687
free(response);
692688
response = NULL;
693689
bool context_ok = root_ok && app_test_context_request(root, root, &context, &context_length);
@@ -703,8 +699,8 @@ TEST(daemon_application_requires_immutable_explicit_context) {
703699
: CBM_DAEMON_RUNTIME_APPLICATION_TRANSPORT_ERROR;
704700
free(response);
705701
response = NULL;
706-
cbm_daemon_runtime_application_status_t after = app_test_request(
707-
&callbacks, session, operation, operation_length, &response, &response_length);
702+
cbm_daemon_runtime_application_status_t after =
703+
app_test_request(&callbacks, session, operation, operation_length, &response, &response_length);
708704
bool operation_response = response && response_length > 1 && response[0] == 0;
709705

710706
callbacks.session_close(callbacks.context, session);
@@ -777,11 +773,11 @@ TEST(daemon_application_hook_context_preserves_event_and_dialect) {
777773
(void)snprintf(input, sizeof(input), "{\"cwd\":\"%s\"}", root);
778774
uint8_t *hook = NULL;
779775
uint32_t hook_length = 0;
780-
bool encoded = root_ok && session &&
781-
app_test_context_request_options(root, root, "SessionStart", "copilot", &context,
782-
&context_length) &&
783-
app_test_text_request(CBM_DAEMON_APPLICATION_REQUEST_HOOK_AUGMENT, input, &hook,
784-
&hook_length);
776+
bool encoded =
777+
root_ok && session &&
778+
app_test_context_request_options(root, root, "SessionStart", "copilot", &context, &context_length) &&
779+
app_test_text_request(CBM_DAEMON_APPLICATION_REQUEST_HOOK_AUGMENT, input, &hook,
780+
&hook_length);
785781
uint8_t *response = NULL;
786782
uint32_t response_length = 0;
787783
cbm_daemon_runtime_application_status_t context_status =
@@ -1623,22 +1619,23 @@ static bool app_env_backup_restore(app_env_backup_t *backup) {
16231619
return status == 0;
16241620
}
16251621

1626-
static bool app_test_initialize_session(const cbm_daemon_runtime_application_callbacks_t *callbacks,
1627-
cbm_daemon_runtime_application_session_t *session,
1628-
const char *root, const char *hook_event,
1629-
const char *hook_dialect) {
1622+
static bool app_test_initialize_session(
1623+
const cbm_daemon_runtime_application_callbacks_t *callbacks,
1624+
cbm_daemon_runtime_application_session_t *session, const char *root,
1625+
const char *hook_event, const char *hook_dialect) {
16301626
uint8_t *context = NULL;
16311627
uint32_t context_length = 0;
1632-
bool encoded = session && app_test_context_request_options(root, root, hook_event, hook_dialect,
1633-
&context, &context_length);
1628+
bool encoded = session &&
1629+
app_test_context_request_options(root, root, hook_event, hook_dialect,
1630+
&context, &context_length);
16341631
uint8_t *response = NULL;
16351632
uint32_t response_length = 0;
16361633
cbm_daemon_runtime_application_status_t status =
16371634
encoded ? app_test_request(callbacks, session, context, context_length, &response,
16381635
&response_length)
16391636
: CBM_DAEMON_RUNTIME_APPLICATION_TRANSPORT_ERROR;
1640-
bool initialized =
1641-
status == CBM_DAEMON_RUNTIME_APPLICATION_OK && response == NULL && response_length == 0;
1637+
bool initialized = status == CBM_DAEMON_RUNTIME_APPLICATION_OK && response == NULL &&
1638+
response_length == 0;
16421639
free(response);
16431640
free(context);
16441641
return initialized;
@@ -1679,9 +1676,9 @@ static cbm_daemon_runtime_application_status_t app_test_list_projects(
16791676
return status;
16801677
}
16811678

1682-
/* Regression contract: neutral context establishment is the ownership boundary for daemon
1683-
* background indexing. Hook sessions do not participate; identical roots share one physical worker
1684-
* but retain one subscription per live session. */
1679+
/* Regression contract: neutral context establishment is the ownership boundary for daemon background
1680+
* indexing. Hook sessions do not participate; identical roots share
1681+
* one physical worker but retain one subscription per live session. */
16851682
TEST(daemon_application_initialize_coalesces_auto_index_for_full_sessions) {
16861683
app_env_backup_t cache_environment;
16871684
bool cache_saved = app_env_backup_capture(&cache_environment, "CBM_CACHE_DIR");
@@ -1723,21 +1720,20 @@ TEST(daemon_application_initialize_coalesces_auto_index_for_full_sessions) {
17231720
}
17241721

17251722
int bg_baseline = cbm_daemon_application_background_initializes_for_test();
1726-
bool hook_only_initialized =
1727-
app_test_initialize_session(&callbacks, sessions[2], root, "SessionStart", "copilot");
1728-
bool hook_initialized =
1729-
app_test_initialize_session(&callbacks, sessions[3], root, "SessionStart", "copilot");
1723+
bool hook_only_initialized = app_test_initialize_session(&callbacks, sessions[2], root, "SessionStart", "copilot");
1724+
bool hook_initialized = app_test_initialize_session(
1725+
&callbacks, sessions[3], root, "SessionStart", "copilot");
17301726
bool admissions_evaluated = app_wait_for_background_initializes(bg_baseline + 2);
17311727
bool restricted_started_nothing =
17321728
admissions_evaluated && atomic_load(&fake.starts) == 0 && application && project &&
1733-
cbm_daemon_application_job_subscribers(application, project) == 0 && true;
1729+
cbm_daemon_application_job_subscribers(application, project) == 0 &&
1730+
true;
17341731

17351732
bool first_initialized = app_test_initialize_session(&callbacks, sessions[0], root, NULL, NULL);
17361733
bool first_owned = first_initialized && project &&
17371734
app_wait_for_subscribers(application, project, 1) &&
17381735
app_wait_for_atomic_int(&fake.starts, 1);
1739-
bool second_initialized =
1740-
app_test_initialize_session(&callbacks, sessions[1], root, NULL, NULL);
1736+
bool second_initialized = app_test_initialize_session(&callbacks, sessions[1], root, NULL, NULL);
17411737
bool coalesced = first_owned && second_initialized && project &&
17421738
app_wait_for_subscribers(application, project, 2) &&
17431739
cbm_daemon_application_active_jobs(application) == 1 &&
@@ -1870,15 +1866,14 @@ TEST(daemon_application_sensitive_root_blocks_auto_index_but_preserves_controls)
18701866
application ? app_test_open(&callbacks, 4032) : NULL;
18711867

18721868
int background_baseline = cbm_daemon_application_background_initializes_for_test();
1873-
bool sensitive_initialized =
1874-
app_test_initialize_session(&callbacks, sensitive_session, sensitive, NULL, NULL);
1869+
bool sensitive_initialized = app_test_initialize_session(
1870+
&callbacks, sensitive_session, sensitive, NULL, NULL);
18751871
bool sensitive_evaluated = app_wait_for_background_initializes(background_baseline + 1);
18761872
bool sensitive_blocked = sensitive_initialized && sensitive_evaluated &&
18771873
atomic_load(&fake.starts) == 0 &&
18781874
cbm_daemon_application_active_jobs(application) == 0;
18791875

1880-
bool ordinary_initialized =
1881-
app_test_initialize_session(&callbacks, ordinary_session, ordinary, NULL, NULL);
1876+
bool ordinary_initialized = app_test_initialize_session(&callbacks, ordinary_session, ordinary, NULL, NULL);
18821877
bool ordinary_admitted = ordinary_initialized && app_wait_for_atomic_int(&fake.starts, 1) &&
18831878
cbm_daemon_application_active_jobs(application) == 1;
18841879
if (ordinary_session) {
@@ -1894,8 +1889,7 @@ TEST(daemon_application_sensitive_root_blocks_auto_index_but_preserves_controls)
18941889
bool approved = ordinary_reaped && cbm_workspace_grant_add(cache, sensitive, sensitive, true,
18951890
grant_error, sizeof(grant_error));
18961891
bool approved_initialized =
1897-
approved &&
1898-
app_test_initialize_session(&callbacks, approved_session, sensitive, NULL, NULL);
1892+
approved && app_test_initialize_session(&callbacks, approved_session, sensitive, NULL, NULL);
18991893
bool approved_admitted = approved_initialized && app_wait_for_atomic_int(&fake.starts, 2) &&
19001894
cbm_daemon_application_active_jobs(application) == 1;
19011895

@@ -2004,11 +1998,10 @@ TEST(daemon_application_sensitive_root_blocks_watch_but_preserves_controls) {
20041998
cbm_daemon_runtime_application_session_t *approved_session =
20051999
application ? app_test_open(&callbacks, 4035) : NULL;
20062000

2007-
bool sensitive_initialized =
2008-
app_test_initialize_session(&callbacks, sensitive_session, sensitive, NULL, NULL);
2001+
bool sensitive_initialized = app_test_initialize_session(
2002+
&callbacks, sensitive_session, sensitive, NULL, NULL);
20092003
bool sensitive_blocked = sensitive_initialized && cbm_watcher_watch_count(watcher) == 0;
2010-
bool ordinary_initialized =
2011-
app_test_initialize_session(&callbacks, ordinary_session, ordinary, NULL, NULL);
2004+
bool ordinary_initialized = app_test_initialize_session(&callbacks, ordinary_session, ordinary, NULL, NULL);
20122005
bool ordinary_watched = ordinary_initialized && cbm_watcher_watch_count(watcher) == 1;
20132006
if (ordinary_session) {
20142007
callbacks.session_close(callbacks.context, ordinary_session);
@@ -2020,8 +2013,7 @@ TEST(daemon_application_sensitive_root_blocks_watch_but_preserves_controls) {
20202013
bool approved = ordinary_released && cbm_workspace_grant_add(cache, sensitive, sensitive, true,
20212014
grant_error, sizeof(grant_error));
20222015
bool approved_initialized =
2023-
approved &&
2024-
app_test_initialize_session(&callbacks, approved_session, sensitive, NULL, NULL);
2016+
approved && app_test_initialize_session(&callbacks, approved_session, sensitive, NULL, NULL);
20252017
bool approved_watched = approved_initialized && cbm_watcher_watch_count(watcher) == 1;
20262018

20272019
if (sensitive_session) {
@@ -2263,8 +2255,8 @@ TEST(daemon_application_auto_index_retries_transient_busy_admission) {
22632255
cbm_daemon_runtime_application_session_t *session =
22642256
application ? app_test_open(&callbacks, 4191) : NULL;
22652257
int bg_baseline = cbm_daemon_application_background_initializes_for_test();
2266-
bool initialized = occupied_admitted &&
2267-
app_test_initialize_session(&callbacks, session, auto_root, NULL, NULL);
2258+
bool initialized =
2259+
occupied_admitted && app_test_initialize_session(&callbacks, session, auto_root, NULL, NULL);
22682260
bool admission_evaluated = app_wait_for_background_initializes(bg_baseline + 1);
22692261
bool initially_deferred = initialized && admission_evaluated && atomic_load(&fake.starts) == 1;
22702262

@@ -2404,12 +2396,8 @@ TEST(daemon_application_coalesces_semantically_identical_index_requests) {
24042396
ASSERT_EQ(atomic_load(&fake.destroys), 1);
24052397
ASSERT_EQ(requests[0].status, CBM_DAEMON_RUNTIME_APPLICATION_OK);
24062398
ASSERT_EQ(requests[1].status, CBM_DAEMON_RUNTIME_APPLICATION_OK);
2407-
ASSERT_TRUE(
2408-
requests[0].response &&
2409-
app_test_response_contains(requests[0].response, requests[0].response_length, "indexed"));
2410-
ASSERT_TRUE(
2411-
requests[1].response &&
2412-
app_test_response_contains(requests[1].response, requests[1].response_length, "indexed"));
2399+
ASSERT_TRUE(requests[0].response && app_test_response_contains(requests[0].response, requests[0].response_length, "indexed"));
2400+
ASSERT_TRUE(requests[1].response && app_test_response_contains(requests[1].response, requests[1].response_length, "indexed"));
24132401

24142402
free(requests[0].response);
24152403
free(requests[1].response);
@@ -2539,9 +2527,7 @@ TEST(daemon_application_fresh_request_does_not_reuse_terminal_subscribed_job) {
25392527
ASSERT_TRUE(stopped);
25402528
for (size_t i = 0; i < PRIOR_SUBSCRIBERS; i++) {
25412529
ASSERT_EQ(prior[i].status, CBM_DAEMON_RUNTIME_APPLICATION_OK);
2542-
ASSERT_TRUE(prior[i].response &&
2543-
app_test_response_contains(prior[i].response, prior[i].response_length,
2544-
"stale-generation"));
2530+
ASSERT_TRUE(prior[i].response && app_test_response_contains(prior[i].response, prior[i].response_length, "stale-generation"));
25452531
free(prior[i].response);
25462532
}
25472533

@@ -2641,8 +2627,7 @@ TEST(daemon_application_request_cancel_detaches_only_one_coalesced_subscriber) {
26412627
bool stopped = application && cbm_daemon_application_shutdown(application, APP_TEST_TIMEOUT_MS);
26422628
cbm_daemon_application_free(application);
26432629
bool second_indexed =
2644-
requests[1].response &&
2645-
app_test_response_contains(requests[1].response, requests[1].response_length, "indexed");
2630+
requests[1].response && app_test_response_contains(requests[1].response, requests[1].response_length, "indexed");
26462631
int final_cancels = atomic_load(&fake.cancels);
26472632
int final_starts = atomic_load(&fake.starts);
26482633
int final_destroys = atomic_load(&fake.destroys);
@@ -3567,8 +3552,7 @@ TEST(daemon_application_serializes_adr_mutation_with_index_job) {
35673552
bool stopped = application && cbm_daemon_application_shutdown(application, APP_TEST_TIMEOUT_MS);
35683553
cbm_daemon_application_free(application);
35693554
bool adr_response_updated =
3570-
adr_request.response &&
3571-
app_test_response_contains(adr_request.response, adr_request.response_length, "updated");
3555+
adr_request.response && app_test_response_contains(adr_request.response, adr_request.response_length, "updated");
35723556

35733557
free(index_request.response);
35743558
free(adr_request.response);
@@ -4568,11 +4552,9 @@ TEST(daemon_application_queues_explicit_index_behind_physical_job_limit) {
45684552
* admitted and complete on its own. */
45694553
atomic_store(&fake.allow_completion, true);
45704554
bool request_joined = request_started && cbm_thread_join(&request_thread) == 0;
4571-
bool queued_succeeded =
4572-
request_joined && queued.status == CBM_DAEMON_RUNTIME_APPLICATION_OK && queued.response &&
4573-
app_test_response_contains(queued.response, queued.response_length, "indexed") &&
4574-
!app_test_response_contains(queued.response, queued.response_length,
4575-
"physical index job limit");
4555+
bool queued_succeeded = request_joined && queued.status == CBM_DAEMON_RUNTIME_APPLICATION_OK &&
4556+
queued.response && app_test_response_contains(queued.response, queued.response_length, "indexed") &&
4557+
!app_test_response_contains(queued.response, queued.response_length, "physical index job limit");
45764558

45774559
callbacks.session_close(callbacks.context, session);
45784560
bool stopped = application && cbm_daemon_application_shutdown(application, APP_TEST_TIMEOUT_MS);
@@ -4735,16 +4717,20 @@ TEST(daemon_application_rejects_clean_exit_when_process_tree_is_not_contained) {
47354717
PASS();
47364718
}
47374719

4720+
47384721
TEST(daemon_application_index_args_compare_repo_path_separator_equivalently) {
47394722
ASSERT_TRUE(cbm_daemon_application_index_args_equal_for_test(
4740-
"{\"repo_path\":\"C:\\\\repos\\\\cbm\"}", "{\"repo_path\":\"C:/repos/cbm\"}"));
4723+
"{\"repo_path\":\"C:\\\\repos\\\\cbm\"}",
4724+
"{\"repo_path\":\"C:/repos/cbm\"}"));
47414725
ASSERT_TRUE(cbm_daemon_application_index_args_equal_for_test(
47424726
"{\"repo_path\":\"C:\\\\repos\\\\cbm\",\"mode\":\"full\"}",
47434727
"{\"mode\":\"full\",\"repo_path\":\"C:/repos/cbm\"}"));
47444728
ASSERT_FALSE(cbm_daemon_application_index_args_equal_for_test(
4745-
"{\"repo_path\":\"C:\\\\repos\\\\cbm\"}", "{\"repo_path\":\"C:/repos/cbm2\"}"));
4729+
"{\"repo_path\":\"C:\\\\repos\\\\cbm\"}",
4730+
"{\"repo_path\":\"C:/repos/cbm2\"}"));
47464731
ASSERT_FALSE(cbm_daemon_application_index_args_equal_for_test(
4747-
"{\"repo_path\":\"C:\\\\repos\\\\cbm\"}", "{\"repo_path\":\"C:/repos/cbm/sub\"}"));
4732+
"{\"repo_path\":\"C:\\\\repos\\\\cbm\"}",
4733+
"{\"repo_path\":\"C:/repos/cbm/sub\"}"));
47484734
ASSERT_FALSE(cbm_daemon_application_index_args_equal_for_test(
47494735
"{\"repo_path\":\"C:\\\\repos\\\\cbm\",\"mode\":\"incremental\"}",
47504736
"{\"repo_path\":\"C:/repos/cbm\"}"));

0 commit comments

Comments
 (0)