Skip to content

feat: add learner intent xpert api endpoint#212

Open
brobro10000 wants to merge 7 commits into
mainfrom
hu/ent-11858-2-split
Open

feat: add learner intent xpert api endpoint#212
brobro10000 wants to merge 7 commits into
mainfrom
hu/ent-11858-2-split

Conversation

@brobro10000

@brobro10000 brobro10000 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description:
Screenshot 2026-06-24 at 11 21 02 AM

Adds the first Learner Pathways Xpert-backed API endpoint for deriving structured learning intent from learner input.

What changed

  • Added Learner Pathways request/response serializers for learning intent.
  • Added LearnerPathwaysViewSet.learning_intent.
  • Registered the /api/v1/learner-pathways/learning-intent route.
  • Wired the endpoint to the reusable BasePromptViewSet helpers for:
    • request validation
    • prompt lookup
    • system prompt construction
    • Xpert message creation
    • Xpert execution
    • response content extraction
    • JSON parsing
  • Added route-level auth, permission, and scoped throttling.
  • Added learner_pathways_learning_intent throttle rate.
  • Added endpoint tests for serializer validation, routing, auth, throttling, happy path behavior, response passthrough, and failure cases.

Jira:
ENT-11858

Merge checklist:

  • ./manage.py makemigrations has been run
    • Note: This must be run if you modified any models.
      • It may or may not make a migration depending on exactly what you modified, but it should still be run.

Post merge:

  • Ensure that your changes went out to the stage instance
  • Deploy to prod instance

@brobro10000 brobro10000 requested review from a team as code owners June 23, 2026 17:07
Base automatically changed from hu/ent-11858-1 to main June 24, 2026 14:19
brobro10000 and others added 2 commits June 24, 2026 14:28
@brobro10000 brobro10000 force-pushed the hu/ent-11858-2-split branch from f6f1ba1 to c77d518 Compare June 24, 2026 14:31
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.87755% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.51%. Comparing base (0854543) to head (c2f31ab).

Files with missing lines Patch % Lines
...se_access/apps/api/serializers/learner_pathways.py 77.77% 4 Missing ⚠️
enterprise_access/apps/prompts/api/__init__.py 95.74% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (93.87%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #212      +/-   ##
==========================================
- Coverage   86.52%   86.51%   -0.01%     
==========================================
  Files         154      156       +2     
  Lines       12920    12970      +50     
  Branches     1233     1234       +1     
==========================================
+ Hits        11179    11221      +42     
- Misses       1425     1430       +5     
- Partials      316      319       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brobro10000 brobro10000 force-pushed the hu/ent-11858-2-split branch 2 times, most recently from 6b81caf to 96f693e Compare June 24, 2026 16:39
@brobro10000 brobro10000 force-pushed the hu/ent-11858-2-split branch from 96f693e to 5476ef8 Compare June 24, 2026 17:06
Comment thread enterprise_access/apps/api/v1/views/prompt.py Outdated
Comment thread enterprise_access/apps/api/v1/views/prompt.py Outdated
Comment thread enterprise_access/apps/api/v1/views/prompt.py Outdated

def test_learning_intent_scope_in_default_throttle_rates(self):
rates = django_settings.REST_FRAMEWORK.get('DEFAULT_THROTTLE_RATES', {})
self.assertIn('learner_pathways_learning_intent', rates)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: use modern pytest-style assertions, e.g.:

Suggested change
self.assertIn('learner_pathways_learning_intent', rates)
assert 'learner_pathways_learning_intent' in rates

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2026-06-24 at 3 20 10 PM

inform: I have updated the PR, but, there are over 100+ instances of assertIn as a validation approach spanning features like checkout intent, customer billing, provisioning, subsidy access policy, checkout intent/checkout bff and browse and request whereas the modern approach is used sparingly in comparison.

Should there be a seperate initiative via a ticket to modernize the testing prose documented in a separate ticket?

Screenshot 2026-06-24 at 3 22 47 PM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a followup, the skills may also need to be updated to avoid legacy/non-modern approaches to test writing

@brobro10000 brobro10000 requested a review from pwnage101 June 24, 2026 20:10
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.

2 participants