Skip to content

Add beginner-friendly evaluation feedback for Python lessons - #180

Merged
kbuffardi merged 4 commits into
mainfrom
beginner-friendly-eval-messages
Sep 14, 2026
Merged

Add beginner-friendly evaluation feedback for Python lessons#180
kbuffardi merged 4 commits into
mainfrom
beginner-friendly-eval-messages

Conversation

@NickK21

@NickK21 NickK21 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • infers each lesson contract from its referenceTest
  • adds learner hints for missing variables, missing functions, near-miss names, wrong values, syntax errors, indentation errors, output mismatches, dataframe mismatches, and runtime fallbacks
  • keeps beginner-friendly guidance in Outcome and raw technical diagnostics in Output
  • wires structured evaluator data through attempt creation and UI rendering
  • adds focused API and client tests for contract inference, hint generation, and Outcome/Output rendering

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Some diagnostics disappear from the UI, and missing-function or near-match hints can be incorrectly classified.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds structured, beginner-friendly evaluation hints for Python lessons and displays them separately from technical diagnostics.

Changes:

  • Infers lesson contracts and generates targeted learner hints.
  • Propagates hint data through API and shared interfaces.
  • Updates Outcome/Output rendering with focused tests.
File summaries
File Description
codewit/lib/shared/interfaces/src/lib/output.ts Defines learner hint types.
codewit/client/src/interfaces/evaluation.ts Adds hints to client responses.
codewit/client/src/components/codeblock/CodeSubmission.tsx Separates hints from diagnostics.
codewit/client/src/components/codeblock/CodeSubmission.spec.tsx Tests hint and output rendering.
codewit/api/src/utils/learnerHints.ts Generates learner-facing hints.
codewit/api/src/utils/learnerHints.spec.ts Tests hint generation scenarios.
codewit/api/src/utils/exerciseContract.ts Infers lesson requirements.
codewit/api/src/utils/exerciseContract.spec.ts Tests contract inference.
codewit/api/src/models/attempt.ts Corrects optional creation fields.
codewit/api/src/controllers/attempt.ts Adds hints to evaluation responses.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +69 to +73
return [...new Set(
[...code.matchAll(/\b([A-Za-z_][A-Za-z0-9_]*)\b/g)]
.map((match) => match[1])
.filter((identifier) => !reserved.has(identifier))
)];
const diagnosticText = buildDiagnosticText(detail);
const topicLabel = context.title?.trim() || context.topic?.trim() || 'This lesson';
const lessonLabel = topicLabel;
const missingAttributeMatch = diagnosticText.match(/module 'program' has no attribute '([A-Za-z_][A-Za-z0-9_]*)'/);
const activeIssue = failure_details[issueIdx] || null;
const topLevelHint = 'learner_hint' in evaluation ? (evaluation.learner_hint ?? null) : null;
const activeHint = activeIssue?.learner_hint || topLevelHint || (state === 'passed' ? null : fallbackHint);
const technicalOutput = activeIssue?.rawout || compilation_error || runtime_error || error || '';

@kbuffardi kbuffardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The direction is valuable, but this needs changes before merge because the current implementation can hide diagnostics and confidently give incorrect guidance. The earlier inline findings remain unresolved, and the newly merged Codeval #25 parser exposes an additional cross-product correctness issue.

  1. Multiple failures can be attributed to the wrong variable. extractProgramAssertionIdentifier selects the last assertion found in rawout. Codeval's new parser attaches the complete pytest transcript to every failure detail, so with two failing tests an earlier issue can display the final test's variable name combined with the earlier test's expected/received values. Extract from the detail-specific error_message first, then fall back to a failure block scoped by test_case. Please add an integration fixture with two failures and verify each generated hint names its own variable.

  2. Generated from program import name failures receive an unknown hint. The implementation only recognizes the AttributeError and custom-assertion forms, but Python reports ImportError: cannot import name 'name' from 'program' for the import style generated by seed-db.ts. Match that diagnostic and classify the imported identifier through the inferred contract, with tests for imported variables and functions.

  3. The Output tab can disappear while diagnostics exist. technicalOutput ignores activeIssue.error_message and activeIssue.stderr. This remains relevant outside Codeval's new pytest path; for example, Java failures can have an exception message but no captured output. Build the displayed output from rawout, stderr, and error_message, followed by top-level errors and explicit timeout/memory messages. Add coverage for each fallback.

  4. Near-match detection treats comments and strings as code. Scanning every identifier-like word can produce a high-confidence rename instruction based solely on a comment or string literal. Restrict candidates to actual definitions/bindings, or downgrade to a non-directive hint unless the name is structurally identified, and add regression tests.

  5. Timeout and memory hints are not reachable through the current Codeval contract. Codeval initializes execution_time_exceeded and memory_exceeded to false and never sets them. Either update Codeval to emit these flags or classify its concrete runtime termination messages in Codewit before treating these specialized hints as supported.

Once these correctness and integration issues are addressed, this should be suitable for approval; the overall product direction is an improvement.

kbuffardi and others added 3 commits September 13, 2026 21:03
Use Codeval's per-failure diagnostics, recognize import-based missing names, and limit rename guidance to structurally identified Python bindings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Render failure and top-level diagnostic fallbacks, retain timeout streams, and reset issue navigation when a new evaluation arrives.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Limit module export suggestions to top-level bindings, preserve every non-duplicate diagnostic, and keep timeout guidance ahead of partial test failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@kbuffardi kbuffardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All requested correctness and integration changes are addressed. Failure hints now consume Codeval's scoped diagnostics, import-based missing names and Python bindings are classified conservatively, timeout responses are structured and take precedence, and the UI preserves non-duplicate technical output while resetting issue navigation. The updated API and web checks pass.

@kbuffardi
kbuffardi merged commit a964224 into main Sep 14, 2026
2 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.

3 participants