Skip to content

fix(debug-logger): 8 deploy-time hot-fixes from first smoke test (Jude Dev)#42

Merged
judeper merged 1 commit into
mainfrom
fix/deploy-time-hotfixes
May 21, 2026
Merged

fix(debug-logger): 8 deploy-time hot-fixes from first smoke test (Jude Dev)#42
judeper merged 1 commit into
mainfrom
fix/deploy-time-hotfixes

Conversation

@judeper
Copy link
Copy Markdown
Owner

@judeper judeper commented May 21, 2026

End-to-end smoke test against Jude Dev discovered 8 bugs in the autonomous-build artifacts. All fixes applied and verified — final smoke run wrote 2 rows to cr_agenttrace successfully (env var ON, full Pattern A flow path: REQUEST → env-var read → trace label → payload truncate → Dataverse insert).

Hot-fixes

Script bugs

  1. provision-environment.ps1 — PAC CLI 2.x compat. pac admin list-environments returns Not a valid command with exit code 0 in PAC 2.7, so Basher's prior \0 -ne 0 fallback heuristic never triggered. Added a Test-LooksLikeJson sniff (output must start with [ or {) before parsing.
  2. provision-environment.ps1 — skip UniqueIdentifier columns. Dataverse Web API rejects custom UniqueIdentifier attribute creation with 0x80040203 (cannot be created through the SDK). The platform auto-creates <tablename>id as the PK; documented columns like cr_traceid are informational only. Provision loop now skips them.
  3. deploy-solution.ps1 — MDA precheck path. Was CanvasApps/AgentDebugConsole_* (legacy MDA folder pattern). Modern pac solution clone unpacks MDAs under src/AppModules/cr_AgentDebugConsole/. Also fixed: Get-ChildItem -Directory returns CHILD directories of the path (none — MDA folder only contains XML files), not the path itself. Replaced with Test-Path -PathType Container.
  4. deploy-solution.ps1 — dynamic *.cdsproj discovery. PAC clone produces <SolutionName>.cdsproj (e.g. CopilotAgentDebugLogger.cdsproj); was hard-coded to Solution.cdsproj. Glob now handles both shapes.

Flow bugs (both verified via Flow Management API errors)

  1. flow-1-log-agent-trace.json — Get_DebugLoggerEnabled operationId. GetEnvironmentVariableValue is a fabricated operationId that doesn't exist on the Dataverse connector. Replaced with ListRecords + \ + \ on environmentvariabledefinitions (mirrors the tool flow which was already correct). Compose_EnabledFlag updated accordingly.
  2. flow-1 AND tool-log-agent-trace .json — Compose_PayloadTruncated uses left(). left() is a Power Apps Canvas function, NOT a Workflow Definition Language function. WDL has no left(). Replaced with substring(string(x), 0, min(900000, length(string(x)))) per the WDL grammar.
  3. flow-1 AND tool-log-agent-trace .json — drop item/cr_sourcename. Workaround for the schema collision in [child-flow] child-flow: author flow-1-log-agent-trace.json (manual trigger) #8; the trace label already encodes source/step_name via the concat() Compose.

Schema

  1. agenttrace-table.json — cr_sourcename collision documented. Dataverse auto-generates a Virtual column named cr_sourcename as the formatted-value reflection of the cr_source Picklist. This blocks creation of the documented Text(200) and prevents flows from writing to it. Added a KNOWN COLLISION note in the column description. Follow-up PR will rename to cr_originname and re-add the write to both flows.

Source restructure

  1. src/Solutions/ — Microsoft-canonical layout. Replaced Frank's R2 scaffold (empty Solution.cdsproj + other/{Solution.xml,Customizations.xml} + CanvasApps/.gitkeep) with the layout produced by pac solution clone --name CopilotAgentDebugLogger: src/Entities/, src/AppModules/, src/AppModuleSiteMaps/, src/Other/, src/environmentvariabledefinitions/, CopilotAgentDebugLogger.cdsproj + .gitignore. New cdsproj uses old-style <Import> rather than the SDK alias but builds cleanly with dotnet build. The MDA + Entity XML are now in source (from Jude's Phase-0 authoring → pac solution clone extraction).

Validation

  • dotnet build src/Solutions/CopilotAgentDebugLogger.cdsproj → exit 0, produces bin/Debug/CopilotAgentDebugLogger.zip
  • pwsh provision-environment.ps1 -EnvironmentId <Jude Dev> → exit 0 (idempotent — full creation in first run, all reused on second)
  • pwsh deploy-solution.ps1 -EnvironmentId <Jude Dev> -SkipInjectFlowGuid → exit 0
  • End-to-end smoke test (programmatic flow create via Flow Management API + manual trigger → row insert → MDA visibility) ✅
  • PII scan: clean across all touched files (env IDs in PR body / scripts use <env-id> placeholders)

