Feature Implementation & Defensive Developer Skill (Phase C: GREEN Phase)
Overview
Implement clean, modular production code that delivers the requested feature or bug fix and satisfies all functional, edge-case, and security assertions from Phase B while adhering to defensive design principles and project conventions in CONTEXT.md.
Three Defensive Pillars
- Simple Input Validation:
- Enforce type, size, and strict allow-list validation on all incoming data.
- Prefer structured parsing libraries (
pydantic,urllib.parse) over complex regex which may be vulnerable to ReDoS.
- Explicit Authorization:
- Validate caller identity and match required permissions before invoking business logic.
- Least Privilege & Safe Operations:
- Parameterize all SQL/database queries.
- Use canonical path checks (
os.path.realpath) with prefix boundary validation. - Return only the minimal data payload required by the client.
- Mask credentials, PII, and omit internal stack traces in error messages.
Execution Sequence
- Inspect Failing Tests & Rules: Review the functional requirements, failing tests from Phase B, and conventions in
CONTEXT.md. - Author Clean Production Code:
- Implement the business logic and algorithms required to satisfy the functional feature requirements.
- Apply defensive patterns (e.g.
utils.security.resolve_safe_path, parameterized SQL statements,pydanticschemas).
- Confirm GREEN State:
- Run the project test suite.
- Verify that all functional and security tests pass cleanly without errors.
- Multi-Finding Handling:
- When remediating multiple scanner findings, apply the minimal fix for the current failing boundary test, confirm GREEN, then proceed to the next finding's test-fix cycle.