@metasession.co/devaudit-sdlc 1.7.6 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metasession.co/devaudit-sdlc",
3
- "version": "1.7.6",
3
+ "version": "1.9.0",
4
4
  "description": "DevAudit SDLC CLI Engine — cross-agent terminal-driven SDLC orchestrator.",
5
5
  "bin": {
6
6
  "devaudit-sdlc": "./src/bin/devaudit-sdlc.cjs"
@@ -478,10 +478,13 @@ function classifyPrStatus(pr, checks, portalStatus, watch, options) {
478
478
  }
479
479
 
480
480
  if (failingChecks.length > 0) {
481
+ const redRequired = requiredFailingChecks(failingChecks, isReleasePr);
481
482
  return {
482
483
  kind: 'blocked',
483
484
  exitCode: 3,
484
- summary: `PR #${watch.prNumber} has failing checks that need code fixes: ${failingChecks.map(formatCheckName).join(', ')}.`,
485
+ summary: redRequired.length > 0
486
+ ? `PR #${watch.prNumber} has failing REQUIRED release checks: ${redRequired.map(formatCheckName).join(', ')}. This release is blocked until the failure is fixed or accepted with a documented exception (devaudit-installer#1016); do not proceed to UAT or evidence upload with it unresolved.`
487
+ : `PR #${watch.prNumber} has failing checks that need code fixes: ${failingChecks.map(formatCheckName).join(', ')}.`,
485
488
  };
486
489
  }
487
490
 
@@ -510,6 +513,83 @@ function classifyPrStatus(pr, checks, portalStatus, watch, options) {
510
513
  };
511
514
  }
512
515
 
