Release 12.0 (full): one browser harness that converses, writes from held sources and builds what you describe, keeping each request through corrections and restarts. No language model. (part 4)
04e89f2 verified Download workbench/converse/context_record.py from psiloceyeben/oracle7: direct link, hf CLI and curl.
- Browser
- Download file 2.14 kB
-
https://huggingface.co/psiloceyeben/oracle7/resolve/main/workbench/converse/context_record.py
- Command line
-
hf download hf://psiloceyeben/oracle7/workbench/converse/context_record.py
-
curl -L -o context_record.py https://huggingface.co/psiloceyeben/oracle7/resolve/main/workbench/converse/context_record.py
2.14 kB
| """Recover received context and complete open requests from the delivered ledger. | |
| This part reads records. It never invokes a work part or replays an effect. | |
| """ | |
| import hashlib | |
| import time | |
| def entries(sid, limit=12): | |
| import reflect | |
| return list(reflect.load(sid).get('ledger') or [])[-limit:] | |
| def open_requests(sid): | |
| import reflect | |
| return [item['original'] for item in reflect.load(sid).get('open_requests', []) | |
| if item.get('state') == 'open'] | |
| def record(text, sid, reply, reading=None): | |
| """Keep unfinished instructions whole; retire only exact checked obligations.""" | |
| import reflect | |
| state = reflect.load(sid) | |
| obligations = state.setdefault('open_requests', []) | |
| execution = reply.get('execution') or {} | |
| performed = execution.get('state') in ('checked', 'changed-checked', 'sent', 'done') and not execution.get('holes') | |
| completed = {r.get('text') for r in execution.get('requirements', []) | |
| if r.get('status') in ('passed', 'met')} | |
| if performed: | |
| completed.add(text) | |
| for item in obligations: | |
| if item['original'] in completed: | |
| item.update(state='done', completed=time.time(), receipt=reply.get('path')) | |
| asks_work = bool(reply.get('_open_request') or (reading or {}).get('outcomes')) | |
| # A checked conversational answer or a writer's own durable obligation | |
| # belongs to its owner, not to this record of otherwise unperformed work. | |
| pending = asks_work and not performed and not reply.get('writing') and reply.get('status') != 'answered' | |
| if pending: | |
| identity = hashlib.sha256((sid + '\0' + text).encode('utf-8')).hexdigest()[:24] | |
| item = next((x for x in obligations if x['id'] == identity), None) | |
| if item is None: | |
| item = {'id': identity, 'original': text, 'created': time.time(), 'state': 'open'} | |
| obligations.append(item) | |
| item.update(last_seen=time.time(), path=reply.get('path'), missing=execution.get('holes') or [], | |
| reading=reading, state='open') | |
| reflect.save(sid, state) | |
| reply.pop('_open_request', None) | |
| return reply | |