> For the complete documentation index, see [llms.txt](https://faction-os.gitbook.io/faction-os-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase18-session04-idle-lifecycle-engine-parity/validation.md).

# Validation Report

**Session ID**: `phase18-session04-idle-lifecycle-engine-parity` **Package**: `apps/server` **Validated**: `2026-06-10` **Result**: PASS

***

## Validation Summary

| Check                     | Status | Notes                                                                                                    |
| ------------------------- | ------ | -------------------------------------------------------------------------------------------------------- |
| Tasks Complete            | PASS   | 25/25 tasks complete                                                                                     |
| Files Exist               | PASS   | 11/11 spec deliverables found                                                                            |
| ASCII Encoding            | PASS   | All checked session files and touched server files are ASCII with LF endings                             |
| Tests Passing             | PASS   | 2566/2566 tests passed in the root Vitest suite; 54/54 focused server tests passed                       |
| Database/Schema Alignment | N/A    | No DB-layer changes in this session                                                                      |
| Quality Gates             | PASS   | `git diff --check` passed; server package typecheck passed                                               |
| Conventions               | PASS   | No obvious violations in the touched files                                                               |
| Security & GDPR           | PASS   | No security or GDPR findings                                                                             |
| Behavioral Quality        | PASS   | Trust boundaries, cleanup, cooldown, fallback, and route integration paths are aligned with the protocol |

**Overall**: PASS

***

## 1. Task Completion

### Status: PASS

| Category       | Required | Completed | Status |
| -------------- | -------- | --------- | ------ |
| Setup          | 3        | 3         | PASS   |
| Foundation     | 6        | 6         | PASS   |
| Implementation | 11       | 11        | PASS   |
| Testing        | 5        | 5         | PASS   |

### Incomplete Tasks

None

***

## 2. Deliverables Verification

### Status: PASS

#### Files Created or Updated Per Spec

| File                                                  | Found | Status |
| ----------------------------------------------------- | ----- | ------ |
| `apps/server/src/lib/idleSuggestionContext.ts`        | Yes   | PASS   |
| `apps/server/src/lib/idleSuggestionLifecycle.ts`      | Yes   | PASS   |
| `apps/server/tests/idleSuggestionContext.test.ts`     | Yes   | PASS   |
| `apps/server/tests/idleSuggestionLifecycle.test.ts`   | Yes   | PASS   |
| `apps/server/src/llm/engines/idleSuggestionEngine.ts` | Yes   | PASS   |
| `apps/server/src/routes/llm.ts`                       | Yes   | PASS   |
| `apps/server/src/routes/event.ts`                     | Yes   | PASS   |
| `apps/server/src/server.ts`                           | Yes   | PASS   |
| `apps/server/tests/llm.test.ts`                       | Yes   | PASS   |
| `apps/server/tests/routes.test.ts`                    | Yes   | PASS   |
| `apps/server/README_server.md`                        | Yes   | PASS   |

### Missing Deliverables

None

### Additional Session-Touched Files

* `.spec_system/state.json`
* `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/security-compliance.md`
* `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/validation.md`

***

## 3. ASCII Encoding Check

### Status: PASS

| File                                                                                        | Encoding | Line Endings | Status |
| ------------------------------------------------------------------------------------------- | -------- | ------------ | ------ |
| `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/spec.md`                 | ASCII    | LF           | PASS   |
| `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/tasks.md`                | ASCII    | LF           | PASS   |
| `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/implementation-notes.md` | ASCII    | LF           | PASS   |
| `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/security-compliance.md`  | ASCII    | LF           | PASS   |
| `.spec_system/specs/phase18-session04-idle-lifecycle-engine-parity/validation.md`           | ASCII    | LF           | PASS   |
| `apps/server/src/lib/idleSuggestionContext.ts`                                              | ASCII    | LF           | PASS   |
| `apps/server/src/lib/idleSuggestionLifecycle.ts`                                            | ASCII    | LF           | PASS   |
| `apps/server/src/llm/engines/idleSuggestionEngine.ts`                                       | ASCII    | LF           | PASS   |
| `apps/server/src/routes/event.ts`                                                           | ASCII    | LF           | PASS   |
| `apps/server/src/routes/llm.ts`                                                             | ASCII    | LF           | PASS   |
| `apps/server/src/server.ts`                                                                 | ASCII    | LF           | PASS   |
| `apps/server/tests/idleSuggestionContext.test.ts`                                           | ASCII    | LF           | PASS   |
| `apps/server/tests/idleSuggestionLifecycle.test.ts`                                         | ASCII    | LF           | PASS   |
| `apps/server/tests/llm.test.ts`                                                             | ASCII    | LF           | PASS   |
| `apps/server/tests/routes.test.ts`                                                          | ASCII    | LF           | PASS   |
| `apps/server/README_server.md`                                                              | ASCII    | LF           | PASS   |
| `.spec_system/state.json`                                                                   | ASCII    | LF           | PASS   |

### Encoding Issues

None

***

## 4. Test Results

### Status: PASS

| Metric      | Value                                |
| ----------- | ------------------------------------ |
| Total Tests | 2566                                 |
| Passed      | 2566                                 |
| Failed      | 0                                    |
| Coverage    | Not collected in this validation run |

### Failed Tests

None

***

## 5. Database/Schema Alignment

### Status: N/A

No DB-layer changes were introduced in this session.

***

## 6. Success Criteria

From `spec.md`:

### Functional Requirements

* [x] A hero entering `idle` through `/event` starts one asynchronous generation attempt for the resolved session.
* [x] A repeated idle transition inside 60 seconds does not enqueue duplicate generation for the same session.
* [x] An already-running generation for a session suppresses duplicate work until the first attempt completes or times out.
* [x] Generated idle suggestions are stored as typed manager suggestions with session ID, hero ID, title, text, prompt, category, priority, and created timestamp.
* [x] Generated manager mutations emit `suggestion_update` and current `idle_suggestion` compatibility frames.
* [x] Missing provider transfer, LLM failure, timeout, malformed output, and empty output all fall back to schema-valid deterministic suggestions or an intentional empty result when context is insufficient.
* [x] Modified-file hints prefer safe relative paths from mission tool-use records and never expose absolute paths.
* [x] `POST /llm/idle-suggestion` remains compatible and returns a suggestions array for valid input.

### Testing Requirements

* [x] Context-builder tests are written and passing.
* [x] Lifecycle coordinator tests are written and passing.
* [x] Idle engine parser and fallback tests are written and passing.
* [x] Route integration tests are updated and passing.
* [x] `npm --workspace apps/server run typecheck` passes.

### Quality Gates

* [x] All files ASCII-encoded
* [x] Unix LF line endings
* [x] Code follows project conventions

***

## 7. Conventions Compliance

### Status: PASS

No obvious naming, structure, error-handling, or testing violations in the touched files.

***

## 8. Security & GDPR Compliance

### Status: PASS / N/A

**Full report**: See `security-compliance.md` in this session directory.

#### Summary

| Area     | Status | Findings |
| -------- | ------ | -------- |
| Security | PASS   | 0 issues |
| GDPR     | N/A    | 0 issues |

### Critical Violations

None

***

## 9. Behavioral Quality Spot-Check

### Status: PASS

**Checklist applied**: Yes **Files spot-checked**:

* `apps/server/src/lib/idleSuggestionContext.ts`
* `apps/server/src/lib/idleSuggestionLifecycle.ts`
* `apps/server/src/routes/event.ts`
* `apps/server/src/llm/engines/idleSuggestionEngine.ts`
* `apps/server/tests/routes.test.ts`

| Category           | Status | File                                                  | Details                                                                                      |
| ------------------ | ------ | ----------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| Trust boundaries   | PASS   | `apps/server/src/lib/idleSuggestionContext.ts`        | Unsafe absolute and relative paths are filtered before persistence or emission.              |
| Resource cleanup   | PASS   | `apps/server/src/lib/idleSuggestionLifecycle.ts`      | Timers, in-flight state, and abort resources are cleaned up on completion and shutdown.      |
| Mutation safety    | PASS   | `apps/server/src/lib/idleSuggestionLifecycle.ts`      | In-flight and cooldown guards prevent duplicate writes for the same session.                 |
| Failure paths      | PASS   | `apps/server/src/routes/event.ts`                     | Idle generation failure is handled asynchronously and does not block the HTTP response path. |
| Contract alignment | PASS   | `apps/server/src/llm/engines/idleSuggestionEngine.ts` | Engine output is normalized to the typed suggestion contract before manager writes.          |

### Violations Found

None

### Fixes Applied During Validation

None

## Validation Result

### PASS

The session met its scope, deliverables, tests, encoding, quality, and security requirements.

### Required Actions

None

## Next Steps

Run `updateprd` to mark the session complete.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://faction-os.gitbook.io/faction-os-docs/.spec_system/archive/sessions/phase18-session04-idle-lifecycle-engine-parity/validation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
