Skip to content

merge: resolve conflicts between main and PR #129 (activate-cognitive-systems)#130

Merged
Steake merged 12 commits intomainfrom
copilot/resolve-merge-conflicts-129
Mar 8, 2026
Merged

merge: resolve conflicts between main and PR #129 (activate-cognitive-systems)#130
Steake merged 12 commits intomainfrom
copilot/resolve-merge-conflicts-129

Conversation

Copy link
Contributor

Copilot AI commented Mar 8, 2026

Description

PR #129 branched before PR #128 (dormant modules) landed on main, leaving backend/unified_server.py with two content conflicts. Both are resolved by retaining all changes from both sides.

Conflict 1 — lifespan shutdown block

Conflict 2 — system API endpoints

Scoping fix_hot_reloader was declared after lifespan with no global statement, so the knowledge-persistence endpoints always read None. Fixed by hoisting the declaration above lifespan and adding it to the global list:

# Before lifespan()
_hot_reloader = None

@asynccontextmanager
async def lifespan(app: FastAPI):
    global startup_time, self_modification_engine, _hot_reloader  # ← added

Playwright CI fix — Added missing svelte-frontend/scripts/preflight.js referenced by playwright.config.js as globalSetup. Its absence caused CI to fail with Cannot find module './scripts/preflight.js'. The file exports a no-op async setup function, unblocking Playwright test execution.

Review feedback fixes — Applied all issues raised in the automated code review:

  • GODELOS_ONTOLOGY_DIR default in the knowledge-persistence status endpoint changed from "./ontologies" to "", matching the lifespan behaviour so the endpoint does not report a watch directory that is not active.
  • Corrected misleading docstring on POST /api/system/knowledge-persistence/reload — removed the false claim that the response includes triple counts; the actual response is {"status": "reload_triggered", "watch_dir": ...}.
  • get_breakthroughs() in consciousness_emergence_detector.py now reads only the tail of the log file (limit × 2 KiB from EOF) instead of loading the entire breakthroughs.jsonl into memory, keeping memory usage O(limit) as the log grows.
  • Fixed a bug in _score_coherence (autonomous_goal_engine.py) where an early return 0.5 on a partial domain match prevented later domains from being checked for a full joint match. The partial-match result is now deferred until all domains have been evaluated.
  • Removed unused imports (time, tempfile, Path, AsyncMock, MagicMock) from tests/backend/test_autonomous_goal_engine.py.

Related Issues

Test Evidence

tests/backend/test_autonomous_goal_engine.py  31 passed in 0.28s
CodeQL: 0 alerts

Checklist

  • Tests pass locally (pytest tests/)
  • Code is formatted (black . and isort .)
  • Documentation updated (if applicable)
  • No secrets or credentials committed
  • Related issue linked above

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits March 7, 2026 00:59
…r, CreativeSynthesisEngine, PAT docs

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
…t assertions, timestamp parsing

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Copilot AI and others added 2 commits March 8, 2026 07:18
#129) into resolve-merge-conflicts-129

Keep both sets of changes from HEAD and PR branch:
- Shutdown: retain dormant ticker cancellation + add observatory/hot-reloader stop
- Endpoints: retain /api/system/dormant-modules + add /api/system/knowledge-persistence{,/reload}
…ration

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix merge conflicts with PR #129 merge: resolve conflicts between main and PR #129 (activate-cognitive-systems) Mar 8, 2026
@Steake Steake marked this pull request as ready for review March 8, 2026 11:08
@Steake Steake self-requested a review as a code owner March 8, 2026 11:08
Copilot AI review requested due to automatic review settings March 8, 2026 11:08
@github-actions
Copy link

github-actions bot commented Mar 8, 2026

🧪 CI — Python 3.11

