import sys, os sys.path.insert(0, os.path.abspath(".")) from scratch.detailed_param_check import report artifact_path = "/home/creserver/.gemini/antigravity-cli/brain/02284dc6-4f37-49c2-83dc-cd0ef5262f66/param_mismatch_analysis_report.md" md_lines = [] md_lines.append("# API Parameter & Properties Audit: Nexus vs New Documentation MD") md_lines.append("") md_lines.append("> [!IMPORTANT]") md_lines.append("> This report audits all parameter data and properties shown on **Nexus API Documentation** (`data.json` / `index.html`) against the newly updated **[FASTAPI_BACKEND_API_DOCUMENTATION.md](file:///home/creserver/Desktop/Vaishno_workspace/Unified_Dashboard_Suite_Go/web/docs/FASTAPI_BACKEND_API_DOCUMENTATION.md)**.") md_lines.append("") md_lines.append("## Executive Summary") md_lines.append("") md_lines.append("| Metric | Count |") md_lines.append("| :--- | :--- |") md_lines.append("| **Total Nexus APIs Audited** | 69 APIs (88 callable endpoints) |") md_lines.append("| **Total MD Sections Audited** | 73 sections |") md_lines.append("| **APIs Matching Exactly** | 12 APIs |") md_lines.append("| **APIs with Differences / Mismatches** | 57 APIs |") md_lines.append("| **1. Required vs. Optional Mismatches** | 21 parameters |") md_lines.append("| **2. Parameter Type Mismatches** | 5 parameters |") md_lines.append("| **3. Default Value Discrepancies** | 34 parameters |") md_lines.append("| **4. Primary Name vs. Alias Differences** | 22 parameters |") md_lines.append("| **5. Missing on Nexus (in MD, absent from Nexus)** | 134 parameters |") md_lines.append("| **6. Missing in MD (on Nexus, absent from MD)** | 88 parameters |") md_lines.append("| **7. Missing Services / Entire Route Discrepancies** | 2 services |") md_lines.append("") md_lines.append("---") md_lines.append("") # Section 1: Required vs Optional Mismatches md_lines.append("## 1. Required vs. Optional Mismatches (21 Parameters)") md_lines.append("Parameters where Nexus and the new Markdown documentation disagree on whether the field is **Required** or **Optional**.") md_lines.append("") md_lines.append("| # | Service Group | API / Endpoint | Parameter | Shown on Nexus | Documented in New MD | Discrepancy Analysis |") md_lines.append("| :- | :--- | :--- | :--- | :--- | :--- | :--- |") req_idx = 1 for r in report: for d in r["top_level_diffs"]: if d["type"] == "REQUIRED_MISMATCH": p = d["param"] # get nexus & md values sec = r["section"] api = r["api_title"] if "Nexus has required=False" in d["detail"]: nexus_req_str = "**Optional** (`rq: false`)" md_req_str = "**Required**" analysis_str = "Nexus marked optional, but MD documents as Required" else: nexus_req_str = "**Required** (`rq: true`)" md_req_str = "**Optional**" analysis_str = "Nexus strictly requires, but MD documents as Optional" md_lines.append(f"| {req_idx} | {sec} | `{api}` | `{p}` | {nexus_req_str} | {md_req_str} | {analysis_str} |") req_idx += 1 for s in r.get("sub_ep_diffs", []): for d in s["diffs"]: if d["type"] == "REQUIRED_MISMATCH": p = d["param"] sec = r["section"] api = f"{r['api_title']} → `{s['sub_title']}`" if "Nexus has required=False" in d["detail"]: nexus_req_str = "**Optional** (`rq: false`)" md_req_str = "**Required**" analysis_str = "Nexus sub-endpoint marked optional, but MD documents as Required" else: nexus_req_str = "**Required** (`rq: true`)" md_req_str = "**Optional**" analysis_str = "Nexus sub-endpoint strictly requires, but MD documents as Optional" md_lines.append(f"| {req_idx} | {sec} | {api} | `{p}` | {nexus_req_str} | {md_req_str} | {analysis_str} |") req_idx += 1 md_lines.append("") md_lines.append("---") md_lines.append("") # Section 2: Type Mismatches md_lines.append("## 2. Parameter Type Mismatches (5 Parameters)") md_lines.append("Data types that differ between what Nexus displays and what is specified in the new MD.") md_lines.append("") md_lines.append("| # | Service Group | API / Endpoint | Parameter | Type on Nexus | Type in New MD | Notes / Impact |") md_lines.append("| :- | :--- | :--- | :--- | :--- | :--- | :--- |") type_idx = 1 for r in report: for d in r["top_level_diffs"]: if d["type"] == "TYPE_MISMATCH": md_lines.append(f"| {type_idx} | {r['section']} | `{r['api_title']}` | `{d['param']}` | `{d['detail'].split('Nexus displays ')[1].split(' (norm')[0]}` | `{d['detail'].split('documents ')[1].split(' (norm')[0]}` | Type representation discrepancy |") type_idx += 1 for s in r.get("sub_ep_diffs", []): for d in s["diffs"]: if d["type"] == "TYPE_MISMATCH": md_lines.append(f"| {type_idx} | {r['section']} | `{r['api_title']} → {s['sub_title']}` | `{d['param']}` | `{d['detail'].split('Nexus displays ')[1].split(' (norm')[0]}` | `{d['detail'].split('documents ')[1].split(' (norm')[0]}` | Sub-endpoint type representation discrepancy |") type_idx += 1 md_lines.append("") md_lines.append("---") md_lines.append("") # Section 3: Default Value Discrepancies md_lines.append("## 3. Default Value Discrepancies (34 Parameters)") md_lines.append("Mismatches where the default parameter value shown in Nexus does not match the default specified in the new Markdown.") md_lines.append("") md_lines.append("| # | API | Parameter | Nexus Default | New MD Default | Impact |") md_lines.append("| :- | :--- | :--- | :--- | :--- | :--- |") df_idx = 1 for r in report: for d in r["top_level_diffs"]: if d["type"] == "DEFAULT_MISMATCH": nex_def = d["detail"].split("default=")[1].split(",")[0] md_def = d["detail"].split("documents default=")[1] md_lines.append(f"| {df_idx} | `{r['api_title']}` | `{d['param']}` | `{nex_def}` | `{md_def}` | Default preset / dimension mismatch |") df_idx += 1 for s in r.get("sub_ep_diffs", []): for d in s["diffs"]: if d["type"] == "DEFAULT_MISMATCH": nex_def = d["detail"].split("default=")[1].split(",")[0] md_def = d["detail"].split("documents default=")[1] md_lines.append(f"| {df_idx} | `{r['api_title']} → {s['sub_title']}` | `{d['param']}` | `{nex_def}` | `{md_def}` | Sub-endpoint default mismatch |") df_idx += 1 md_lines.append("") md_lines.append("---") md_lines.append("") # Section 4: Name & Alias Differences md_lines.append("## 4. Parameter Primary Name vs. Alias Discrepancies (22 Parameters)") md_lines.append("Cases where the new MD uses one field name (e.g., `image0`, `gender`, `effectId`), while Nexus has registered another name as primary with an alias.") md_lines.append("") md_lines.append("| # | API | Name in New MD | Primary Name on Nexus | Nexus Alias | Recommendation |") md_lines.append("| :- | :--- | :--- | :--- | :--- | :--- |") alias_idx = 1 for r in report: for d in r["top_level_diffs"]: if d["type"] == "NAME_ALIAS_DIFFERENCE": md_name = d["param"] detail = d["detail"] nex_pri = detail.split("primary name '")[1].split("'")[0] nex_al = detail.split("with alias '")[1].split("')")[0] md_lines.append(f"| {alias_idx} | `{r['api_title']}` | `{md_name}` | `{nex_pri}` | `{nex_al}` | Align primary name or preserve alias fallback |") alias_idx += 1 for s in r.get("sub_ep_diffs", []): for d in s["diffs"]: if d["type"] == "NAME_ALIAS_DIFFERENCE": md_name = d["param"] detail = d["detail"] nex_pri = detail.split("primary name '")[1].split("'")[0] nex_al = detail.split("with alias '")[1].split("')")[0] md_lines.append(f"| {alias_idx} | `{r['api_title']} → {s['sub_title']}` | `{md_name}` | `{nex_pri}` | `{nex_al}` | Sub-endpoint alias alignment |") alias_idx += 1 md_lines.append("") md_lines.append("---") md_lines.append("") # Section 5: Missing on Nexus (Documented in MD but absent from Nexus) md_lines.append("## 5. Parameters Documented in New MD but MISSING on Nexus (134 Parameters)") md_lines.append("These are rich parameters (e.g. generation hyperparameters `strength`, `steps`, `guidance_scale`, `seed`, `output_format` in SDXL, or telemetry client fields in Feedback/Reports) that are documented in the new MD but are not currently populated or exposed in Nexus (`data.json`).") md_lines.append("") md_lines.append("| API / Endpoint | Missing Parameters on Nexus |") md_lines.append("| :--- | :--- |") missing_on_nex_map = {} for r in report: for d in r["top_level_diffs"]: if d["type"] == "MISSING_ON_NEXUS": missing_on_nex_map.setdefault(r["api_title"], []).append(d["param"]) for api_name, p_list in missing_on_nex_map.items(): md_lines.append(f"| `{api_name}` | {', '.join([f'`{p}`' for p in p_list])} |") md_lines.append("") md_lines.append("---") md_lines.append("") # Section 6: Missing in MD (Shown on Nexus, absent from MD) md_lines.append("## 6. Parameters Shown on Nexus but MISSING in New MD (88 Parameters)") md_lines.append("These parameters exist and are actively displayed on Nexus, but were left out of the Markdown tables in the new MD.") md_lines.append("") md_lines.append("| API / Endpoint | Parameters Missing from New MD Table | Root Cause |") md_lines.append("| :--- | :--- | :--- |") missing_in_md_map = {} for r in report: for d in r["top_level_diffs"]: if d["type"] == "MISSING_IN_MD": missing_in_md_map.setdefault(r["api_title"], []).append(d["param"]) for api_name, p_list in missing_in_md_map.items(): sec_p = [p for p in p_list if "secret" in p.lower()] other_p = [p for p in p_list if "secret" not in p.lower()] cause = "Omitted auth `secretKey`" if sec_p and not other_p else ("Sub-endpoint / tuning parameters omitted from MD table" if other_p else "Omitted fields") md_lines.append(f"| `{api_name}` | {', '.join([f'`{p}`' for p in p_list])} | {cause} |") md_lines.append("") md_lines.append("---") md_lines.append("") # Section 7: Structural Discrepancies md_lines.append("## 7. Structural & Service Route Discrepancies") md_lines.append("") md_lines.append("1. **`Credits_Limit` (FLUX Kontext Credits API):**") md_lines.append(" - **Nexus:** Contains an active card with 2 sub-endpoints (`/credits/use` and `/credits/admin/api/accounts`) and parameters (`account_id`, `app_id`, `feature_id`, `user_id`, `amount`, `name`, `initial_credits`, `monthly_refill`).") md_lines.append(" - **New MD:** Entirely missing from the Markdown document.") md_lines.append("") md_lines.append("2. **`hair_style_changer` Sub-Endpoint (FLUX Fill):**") md_lines.append(" - **Nexus:** Categorized under `Stable_Diffusion_Hair_Color_Changer_And_Hair_Style_Changer` with 2 sub-endpoints (`hair_color_changer` with `colorId`, and `hair_style_changer` with `effectId`).") md_lines.append(" - **New MD:** Section 1.1 only documents `hair_color_changer` (`colorId`). The hairstyle changer is only documented under Section 2.5 `Hairstyles` (FLUX Kontext).") md_lines.append("") md_lines.append("3. **Legacy `Cartoon Effects` (`Cre_Aws_Cartoon_Model`):**") md_lines.append(" - **Nexus:** Active card displaying `/cartoon_effects/image/` with `image` and `secretKey`.") md_lines.append(" - **New MD:** Explicitly marked as **NOT FOUND** in FastAPI router codebase with warning to use CartoonGAN / SD New Cartoon.") md_lines.append("") md_lines.append("4. **Hair Segmentation YOLO + SAM Route Path:**") md_lines.append(" - **Nexus:** Categorized as sub-endpoint 2 of `Cre_Hair_Detection_Segment_Model` at `https://apigp0006.creinnovations.in/apis/mlm/hair_segmentation/yolo_sam/`.") md_lines.append(" - **New MD:** Split as a standalone section 3.14 at `https://apigp0006.creinnovations.in/apis/mlm/hair_segmentation_yolo_sam/image/`.") md_lines.append("") md_lines.append("5. **SD 1.5 Caricature Effects Double Slash:**") md_lines.append(" - **Nexus:** Full URL has double image path `.../stable_diffusion_caricature_effects/image/image/`.") md_lines.append(" - **New MD:** Section 3.36 uses single image path `.../stable_diffusion_caricature_effects/image/`.") md_lines.append("") output_content = "\n".join(md_lines) with open(artifact_path, "w") as f: f.write(output_content) print(f"Artifact written successfully to {artifact_path} ({len(output_content)} bytes)")