Decisions in force

  • D8 (unmanaged-only v1) — preserved
  • D15 (PII discipline) — preserved
  • D14 needs-human-review gate — Jude is operator-approving this PR inline; he ran the smoke test and verified each fix

Follow-up backlog (separate PRs)

  • Rename cr_sourcenamecr_originname (re-add to both flows + provision; remove KNOWN COLLISION note from schema)
  • Add a deploy-flows.ps1 script that programmatically creates flow-1-log-agent-trace via Flow Management API (validated to work; the ad-hoc scripts live in coordinator session-state and are not in this PR per Jude's ask)

…de Dev smoke test

Discovered while running provision + deploy + a programmatic
Flow-Management-API child-flow create end-to-end against Jude Dev.
End-to-end smoke test now passes (two cr_agenttrace rows written
from a manual flow trigger with cr_DebugLoggerEnabled=true).

Script fixes:
1. provision-environment.ps1 — PAC CLI 2.x compat:
   'pac admin list-environments' returns 'Not a valid command' with
   exit code 0, so the prior 'exit non-zero -> fallback' heuristic
   never triggered. Added Test-LooksLikeJson sniff that requires
   output to start with '[' or '{' before parsing.
2. provision-environment.ps1 — skip UniqueIdentifier columns:
   Dataverse Web API rejects custom UniqueIdentifier attribute
   creation with 0x80040203 ('cannot be created through the SDK').
   The platform auto-creates <tablename>id as the PK Guid, so
   schema-documented UniqueIdentifier columns (cr_traceid) are
   informational only.
3. deploy-solution.ps1 — MDA precheck path:
   Was 'CanvasApps/AgentDebugConsole_*' (legacy MDA folder).
   Modern 'pac solution clone' unpacks MDAs under
   'src/AppModules/cr_AgentDebugConsole/'. Also switched from
   'Get-ChildItem -Directory' (returns CHILD dirs of the path,
   not the path itself) to 'Test-Path -PathType Container'.
4. deploy-solution.ps1 — dynamic cdsproj discovery:
   Glob '*.cdsproj' instead of hard-coded 'Solution.cdsproj'.
   PAC clone produces '<SolutionName>.cdsproj'.

Flow fixes:
5. flow-1-log-agent-trace.json — Get_DebugLoggerEnabled operationId:
   'GetEnvironmentVariableValue' doesn't exist on the Dataverse
   connector. Replaced with ListRecords + filter on
   environmentvariabledefinitions + expand to
   environmentvariabledefinition_environmentvariablevalue
   (mirrors the tool flow which was already correct).
   Compose_EnabledFlag updated to read from actions(...)?['outputs']
   ?['body']?['value']?[0]?['environmentvariabledefinition_environmentvariablevalue']?[0]?['value']
   with fallback to defaultvalue then 'false'.
6. flow-1 AND tool-log-agent-trace .json — Compose_PayloadTruncated:
   left() is a Power Apps Canvas function, NOT a Workflow Definition
   Language function. WDL has no left(). Replaced with
   substring(string(x), 0, min(900000, length(string(x)))).
7. flow-1 AND tool-log-agent-trace .json — drop item/cr_sourcename:
   Workaround for the schema collision below; the trace label
   already encodes source/step_name via concat().

Schema:
8. agenttrace-table.json — cr_sourcename collision documented:
   Dataverse auto-generates a Virtual column named cr_sourcename
   as the formatted-value reflection of the cr_source Picklist
   column. This blocks creation of the documented Text(200) and
   prevents flows from writing to it. Added a 'KNOWN COLLISION'
   note in the column description. Follow-up PR will rename to
   cr_originname.

Source restructure:
9. src/Solutions/ — replaced Frank's R2 scaffold (empty
   Solution.cdsproj + other/{Solution.xml,Customizations.xml}
   + CanvasApps/.gitkeep) with the Microsoft-canonical layout
   from 'pac solution clone --name CopilotAgentDebugLogger'
   (src/Entities/, src/AppModules/, src/AppModuleSiteMaps/,
   src/Other/, src/environmentvariabledefinitions/,
   CopilotAgentDebugLogger.cdsproj + .gitignore). The new
   cdsproj uses the old-style imports rather than the SDK
   alias but builds cleanly with 'dotnet build'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@judeper judeper merged commit e3f81d7 into main May 21, 2026