516
+ // devaudit-installer#1016 (R5) -- a red REQUIRED check on the release PR must be
517
+ // visible within one poll, not discovered at portal UAT approval. The release
518
+ // approval gate has its own retry path, so it is excluded here.
519
+ function requiredFailingChecks(failingChecks, isReleasePr) {
520
+ if (!isReleasePr) return [];
521
+ return failingChecks.filter(check =>
522
+ REQUIRED_RELEASE_CHECKS.includes(String(check.name || '')) && !isReleaseGateCheck(check));
523
+ }
524
+
525
+ function readGateTimeoutHours() {
526
+ const config = loadJsonFile(path.join(process.cwd(), 'sdlc-config.json'), {});
527
+ const value = Number(config && config.phase4 && config.phase4.gate_timeout_hours);
528
+ return Number.isFinite(value) && value > 0 ? value : 24;
529
+ }
530
+
531
+ function updateStickyStatus(issue, last, next) {
532
+ const script = path.join(process.cwd(), 'scripts', 'update-sdlc-status.sh');
533
+ if (!issue || !fs.existsSync(script)) return;
534
+ spawnSync('bash', [script, String(issue), last, next], { cwd: process.cwd(), encoding: 'utf8', env: process.env });
535
+ }
536
+
537
+ function notifyRequiredGateFailure(repo, watch, pr, checks, options) {
538
+ const failing = checks.filter(check => isFailingState(check.state || check.bucket));
539
+ const red = requiredFailingChecks(failing, isReleasePromotionPr(pr || {}, options));
540
+ if (red.length === 0) {
541
+ delete watch.triageNotified;
542
+ delete watch.redSince;
543
+ delete watch.escalatedFor;
544
+ return;
545
+ }
546
+ const issue = options.issue || process.env.ISSUE_NUM || null;
547
+ const names = red.map(formatCheckName).sort();
548
+ const key = names.join(' | ');
549
+ const now = new Date();
550
+ watch.redSince = watch.redSince || now.toISOString();
551
+ const links = red.map(check => `- ${formatCheckName(check)}${check.link ? `: ${check.link}` : ''}`).join('\n');
552
+ const post = (title, extra) => {
553
+ const body = [
554
+ `**${title}**`,
555
+ '',
556
+ `Required check(s) failing on release PR #${watch.prNumber}:`,
557
+ links,
558
+ '',
559
+ 'This release is blocked until one of these is completed:',
560
+ '1. **Fix** - a `fix/<issue#>-<slug>` PR into the integration branch, then a green re-run on the PR head SHA.',
561
+ '2. **Accept** - a documented exception: copy `.claude/skills/sdlc-implementer/references/e2e-accepted-failure.md.template` to `compliance/evidence/REQ-XXX/accepted-e2e-failure-<spec>.md`, fill the impact assessment, and record it with `scripts/report-test-execution.sh resolve --resolution-type accepted_exception --remediation-reference <tracking-issue> --record <that file>`. Never automatic: the operator decides.',
562
+ '',
563
+ 'No merge into the release head is needed to record the triage in the portal.',
564
+ extra || '',
565
+ ].join('\n');
566
+ if (issue) {
567
+ try {
568
+ runGh(['issue', 'comment', String(issue), '--repo', repo, '--body', body]);
569
+ } catch (error) {
570
+ console.error(`⚠️ Could not comment on issue #${issue}: ${error.message}`);
571
+ }
572
+ }
573
+ };
574
+ if (watch.triageNotified !== key) {
575
+ post('Required gate failing on the release PR - fix or accept with a documented exception');
576
+ updateStickyStatus(
577
+ issue,
578
+ `Phase 4 BLOCKED - required check(s) failing on release PR #${watch.prNumber}: ${key}`,
579
+ 'Operator action - fix the failure, or accept it with a documented exception record (impact, owner, review date, tracking issue); sdlc-implementer will not proceed to UAT with it unresolved',
580
+ );
581
+ watch.triageNotified = key;
582
+ console.log(`🚨 Required release check(s) failing: ${key}. Fix or accept with a documented exception.`);
583
+ }
584
+ const hours = readGateTimeoutHours();
585
+ const elapsedHours = (now.getTime() - new Date(watch.redSince).getTime()) / 3600000;
586
+ if (elapsedHours >= hours && watch.escalatedFor !== key) {
587
+ post(`Phase 4 BLOCKED ${hours}h - required gate still failing`, `Escalation required: ${key} has been red for ${Math.floor(elapsedHours)}h.`);
588
+ updateStickyStatus(issue, `Phase 4 BLOCKED ${hours}h - required check(s) still failing: ${key}`, 'Escalation required');
589
+ watch.escalatedFor = key;
590
+ }
591
+ }
592
+
513
593
  function performWatchAction(repo, watch, decision) {
514
594
  if (!decision.action) return;
515
595
  runGh(['run', 'rerun', decision.action.runId, '--repo', repo]);
@@ -557,6 +637,7 @@ async function watchPullRequest() {
557
637
  flakyPatterns: flakyPatterns.length > 0 ? flakyPatterns : DEFAULT_FLAKY_PATTERNS,
558
638
  integrationBranch: getOption('integration-branch') || DEFAULT_INTEGRATION_BRANCH,
559
639
  releaseBranch: getOption('release-branch') || DEFAULT_RELEASE_BRANCH,
640
+ issue: getOption('issue'),
560
641
  };
561
642
 
562
643
  let pollsRemaining = once ? 1 : maxPolls;
@@ -580,6 +661,7 @@ async function watchPullRequest() {
580
661
  watch.lastPortalStatus = portalStatus || watch.lastPortalStatus || null;
581
662
 
582
663
  const decision = classifyPrStatus(pr || {}, checks, portalStatus, watch, options);
664
+ notifyRequiredGateFailure(repo, watch, pr || {}, checks, options);
583
665
  if (decision.kind === 'action') {
584
666
  try {
585
667
  performWatchAction(repo, watch, decision);
@@ -273,7 +273,7 @@ git pull --rebase origin develop
273
273
  git push origin develop
274
274
  ```
275
275
 
276
- Pushing to `develop` triggers the full CI pipeline (TypeScript, SAST, dependency audit, E2E, build). All gate results are automatically uploaded to DevAudit tagged with the release version and `environment=uat`. The develop branch auto-deploys to the UAT environment (Railway staging). UAT will be formally reviewed and approved in DevAudit before a PR to main can be created.
276
+ Pushing to `develop` triggers the full CI pipeline (TypeScript, SAST, dependency audit, E2E, build). All gate results are automatically uploaded to DevAudit tagged with the release version and `environment=uat`. The develop branch auto-deploys to the UAT environment (your hosting platform's staging). UAT will be formally reviewed and approved in DevAudit before a PR to main can be created.
277
277
 
278
278
  ### WAIT CHECKPOINT: Confirm CI Green
279
279
 
@@ -45,7 +45,7 @@ If you are an AI agent reading this file, you are strictly prohibited from manua
45
45
  | `compliance/evidence/REQ-XXX/ai-use-note.md` | Git | Small markdown, needs PR review |
46
46
  | `compliance/evidence/REQ-XXX/ai-prompts.md` | Git | Small markdown, needs PR review |
47
47
  | `compliance/evidence/REQ-XXX/security-summary.md` | Git | Small markdown, needs PR review |
48
- | `compliance/pending-releases/RELEASE-TICKET-*.md` | Git | Reviewed and moved to approved-releases |
48
+ | `compliance/pending-releases/RELEASE-TICKET-*.md` | Git | Reviewed and moved to approved-releases (a deferred ticket stays in `pending-releases/`) |
49
49
  | E2E results (JSON) | DevAudit | Large, bloats git history |
50
50
  | Screenshots (PNG/JPG) | DevAudit | Binary, bloats git history |
51
51
  | SAST results (JSON) | DevAudit | Large JSON, bloats git history |
@@ -82,7 +82,7 @@ A release is classified by version shape and release mode. **Most of this doc wa
82
82
 
83
83
  ### Housekeeping outcomes
84
84
 
85
- Normal housekeeping skips the per-requirement evidence and approval path. Run the relevant gates, obtain terminal-green PR review, and merge to `develop`; the bare-date portal row is integration history. When a tracked release later absorbs the work, its bundled-change manifest preserves the source title, evidence ownership, stage, and executions.
85
+ Normal housekeeping skips the per-requirement evidence and approval path. Run the relevant gates, obtain terminal-green PR review, and merge to `develop`; integration housekeeping registers no portal row (#1020), so the run is GitHub CI history only. When a tracked release later absorbs the work, its bundled-change manifest preserves the source title, evidence ownership, stage, and executions.
86
86
 
87
87
  Use standalone housekeeping only when the change cannot reasonably wait for that tracked release. Follow `docs/release-playbooks/housekeeping-release.md`: add the validated `STANDALONE-HOUSEKEEPING-vYYYY.MM.DD.json` declaration, document why promotion is necessary, pass the required checks, and verify production. There is no automatic release-ticket or security-summary stub PR for either housekeeping outcome.
88
88
 
@@ -132,6 +132,7 @@ cat > compliance/evidence/REQ-XXX/test-execution-summary.md << 'EOF'
132
132
  **Date:** [YYYY-MM-DD]
133
133
  **Git SHA:** [short SHA]
134
134
  **CI Run:** [run ID or "local"]
135
+ **CI as of:** [run id]/[attempt] @ [head sha] <!-- authored pre-PR: use `local @ <sha>`; regenerate after the release PR's CI reaches a terminal state and after every re-run, triage, fix or deferral (devaudit-installer#1016) -->
135
136
 
136
137
  ## Test design (devaudit#50)
137
138
 
@@ -161,6 +162,22 @@ Records the design-time decisions before listing run results — what was tested
161
162
  | E2E Tests | PASS | [N]/[N] passed |
162
163
  | Build | PASS | Production build succeeded |
163
164
 
165
+ ## E2E failures & triage
166
+
167
+ Required whenever ANY execution failed - local runs and every CI attempt, including a failed attempt that a later re-run superseded (devaudit-installer#1016). Optional ("None - no failed execution") when nothing failed. A gate row may not read PASS while a failure here is unresolved, and "known unrelated flakes" is not a disposition. The validator (`validate-test-summary.sh`) fails when a failure is recorded without a row, and `reconcile-e2e-summary.sh` compares these rows with the CI results for the head SHA.
168
+
169
+ | Spec / check | Source | Classification | Evidence | Disposition | Reference |
170
+ | ------------ | ------ | -------------- | -------- | ----------- | --------- |
171
+ | e2e/critical/foo.spec.ts | CI 123/1 | flake | 5 isolated re-runs pass, code unchanged since REQ-049 | Fix | PR #510 |
172
+ | e2e/critical/bar.spec.ts | local | seed-data gap | seed lacks a transaction for the day | Accepted exception | compliance/evidence/REQ-XXX/accepted-e2e-failure-bar.md |
173
+ | e2e/critical/baz.spec.ts | CI 123/1 | test bug | selector drift | Deferral | https://github.com/owner/repo/issues/512 |
174
+
175
+ Rules:
176
+ - **Source** is `local` or `CI <run id>/<attempt>`.
177
+ - **Classification** is one of `flake`, `test bug`, `app defect`, `seed-data gap` (the `e2e-test-engineer` Phase 6 buckets).
178
+ - **Disposition** is `Fix` (a `fix/` PR and a green re-run on the head SHA), `Accepted exception` (the record from `.claude/skills/sdlc-implementer/references/e2e-accepted-failure.md.template`, recorded in the portal with `report-test-execution.sh resolve --resolution-type accepted_exception --record ...`), or `Deferral` (tracking issue and target release).
179
+ - **Reference** is mandatory: PR/issue (`#N` or URL) for Fix and Deferral; the accepted-failure record path or tracking issue URL for Accepted exception.
180
+
164
181
  ## Accepted skips
165
182
 
166
183
  Required when E2E gate result is `SKIPPED`. Optional when no accepted skips exist.
@@ -187,7 +204,7 @@ curl -s -H "Authorization: Bearer ${DEVAUDIT_API_KEY}" \
187
204
  bash scripts/render-test-executions.sh /tmp/release-journey.json
188
205
  ```
189
206
 
190
- The helper renders a first-class table when `.testExecutions[]` is present. It must not infer executions from legacy artifact grouping.
207
+ The helper renders a first-class table when `.testExecutions[]` is present, preceded by a `<!-- generated-by: render-test-executions.sh ... -->` marker. It must not infer executions from legacy artifact grouping. **Paste the helper's output as-is - never type rows by hand.** It lists every CI execution per attempt (run id and attempt), so a failed attempt 1 that a passing attempt 2 superseded stays visible. A summary carrying a `CI as of:` stamp without the marker fails validation (devaudit-installer#1016); record local runs with their real counts (`3 failed`), never plain `passed` when failures occurred.
191
208
 
192
209
  | Source Release | SDLC Stage | Execution | Kind | Outcome | Workflow / Run | Related Evidence | Incident / Remediation | Date |
193
210
  | --- | --- | --- | --- | --- | --- | --- | --- | --- |
@@ -519,6 +536,10 @@ Create `compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md`:
519
536
  **Risk Level:** [LOW / MEDIUM / HIGH]
520
537
  **PR:** [Will be linked when PR is created]
521
538
 
539
+ <!-- OPTIONAL. Add this bullet ONLY when this release PR is closed without releasing and the REQ is deferred into the next release (omit it otherwise; absent = no declared intent):
540
+ - **Release intent:** deferred-to-next — <reason, PR #N closed unmerged>
541
+ (indented here so a copied template never matches the guards.) The absorbing release must then list this REQ under "Absorbed predecessor releases". This ticket field is the sole declaration of deferral; the portal never writes it back. The RTM row becomes `DEFERRED` (non-terminal). A portal admin may additionally defer the portal release manually (see Stage 4). -->
542
+
522
543
  ---
523
544
 
524
545
  ## Summary
@@ -526,7 +547,7 @@ Create `compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md`:
526
547
 
527
548
  ## Bundled Changes
528
549
 
529
- Required when `compliance/pending-releases/BUNDLED-CHANGES-REQ-XXX.md` exists or when predecessor bare-date releases are being superseded into this REQ.
550
+ Required when `compliance/pending-releases/BUNDLED-CHANGES-REQ-XXX.md` exists or when legacy predecessor bare-date releases (rows created before #1020) are being superseded into this REQ.
530
551
 
531
552
  - **Core tracked release:** [REQ-XXX]
532
553
  - **Absorbed predecessor releases:** [versions or `None`]
@@ -790,7 +811,7 @@ The script:
790
811
  2. Checks a `RELEASE-TICKET-*.md` exists in `compliance/pending-releases/`.
791
812
  3. Checks CI gates are green on the current develop HEAD (via `gh run list`).
792
813
  4. Resolves the release id from DevAudit using `DEVAUDIT_API_KEY` (existing).
793
- 5. Submits with `DEVAUDIT_USER_TOKEN` (Personal Access Token issued from `/settings/tokens` in DevAudit). The submission carries the issuing user's identity, so `isOwnRelease` keeps holding for Step 11b under `dual_actor`.
814
+ 5. Submits with `DEVAUDIT_USER_TOKEN` (Personal Access Token issued from `/settings/tokens` in DevAudit). The submission carries the issuing user's identity, so `isOwnRelease` keeps holding for Step 11b under `dual_actor`. The same PAT is also the credential for an admin's manual portal defer/resume of a release (admin-only; never `DEVAUDIT_API_KEY`, the viewer key or CI).
794
815
  6. Idempotent — if the release is already in `uat_review` (or later), exits 0 with a note rather than failing.
795
816
 
796
817
  Required environment variables for the scripted path:
@@ -877,6 +898,7 @@ Copy these from `sdlc/files/ci/` into your project's `.github/workflows/`:
877
898
 
878
899
  **`check-release-approval.yml`** (renamed from `check-uat-approval.yml` in sdlc-v1.22.0) — Release Approval Gate on PRs to main:
879
900
  - Blocks merge until the release is approved in DevAudit (`uat_approved` / `release_approved` / downstream statuses)
901
+ - Fails with a specific message when the portal status is `deferred` (a deferred release is not approved; an admin must resume it, which returns it to `draft`)
880
902
  - Add as a required status check on the `main` branch protection rule
881
903
 
882
904
  **`post-deploy-prod.yml`** — Production evidence capture after merge to main:
@@ -889,7 +911,7 @@ The source of truth for compliance documents remains in git. DevAudit holds read
889
911
  ## Output
890
912
 
891
913
  - RTM: `TESTED - PENDING SIGN-OFF`
892
- - Release ticket in `compliance/pending-releases/`
914
+ - Release ticket in `compliance/pending-releases/` (carries `**Release intent:** deferred-to-next — …` only if the REQ is later deferred)
893
915
  - Test + security + AI evidence uploaded to DevAudit (or in `compliance/evidence/REQ-XXX/` if git-based)
894
916
  - Compliance documents (test scope, AI notes, security summary) committed to git and pushed
895
917
  - Test scope fully addressed
@@ -30,7 +30,7 @@ If you are an AI agent reading this file, you are strictly prohibited from manua
30
30
  - CI on `develop` is green
31
31
  - UAT-environment verification has passed (only if Stage 3 Step 10 applied — opt-in by risk class)
32
32
  - Evidence is compiled, committed, and uploaded
33
- - **Release is approved in DevAudit** (status: `uat_approved` — backend enum kept as-is in v1.22.x for backwards-compat; renamed to `release_approved` in v1.23.0)
33
+ - **Release is approved in DevAudit** (status: `uat_approved` — backend enum kept as-is in v1.22.x for backwards-compat; renamed to `release_approved` in v1.23.0). A release that a portal admin has deferred (`deferred`) is not approved and fails the gate until it is resumed (back to `draft`)
34
34
 
35
35
  The PR is the **merge request**, not the development workspace. Develop on `develop`, iterate until ready, then create the PR as the final step before merge.
36
36
 
@@ -69,7 +69,7 @@ Before creating a PR, verify all prerequisites are met. **Do NOT skip this check
69
69
  - [ ] CI is not stale (ran against the latest commit): compare CI commit SHA with `git rev-parse develop`
70
70
  - [ ] Working tree is clean: `git status`
71
71
  - [ ] UAT-environment verification passed (only if Stage 3 Step 10 applied to this requirement)
72
- - [ ] Release approved in DevAudit (Stage 3 Step 11)
72
+ - [ ] Release approved in DevAudit (Stage 3 Step 11), and not `deferred`
73
73
 
74
74
  **For tracked requirements (REQ-XXX):**
75
75
  - [ ] `compliance/evidence/REQ-XXX/test-scope.md` exists and all items addressed
@@ -77,6 +77,7 @@ Before creating a PR, verify all prerequisites are met. **Do NOT skip this check
77
77
  - [ ] `compliance/evidence/REQ-XXX/ai-prompts.md` exists (if AI was used on MEDIUM/HIGH risk)
78
78
  - [ ] RTM status is `TESTED - PENDING SIGN-OFF`: `grep 'REQ-XXX' compliance/RTM.md`
79
79
  - [ ] Release ticket exists: `ls compliance/pending-releases/RELEASE-TICKET-REQ-XXX.md`
80
+ - [ ] Any REQ deferred earlier (ticket `**Release intent:** deferred-to-next`) is listed under `Absorbed predecessor releases` in this release's ticket; the develop-to-main promotion gate (`check-deferred-reqs-in-range.sh`, inside the Release Scope Integrity job) fails the PR otherwise
80
81
  - [ ] Evidence uploaded to DevAudit (or saved locally if git-based)
81
82
 
82
83
  **Risk-tier reminder:**
@@ -168,7 +168,7 @@ consumer repository. `close-out-release.yml` then opens a
168
168
  `chore/close-out-REQ-XXX` PR to the configured integration branch. That PR is
169
169
  the canonical reconciliation record: it updates the RTM, moves the release
170
170
  ticket to `approved-releases/`, and moves manifest-listed absorbed predecessors
171
- to `superseded-releases/`.
171
+ to `superseded-releases/`. A deferred predecessor that this release absorbs (listed under `Absorbed predecessor releases`) is superseded here, the same way; one that was not absorbed stays pending and, if a portal admin deferred it, remains `deferred` (reversible) until resumed or superseded. Deferring or resuming a portal release is a manual admin action with a PAT or portal session, never part of this flow.
172
172
 
173
173
  Review and merge the close-out PR after its required checks are terminal green
174
174
  on its current head SHA. It is an administrative reconciliation PR, not a new
@@ -55,7 +55,7 @@ A worked end-to-end example for a zero-risk change (a typo, a dependency bump, a
55
55
  3. **Commit with a housekeeping type.** `docs:` / `chore:` / `ci:` / `build:` / `test:` / `revert:` are **exempt** from the `[REQ-XXX]` rule — e.g. `git commit -m "docs: fix typo in README"`. A `feat` / `fix` / `refactor` / `perf` subject without a `[REQ-XXX]` or `Ref: REQ-XXX` is **rejected** by commitlint and `validate-commits.sh` — if that fires, you picked the wrong type and the change isn't trivial.
56
56
  4. **Run the gates locally — not optional.** `npx tsc --noEmit`, lint, and the test suite must pass before you push. Trivial ≠ unverified.
57
57
  5. **Push and open a PR.** CI runs the same quality gates. `compliance-validation.yml` finds no `REQ-XXX` and **skips** artifact validation; no release ticket, no RTM row, no evidence pack is required.
58
- 6. **Merge only after terminal-green CI** and reviewer approval. A housekeeping push may create a bare-date portal row, but it is integration history, not a UAT/production approval release. It needs no release ticket, security-summary stub, per-REQ evidence pack, or portal sign-off. The next tracked REQ records absorbed work through bundled-change lineage. Use standalone housekeeping only through the explicit declaration and production-verification path in the release playbook.
58
+ 6. **Merge only after terminal-green CI** and reviewer approval. A housekeeping push registers no portal release (#1020): it is GitHub CI history only, not a UAT/production approval release. It needs no release ticket, security-summary stub, per-REQ evidence pack, or portal sign-off. The next tracked REQ records absorbed work through bundled-change lineage. Use standalone housekeeping only through the explicit declaration and production-verification path in the release playbook.
59
59
 
60
60
  If at any step it stops feeling trivial — it changes behaviour, touches auth/payments/data, or an auditor would ask about it — switch to a tracked change and run `sdlc-implementer`. When unsure, it's not trivial.
61
61