Skip to content

chore: constitution v1.2.0 (Principle VI + TDD) + stage-buttons UI + pre-commit lint gate - #2

Merged
Baruch4413 merged 4 commits into
mainfrom
chore/constitution-hygiene-and-stage-actions-ui
May 5, 2026
Merged

chore: constitution v1.2.0 (Principle VI + TDD) + stage-buttons UI + pre-commit lint gate#2
Baruch4413 merged 4 commits into
mainfrom
chore/constitution-hygiene-and-stage-actions-ui

Conversation

@Baruch4413

@Baruch4413 Baruch4413 commented May 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Constitution v1.2.0
    • Principle II reframed: "Test-First" → explicit Test-Driven Development (NON-NEGOTIABLE) with Red-Green-Refactor cycle, Vitest coverage for frontend, and a PR rule that production code MUST arrive with the failing test that motivated it.
    • Principle VI added (this PR, prior commit): Code Hygiene — DRY, SOLID, KISS — with concrete Laravel-stack rules.
    • Development Workflow gains an Automated Lint Gate subsection mandating the .githooks/pre-commit ESLint hook and forbidding silent removal/bypass.
    • Sync Impact Report and amendment date updated. Bump 1.0.0 → 1.1.0 → 1.2.0.
  • Pre-commit hook (zero new deps)
    • .githooks/pre-commit runs ESLint against staged *.js/*.jsx/*.ts/*.tsx/*.cjs/*.mjs files via bun x eslint (or npx eslint) and aborts on any error.
    • package.json adds a prepare script that sets core.hooksPath=.githooks on install — contributors auto-activate after bun install / npm install.
    • Existing clones can opt in once via: git config --local core.hooksPath .githooks.
  • UI: "Iniciar proyecto" / "Abortar proyecto" / completion buttons now render inside the volunteer progress card on the project detail page. CrowdfundingProgress gains a children slot; show.tsx passes ProjectStageActions (owner-gated) as the child.

Test plan

  • Visit project detail page as the owner — stage buttons appear inside the progress card, below the percentage line.
  • Click "Iniciar proyecto" / "Abortar proyecto" — transition still POSTs and the terminal-confirmation dialog still works.
  • Visit as a non-owner — no buttons render; progress card lays out unchanged.
  • Run bun install (or npm install) on a fresh clone — confirm git config core.hooksPath reads .githooks.
  • Stage a JS/TS file with an intentional ESLint error — commit MUST be blocked by the hook with the ESLint output.
  • Stage a JS/TS file with no ESLint errors — commit proceeds.
  • Stage only PHP/Markdown changes — hook short-circuits (no ESLint run).
  • php artisan test --compact passes.
  • bun run test:js passes.
  • vendor/bin/pint --test --format agent passes.
  • Constitution diff renders cleanly; verify version badge reads 1.2.0.

Notes

  • Three logical commits on the branch for clean review: (1) Constitution v1.1.0 — Principle VI; (2) UI — nest stage buttons; (3) Constitution v1.2.0 + TDD + ESLint pre-commit hook.
  • No new npm dependencies were introduced — the hook is plain bash and the prepare script is one line. Honors Constitution Principle III ("Convention Over Custom") and the Technology Constraints section ("Dependency additions … MUST be approved").

Summary by CodeRabbit

  • New Features

    • Enhanced component flexibility to support additional content within project progress displays.
  • Bug Fixes

    • Improved error handling for comment loading on project pages; gracefully handles failures.
  • Chores

    • Updated development standards and version to 1.2.0.
    • Implemented automated code quality checks for staged files.
    • Refined project page layout organization.

Baruch Espinoza added 2 commits May 4, 2026 23:48
Adds a sixth core principle codifying code-hygiene expectations enforced
by /speckit-plan Constitution Check and PR review:

- DRY: rule-of-three extraction, ban literal config/string duplication,
  reject premature abstraction.
- SOLID: SRP/OCP/LSP/ISP/DIP mapped to Laravel idioms (slim controllers,
  policies/events for OCP, container-resolved dependencies, focused
  interfaces, contract-honoring subclasses).
- KISS: simplest design wins; no speculative configurability or plugin
  layers; reduce indirection; prefer framework-native primitives.

Bump 1.0.0 -> 1.1.0 (MINOR, additive). Sync Impact Report and amendment
date updated.
…s box

The "Iniciar proyecto" / "Abortar proyecto" / completion buttons now live
inside the volunteer progress card on the project detail page instead of
floating between the header and the gallery. CrowdfundingProgress accepts
an optional children slot rendered after the percentage line; show.tsx
passes ProjectStageActions (owner-gated) as the child. Standalone block
removed.
@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3955a453-aa84-4014-8d9b-d2cd03fea234

📥 Commits

Reviewing files that changed from the base of the PR and between de1d0a7 and 15cc6d6.

📒 Files selected for processing (4)
  • .githooks/pre-commit
  • package.json
  • resources/js/components/ui/proyectos/CrowdfundingProgress.tsx
  • resources/js/pages/proyectos/show.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • resources/js/components/ui/proyectos/CrowdfundingProgress.tsx

📝 Walkthrough

Walkthrough

Bumps constitution to v1.2.0 (Last Amended 2026-05-05), replaces Principle II with an explicit Red‑Green‑Refactor TDD mandate, adds Automated Lint Gate requiring a tracked .githooks/pre-commit ESLint hook, and expands code-hygiene guidance. Also: adds children to CrowdfundingProgress, moves owner actions into it, adds pre-commit hook and a prepare script.

Changes

Constitution Document Update

Layer / File(s) Summary
Principle Rewrite / Rules
.specify/memory/constitution.md
Replaces Principle II with an explicit Red‑Green‑Refactor TDD procedure requiring failing tests before production code, minimal production code to pass tests, and test-driven refactors; tightens PR rejection rules when production code lacks test history.
Development Workflow / Lint Gate
.specify/memory/constitution.md
Adds "Automated Lint Gate" subsection mandating a tracked .githooks/pre-commit ESLint hook, activation via prepare/core.hooksPath, explicit prohibitions against bypassing or weakening lint rules, and rules treating hook removal/disablement as a constitutional amendment.
Code Hygiene Principle
.specify/memory/constitution.md
Adds Principle VI covering DRY, SOLID, and KISS with extraction rules, SOLID sub-rules, KISS constraints, and guidance for recording justified deviations.
Metadata / Version Bump
.specify/memory/constitution.md
Updates sync report and footer metadata: version bumped to 1.2.0, Last Amended set to 2026-05-05, and related template/impact notes adjusted.

Frontend Composition + Git Hook

Layer / File(s) Summary
Props / Types
resources/js/components/ui/proyectos/CrowdfundingProgress.tsx
Adds ReactNode import and extends CrowdfundingProgressProps with optional children?: ReactNode.
Component Implementation
resources/js/components/ui/proyectos/CrowdfundingProgress.tsx
Component signature updated to accept/destructure children and renders {children} after the completion text when totalSlots > 0.
Wiring / Layout Change
resources/js/pages/proyectos/show.tsx
Moves owner-only ProjectStageActions into CrowdfundingProgress as conditional children (isOwner && project.allowedTransitions.length > 0) and adds error handling to loadComments() call in useEffect.
Git Hook Script
.githooks/pre-commit
Adds pre-commit Bash hook that lints staged JS/TS files with ESLint, rejects partially staged JS/TS, prefers bun x eslint and falls back to npx --no-install eslint, and errors with instructions if neither runner is available.
Prepare Script / Hook Activation
package.json
Adds prepare script that attempts git config --local core.hooksPath .githooks and prints a warning message if it fails, to help activate the tracked hook.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble at specs by lantern light,
Red, green, refactor—hop through the night. 🐇
Lint hooks guard the burrow gate,
Components nest, transitions migrate.
A tidy patch; the burrow’s bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title comprehensively summarizes all major changes: constitution v1.2.0, Principle II TDD updates, stage-buttons UI refactor, and pre-commit lint gate implementation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/constitution-hygiene-and-stage-actions-ui

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
resources/js/pages/proyectos/show.tsx (1)

101-103: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add rejection handler to the loadComments call in the effect.

loadComments is an async function that can reject on fetch or JSON parsing errors, but the useEffect at lines 101-103 doesn't handle promise rejections. If the request fails, you'll get an unhandled promise rejection.

Proposed fix
     useEffect(() => {
-loadComments()
+    void loadComments().catch(() => {
+        setCommentsList([])
+    })
     }, [])

Also note the indentation issue on line 102.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@resources/js/pages/proyectos/show.tsx` around lines 101 - 103, The useEffect
currently calls the async loadComments() without handling rejections and has an
indentation issue; update the effect (the useEffect block that invokes
loadComments) to either call an async IIFE that awaits loadComments inside a
try/catch or append a .catch handler to loadComments() and log or handle the
error appropriately, and fix the indentation on the loadComments() line so it
aligns with the effect body; reference the loadComments function and the
useEffect wrapper to locate where to add the error handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@resources/js/components/ui/proyectos/CrowdfundingProgress.tsx`:
- Around line 1-4: Reorder the imports to satisfy the ESLint import/order rule
by moving the type import for ProjectRole (from
'@/components/ui/proyectos/ProjectRoles') above the CoinIcon import;
specifically ensure the type-only import (ProjectRole) appears with other
local/module imports before the component import CoinIcon so the import order
groups types and modules correctly and the linter error is resolved.

---

Outside diff comments:
In `@resources/js/pages/proyectos/show.tsx`:
- Around line 101-103: The useEffect currently calls the async loadComments()
without handling rejections and has an indentation issue; update the effect (the
useEffect block that invokes loadComments) to either call an async IIFE that
awaits loadComments inside a try/catch or append a .catch handler to
loadComments() and log or handle the error appropriately, and fix the
indentation on the loadComments() line so it aligns with the effect body;
reference the loadComments function and the useEffect wrapper to locate where to
add the error handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 733216f9-2aac-4376-8dcf-5fe4c1aa8193

📥 Commits

Reviewing files that changed from the base of the PR and between 86e6cf1 and c86e04d.

📒 Files selected for processing (3)
  • .specify/memory/constitution.md
  • resources/js/components/ui/proyectos/CrowdfundingProgress.tsx
  • resources/js/pages/proyectos/show.tsx

Comment thread resources/js/components/ui/proyectos/CrowdfundingProgress.tsx Outdated
Constitution v1.2.0:
- Reframe Principle II from "Test-First" to explicit "Test-Driven
  Development (NON-NEGOTIABLE)" — Red-Green-Refactor cycle, Vitest
  coverage for frontend in addition to Pest, requirement that PRs show
  the test arriving with or before production code.
- Add "Automated Lint Gate" subsection to Development Workflow.
- Bump 1.1.0 -> 1.2.0 (MINOR, additive expansion).

Pre-commit hook:
- New .githooks/pre-commit runs ESLint against staged JS/TS files
  (filtered via git diff --cached), aborts commit on any error.
- Zero new dependencies — hook is plain bash, dispatches via bun x or
  npx. Honors Constitution Principle III (no parallel framework).
- package.json gains a "prepare" script that sets
  core.hooksPath=.githooks on install so contributors auto-activate the
  hook after `bun install` / `npm install`.
- Existing clones can opt in once via:
    git config --local core.hooksPath .githooks

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.githooks/pre-commit:
- Around line 21-24: The hook invokes ESLint via "bun x eslint" and "npx
--no-install eslint" passing "${staged[@]}" directly which allows filenames
beginning with "-" to be treated as options; update the two invocations in
.githooks/pre-commit (the lines calling bun x eslint and npx --no-install
eslint) to insert a standalone "--" before the file arguments so ESLint treats
staged entries as paths, not flags.
- Around line 12-24: The hook runs ESLint on working-tree files (the bun/npx
eslint invocations) which fails for partially staged files; change the ES Lint
invocation to lint the staged snapshot instead by extracting each staged path
from the staged array and passing staged contents to ESLint (e.g. use git show
:<path> piped to eslint --stdin --stdin-filename or write each git show :<path>
to a temporary file and run eslint on those temp files) so that the bun x eslint
/ npx --no-install eslint calls operate on the staged snapshot rather than the
working tree; update the logic around staged (the staged array and the two
eslint invocations) to perform this extraction for each file and clean up any
temp files afterward.

In `@package.json`:
- Line 12: The prepare script is currently hiding failures by redirecting stderr
and forcing success; update the "prepare" script in package.json (the "prepare"
property) to stop swallowing errors from git config --local core.hooksPath
.githooks so hook-install failures surface. Replace the current command's
redirection and "|| true" with a command that either lets git's non‑zero exit
bubble up or explicitly checks the exit code and prints a clear error message
(referencing core.hooksPath and .githooks) and exits non‑zero so CI/devs are
alerted when hook installation fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8662a3ca-8feb-4bbd-8bbd-0a0344a0dbd7

📥 Commits

Reviewing files that changed from the base of the PR and between c86e04d and de1d0a7.

📒 Files selected for processing (3)
  • .githooks/pre-commit
  • .specify/memory/constitution.md
  • package.json

Comment thread .githooks/pre-commit Outdated
Comment thread .githooks/pre-commit Outdated
Comment thread package.json Outdated
@Baruch4413 Baruch4413 changed the title chore: constitution Principle VI (DRY/SOLID/KISS) + nest stage buttons in progress box chore: constitution v1.2.0 (Principle VI + TDD) + stage-buttons UI + pre-commit lint gate May 5, 2026
- CrowdfundingProgress.tsx: fix import/order (ProjectRoles before CoinIcon).
- show.tsx: add .catch() to the loadComments() invocation in useEffect so a
  failed fetch resets the loading state and shows an empty comments view
  instead of leaving the spinner stuck (CodeRabbit outside-diff finding;
  drive-by fix).
- .githooks/pre-commit:
  - Reject partially staged JS/TS files. ESLint reads the working tree, so
    linting partially staged content would produce false pass/fail and
    silently undermine the staged-content gate.
  - Insert `--` before "${staged[@]}" in both bun and npx invocations so
    a filename starting with `-` cannot be misread as an ESLint flag.
- package.json: replace silent `2>/dev/null || true` on the prepare script
  with a visible warning when `git config core.hooksPath` cannot be set
  (e.g., installing from a tarball outside a git checkout). Errors no
  longer disappear; the developer is told to run the command manually.
@Baruch4413
Baruch4413 merged commit 0a0771e into main May 5, 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