Derive tier siblings only from the exact shipped Verify basename. This keeps * vendor-specific suffixes such as .agent.md, .toml, and .json intact. */
| 7611 | /* Derive tier siblings only from the exact shipped Verify basename. This keeps |
| 7612 | * vendor-specific suffixes such as .agent.md, .toml, and .json intact. */ |
| 7613 | static int cbm_tiered_profile_path(const char *verify_path, cbm_graph_tier_t tier, char *output, |
| 7614 | size_t output_size) { |
| 7615 | static const char verify_basename[] = "codebase-memory"; |
| 7616 | if (!verify_path || !verify_path[0] || !output || output_size == 0U) { |
| 7617 | return CLI_ERR; |
| 7618 | } |
| 7619 | const char *basename = strrchr(verify_path, '/'); |
| 7620 | const char *backslash = strrchr(verify_path, '\\'); |
| 7621 | if (backslash && (!basename || backslash > basename)) { |
| 7622 | basename = backslash; |
| 7623 | } |
| 7624 | basename = basename ? basename + 1U : verify_path; |
| 7625 | size_t verify_len = strlen(verify_basename); |
| 7626 | if (strncmp(basename, verify_basename, verify_len) != 0 || basename[verify_len] != '.') { |
| 7627 | return CLI_ERR; |
| 7628 | } |
| 7629 | const char *slug = cbm_graph_tier_slug(tier); |
| 7630 | if (!slug) { |
| 7631 | return CLI_ERR; |
| 7632 | } |
| 7633 | const char *suffix = basename + verify_len; |
| 7634 | size_t directory_len = (size_t)(basename - verify_path); |
| 7635 | size_t slug_len = strlen(slug); |
| 7636 | size_t suffix_len = strlen(suffix); |
| 7637 | if (directory_len >= output_size || slug_len > output_size - directory_len - 1U || |
| 7638 | suffix_len > output_size - directory_len - slug_len - 1U) { |
| 7639 | return CLI_ERR; |
| 7640 | } |
| 7641 | memcpy(output, verify_path, directory_len); |
| 7642 | memcpy(output + directory_len, slug, slug_len); |
| 7643 | memcpy(output + directory_len + slug_len, suffix, suffix_len + 1U); |
| 7644 | return CLI_OK; |
| 7645 | } |
| 7646 | |
| 7647 | static cbm_graph_access_t cbm_tiered_profile_access(cbm_graph_profile_dialect_t dialect) { |
| 7648 | return cbm_graph_dialect_direct_capable(dialect) ? CBM_GRAPH_ACCESS_DIRECT |
no test coverage detected