1 check failed
@judeper judeper deleted the fix/deploy-time-hotfixes branch May 21, 2026 22:46
judeper added a commit that referenced this pull request May 21, 2026
… AGENTS.md convention (#43)

Two motivations:

1. The autonomous build's docs were written before any of the
   POC artifacts had been deployed to a tenant. The first deploy
   (PR #42) discovered 8 bugs and surfaced 6 documentation drifts
   that this PR fixes. Without these refreshes, future AI agents
   reading the docs would replicate the same fabricated APIs,
   missing colliding columns, and the wrong solution layout.

2. The repo previously had no AGENTS.md convention — only
   .github/copilot-instructions.md at root. Establishing
   per-solution AGENTS.md (terse, AI-context-optimized) gives
   contributors a dedicated companion to the human-facing README
   that documents critical constraints, known issues, schema-
   prompt-code contract, and 'where to look first when something
   breaks' diagnostics.

Stale-info fixes (per-file):

- copilot-agent-debug-logger/README.md
  * File Map updated to Microsoft-canonical layout (src/Solutions/
    src/Entities/, AppModules/, AppModuleSiteMaps/, etc.) replacing
    the obsolete Frank R2 scaffold shape (Solution.cdsproj + other/
    + CanvasApps/.gitkeep). Added a layout note explaining the
    restructure.
  * cr_payload truncation reference: left(string(...)) → substring()
    with min()/length() (WDL-native; left() is Power Apps Canvas).
  * cr_sourcename data-contract row marked '_documented but not
    stored_' with pointer to Known Issues.
  * 'No managed-solution ALM' line: Solution.cdsproj → CopilotAgentDebugLogger.cdsproj
  * NEW 'Known Issues (deploy-time discoveries)' section with 6
    items: cr_sourcename collision, env-var yes/no storage, PVA
    tool flow Action-add requirement, Phase-0 nested clone layout,
    UniqueIdentifier rejection, PAC CLI 2.x list-environments drop.
    Each cites its backlog todo.

- copilot-agent-debug-logger/docs/phase-0-mda-authoring.md
  * Step 3 expected result: legacy CanvasApps/AgentDebugConsole_*
    path → src/Solutions/src/AppModules/cr_AgentDebugConsole/.
  * Step 5 cr_sourcename form-field item: noted as unwritable with
    pointer to Known Issues.
  * Sample precheck PowerShell: Get-ChildItem -Directory → Test-Path
    -PathType Container (correctness fix from PR #42).

- copilot-agent-debug-logger/docs/maker-guide.md
  * Data-contract cr_sourcename row updated.
  * Payload-truncation pattern (Quick Start + Pattern A Common Setup
    + Pattern A truncation reminder) updated to WDL substring().
  * Pattern C/D smoke-test row expectations: cr_sourcename = ... →
    cr_tracelabel begins with COPILOT_TOPIC/CoT @ or
    COPILOT_TOPIC/ConversationHistory @.

- copilot-agent-debug-logger/docs/deployment-guide.md
  * Step 2 expected-source-state snippet: Get-ChildItem ->
    Test-Path -PathType Container; legacy CanvasApps path -> new
    src/Solutions/src/AppModules path.
  * Step 4 build description: Solution.cdsproj -> CopilotAgentDebugLogger.cdsproj.
  * Pattern C/D row-value expectations rewritten to match cr_tracelabel
    encoding.
  * Validation-checklist MDA-artifacts path updated to canonical layout.

- copilot-agent-debug-logger/scripts/deploy-solution.ps1
  * .SYNOPSIS / .DESCRIPTION / .PARAMETER docstring updated to mention
    the *.cdsproj auto-discovery glob (the script logic was already
    correct per PR #42; this catches the help text up).

- .github/copilot-instructions.md
  * POC Constraints A15 entry updated: left() -> substring(...).
  * D7 MDA constraint updated: CanvasApps -> src/AppModules layout.
  * NEW 'Known issues from first deploy (PR #42)' bullet expanding the
    POC Constraints section with the 6 deploy-time discoveries.
  * NEW 'Per-solution AGENTS.md convention' section between Planning
    Structure and POC Constraints — discoverability for AI agents.

Newly created:
- copilot-agent-debug-logger/AGENTS.md (153 lines) — establishes the
  convention. Sections: Mission, Stack, Commands, File map, Critical
  constraints (A1/A2-D3/A3-D4/A4/A9/A15/D1/D2-A5-A6/D5-B1/D6/D7/D8/D15),
  Schema-prompt-code contract, Known issues table with workarounds and
  follow-up backlog refs, Operational sequence, IWL reference precedents,
  Don't list, Where to look first when something breaks table,
  Cross-references. Template for the other 3 solutions per backlog
  todo agentsmd-other-solutions.

Verification:
- All 4 .topic.mcs.yml YAMLs still parse via python yaml.safe_load
- Both flow JSONs parse via JSON.parse
- Schema JSON parses + still has 13 columns
- deploy-solution.ps1 + provision-environment.ps1 still parse via PS AST
- Repo grep for stale refs: only intentional 'legacy X -> new Y; see PR #42'
  historical references remain
- PII scan: clean (only example.com / placeholder GUIDs across touched files)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant