Skip to content

Commit 05e0cca

Browse files
test(mcp): tighten systemic failure test assertions and sweep phase comments
- Return IDXPAR_NULL_RESP if supervised run produces NULL response - Pin exact {"status":"error","outcome":"exit_nonzero"} JSON contract in systemic test - Update phase comments in mcp.c to document "error" alongside "crash" and "hang" Signed-off-by: Shashwat Mishra <shashwat78.nits@gmail.com>
1 parent 6554a06 commit 05e0cca

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

‎src/mcp/mcp.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7756,7 +7756,7 @@ static bool supervisor_suspect_contains(char **s, int n, const char *rel) {
77567756
return false;
77577757
}
77587758

7759-
/* Append one quarantine entry "rel\tphase\n" (phase = "crash"|"hang") to the
7759+
/* Append one quarantine entry "rel\tphase\n" (phase = "crash"|"hang"|"error") to the
77607760
* quarantine list. The worker's loader parses this back and reports the skip's
77617761
* phase in skipped[]; a bare "rel" line is still tolerated there (defaults crash). */
77627762
static bool supervisor_append_quarantine(const char *path, const char *rel, const char *phase) {
@@ -7790,7 +7790,7 @@ cbm_mcp_supervised_result_disposition_t cbm_mcp_supervised_result_disposition(
77907790
* - the worker's own response on a clean first run (the common path);
77917791
* - after a crash/hang, the response from a clean single-threaded RECOVERY run
77927792
* that quarantines the culprit file(s) — status="indexed" with them listed in
7793-
* skipped[] as phase="crash"/"hang", and the good files indexed;
7793+
* skipped[] as phase="crash"/"hang"/"error", and the good files indexed;
77947794
* - a best-effort PARTIAL index (one final quarantine-only run) if the recovery
77957795
* loop cannot converge but at least one file was quarantined;
77967796
* - a contained-failure response only if even that cannot produce a clean run.
@@ -7839,7 +7839,7 @@ static char *index_run_supervised(cbm_mcp_server_t *srv, const char *args) {
78397839
* (for a hang the oldest still-open file IS the stuck one; for a crash
78407840
* it is the longest-running suspect — the best single deterministic
78417841
* pick). A clean run then indexes the good files and reports the
7842-
* quarantined ones as phase="crash"/"hang" skips via the ordinary
7842+
* quarantined ones as phase="crash"/"hang"/"error" skips via the ordinary
78437843
* Stage-2 skip plumbing. The old design re-ran SINGLE-THREADED to keep
78447844
* one exact marker; at scale that fell into the sequential crawl, went
78457845
* quiet, was killed as a hang mid-pass, and the stale marker got FOUR

‎tests/test_mcp.c‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10048,6 +10048,8 @@ enum {
1004810048
IDXPAR_NO_QUARANTINE = 64, /* crasher missing from skipped[] */
1004910049
IDXPAR_INNOCENT_HIT = 65, /* a good file was quarantined/skipped */
1005010050
IDXPAR_GOOD_MISSING = 66, /* good file's Function absent from the store */
10051+
IDXPAR_NOT_ERROR = 67, /* systemic failure did not report status error */
10052+
IDXPAR_OUTCOME_WRONG = 68, /* systemic failure outcome is not exit_nonzero */
1005110053
};
1005210054

1005310055
#ifndef _WIN32
@@ -10176,13 +10178,24 @@ static int idxpar_systemic_exit_nonzero_give_up_check(const char *repo_dir) {
1017610178
cbm_unsetenv("CBM_TEST_EXIT_ON");
1017710179

1017810180
if (!resp) {
10179-
return IDXPAR_OK;
10181+
return IDXPAR_NULL_RESP;
1018010182
}
10181-
bool gave_up = response_contains_json_fragment(resp, "\"status\":\"gave_up\"") ||
10182-
response_contains_json_fragment(resp, "\"status\":\"error\"") ||
10183-
response_contains_json_fragment(resp, "\"action\":\"give_up\"");
10183+
bool is_error = response_contains_json_fragment(resp, "\"status\":\"error\"");
10184+
bool is_exit_nonzero = response_contains_json_fragment(resp, "\"outcome\":\"exit_nonzero\"");
10185+
bool innocent_hit =
10186+
strstr(resp, "idxpar_good_a.py") != NULL || strstr(resp, "idxpar_good_b.py") != NULL;
1018410187
free(resp);
10185-
return gave_up ? IDXPAR_OK : 99;
10188+
10189+
if (!is_error) {
10190+
return IDXPAR_NOT_ERROR;
10191+
}
10192+
if (!is_exit_nonzero) {
10193+
return IDXPAR_OUTCOME_WRONG;
10194+
}
10195+
if (innocent_hit) {
10196+
return IDXPAR_INNOCENT_HIT;
10197+
}
10198+
return IDXPAR_OK;
1018610199
}
1018710200
#endif /* !_WIN32 */
1018810201

0 commit comments

Comments
 (0)