Skip to content

fix(#251): enforce strict website_scan v2 contract - #265

Merged
mottych merged 6 commits into
masterfrom
hotfix/issue-251-scan-website-items-to-adjust
Mar 12, 2026
Merged

fix(#251): enforce strict website_scan v2 contract#265
mottych merged 6 commits into
masterfrom
hotfix/issue-251-scan-website-items-to-adjust

Conversation

@mottych

@mottych mottych commented Mar 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Enforce a strict website_scan v2 response contract with canonical fields only (no legacy alias handling).
  • Normalize business profile fields for reliability (business_description, industry, year_founded, business_address) and reject legacy flat payload shapes.
  • Make scan_id and captured_at server-owned metadata that are always generated at validation time.
  • Update retrieval/spec docs/prompts and stabilize preprod deploy reliability for the shared coaching ECR repository.

Incident Context

Issue #251 reported missing or noisy business profile data from website scans. Root cause was permissive/variable payload handling and unconstrained metadata values.

Validation Evidence

  • Preprod deploy run succeeded: https://github.com/mottych/PurposePath_AI/actions/runs/22984795257
  • Manual preprod validation confirmed:
    • business_profile.business_address is present (and headquarters_location is absent)
    • industry is constrained/normalized to allowed enum values
    • scan_id and captured_at are server-generated per response

Test Plan

  • uv run ruff check coaching/src/api/models/onboarding.py coaching/tests/unit/test_onboarding_models.py coaching/src/core/topic_seed_data.py coaching/src/core/retrieval_method_registry.py
  • uv run mypy coaching/src/api/models/onboarding.py --explicit-package-bases
  • uv run pytest coaching/tests/unit/test_onboarding_models.py -k WebsiteScanResponse
  • Preprod manual validation against incident scenario
  • Production post-deploy verification after merge

Add backward-compatible mapping for legacy and alias website-scan fields so business name, description, address, industry, and founded year consistently populate the canonical business_profile payload while preserving existing canonical properties.

Made-with: Cursor
mottych added 3 commits March 11, 2026 18:14
Clarify the canonical business_profile response contract and the new server-side alias normalization/description isolation behavior so frontend validation can target stable fields.

Made-with: Cursor
Align website scan outputs with the permanent v2 schema by using business_address, rejecting legacy shapes, and constraining industry to Business Foundation options so preprod/frontend consume a deterministic contract.

Made-with: Cursor
Prevent preprod/prod pulumi deploys from failing when the shared purposepath-coaching ECR repository is absent by creating it as a fallback and reusing the shared name.

Made-with: Cursor
@pulumi

pulumi Bot commented Mar 12, 2026

Copy link
Copy Markdown

🍹 The Update for mottych/purposepath-coaching-api/preprod (at 96d1e98) was successful.

✨ Neo Explanation

A new coaching API Docker image has been built and is being deployed to the preprod Lambda function, updating the container from the previous image version to the newly built one. This is a routine code deployment with no risk of downtime or data loss.

Root Cause Analysis

A new version of the coaching API application has been built and is being deployed to the preprod environment. The Docker image was rebuilt with a new BUILD_TIMESTAMP of March 12, 2026, producing a new image digest, which triggers an update to the Lambda function to point to that new image.

Dependency Chain

A new Docker image (coaching-image) was built from the coaching Dockerfile → the image was pushed to ECR with a new content digest → the Lambda function (coaching-api) is updated to reference the new image URI. The remaining 21 resources (API Gateway, DynamoDB tables, IAM roles, etc.) are unaffected.

Risk analysis

No stateful resources are being replaced or deleted. This is a standard Lambda container image swap — the function will serve the new image on its next invocation with no infrastructure recreation required.

Resource Changes

    Name            Type                          Operation
~   coaching-image  docker:index/image:Image      update
~   coaching-api    aws:lambda/function:Function  update

mottych added 2 commits March 11, 2026 21:59
Stamp scan_id and captured_at server-side on every website_scan response so stale model-provided values cannot leak to clients, and document the behavior in prompt/spec contracts.

Made-with: Cursor
Bind purposepath-coaching to a stable Pulumi resource using Repository.get when it already exists so subsequent updates do not attempt to delete a non-empty repository.

Made-with: Cursor
@mottych mottych changed the title fix(#251): stabilize website scan business profile extraction fix(#251): enforce strict website_scan v2 contract Mar 12, 2026
@mottych
mottych merged commit 48cc451 into master Mar 12, 2026
3 checks passed
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