diff --git a/.claude/agents/instruction-tester.md b/.claude/agents/instruction-tester.md new file mode 100644 index 0000000..310bec7 --- /dev/null +++ b/.claude/agents/instruction-tester.md @@ -0,0 +1,90 @@ +--- +name: instruction-tester +description: "Use this agent when you need to validate project instructions, tutorials, or learning materials by simulating a student following them step-by-step. Examples:\\n\\n\\nContext: User has just finished writing a setup guide for their project.\\nuser: \"I've just updated the README with installation instructions. Can you check if they work?\"\\nassistant: \"I'll use the Task tool to launch the instruction-tester agent to follow your installation instructions as a student would and identify any issues or unclear steps.\"\\n\\n\\n\\nContext: User is creating a tutorial for a new feature.\\nuser: \"Here's my tutorial for the authentication flow. I want to make sure it's clear.\"\\nassistant: \"Let me use the instruction-tester agent to work through your authentication tutorial step-by-step and report on clarity, completeness, and any bugs.\"\\n\\n\\n\\nContext: User has made changes to onboarding documentation.\\nuser: \"I've revised the getting started guide. Please verify it.\"\\nassistant: \"I'm launching the instruction-tester agent to test your getting started guide by following it as a new user would, checking for gaps or errors.\"\\n" +model: sonnet +--- + +You are an Instruction Testing Agent - a diligent student persona designed to rigorously validate project instructions, tutorials, and learning materials by following them exactly as written. + +**Your Core Responsibilities:** + +1. **Execute Instructions Literally**: Follow the provided instructions step-by-step exactly as they are written. Do not fill in gaps with assumptions or prior knowledge. If an instruction is unclear or missing, note it as a bug rather than working around it. + +2. **Adopt Beginner Mindset**: Approach each instruction set as if you are encountering the concepts for the first time. Question terminology that isn't explained, flag missing context, and identify steps that assume prerequisite knowledge not mentioned in the instructions. + +3. **Document Your Journey**: As you work through instructions, track: + - Steps that worked as expected + - Steps that failed or produced unexpected results + - Steps that were unclear or ambiguous + - Missing steps or information gaps + - Points where you got stuck or confused + +4. **Assess Learning Outcomes**: After completing (or attempting to complete) the instructions, evaluate: + - Whether you could achieve the stated goal + - How well you understand the concepts after following the instructions + - What knowledge gaps remain + - Whether the difficulty level matches the intended audience + +5. **Report Findings Systematically**: Structure your report with: + - **Summary**: Overall assessment of instruction quality and completeness + - **Bugs Found**: Critical errors that prevent successful completion (numbered list) + - **Unclear Sections**: Ambiguous or confusing instructions that need clarification (numbered list) + - **Learning Assessment**: Your confidence level (0-10) in having mastered the material and specific gaps + - **Minimal Improvements**: ONLY 2-3 highest-impact suggestions for enhancement (be selective) + +**Operational Guidelines:** + +- **Be Thorough but Efficient**: Test every step, but don't overthink. If something doesn't work after a reasonable attempt following the instructions, document it and move on. + +- **Distinguish Error Types**: + - **Bugs**: Instructions that are factually wrong or lead to errors + - **Clarity Issues**: Instructions that are confusing but technically correct + - **Gaps**: Missing steps or information needed for success + +- **Maintain Focus**: Your primary job is finding bugs and assessing learnability, not redesigning the instructions. Improvements should be minimal and high-value only. + +- **Be Specific**: When reporting issues, cite exact instruction text, step numbers, or section headers. Provide concrete examples of what went wrong. + +- **Simulate Real Conditions**: Consider the environment a typical student would have. Don't assume access to tools, knowledge, or resources not mentioned in the instructions. + +- **Self-Verify**: Before reporting a bug, double-check that you followed the instructions correctly. If you're uncertain, note it as "possible bug (needs verification)". + +**Output Format:** + +Your reports should follow this structure: + +``` +## Instruction Test Report + +### Summary +[2-3 sentences on overall quality and whether instructions achieve their goal] + +### Bugs Found +1. [Specific bug with location reference] +2. [Specific bug with location reference] +... + +### Unclear Sections +1. [Ambiguous instruction with location reference] +2. [Confusing step with location reference] +... + +### Learning Assessment +Confidence Level: [0-10]/10 +Gaps: [Specific topics or skills not adequately covered] +Difficulty Match: [Whether difficulty aligns with target audience] + +### Minimal Improvements (Top 2-3 Only) +1. [Highest-impact improvement] +2. [Second highest-impact improvement] +3. [Third highest-impact improvement if warranted] +``` + +**Quality Standards:** +- Never invent solutions to broken instructions - report them +- Be honest about confusion - it indicates instruction problems +- Prioritize findability of issues over comprehensive rewrites +- Keep improvement suggestions actionable and specific +- If instructions work perfectly, say so clearly + +You are a quality assurance mechanism for educational content. Your student perspective is invaluable for identifying assumptions and gaps that experts might miss. diff --git a/LEARNINGS-aalbelad.md b/LEARNINGS-aalbelad.md new file mode 100644 index 0000000..6c7a3f4 --- /dev/null +++ b/LEARNINGS-aalbelad.md @@ -0,0 +1,81 @@ +# LEARNINGS-aalbelad.md + +## CP1 – Staging vs Committing +Commands: +- git checkout -b feature/aalbelad starter/role-A +- pytest tests/ +- git add src/validator.py tests/test_calculator.py +- git commit -m "fix" +- git add src/calculator.py +- git commit -m "update" + +Reflection: +I learned how staging allows me to control exactly what goes into each commit. Separating the fix and update commits helped me understand how to create clear, meaningful commit history. + +## CP2 – Reverting a Bad Commit +Commands: +- git log --oneline +- git revert + +Reflection: +I learned that git revert safely undoes a commit by creating a new commit instead of deleting history. This is important for collaboration because it keeps a full and transparent record of changes. + +## CP3 – Moving a Commit with Cherry-Pick +Commands: +- git checkout main +- git add src/validator.py +- git commit -m "Add is_positive helper function" +- git log --oneline -1 +- git reset --hard HEAD~1 +- git checkout feature/aalbelad +- git cherry-pick + +Reflection: +I learned how to recover from committing on the wrong branch by using cherry-pick. This allows moving a specific change without rewriting the code manually. + +## CP4 – Recovering Lost Work with Reflog +Commands: +- git checkout -b experiment/aalbelad +- git add src/calculator.py +- git commit -m "Experiment change" +- git checkout feature/aalbelad +- git branch -D experiment/aalbelad +- git reflog +- git checkout -b recovered/aalbelad +- git checkout feature/aalbelad +- git merge recovered/aalbelad + +Reflection: +I learned that even after deleting a branch, Git can recover lost commits using reflog. This shows that most mistakes in Git are reversible if you know the right tools. + +## CP5 – Syncing with Upstream and Rebasing +Commands: +- git remote set-url upstream https://github.com/mdurrani808/git_project_1.git +- git fetch upstream +- git checkout main +- git reset --hard upstream/main +- git checkout feature/aalbelad +- git rebase main +- git push --force-with-lease origin feature/aalbelad + +Reflection: +I learned how to synchronize my work with the latest changes from the original repository using rebase. This keeps the commit history clean and avoids unnecessary merge commits. + +## CP6 – Cleaning Commit History +Commands: +- git log main..HEAD --oneline +- git rebase -i main +- git push --force-with-lease origin feature/aalbelad + +Reflection: +I learned how to clean up commit history by rewriting commit messages using interactive rebase. This makes the project easier to review and improves code readability. + +## CP7 – Pull Requests and Code Review +Commands: +- git push origin feature/aalbelad +- Open pull request (feature/aalbelad → main) +- Review teammate PR and request changes +- Respond to comments on my PR + +Reflection: +I learned how to collaborate using pull requests by reviewing teammate code, requesting changes, and responding to feedback. This helped me understand how real-world team workflows operate in GitHub. \ No newline at end of file diff --git a/LEARNINGS-fterrone.md b/LEARNINGS-fterrone.md new file mode 100644 index 0000000..17b4930 --- /dev/null +++ b/LEARNINGS-fterrone.md @@ -0,0 +1,56 @@ +Checkpoint 1 +- git switch -c feature/fterrone +- git add . +- git commit -m "fix" +- git add . +- git commit -m "update" +- git push origin feature/fterrone + +During this checkpoint, I learned how to add files to the staging area, commit them, and push them. + +Checkpoint 2 +- git log --oneline +- git revert b19f233 + +This checkpoint taught me how to undo commits without deleting them from the history using revert. + +Checkpoint 3 +- Git switch main +- git add . +- git commit -m "Add is_positive helper function" +- git log --oneline +- git reset --hard HEAD~1 +- git switch feature/fterrone +- git cherry-pick ed58ac4 +- git add . +- git cherry-pick --continue +- git push origin feature/fterrone + +This checkpoint taught me how to delete a branch and recover the comment. It also taught me how to use cherry-pick and fix merge conflicts. + +Checkpoint 4 +- git switch -c experiment/fterrone +- git add. +- git commit -m "add a comment" +- git branch -D experiment/fterrone +- git reflog +- git switch -c recovered/fterrone 2be781c +- git switch feature/fterrone +- git merge recovered/fterrone +- git_project_1 % git log + +Checkpoint 4 taught me how to recover a deleted branch by using reflog. It also taught me how to merge two branches. + +Checkpoint 6 + +- git rebase -i main +- git push --force-with-lease + +This checkpoint taught me how to use the rebase-interactive editor to clean up and improve the commit history. + +checkpoint 7 +- git add . +- git commit -m "add comments to validate_operation and added Learning files" +- git rebase -i main +- git push --force-with-lease +This check point helped me learn to give feed back on poll request. it also allowed me to apllay how to handel feed back. diff --git a/LEARNINGS-rnair124.md b/LEARNINGS-rnair124.md new file mode 100644 index 0000000..d4751de --- /dev/null +++ b/LEARNINGS-rnair124.md @@ -0,0 +1,52 @@ +Checkpoint 1 + Commands Used: + git add src/calculator.py + git commit -m “fix” + git add src/validator.py + git commit -m “update” + + I learned how to use the staging area to control what goes into each commit. + +Checkpoint 2 + Commands Used: + git log –oneline + git revert + + I learned how to undo a commit without deleting it from history using git revert. + +Checkpoint 3 + Commands Used: + git switch main + git commit -m “Add is_positive helper function” + git cherry-pick + + I learned how to move a commit from one branch to another using cherry-pick. + +Checkpoint 4 + Commands Used: + git reflog + git branch -D experiment/rnair124 + git merge recovered/rnair124 + + I learned how to recover lost work using git reflog. + +Checkpoint 5 + Commands Used: + git remote add upstream + git merge –ff-only upstream/main + git rebase main + git push –force-with-lease + + I learned how to sync my branch with the upstream repository and rebase my changes. + +Checkpoint 6 + Commands Used: + git log main..HEAD –oneline + git rebase -i main + git push –force-with-lease + + I learned how to clean up commit history using interactive rebase. + +Checkpoint 7 + + I learned how to review teammates’ code and provide meaningful feedback to other peoples code through pull requests. \ No newline at end of file diff --git a/reflog_fterrone.md b/reflog_fterrone.md new file mode 100644 index 0000000..edc0f35 --- /dev/null +++ b/reflog_fterrone.md @@ -0,0 +1,79 @@ +2f36d71 (HEAD -> feature/fterrone, origin/feature/fterrone) HEAD@{0}: rebase (finish): returning to refs/heads/feature/fterrone +2f36d71 (HEAD -> feature/fterrone, origin/feature/fterrone) HEAD@{1}: rebase (reword): add comments to validate_operation and added Learning files +96da473 HEAD@{2}: rebase (reword): added learnings files +36f9841 HEAD@{3}: rebase (reword): Add is_positive helper function. +cf600d0 HEAD@{4}: rebase: fast-forward +c914eb7 HEAD@{5}: rebase (start): checkout main +57577d4 HEAD@{6}: rebase (finish): returning to refs/heads/feature/fterrone +57577d4 HEAD@{7}: rebase (squash): added learnings files +65b8cd0 HEAD@{8}: rebase (squash): # This is a combination of 2 commits. +f44fdd2 HEAD@{9}: rebase (start): checkout main +ab05f8e HEAD@{10}: checkout: moving from main to feature/fterrone +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{11}: checkout: moving from feature/fterrone to main +ab05f8e HEAD@{12}: rebase (abort): returning to refs/heads/feature/fterrone +44188cc HEAD@{13}: rebase (squash): # This is a combination of 2 commits. +f44fdd2 HEAD@{14}: rebase (start): checkout main +ab05f8e HEAD@{15}: commit: add comments to validate_operation and added Learning files +6cf44f6 HEAD@{16}: rebase (finish): returning to refs/heads/feature/fterrone +6cf44f6 HEAD@{17}: commit: add comments to validate_operation and added Learning files +f44fdd2 HEAD@{18}: rebase (start): checkout main +8d1bc67 HEAD@{19}: commit: add comments to validate_operation and added Learning files +f44fdd2 HEAD@{20}: rebase (finish): returning to refs/heads/feature/fterrone +f44fdd2 HEAD@{21}: rebase (reword): added learnings files +4942e2e HEAD@{22}: rebase: fast-forward +cf600d0 HEAD@{23}: rebase (start): checkout main +4942e2e HEAD@{24}: rebase (finish): returning to refs/heads/feature/fterrone +4942e2e HEAD@{25}: rebase (continue): added learnings files +dfe2634 HEAD@{26}: rebase (squash): # This is a combination of 2 commits. +4af4746 HEAD@{27}: rebase (start): checkout main +13f63d5 HEAD@{28}: checkout: moving from recovered/fterrone to feature/fterrone +2be781c (recovered/fterrone) HEAD@{29}: checkout: moving from main to recovered/fterrone +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{30}: reset: moving to f1deb16 +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{31}: reset: moving to f1deb16 +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{32}: reset: moving to f1deb16 +5ce58d5 HEAD@{33}: revert: Revert "Initial commit: Calculator project structure" +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{34}: checkout: moving from feature/fterrone to main +13f63d5 HEAD@{35}: commit: Updated learning files +30ef0e0 HEAD@{36}: commit: Learning Files +4af4746 HEAD@{37}: commit: added learnings files +cf600d0 HEAD@{38}: rebase (finish): returning to refs/heads/feature/fterrone +cf600d0 HEAD@{39}: rebase (squash): Add is_positive helper function and add some useless comments. +de3e5ab HEAD@{40}: rebase (pick): Add is_positive helper function +c914eb7 HEAD@{41}: rebase (pick): Undos excessive debug logging +88d9fef HEAD@{42}: rebase (reword): Updates module docstring in validator +26b2784 HEAD@{43}: rebase (reword): update +ea8f2db HEAD@{44}: rebase (reword): Fix the failing power test +9d5fcf0 HEAD@{45}: rebase: fast-forward +d4a52e2 (upstream/starter/role-B, starter/role-B) HEAD@{46}: rebase (start): checkout main +5b412db HEAD@{47}: checkout: moving from feature/fterrone to feature/fterrone +5b412db HEAD@{48}: checkout: moving from main to feature/fterrone +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{49}: checkout: moving from feature/fterrone to main +5b412db HEAD@{50}: rebase (finish): returning to refs/heads/feature/fterrone +5b412db HEAD@{51}: rebase (start): checkout main +5b412db HEAD@{52}: rebase (finish): returning to refs/heads/feature/fterrone +5b412db HEAD@{53}: rebase (pick): add a comment +4179f84 HEAD@{54}: rebase (pick): Add is_positive helper function +54eb0a6 HEAD@{55}: rebase (pick): Undos excessive debug logging +f05a66e HEAD@{56}: rebase (pick): update +9d5fcf0 HEAD@{57}: rebase (reword): fix +76598d1 HEAD@{58}: rebase: fast-forward +d4a52e2 (upstream/starter/role-B, starter/role-B) HEAD@{59}: rebase (start): checkout main +2be781c (recovered/fterrone) HEAD@{60}: merge recovered/fterrone: Fast-forward +5b1cd67 HEAD@{61}: checkout: moving from recovered/fterrone to feature/fterrone +2be781c (recovered/fterrone) HEAD@{62}: checkout: moving from feature/fterrone to recovered/fterrone +5b1cd67 HEAD@{63}: checkout: moving from experiment/fterrone to feature/fterrone +2be781c (recovered/fterrone) HEAD@{64}: commit: add a comment +5b1cd67 HEAD@{65}: checkout: moving from feature/fterrone to experiment/fterrone +5b1cd67 HEAD@{66}: checkout: moving from main to feature/fterrone +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{67}: checkout: moving from feature/fterrone to main +5b1cd67 HEAD@{68}: commit (cherry-pick): Add is_positive helper function +e4ded56 HEAD@{69}: checkout: moving from main to feature/fterrone +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{70}: reset: moving to HEAD~1 +ed58ac4 HEAD@{71}: commit: Add is_positive helper function +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{72}: checkout: moving from feature/fterrone to main +e4ded56 HEAD@{73}: revert: Undos excessive debug logging +dd97500 HEAD@{74}: commit: update +76598d1 HEAD@{75}: commit: fix +d4a52e2 (upstream/starter/role-B, starter/role-B) HEAD@{76}: checkout: moving from starter/role-B to feature/fterrone +d4a52e2 (upstream/starter/role-B, starter/role-B) HEAD@{77}: checkout: moving from main to starter/role-B +f1deb16 (upstream/main, upstream/HEAD, origin/main, origin/feature/tngwafor, origin/HEAD, main) HEAD@{78}: clone: from github.com:Abdulrahman-Albeladi/git_project_1.git \ No newline at end of file diff --git a/src/calculator.py b/src/calculator.py index e828684..b480412 100644 --- a/src/calculator.py +++ b/src/calculator.py @@ -1,5 +1,8 @@ """Basic calculator operations.""" +import math +"""Basic calculator operations with support for arithmetic and modulo.""" +# Temporary experiment change def add(a, b): """Add two numbers.""" return a + b @@ -16,4 +19,18 @@ def divide(a, b): """Divide a by b.""" if b == 0: raise ValueError("Cannot divide by zero") + result = a / b + return result + +def square_root(a): + """Calculate square root of a.""" + if a < 0: + raise ValueError("Cannot calculate square root of negative number") + return math.sqrt(a) return a / b + +def modulo(a, b): + """Return remainder of a divided by b.""" + if b == 0: + raise ValueError("Cannot modulo by zero") + return a % b diff --git a/src/validator.py b/src/validator.py index 7a70d84..b7990b9 100644 --- a/src/validator.py +++ b/src/validator.py @@ -1,5 +1,6 @@ -"""Input validation for calculator.""" - +"""These are the validation functions for the calculator inputs and are used in the main calculator logic before the operations are performed.""" +# temporary comment for CheckPoint 4 +"""Module provides functions to check if input is valid""" def validate_number(value): """Validate that value can be converted to a number.""" try: @@ -10,5 +11,25 @@ def validate_number(value): def validate_operation(op): """Validate that operation is supported.""" - valid_ops = ['+', '-', '*', '/'] + # an list of valid operation + valid_ops = ['+', '-', '*', '/', '%'] return op in valid_ops + +def validate_non_negative(n): + """Validate that a number is non-negative.""" + try: + num = float(n) + return num >= 0 + except (ValueError, TypeError): + return False + +def validate_range(value, min_val=-1000, max_val=1000): + """Validate that number is within acceptable range.""" + try: + num = float(value) + return min_val <= num <= max_val + except (ValueError, TypeError): + return False +def is_positive(n): + """Check if a number is positive.""" + return n > 0 diff --git a/tests/test_calculator.py b/tests/test_calculator.py index ffc0154..0118be6 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,6 +1,9 @@ """Tests for calculator operations.""" import pytest -from src.calculator import add, subtract, multiply, divide +from src.calculator import add, subtract, multiply, divide, square_root +from src.validator import validate_non_negative +from src.calculator import add, subtract, multiply, divide, modulo +from src.validator import validate_range def test_add(): assert add(2, 3) == 5 @@ -21,3 +24,29 @@ def test_divide(): def test_divide_by_zero(): with pytest.raises(ValueError): divide(5, 0) + +def test_square_root(): + assert square_root(9) == 3 + assert square_root(16) == 4 + assert square_root(2) == pytest.approx(1.414, rel=0.01) + +def test_square_root_negative(): + with pytest.raises(ValueError): + square_root(-1) + +def test_validate_non_negative(): + assert validate_non_negative(5) == True + assert validate_non_negative(0) == True + assert validate_non_negative(-5) == False +def test_modulo(): + assert modulo(10, 3) == 1 + assert modulo(7, 2) == 1 + +def test_modulo_by_zero(): + with pytest.raises(ValueError): + modulo(5, 0) + +def test_range_validation(): + assert validate_range(100) == True + assert validate_range(2000) == False + assert validate_range(-2000) == False