Derive tier siblings only from the exact shipped Verify basename. This keeps * vendor-specific suffixes such as .agent.md, .toml, and .json intact. */
| 7524 | /* Derive tier siblings only from the exact shipped Verify basename. This keeps |
| 7525 | * vendor-specific suffixes such as .agent.md, .toml, and .json intact. */ |
| 7526 | static int cbm_tiered_profile_path(const char *verify_path, cbm_graph_tier_t tier, char *output, |
| 7527 | size_t output_size) { |
| 7528 | static const char verify_basename[] = "codebase-memory"; |
| 7529 | if (!verify_path || !verify_path[0] || !output || output_size == 0U) { |
| 7530 | return CLI_ERR; |
| 7531 | } |
| 7532 | const char *basename = strrchr(verify_path, '/'); |
| 7533 | const char *backslash = strrchr(verify_path, '\\'); |
| 7534 | if (backslash && (!basename || backslash > basename)) { |
| 7535 | basename = backslash; |
| 7536 | } |
| 7537 | basename = basename ? basename + 1U : verify_path; |
| 7538 | size_t verify_len = strlen(verify_basename); |
| 7539 | if (strncmp(basename, verify_basename, verify_len) != 0 || basename[verify_len] != '.') { |
| 7540 | return CLI_ERR; |
| 7541 | } |
| 7542 | const char *slug = cbm_graph_tier_slug(tier); |
| 7543 | if (!slug) { |
| 7544 | return CLI_ERR; |
| 7545 | } |
| 7546 | const char *suffix = basename + verify_len; |
| 7547 | size_t directory_len = (size_t)(basename - verify_path); |
| 7548 | size_t slug_len = strlen(slug); |
| 7549 | size_t suffix_len = strlen(suffix); |
| 7550 | if (directory_len >= output_size || slug_len > output_size - directory_len - 1U || |
| 7551 | suffix_len > output_size - directory_len - slug_len - 1U) { |
| 7552 | return CLI_ERR; |
| 7553 | } |
| 7554 | memcpy(output, verify_path, directory_len); |
| 7555 | memcpy(output + directory_len, slug, slug_len); |
| 7556 | memcpy(output + directory_len + slug_len, suffix, suffix_len + 1U); |
| 7557 | return CLI_OK; |
| 7558 | } |
| 7559 | |
| 7560 | static cbm_graph_access_t cbm_tiered_profile_access(cbm_graph_profile_dialect_t dialect) { |
| 7561 | return cbm_graph_dialect_direct_capable(dialect) ? CBM_GRAPH_ACCESS_DIRECT |
no test coverage detected