�[31mERROR�[0m tests/test_cognitive_subsystem_activation.py::�[1mTestEndToEndFlow::test_context_engine_round_trip�[0m - ModuleNotFoundError: No module named 'requests'
�[31mERROR�[0m tests/test_cognitive_subsystem_activation.py::�[1mTestEndToEndFlow::test_nlg_pipeline_process�[0m - ModuleNotFoundError: No module named 'requests'
�[31m====== �[31m�[1m4 failed�[0m, �[32m984 passed�[0m, �[33m81 skipped�[0m, �[33m65 warnings�[0m, �[31m�[1m22 errors�[0m�[31m in 35.10s�[0m�[31m ======�[0m

@github-actions
Copy link

github-actions bot commented Mar 8, 2026

🧪 CI — Python 3.10

�[31mERROR�[0m tests/test_cognitive_subsystem_activation.py::�[1mTestEndToEndFlow::test_context_engine_round_trip�[0m - ModuleNotFoundError: No module named 'requests'
�[31mERROR�[0m tests/test_cognitive_subsystem_activation.py::�[1mTestEndToEndFlow::test_nlg_pipeline_process�[0m - ModuleNotFoundError: No module named 'requests'
�[31m====== �[31m�[1m4 failed�[0m, �[32m984 passed�[0m, �[33m81 skipped�[0m, �[33m65 warnings�[0m, �[31m�[1m22 errors�[0m�[31m in 35.13s�[0m�[31m ======�[0m

@Steake
Copy link
Owner

Steake commented Mar 8, 2026

@copilot

Title: Add missing scripts/preflight.js to fix Playwright global setup error

Problem statement:
The Playwright configuration (svelte-frontend/playwright.config.js) references a globalSetup script at svelte-frontend/scripts/preflight.js. The recent CI run failed with the following error:

Error: Cannot find module './scripts/preflight.js'
Require stack:

  • .../svelte-frontend/playwright.config.js

To resolve this, add a basic placeholder preflight.js file exporting an async setup function. This will unblock Playwright test execution while allowing future customization as needed.

Example content for svelte-frontend/scripts/preflight.js:

// svelte-frontend/scripts/preflight.js
module.exports = async () => {
  // Custom setup before Playwright tests run
};

Add this file, commit, and I shall re-run the workflow. Proceed.

…global setup

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot

Title: Add missing scripts/preflight.js to fix Playwright global setup error
...

Added svelte-frontend/scripts/preflight.js in commit 49810ff. The file exports an async no-op setup function exactly as specified, which satisfies playwright.config.js's globalSetup: require.resolve('./scripts/preflight.js') reference.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR resolves merge conflicts between main (which includes PR #128 — dormant modules and self-modification engine) and PR #129 (activate cognitive systems: autonomous goal engine, consciousness observatory, knowledge persistence). Both sets of changes are retained, with a scoping fix for _hot_reloader (hoisted to module scope with global declaration in lifespan).

Changes:

  • Merges PR #129 features (consciousness observatory, autonomous goal engine, breakthrough log, knowledge persistence/hot-reload endpoints, and new dashboard tabs) alongside PR #128 features (dormant module ticker, self-modification engine) in unified_server.py's lifespan and shutdown blocks.
  • Adds new backend modules (autonomous_goal_engine.py, UnifiedConsciousnessObservatory in consciousness_emergence_detector.py) and REST endpoints for goals, breakthroughs, observatory, and knowledge persistence.
  • Extends the Svelte UnifiedConsciousnessDashboard with three new tabs (Autonomous Goals, Breakthrough Log, Subsystem Health) and adds PAT documentation to CONTRIBUTING.md.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backend/unified_server.py Hoists _hot_reloader to module scope, adds it to global in lifespan; initializes observatory, goal engine, and hot-reloader at startup; shuts them down cleanly; adds 2 knowledge-persistence endpoints
backend/core/consciousness_emergence_detector.py Adds get_breakthroughs() method to read from JSONL log; adds UnifiedConsciousnessObservatory class with start/stop/record_state/get_report
backend/core/autonomous_goal_engine.py New file with AutonomousGoalGenerator (state-gap monitoring, dedup, cap at 10 active goals) and CreativeSynthesisEngine (concept-pair synthesis with novelty/coherence scoring)
backend/api/consciousness_endpoints.py Adds endpoints for breakthroughs, observatory, goals, goal generation, and creative synthesis; adds setter/getter functions and updates __all__
svelte-frontend/src/components/UnifiedConsciousnessDashboard.svelte Adds three new tabs with data loading functions, UI templates, and styles for goals, breakthroughs, and subsystem health
tests/backend/test_autonomous_goal_engine.py 31 new tests covering AutonomousGoalGenerator, CreativeSynthesisEngine, UnifiedConsciousnessObservatory, and breakthrough log reading
docs/CONTRIBUTING.md Adds PAT setup documentation with required scopes, rotation schedule, and verification instructions

import os
backend = os.environ.get("KNOWLEDGE_STORE_BACKEND", "memory")
store_path = os.environ.get("KNOWLEDGE_STORE_PATH", "./data/chroma")
ontology_dir = os.environ.get("GODELOS_ONTOLOGY_DIR", "./ontologies")
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent default for GODELOS_ONTOLOGY_DIR: In lifespan (line 697), the default is "" (empty string), so the hot reloader is not initialized when the env var is unset. But here the default is "./ontologies", which will be displayed to the API consumer even when the env var isn't set and the reloader isn't active. This is misleading — the endpoint shows a directory that nobody is actually watching. Use "" as the default here too (matching the lifespan behaviour), or explicitly show that it's unset.

Suggested change
ontology_dir = os.environ.get("GODELOS_ONTOLOGY_DIR", "./ontologies")
ontology_dir = os.environ.get("GODELOS_ONTOLOGY_DIR", "")

Copilot uses AI. Check for mistakes.
if not self._log_path.exists():
return []
try:
lines = self._log_path.read_text(encoding="utf-8").splitlines()
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read_text() reads the entire breakthroughs.jsonl file into memory before iterating in reverse, even when only a small limit (e.g. 10) is requested. As the log grows over time this will become increasingly expensive. Consider reading the file backwards (e.g. using seek from the end) or capping file size with rotation, so that fetching a small number of recent breakthroughs doesn't require loading the entire history.

Copilot uses AI. Check for mistakes.
Comment on lines +2625 to +2642
Reads all ``.ttl`` and ``.json-ld`` files in ``GODELOS_ONTOLOGY_DIR``,
computes the delta against the last snapshot, and applies it to the
running knowledge graph. Returns the number of triples added/removed.
"""
try:
if _hot_reloader is None:
raise HTTPException(
status_code=503,
detail=(
"Hot-reloader is not active. "
"Set GODELOS_ONTOLOGY_DIR and restart the server to enable it."
),
)
# OntologyHotReloader.reload() is synchronous — run in executor
import asyncio
loop = asyncio.get_event_loop()
await loop.run_in_executor(None, _hot_reloader.reload)
return {"status": "reload_triggered", "watch_dir": _hot_reloader.watch_dir}
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring states "Returns the number of triples added/removed", but the actual response is {"status": "reload_triggered", "watch_dir": ...} which does not include any triple counts. Either update the docstring to match the actual response, or capture the return value from _hot_reloader.reload() and include the counts in the response.

Copilot uses AI. Check for mistakes.
Comment on lines +18 to +21
import time
import tempfile
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several unused imports: time, tempfile, Path, AsyncMock, and MagicMock are imported but never used in this test file. Consider removing them to keep the test module clean.

Suggested change
import time
import tempfile
from pathlib import Path
from unittest.mock import AsyncMock, MagicMock

Copilot uses AI. Check for mistakes.
Comment on lines +412 to +418
for domain in _DOMAIN_TAGS:
a_match = any(t in a_lower for t in domain)
b_match = any(t in b_lower for t in domain)
if a_match and b_match:
return 0.8 # same domain → coherent
if a_match or b_match:
return 0.5 # partial domain overlap
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug in _score_coherence: The early return on partial match (a_match or b_match) on line 418 prevents checking later domains. If concept a matches in domain 0 but concept b only matches in domain 1 (where both should score 0.8 for that domain), the function returns 0.5 prematurely.

For example, _score_coherence("quantum leap", "cognitive bias") would return 0.5 because "quantum" matches domain 0, but "cognitive" doesn't match domain 0 — so it returns 0.5 before reaching domain 1 where "cognitive" matches. But both concepts could still match domain 1 (cognitive/mind), and should score 0.8 for that domain.

The fix is to first check all domains for a joint match (both a and b), and only then check for partial matches.

Suggested change
for domain in _DOMAIN_TAGS:
a_match = any(t in a_lower for t in domain)
b_match = any(t in b_lower for t in domain)
if a_match and b_match:
return 0.8 # same domain → coherent
if a_match or b_match:
return 0.5 # partial domain overlap
any_partial = False
for domain in _DOMAIN_TAGS:
a_match = any(t in a_lower for t in domain)
b_match = any(t in b_lower for t in domain)
if a_match and b_match:
return 0.8 # same domain → coherent
if a_match or b_match:
any_partial = True # remember partial domain overlap
if any_partial:
return 0.5 # at least one partial domain overlap

Copilot uses AI. Check for mistakes.
Copilot AI and others added 3 commits March 8, 2026 11:31
…s dir

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
…t to avoid tracked file conflict

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
…der-issue

fix(playwright): move HTML reporter output folder outside test-results dir
@Steake
Copy link
Owner

Steake commented Mar 8, 2026

@copilot apply changes based on the comments in this thread

- unified_server.py: GODELOS_ONTOLOGY_DIR default changed from './ontologies' to '' to match lifespan behavior
- unified_server.py: fix misleading docstring on knowledge-persistence/reload endpoint
- consciousness_emergence_detector.py: get_breakthroughs() now reads only the tail of the file (limit * 2048 bytes) instead of the full log
- autonomous_goal_engine.py: fix _score_coherence early-return bug; now checks all domains before returning partial-match score
- test_autonomous_goal_engine.py: remove unused imports (time, tempfile, Path, AsyncMock, MagicMock)"

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 8, 2026

@copilot apply changes based on the comments in this thread

Applied all review comments in commit 9082578:

  • GODELOS_ONTOLOGY_DIR default — changed from "./ontologies" to "" so the status endpoint reflects the same "not active" semantics as lifespan.
  • Reload docstring — updated to accurately describe the actual response ({"status": "reload_triggered", "watch_dir": ...}) rather than the old triple-count claim.
  • get_breakthroughs() memory — replaced read_text() + full reverse-iterate with a bounded tail-read (limit * 2048 bytes from EOF), keeping memory usage O(limit) regardless of log size.
  • _score_coherence bug — deferred the partial-match return 0.5 until after all domains have been checked, so a full domain match in a later domain is never missed.
  • Unused imports — removed time, tempfile, Path, AsyncMock, MagicMock from the test file.

All 31 tests still pass.

@Steake Steake merged commit df63536 into main Mar 8, 2026
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.

3 participants